public void set(Object obj, long value) { try { this.field.setLong(obj, value); } catch (Exception e) { //Ignore } } }
public final void setLongValue(Object newObj, long i1) throws IllegalAccessException { if (!isAndroid && memOffset >= 0) { FSTUtil.unFlaggedUnsafe.putLong(newObj, memOffset, i1); return; } field.setLong(newObj, i1); }
public void setLong(Object o, long v) throws IllegalArgumentException, IllegalAccessException { this.field.setLong(o, v); }
public static long callSetLong(Field thiz, Object o) throws IllegalArgumentException, IllegalAccessException { thiz.setLong(o, 12345); return thiz.getLong(o); }
public void setLongJ() throws Exception { f_j.setAccessible(true); f_j.setLong(t, (long) 77); }
public final void setLongValue(Object newObj, long i1) throws IllegalAccessException { if (!isAndroid && memOffset >= 0) { FSTUtil.unFlaggedUnsafe.putLong(newObj, memOffset, i1); return; } field.setLong(newObj, i1); }
private static void patchUriField(Long maskValue, String fieldName) throws IOException { try { Field field = URI.class.getDeclaredField(fieldName); Field modifiers = Field.class.getDeclaredField("modifiers"); modifiers.setAccessible(true); modifiers.setInt(field, field.getModifiers() & ~Modifier.FINAL); field.setAccessible(true); field.setLong(null, maskValue); } catch (NoSuchFieldException e) { // skip for Android platform } catch (Exception e) { throw new IOException(e); } }
public static long callSetAndGetLong(Field thiz, Object o) throws IllegalArgumentException, IllegalAccessException { thiz.setLong(o, thiz.getLong(o)); return thiz.getLong(o); }
private static void patchUriField(Long maskValue, String fieldName) throws IOException { try { Field field = URI.class.getDeclaredField(fieldName); Field modifiers = Field.class.getDeclaredField("modifiers"); modifiers.setAccessible(true); modifiers.setInt(field, field.getModifiers() & ~Modifier.FINAL); field.setAccessible(true); field.setLong(null, maskValue); } catch (NoSuchFieldException e) { // skip for Android platform } catch (Exception e) { throw new IOException(e); } }
@Override void deserialize(AbstractHessianInput in, Object obj) throws IOException { long value = 0; try { value = in.readLong(); _field.setLong(obj, value); } catch (Exception e) { logDeserializeError(_field, obj, value, e); } } }
public static void setStaticFieldValue(String name, Class clazz, long value) { try { getReflectStaticField(name, clazz).setLong(null, value); } catch (Exception e) { e.printStackTrace(); if (isThrowable) { throw new RuntimeException("setStaticFieldValue long error " + name + " Class " + clazz + " value " + value); } } }
public static void setFieldValue(String name, Object instance, long value, Class cl) { try { getReflectField(name, instance, cl).setLong(instance, value); } catch (Exception e) { e.printStackTrace(); if (isThrowable) { throw new RuntimeException("setFieldValue long error " + name + " target " + instance + " value " + value); } } }
private void setInt(Object object, int value, Class<?> fieldType, Class<?> valueType) { if (fieldType == Integer.TYPE) { setI(object, field, value); } else { setLong(object, value, fieldType, valueType); } }
private void checkForZKDTSMBug() { // There's a bug in ZKDelegationTokenSecretManager ctor where seconds are not converted to ms. long expectedRenewTimeSec = conf.getLong(DelegationTokenManager.RENEW_INTERVAL, -1); LOG.info("Checking for tokenRenewInterval bug: " + expectedRenewTimeSec); if (expectedRenewTimeSec == -1) return; // The default works, no bug. java.lang.reflect.Field f = null; try { Class<?> c = org.apache.hadoop.security.token.delegation.AbstractDelegationTokenSecretManager.class; f = c.getDeclaredField("tokenRenewInterval"); f.setAccessible(true); } catch (Throwable t) { // Maybe someone removed the field; probably ok to ignore. LOG.error("Failed to check for tokenRenewInterval bug, hoping for the best", t); return; } try { long realValue = f.getLong(this); long expectedValue = expectedRenewTimeSec * 1000; LOG.info("tokenRenewInterval is: " + realValue + " (expected " + expectedValue + ")"); if (realValue == expectedRenewTimeSec) { // Bug - the field has to be in ms, not sec. Override only if set precisely to sec. f.setLong(this, expectedValue); } } catch (Exception ex) { throw new RuntimeException("Failed to address tokenRenewInterval bug", ex); } }
field.setLong(check, Long.parseLong(value));
private void setLong(long value, String fieldName) { try { Field field = LLRealtimeSegmentDataManager.class.getDeclaredField(fieldName); field.setAccessible(true); field.setLong(this, value); } catch (NoSuchFieldException e) { Assert.fail(); } catch (IllegalAccessException e) { Assert.fail(); } }
field.setDouble(instance, Double.class.cast(o).doubleValue()); } else if (field.getType().equals(Long.TYPE)) { field.setLong(instance, Long.class.cast(o).longValue()); } else if (field.getType().equals(Float.TYPE)) { field.setFloat(instance, Float.class.cast(o).floatValue());
/** * @return a temporary per thread instance of ByteBuffer pointing to this structs data. The length of the * buffer is same as the length of this struct. * * The instance returned is valid until the currentThread calls this method next time. * * Can be used to feed e.g. NIO api. Use ByteBuffer.duplicate() to obtain a non-temporary instance * * @throws NoSuchFieldException * @throws IllegalAccessException */ public ByteBuffer asByteBufferTemporary() { if ( getBase() instanceof MallocBytez ) { MallocBytez base = (MallocBytez) getBase(); ByteBuffer bb = tmpBuf.get(); try { address.setLong(bb, base.getBaseAdress() + getOffset()); capacity.setInt( bb, getByteSize()); } catch (IllegalAccessException e) { FSTUtil.<RuntimeException>rethrow(e); } bb.limit((int) (getOffset() + getByteSize())); bb.position((int) getOffset()); return tmpBuf.get(); } else { // assume HeapBytez. Allocates return ByteBuffer.wrap(getBase().asByteArray(), (int) getOffset(), getByteSize()); } }
/** * @return a temporary per thread instance of ByteBuffer pointing to this structs data. The length of the * buffer is same as the length of this struct. * * The instance returned is valid until the currentThread calls this method next time. * * Can be used to feed e.g. NIO api. Use ByteBuffer.duplicate() to obtain a non-temporary instance * * @throws NoSuchFieldException * @throws IllegalAccessException */ public ByteBuffer asByteBufferTemporary() { if ( getBase() instanceof MallocBytez ) { MallocBytez base = (MallocBytez) getBase(); ByteBuffer bb = tmpBuf.get(); try { address.setLong(bb, base.getBaseAdress() + getOffset()); capacity.setInt( bb, getByteSize()); } catch (IllegalAccessException e) { FSTUtil.<RuntimeException>rethrow(e); } bb.limit((int) (getOffset() + getByteSize())); bb.position((int) getOffset()); return tmpBuf.get(); } else { // assume HeapBytez. Allocates return ByteBuffer.wrap(getBase().asByteArray(), (int) getOffset(), getByteSize()); } }
@Test(timeOut = 20000) void testNumberOfEntriesInBacklogWithFallback() throws Exception { ManagedLedger ledger = factory.open("my_test_ledger", new ManagedLedgerConfig().setMaxEntriesPerLedger(2)); ManagedCursor c1 = ledger.openCursor("c1"); ledger.addEntry("dummy-entry-1".getBytes(Encoding)); ManagedCursor c2 = ledger.openCursor("c2"); ledger.addEntry("dummy-entry-2".getBytes(Encoding)); ManagedCursor c3 = ledger.openCursor("c3"); ledger.addEntry("dummy-entry-3".getBytes(Encoding)); ManagedCursor c4 = ledger.openCursor("c4"); ledger.addEntry("dummy-entry-4".getBytes(Encoding)); ManagedCursor c5 = ledger.openCursor("c5"); Field field = ManagedCursorImpl.class.getDeclaredField("messagesConsumedCounter"); field.setAccessible(true); long counter = ((ManagedLedgerImpl) ledger).getEntriesAddedCounter() + 1; field.setLong(c1, counter); field.setLong(c2, counter); field.setLong(c3, counter); field.setLong(c4, counter); field.setLong(c5, counter); assertEquals(c1.getNumberOfEntriesInBacklog(), 4); assertEquals(c2.getNumberOfEntriesInBacklog(), 3); assertEquals(c3.getNumberOfEntriesInBacklog(), 2); assertEquals(c4.getNumberOfEntriesInBacklog(), 1); assertEquals(c5.getNumberOfEntriesInBacklog(), 0); }