src/share/classes/sun/misc/Unsafe.java

Print this page

        

*** 79,89 **** * @exception SecurityException if a security manager exists and its * <code>checkPropertiesAccess</code> method doesn't allow * access to the system properties. */ public static Unsafe getUnsafe() { ! Class cc = sun.reflect.Reflection.getCallerClass(2); if (cc.getClassLoader() != null) throw new SecurityException("Unsafe"); return theUnsafe; } --- 79,89 ---- * @exception SecurityException if a security manager exists and its * <code>checkPropertiesAccess</code> method doesn't allow * access to the system properties. */ public static Unsafe getUnsafe() { ! Class<?> cc = sun.reflect.Reflection.getCallerClass(2); if (cc.getClassLoader() != null) throw new SecurityException("Unsafe"); return theUnsafe; }
*** 614,624 **** * to obtain the base pertaining to a specific {@link Field}. * This method works only for JVMs which store all statics * for a given class in one place. */ @Deprecated ! public Object staticFieldBase(Class c) { Field[] fields = c.getDeclaredFields(); for (int i = 0; i < fields.length; i++) { if (Modifier.isStatic(fields[i].getModifiers())) { return staticFieldBase(fields[i]); } --- 614,624 ---- * to obtain the base pertaining to a specific {@link Field}. * This method works only for JVMs which store all statics * for a given class in one place. */ @Deprecated ! public Object staticFieldBase(Class<?> c) { Field[] fields = c.getDeclaredFields(); for (int i = 0; i < fields.length; i++) { if (Modifier.isStatic(fields[i].getModifiers())) { return staticFieldBase(fields[i]); }
*** 680,690 **** /** * Ensure the given class has been initialized. This is often * needed in conjunction with obtaining the static field base of a * class. */ ! public native void ensureClassInitialized(Class c); /** * Report the offset of the first element in the storage allocation of a * given array class. If {@link #arrayIndexScale} returns a non-zero value * for the same class, you may use that scale factor, together with this --- 680,690 ---- /** * Ensure the given class has been initialized. This is often * needed in conjunction with obtaining the static field base of a * class. */ ! public native void ensureClassInitialized(Class<?> c); /** * Report the offset of the first element in the storage allocation of a * given array class. If {@link #arrayIndexScale} returns a non-zero value * for the same class, you may use that scale factor, together with this
*** 692,702 **** * given class. * * @see #getInt(Object, long) * @see #putInt(Object, long, int) */ ! public native int arrayBaseOffset(Class arrayClass); /** The value of {@code arrayBaseOffset(boolean[].class)} */ public static final int ARRAY_BOOLEAN_BASE_OFFSET = theUnsafe.arrayBaseOffset(boolean[].class); --- 692,702 ---- * given class. * * @see #getInt(Object, long) * @see #putInt(Object, long, int) */ ! public native int arrayBaseOffset(Class<?> arrayClass); /** The value of {@code arrayBaseOffset(boolean[].class)} */ public static final int ARRAY_BOOLEAN_BASE_OFFSET = theUnsafe.arrayBaseOffset(boolean[].class);
*** 741,751 **** * * @see #arrayBaseOffset * @see #getInt(Object, long) * @see #putInt(Object, long, int) */ ! public native int arrayIndexScale(Class arrayClass); /** The value of {@code arrayIndexScale(boolean[].class)} */ public static final int ARRAY_BOOLEAN_INDEX_SCALE = theUnsafe.arrayIndexScale(boolean[].class); --- 741,751 ---- * * @see #arrayBaseOffset * @see #getInt(Object, long) * @see #putInt(Object, long, int) */ ! public native int arrayIndexScale(Class<?> arrayClass); /** The value of {@code arrayIndexScale(boolean[].class)} */ public static final int ARRAY_BOOLEAN_INDEX_SCALE = theUnsafe.arrayIndexScale(boolean[].class);
*** 803,817 **** /** * Tell the VM to define a class, without security checks. By default, the * class loader and protection domain come from the caller's class. */ ! public native Class defineClass(String name, byte[] b, int off, int len, ClassLoader loader, ProtectionDomain protectionDomain); ! public native Class defineClass(String name, byte[] b, int off, int len); /** * Define a class but do not make it known to the class loader or system dictionary. * <p> * For each CP entry, the corresponding CP patch must either be null or have --- 803,817 ---- /** * Tell the VM to define a class, without security checks. By default, the * class loader and protection domain come from the caller's class. */ ! public native Class<?> defineClass(String name, byte[] b, int off, int len, ClassLoader loader, ProtectionDomain protectionDomain); ! public native Class<?> defineClass(String name, byte[] b, int off, int len); /** * Define a class but do not make it known to the class loader or system dictionary. * <p> * For each CP entry, the corresponding CP patch must either be null or have
*** 825,840 **** * </ul> * @params hostClass context for linkage, access control, protection domain, and class loader * @params data bytes of a class file * @params cpPatches where non-null entries exist, they replace corresponding CP entries in data */ ! public native Class defineAnonymousClass(Class hostClass, byte[] data, Object[] cpPatches); /** Allocate an instance but do not run any constructor. Initializes the class if it has not yet been. */ ! public native Object allocateInstance(Class cls) throws InstantiationException; /** Lock the object. It must get unlocked via {@link #monitorExit}. */ public native void monitorEnter(Object o); --- 825,840 ---- * </ul> * @params hostClass context for linkage, access control, protection domain, and class loader * @params data bytes of a class file * @params cpPatches where non-null entries exist, they replace corresponding CP entries in data */ ! public native Class<?> defineAnonymousClass(Class<?> hostClass, byte[] data, Object[] cpPatches); /** Allocate an instance but do not run any constructor. Initializes the class if it has not yet been. */ ! public native Object allocateInstance(Class<?> cls) throws InstantiationException; /** Lock the object. It must get unlocked via {@link #monitorExit}. */ public native void monitorEnter(Object o);