public Bridge run() { return Bridge.get(); } });
@SuppressWarnings("unchecked") private Bridge() { latestUserDefinedLoaderMethod = getLatestUserDefinedLoaderMethod(); unsafe = getUnsafe(); reflectionFactory = (ReflectionFactory) AccessController .doPrivileged(new ReflectionFactory.GetReflectionFactoryAction()); }
void setField(Field field) { this.field = field; this.fieldID = bridge.objectFieldOffset(field); }
bridge.putByte(o, field.getFieldID(), byteValue); bridge.putBoolean(o, field.getFieldID(), booleanValue); bridge.putChar(o, field.getFieldID(), charValue); bridge.putShort(o, field.getFieldID(), shortValue); bridge.putInt(o, field.getFieldID(), intValue); bridge.putLong(o, field.getFieldID(), longValue); bridge.putFloat(o, field.getFieldID(), floatValue); bridge.putDouble(o, field.getFieldID(), doubleValue);
private static void setFloatField(Object o, Class<?> c, String fieldName, float v) { try { Field fld = c.getDeclaredField(fieldName); long key = bridge.objectFieldOffset(fld); bridge.putFloat(o, key, v); } catch (Exception e) { throw utilWrapper.errorSetFloatField(e, fieldName, o.toString(), new Float(v)); } }
private static void setDoubleField(Object o, Class<?> c, String fieldName, double v) { try { Field fld = c.getDeclaredField(fieldName); long key = bridge.objectFieldOffset(fld); bridge.putDouble(o, key, v); } catch (Exception e) { throw utilWrapper.errorSetDoubleField(e, fieldName, o.toString(), new Double(v)); } }
private static void setCharField(Object o, Class<?> c, String fieldName, char v) { try { Field fld = c.getDeclaredField(fieldName); long key = bridge.objectFieldOffset(fld); bridge.putChar(o, key, v); } catch (Exception e) { throw utilWrapper.errorSetCharField(e, fieldName, o.toString(), new Character(v)); } }
private static void setLongField(Object o, Class<?> c, String fieldName, long v) { try { Field fld = c.getDeclaredField(fieldName); long key = bridge.objectFieldOffset(fld); bridge.putLong(o, key, v); } catch (Exception e) { throw utilWrapper.errorSetLongField(e, fieldName, o.toString(), new Long(v)); } }
private static void setBooleanField(Object o, Class<?> c, String fieldName, boolean v) { try { Field fld = c.getDeclaredField(fieldName); long key = bridge.objectFieldOffset(fld); bridge.putBoolean(o, key, v); } catch (Exception e) { throw utilWrapper.errorSetBooleanField(e, fieldName, o.toString(), new Boolean(v)); } }
private static void setObjectField(Object o, Class<?> c, String fieldName, Object v) { try { Field fld = c.getDeclaredField(fieldName); long key = bridge.objectFieldOffset(fld); bridge.putObject(o, key, v); } catch (Exception e) { throw utilWrapper.errorSetObjectField(e, fieldName, o.toString(), v.toString()); } }
private static void setByteField(Object o, Class<?> c, String fieldName, byte v) { try { Field fld = c.getDeclaredField(fieldName); long key = bridge.objectFieldOffset(fld); bridge.putByte(o, key, v); } catch (Exception e) { throw utilWrapper.errorSetByteField(e, fieldName, o.toString(), new Byte(v)); } }
private static void setIntField(Object o, Class<?> c, String fieldName, int v) { try { Field fld = c.getDeclaredField(fieldName); long key = bridge.objectFieldOffset(fld); bridge.putInt(o, key, v); } catch (Exception e) { throw utilWrapper.errorSetIntField(e, fieldName, o.toString(), new Integer(v)); } }
private static void setShortField(Object o, Class<?> c, String fieldName, short v) { try { Field fld = c.getDeclaredField(fieldName); long key = bridge.objectFieldOffset(fld); bridge.putShort(o, key, v); } catch (Exception e) { throw utilWrapper.errorSetShortField(e, fieldName, o.toString(), new Short(v)); } }
/** * Fetch the Bridge singleton. This requires the following permissions: * <ul> * <li>RuntimePermission "reflectionFactoryAccess"</li> * <li>BridgePermission "getBridge"</li> * <li>ReflectPermission "suppressAccessChecks"</li> * </ul> * * @return The singleton instance of the Bridge class * @throws SecurityException * if the caller does not have the required permissions and the caller has a non-null security manager. */ public static final synchronized Bridge get() { SecurityManager sman = System.getSecurityManager(); if (sman != null) sman.checkPermission(getBridgePermission); if (bridge == null) { bridge = new Bridge(); } return bridge; }
cons = bridge.newConstructorForSerialization(cl, cons); cons.setAccessible(true); return cons;
loader = bridge.getLatestUserDefinedLoader();
bridge.putByte(o, field.getFieldID(), byteValue); bridge.putBoolean(o, field.getFieldID(), booleanValue); bridge.putChar(o, field.getFieldID(), charValue); bridge.putShort(o, field.getFieldID(), shortValue); bridge.putInt(o, field.getFieldID(), intValue); bridge.putLong(o, field.getFieldID(), longValue); bridge.putFloat(o, field.getFieldID(), floatValue); bridge.putDouble(o, field.getFieldID(), doubleValue);
private static void setFloatField(Object o, Class<?> c, String fieldName, float v) { try { Field fld = c.getDeclaredField(fieldName); long key = bridge.objectFieldOffset(fld); bridge.putFloat(o, key, v); } catch (Exception e) { throw utilWrapper.errorSetFloatField(e, fieldName, o.toString(), new Float(v)); } }
private static void setDoubleField(Object o, Class<?> c, String fieldName, double v) { try { Field fld = c.getDeclaredField(fieldName); long key = bridge.objectFieldOffset(fld); bridge.putDouble(o, key, v); } catch (Exception e) { throw utilWrapper.errorSetDoubleField(e, fieldName, o.toString(), new Double(v)); } }
private static void setCharField(Object o, Class<?> c, String fieldName, char v) { try { Field fld = c.getDeclaredField(fieldName); long key = bridge.objectFieldOffset(fld); bridge.putChar(o, key, v); } catch (Exception e) { throw utilWrapper.errorSetCharField(e, fieldName, o.toString(), new Character(v)); } }