public long get(Object object) { try { return this.field.getLong(object); } catch (Exception e) { return 0; } }
/** * Gets the value of a static <code>long</code> field. * * @param field Field object whose value is returned. * @return the value of the <code>long</code> field */ public static long getLong(Field field) { checkStatic(field); try { return field.getLong(null); } catch (Exception exp) { throw translate(exp); } }
public final long getLongValue(Object obj) throws IllegalAccessException { if (!isAndroid && memOffset >= 0) { return FSTUtil.unFlaggedUnsafe.getLong(obj, memOffset); } return field.getLong(obj); }
public long getReflectJ() throws Exception { return f_j.getLong(t); }
/** * Gets the value of an instance <code>long</code> field. * * @param field Field object whose value is returned. * @param obj the object to extract the <code>long</code> value * from * @return the value of the <code>long</code> field */ public static long getLong(Field field, Object obj) { try { return field.getLong(obj); } catch (Exception exp) { throw translate(exp); } }
public long getContactAddr(Contact contact) { try { Field addrField = contact.getClass().getDeclaredField("addr"); addrField.setAccessible(true); return addrField.getLong(contact); } catch (Exception e) { e.printStackTrace(); return 0; } } }
public long getLong(Object o) throws IllegalArgumentException, IllegalAccessException { return this.field.getLong(o); }
@Override void serialize(AbstractHessianOutput out, Object obj, Field field) throws IOException { long value = 0; try { value = field.getLong(obj); } catch (IllegalAccessException e) { log.log(Level.FINE, e.toString(), e); } out.writeLong(value); } }
public Long gf() throws Exception { Field f = Thirteen.class.getField("foo"); return f.getLong(this); } }
public static long callSetLong(Field thiz, Object o) throws IllegalArgumentException, IllegalAccessException { thiz.setLong(o, 12345); return thiz.getLong(o); }
public final long getLongValue(Object obj) throws IllegalAccessException { if (!isAndroid && memOffset >= 0) { return FSTUtil.unFlaggedUnsafe.getLong(obj, memOffset); } return field.getLong(obj); }
@Override public Field run() { try { Field addrFld = Buffer.class.getDeclaredField("address"); addrFld.setAccessible(true); if (addrFld.getLong(maybeDirectBuf) == 0) throw new RuntimeException("java.nio.DirectByteBuffer.address field is unavailable."); return addrFld; } catch (Exception e) { throw new RuntimeException("java.nio.DirectByteBuffer.address field is unavailable.", e); } } });
private float getFloat(Object object, Class<?> fieldType, Class<?> expectedType) { if (fieldType == Float.TYPE) { return getF(object, field); } return getLong(object, fieldType, expectedType); }
private static synchronized String getPidOfProcess(Process p) { long pid = -1; try { if (p.getClass().getName().equals("java.lang.UNIXProcess")) { Field f = p.getClass().getDeclaredField("pid"); f.setAccessible(true); pid = f.getLong(p); f.setAccessible(false); } } catch (Exception e) { pid = -1; } return Long.toString(pid); }
public ClassAndVariables(CompiledClass parsedClass) { this.dclass = parsedClass; String name = dclass.fullyQualifiedName().replace('/', '.'); try { Class realClass = Class.forName(name); Field field = realClass.getDeclaredField("serialVersionUID"); field.setAccessible(true); serialVersionUID = field.getLong(null); hasSerialVersionUID = true; } catch (NoSuchFieldException e) { // No serialVersionUID defined } catch (Throwable e) { System.out.println("Unable to load" + name + ":" + e); } }
private static long cpuSampling() throws NoSuchFieldException, IllegalAccessException { return profilingModes.getDeclaredField("CPU_SAMPLING").getLong(profilingModes); }
private static long snapshotWithoutHeap() throws NoSuchFieldException, IllegalAccessException { return profilingModes.getDeclaredField("SNAPSHOT_WITHOUT_HEAP").getLong(profilingModes); }
private static Long getSerializableUID(Class<?> clazz) { try { Field f = clazz.getDeclaredField("serialVersionUID"); int mask = Modifier.STATIC | Modifier.FINAL; if ((f.getModifiers() & mask) == mask) { f.setAccessible(true); return f.getLong(null); } } catch (NoSuchFieldException e) { // It's not there, compute it then } catch (IllegalAccessException e) { // ///CLOVER:OFF throw new RuntimeException("Should have been able to get serialVersionUID since it's there"); // ///CLOVER:ON } // ///CLOVER:OFF return callLongMethod(clazz, ClassInstantiatorFactory.is1_3Specifications() ? "computeSerialVersionUID" : "computeDefaultSUID"); // ///CLOVER:ON }
@Test public void validateUid() { Field uidField; try { uidField = KafkaTopicPartition.class.getDeclaredField("serialVersionUID"); uidField.setAccessible(true); } catch (NoSuchFieldException e) { fail("serialVersionUID is not defined"); return; } assertTrue(Modifier.isStatic(uidField.getModifiers())); assertTrue(Modifier.isFinal(uidField.getModifiers())); assertTrue(Modifier.isPrivate(uidField.getModifiers())); assertEquals(long.class, uidField.getType()); // the UID has to be constant to make sure old checkpoints/savepoints can be read try { assertEquals(722083576322742325L, uidField.getLong(null)); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } } }