Removing default implementation from reflection APIs reflection
authorJaroslav Tulach <jaroslav.tulach@apidesign.org>
Tue, 04 Dec 2012 14:31:11 +0100
branchreflection
changeset 2601d03cb35fbda
parent 259 9b0fbf4ec230
child 261 5d1e20215d12
Removing default implementation from reflection APIs
emul/src/main/java/java/lang/Class.java
emul/src/main/java/java/lang/reflect/AccessibleObject.java
emul/src/main/java/java/lang/reflect/Field.java
emul/src/main/java/java/lang/reflect/Method.java
emul/src/main/java/java/lang/reflect/Modifier.java
     1.1 --- a/emul/src/main/java/java/lang/Class.java	Tue Dec 04 14:08:19 2012 +0100
     1.2 +++ b/emul/src/main/java/java/lang/Class.java	Tue Dec 04 14:31:11 2012 +0100
     1.3 @@ -27,6 +27,7 @@
     1.4  
     1.5  import java.io.InputStream;
     1.6  import java.lang.annotation.Annotation;
     1.7 +import java.lang.reflect.TypeVariable;
     1.8  import org.apidesign.bck2brwsr.core.JavaScriptBody;
     1.9  
    1.10  /**
    1.11 @@ -75,10 +76,10 @@
    1.12   * @since   JDK1.0
    1.13   */
    1.14  public final
    1.15 -    class Class<T> implements java.io.Serializable {
    1.16 -//                              java.lang.reflect.GenericDeclaration,
    1.17 -//                              java.lang.reflect.Type,
    1.18 -//                              java.lang.reflect.AnnotatedElement {
    1.19 +    class Class<T> implements java.io.Serializable,
    1.20 +                              java.lang.reflect.GenericDeclaration,
    1.21 +                              java.lang.reflect.Type,
    1.22 +                              java.lang.reflect.AnnotatedElement {
    1.23      private static final int ANNOTATION= 0x00002000;
    1.24      private static final int ENUM      = 0x00004000;
    1.25      private static final int SYNTHETIC = 0x00001000;
    1.26 @@ -396,6 +397,26 @@
    1.27      @JavaScriptBody(args = "self", body = "return self.jvmName;")
    1.28      private native String jvmName();
    1.29  
    1.30 +    
    1.31 +    /**
    1.32 +     * Returns an array of {@code TypeVariable} objects that represent the
    1.33 +     * type variables declared by the generic declaration represented by this
    1.34 +     * {@code GenericDeclaration} object, in declaration order.  Returns an
    1.35 +     * array of length 0 if the underlying generic declaration declares no type
    1.36 +     * variables.
    1.37 +     *
    1.38 +     * @return an array of {@code TypeVariable} objects that represent
    1.39 +     *     the type variables declared by this generic declaration
    1.40 +     * @throws java.lang.reflect.GenericSignatureFormatError if the generic
    1.41 +     *     signature of this generic declaration does not conform to
    1.42 +     *     the format specified in
    1.43 +     *     <cite>The Java&trade; Virtual Machine Specification</cite>
    1.44 +     * @since 1.5
    1.45 +     */
    1.46 +    public TypeVariable<Class<T>>[] getTypeParameters() {
    1.47 +        throw new UnsupportedOperationException();
    1.48 +    }
    1.49 + 
    1.50      /**
    1.51       * Returns the {@code Class} representing the superclass of the entity
    1.52       * (class, interface, primitive type or void) represented by this
     2.1 --- a/emul/src/main/java/java/lang/reflect/AccessibleObject.java	Tue Dec 04 14:08:19 2012 +0100
     2.2 +++ b/emul/src/main/java/java/lang/reflect/AccessibleObject.java	Tue Dec 04 14:31:11 2012 +0100
     2.3 @@ -25,9 +25,6 @@
     2.4  
     2.5  package java.lang.reflect;
     2.6  
     2.7 -import java.security.AccessController;
     2.8 -import sun.reflect.Reflection;
     2.9 -import sun.reflect.ReflectionFactory;
    2.10  import java.lang.annotation.Annotation;
    2.11  
    2.12  /**
    2.13 @@ -57,14 +54,6 @@
    2.14  public class AccessibleObject implements AnnotatedElement {
    2.15  
    2.16      /**
    2.17 -     * The Permission object that is used to check whether a client
    2.18 -     * has sufficient privilege to defeat Java language access
    2.19 -     * control checks.
    2.20 -     */
    2.21 -    static final private java.security.Permission ACCESS_PERMISSION =
    2.22 -        new ReflectPermission("suppressAccessChecks");
    2.23 -
    2.24 -    /**
    2.25       * Convenience method to set the {@code accessible} flag for an
    2.26       * array of objects with a single security check (for efficiency).
    2.27       *
    2.28 @@ -91,11 +80,7 @@
    2.29       */
    2.30      public static void setAccessible(AccessibleObject[] array, boolean flag)
    2.31          throws SecurityException {
    2.32 -        SecurityManager sm = System.getSecurityManager();
    2.33 -        if (sm != null) sm.checkPermission(ACCESS_PERMISSION);
    2.34 -        for (int i = 0; i < array.length; i++) {
    2.35 -            setAccessible0(array[i], flag);
    2.36 -        }
    2.37 +        throw new SecurityException();
    2.38      }
    2.39  
    2.40      /**
    2.41 @@ -124,23 +109,7 @@
    2.42       * @see java.lang.RuntimePermission
    2.43       */
    2.44      public void setAccessible(boolean flag) throws SecurityException {
    2.45 -        SecurityManager sm = System.getSecurityManager();
    2.46 -        if (sm != null) sm.checkPermission(ACCESS_PERMISSION);
    2.47 -        setAccessible0(this, flag);
    2.48 -    }
    2.49 -
    2.50 -    /* Check that you aren't exposing java.lang.Class.<init>. */
    2.51 -    private static void setAccessible0(AccessibleObject obj, boolean flag)
    2.52 -        throws SecurityException
    2.53 -    {
    2.54 -        if (obj instanceof Constructor && flag == true) {
    2.55 -            Constructor<?> c = (Constructor<?>)obj;
    2.56 -            if (c.getDeclaringClass() == Class.class) {
    2.57 -                throw new SecurityException("Can not make a java.lang.Class" +
    2.58 -                                            " constructor accessible");
    2.59 -            }
    2.60 -        }
    2.61 -        obj.override = flag;
    2.62 +        throw new SecurityException();
    2.63      }
    2.64  
    2.65      /**
    2.66 @@ -165,13 +134,6 @@
    2.67      // outside this package.
    2.68      boolean override;
    2.69  
    2.70 -    // Reflection factory used by subclasses for creating field,
    2.71 -    // method, and constructor accessors. Note that this is called
    2.72 -    // very early in the bootstrapping process.
    2.73 -    static final ReflectionFactory reflectionFactory =
    2.74 -        AccessController.doPrivileged(
    2.75 -            new sun.reflect.ReflectionFactory.GetReflectionFactoryAction());
    2.76 -
    2.77      /**
    2.78       * @throws NullPointerException {@inheritDoc}
    2.79       * @since 1.5
    2.80 @@ -202,73 +164,4 @@
    2.81      public Annotation[] getDeclaredAnnotations()  {
    2.82          throw new AssertionError("All subclasses should override this method");
    2.83      }
    2.84 -
    2.85 -
    2.86 -    // Shared access checking logic.
    2.87 -
    2.88 -    // For non-public members or members in package-private classes,
    2.89 -    // it is necessary to perform somewhat expensive security checks.
    2.90 -    // If the security check succeeds for a given class, it will
    2.91 -    // always succeed (it is not affected by the granting or revoking
    2.92 -    // of permissions); we speed up the check in the common case by
    2.93 -    // remembering the last Class for which the check succeeded.
    2.94 -    //
    2.95 -    // The simple security check for Constructor is to see if
    2.96 -    // the caller has already been seen, verified, and cached.
    2.97 -    // (See also Class.newInstance(), which uses a similar method.)
    2.98 -    //
    2.99 -    // A more complicated security check cache is needed for Method and Field
   2.100 -    // The cache can be either null (empty cache), a 2-array of {caller,target},
   2.101 -    // or a caller (with target implicitly equal to this.clazz).
   2.102 -    // In the 2-array case, the target is always different from the clazz.
   2.103 -    volatile Object securityCheckCache;
   2.104 -
   2.105 -    void checkAccess(Class<?> caller, Class<?> clazz, Object obj, int modifiers)
   2.106 -        throws IllegalAccessException
   2.107 -    {
   2.108 -        if (caller == clazz) {  // quick check
   2.109 -            return;             // ACCESS IS OK
   2.110 -        }
   2.111 -        Object cache = securityCheckCache;  // read volatile
   2.112 -        Class<?> targetClass = clazz;
   2.113 -        if (obj != null
   2.114 -            && Modifier.isProtected(modifiers)
   2.115 -            && ((targetClass = obj.getClass()) != clazz)) {
   2.116 -            // Must match a 2-list of { caller, targetClass }.
   2.117 -            if (cache instanceof Class[]) {
   2.118 -                Class<?>[] cache2 = (Class<?>[]) cache;
   2.119 -                if (cache2[1] == targetClass &&
   2.120 -                    cache2[0] == caller) {
   2.121 -                    return;     // ACCESS IS OK
   2.122 -                }
   2.123 -                // (Test cache[1] first since range check for [1]
   2.124 -                // subsumes range check for [0].)
   2.125 -            }
   2.126 -        } else if (cache == caller) {
   2.127 -            // Non-protected case (or obj.class == this.clazz).
   2.128 -            return;             // ACCESS IS OK
   2.129 -        }
   2.130 -
   2.131 -        // If no return, fall through to the slow path.
   2.132 -        slowCheckMemberAccess(caller, clazz, obj, modifiers, targetClass);
   2.133 -    }
   2.134 -
   2.135 -    // Keep all this slow stuff out of line:
   2.136 -    void slowCheckMemberAccess(Class<?> caller, Class<?> clazz, Object obj, int modifiers,
   2.137 -                               Class<?> targetClass)
   2.138 -        throws IllegalAccessException
   2.139 -    {
   2.140 -        Reflection.ensureMemberAccess(caller, clazz, obj, modifiers);
   2.141 -
   2.142 -        // Success: Update the cache.
   2.143 -        Object cache = ((targetClass == clazz)
   2.144 -                        ? caller
   2.145 -                        : new Class<?>[] { caller, targetClass });
   2.146 -
   2.147 -        // Note:  The two cache elements are not volatile,
   2.148 -        // but they are effectively final.  The Java memory model
   2.149 -        // guarantees that the initializing stores for the cache
   2.150 -        // elements will occur before the volatile write.
   2.151 -        securityCheckCache = cache;         // write volatile
   2.152 -    }
   2.153  }
     3.1 --- a/emul/src/main/java/java/lang/reflect/Field.java	Tue Dec 04 14:08:19 2012 +0100
     3.2 +++ b/emul/src/main/java/java/lang/reflect/Field.java	Tue Dec 04 14:31:11 2012 +0100
     3.3 @@ -25,15 +25,7 @@
     3.4  
     3.5  package java.lang.reflect;
     3.6  
     3.7 -import sun.reflect.FieldAccessor;
     3.8 -import sun.reflect.Reflection;
     3.9 -import sun.reflect.generics.repository.FieldRepository;
    3.10 -import sun.reflect.generics.factory.CoreReflectionFactory;
    3.11 -import sun.reflect.generics.factory.GenericsFactory;
    3.12 -import sun.reflect.generics.scope.ClassScope;
    3.13  import java.lang.annotation.Annotation;
    3.14 -import java.util.Map;
    3.15 -import sun.reflect.annotation.AnnotationParser;
    3.16  
    3.17  
    3.18  /**
    3.19 @@ -67,13 +59,7 @@
    3.20      private int                 modifiers;
    3.21      // Generics and annotations support
    3.22      private transient String    signature;
    3.23 -    // generic info repository; lazily initialized
    3.24 -    private transient FieldRepository genericInfo;
    3.25      private byte[]              annotations;
    3.26 -    // Cached field accessor created without override
    3.27 -    private FieldAccessor fieldAccessor;
    3.28 -    // Cached field accessor created with override
    3.29 -    private FieldAccessor overrideFieldAccessor;
    3.30      // For sharing of FieldAccessors. This branching structure is
    3.31      // currently only two levels deep (i.e., one root Field and
    3.32      // potentially many Field objects pointing to it.)
    3.33 @@ -83,24 +69,6 @@
    3.34  
    3.35      private String getGenericSignature() {return signature;}
    3.36  
    3.37 -    // Accessor for factory
    3.38 -    private GenericsFactory getFactory() {
    3.39 -        Class<?> c = getDeclaringClass();
    3.40 -        // create scope and factory
    3.41 -        return CoreReflectionFactory.make(c, ClassScope.make(c));
    3.42 -    }
    3.43 -
    3.44 -    // Accessor for generic info repository
    3.45 -    private FieldRepository getGenericInfo() {
    3.46 -        // lazily initialize repository if necessary
    3.47 -        if (genericInfo == null) {
    3.48 -            // create and cache generic info repository
    3.49 -            genericInfo = FieldRepository.make(getGenericSignature(),
    3.50 -                                               getFactory());
    3.51 -        }
    3.52 -        return genericInfo; //return cached repository
    3.53 -    }
    3.54 -
    3.55  
    3.56      /**
    3.57       * Package-private constructor used by ReflectAccess to enable
    3.58 @@ -139,9 +107,6 @@
    3.59          // objects.)
    3.60          Field res = new Field(clazz, name, type, modifiers, slot, signature, annotations);
    3.61          res.root = this;
    3.62 -        // Might as well eagerly propagate this if already present
    3.63 -        res.fieldAccessor = fieldAccessor;
    3.64 -        res.overrideFieldAccessor = overrideFieldAccessor;
    3.65          return res;
    3.66      }
    3.67  
    3.68 @@ -232,10 +197,7 @@
    3.69       * @since 1.5
    3.70       */
    3.71      public Type getGenericType() {
    3.72 -        if (getGenericSignature() != null)
    3.73 -            return getGenericInfo().getGenericType();
    3.74 -        else
    3.75 -            return getType();
    3.76 +        throw new UnsupportedOperationException();
    3.77      }
    3.78  
    3.79  
    3.80 @@ -924,65 +886,28 @@
    3.81      private FieldAccessor getFieldAccessor(Object obj)
    3.82          throws IllegalAccessException
    3.83      {
    3.84 -        doSecurityCheck(obj);
    3.85 -        boolean ov = override;
    3.86 -        FieldAccessor a = (ov)? overrideFieldAccessor : fieldAccessor;
    3.87 -        return (a != null)? a : acquireFieldAccessor(ov);
    3.88 +        throw new SecurityException();
    3.89      }
    3.90 -
    3.91 -    // NOTE that there is no synchronization used here. It is correct
    3.92 -    // (though not efficient) to generate more than one FieldAccessor
    3.93 -    // for a given Field. However, avoiding synchronization will
    3.94 -    // probably make the implementation more scalable.
    3.95 -    private FieldAccessor acquireFieldAccessor(boolean overrideFinalCheck) {
    3.96 -        // First check to see if one has been created yet, and take it
    3.97 -        // if so
    3.98 -        FieldAccessor tmp = null;
    3.99 -        if (root != null) tmp = root.getFieldAccessor(overrideFinalCheck);
   3.100 -        if (tmp != null) {
   3.101 -            if (overrideFinalCheck)
   3.102 -                overrideFieldAccessor = tmp;
   3.103 -            else
   3.104 -                fieldAccessor = tmp;
   3.105 -        } else {
   3.106 -            // Otherwise fabricate one and propagate it up to the root
   3.107 -            tmp = reflectionFactory.newFieldAccessor(this, overrideFinalCheck);
   3.108 -            setFieldAccessor(tmp, overrideFinalCheck);
   3.109 -        }
   3.110 -
   3.111 -        return tmp;
   3.112 -    }
   3.113 -
   3.114 -    // Returns FieldAccessor for this Field object, not looking up
   3.115 -    // the chain to the root
   3.116 -    private FieldAccessor getFieldAccessor(boolean overrideFinalCheck) {
   3.117 -        return (overrideFinalCheck)? overrideFieldAccessor : fieldAccessor;
   3.118 -    }
   3.119 -
   3.120 -    // Sets the FieldAccessor for this Field object and
   3.121 -    // (recursively) its root
   3.122 -    private void setFieldAccessor(FieldAccessor accessor, boolean overrideFinalCheck) {
   3.123 -        if (overrideFinalCheck)
   3.124 -            overrideFieldAccessor = accessor;
   3.125 -        else
   3.126 -            fieldAccessor = accessor;
   3.127 -        // Propagate up
   3.128 -        if (root != null) {
   3.129 -            root.setFieldAccessor(accessor, overrideFinalCheck);
   3.130 -        }
   3.131 -    }
   3.132 -
   3.133 -    // NOTE: be very careful if you change the stack depth of this
   3.134 -    // routine. The depth of the "getCallerClass" call is hardwired so
   3.135 -    // that the compiler can have an easier time if this gets inlined.
   3.136 -    private void doSecurityCheck(Object obj) throws IllegalAccessException {
   3.137 -        if (!override) {
   3.138 -            if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) {
   3.139 -                Class<?> caller = Reflection.getCallerClass(4);
   3.140 -
   3.141 -                checkAccess(caller, clazz, obj, modifiers);
   3.142 -            }
   3.143 -        }
   3.144 +    
   3.145 +    private static abstract class FieldAccessor {
   3.146 +        abstract void setShort(Object obj, short s);
   3.147 +        abstract void setInt(Object obj, int i);
   3.148 +        abstract void setChar(Object obj, char c);
   3.149 +        abstract void setByte(Object obj, byte b);
   3.150 +        abstract void setBoolean(Object obj, boolean z);
   3.151 +        abstract void set(Object obj, Object value);
   3.152 +        abstract double getDouble(Object obj);
   3.153 +        abstract void setLong(Object obj, long l);
   3.154 +        abstract void setFloat(Object obj, float f);
   3.155 +        abstract void setDouble(Object obj, double d);
   3.156 +        abstract long getLong(Object obj);
   3.157 +        abstract int getInt(Object obj);
   3.158 +        abstract short getShort(Object obj);
   3.159 +        abstract char getChar(Object obj);
   3.160 +        abstract byte getByte(Object obj);
   3.161 +        abstract boolean getBoolean(Object obj);
   3.162 +        abstract Object get(Object obj);
   3.163 +        abstract float getFloat(Object obj);
   3.164      }
   3.165  
   3.166      /*
   3.167 @@ -1016,25 +941,13 @@
   3.168          if (annotationClass == null)
   3.169              throw new NullPointerException();
   3.170  
   3.171 -        return (T) declaredAnnotations().get(annotationClass);
   3.172 +        throw new UnsupportedOperationException();
   3.173      }
   3.174  
   3.175      /**
   3.176       * @since 1.5
   3.177       */
   3.178      public Annotation[] getDeclaredAnnotations()  {
   3.179 -        return AnnotationParser.toArray(declaredAnnotations());
   3.180 -    }
   3.181 -
   3.182 -    private transient Map<Class<? extends Annotation>, Annotation> declaredAnnotations;
   3.183 -
   3.184 -    private synchronized  Map<Class<? extends Annotation>, Annotation> declaredAnnotations() {
   3.185 -        if (declaredAnnotations == null) {
   3.186 -            declaredAnnotations = AnnotationParser.parseAnnotations(
   3.187 -                annotations, sun.misc.SharedSecrets.getJavaLangAccess().
   3.188 -                getConstantPool(getDeclaringClass()),
   3.189 -                getDeclaringClass());
   3.190 -        }
   3.191 -        return declaredAnnotations;
   3.192 +        throw new UnsupportedOperationException();
   3.193      }
   3.194  }
     4.1 --- a/emul/src/main/java/java/lang/reflect/Method.java	Tue Dec 04 14:08:19 2012 +0100
     4.2 +++ b/emul/src/main/java/java/lang/reflect/Method.java	Tue Dec 04 14:31:11 2012 +0100
     4.3 @@ -25,18 +25,7 @@
     4.4  
     4.5  package java.lang.reflect;
     4.6  
     4.7 -import sun.reflect.MethodAccessor;
     4.8 -import sun.reflect.Reflection;
     4.9 -import sun.reflect.generics.repository.MethodRepository;
    4.10 -import sun.reflect.generics.factory.CoreReflectionFactory;
    4.11 -import sun.reflect.generics.factory.GenericsFactory;
    4.12 -import sun.reflect.generics.scope.MethodScope;
    4.13 -import sun.reflect.annotation.AnnotationType;
    4.14 -import sun.reflect.annotation.AnnotationParser;
    4.15  import java.lang.annotation.Annotation;
    4.16 -import java.lang.annotation.AnnotationFormatError;
    4.17 -import java.nio.ByteBuffer;
    4.18 -import java.util.Map;
    4.19  
    4.20  /**
    4.21   * A {@code Method} provides information about, and access to, a single method
    4.22 @@ -72,12 +61,9 @@
    4.23      private int                 modifiers;
    4.24      // Generics and annotations support
    4.25      private transient String              signature;
    4.26 -    // generic info repository; lazily initialized
    4.27 -    private transient MethodRepository genericInfo;
    4.28      private byte[]              annotations;
    4.29      private byte[]              parameterAnnotations;
    4.30      private byte[]              annotationDefault;
    4.31 -    private volatile MethodAccessor methodAccessor;
    4.32      // For sharing of MethodAccessors. This branching structure is
    4.33      // currently only two levels deep (i.e., one root Method and
    4.34      // potentially many Method objects pointing to it.)
    4.35 @@ -87,23 +73,6 @@
    4.36  
    4.37      private String getGenericSignature() {return signature;}
    4.38  
    4.39 -    // Accessor for factory
    4.40 -    private GenericsFactory getFactory() {
    4.41 -        // create scope and factory
    4.42 -        return CoreReflectionFactory.make(this, MethodScope.make(this));
    4.43 -    }
    4.44 -
    4.45 -    // Accessor for generic info repository
    4.46 -    private MethodRepository getGenericInfo() {
    4.47 -        // lazily initialize repository if necessary
    4.48 -        if (genericInfo == null) {
    4.49 -            // create and cache generic info repository
    4.50 -            genericInfo = MethodRepository.make(getGenericSignature(),
    4.51 -                                                getFactory());
    4.52 -        }
    4.53 -        return genericInfo; //return cached repository
    4.54 -    }
    4.55 -
    4.56      /**
    4.57       * Package-private constructor used by ReflectAccess to enable
    4.58       * instantiation of these objects in Java code from the java.lang
    4.59 @@ -151,8 +120,6 @@
    4.60                                  exceptionTypes, modifiers, slot, signature,
    4.61                                  annotations, parameterAnnotations, annotationDefault);
    4.62          res.root = this;
    4.63 -        // Might as well eagerly propagate this if already present
    4.64 -        res.methodAccessor = methodAccessor;
    4.65          return res;
    4.66      }
    4.67  
    4.68 @@ -199,10 +166,7 @@
    4.69       * @since 1.5
    4.70       */
    4.71      public TypeVariable<Method>[] getTypeParameters() {
    4.72 -        if (getGenericSignature() != null)
    4.73 -            return (TypeVariable<Method>[])getGenericInfo().getTypeParameters();
    4.74 -        else
    4.75 -            return (TypeVariable<Method>[])new TypeVariable[0];
    4.76 +        throw new UnsupportedOperationException();
    4.77      }
    4.78  
    4.79      /**
    4.80 @@ -240,9 +204,7 @@
    4.81       * @since 1.5
    4.82       */
    4.83      public Type getGenericReturnType() {
    4.84 -      if (getGenericSignature() != null) {
    4.85 -        return getGenericInfo().getReturnType();
    4.86 -      } else { return getReturnType();}
    4.87 +        throw new UnsupportedOperationException();
    4.88      }
    4.89  
    4.90  
    4.91 @@ -287,10 +249,7 @@
    4.92       * @since 1.5
    4.93       */
    4.94      public Type[] getGenericParameterTypes() {
    4.95 -        if (getGenericSignature() != null)
    4.96 -            return getGenericInfo().getParameterTypes();
    4.97 -        else
    4.98 -            return getParameterTypes();
    4.99 +        throw new UnsupportedOperationException();
   4.100      }
   4.101  
   4.102  
   4.103 @@ -331,12 +290,7 @@
   4.104       * @since 1.5
   4.105       */
   4.106        public Type[] getGenericExceptionTypes() {
   4.107 -          Type[] result;
   4.108 -          if (getGenericSignature() != null &&
   4.109 -              ((result = getGenericInfo().getExceptionTypes()).length > 0))
   4.110 -              return result;
   4.111 -          else
   4.112 -              return getExceptionTypes();
   4.113 +        throw new UnsupportedOperationException();
   4.114        }
   4.115  
   4.116      /**
   4.117 @@ -587,18 +541,7 @@
   4.118          throws IllegalAccessException, IllegalArgumentException,
   4.119             InvocationTargetException
   4.120      {
   4.121 -        if (!override) {
   4.122 -            if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) {
   4.123 -                Class<?> caller = Reflection.getCallerClass(1);
   4.124 -
   4.125 -                checkAccess(caller, clazz, obj, modifiers);
   4.126 -            }
   4.127 -        }
   4.128 -        MethodAccessor ma = methodAccessor;             // read volatile
   4.129 -        if (ma == null) {
   4.130 -            ma = acquireMethodAccessor();
   4.131 -        }
   4.132 -        return ma.invoke(obj, args);
   4.133 +        throw new UnsupportedOperationException();
   4.134      }
   4.135  
   4.136      /**
   4.137 @@ -638,42 +581,6 @@
   4.138          return Modifier.isSynthetic(getModifiers());
   4.139      }
   4.140  
   4.141 -    // NOTE that there is no synchronization used here. It is correct
   4.142 -    // (though not efficient) to generate more than one MethodAccessor
   4.143 -    // for a given Method. However, avoiding synchronization will
   4.144 -    // probably make the implementation more scalable.
   4.145 -    private MethodAccessor acquireMethodAccessor() {
   4.146 -        // First check to see if one has been created yet, and take it
   4.147 -        // if so
   4.148 -        MethodAccessor tmp = null;
   4.149 -        if (root != null) tmp = root.getMethodAccessor();
   4.150 -        if (tmp != null) {
   4.151 -            methodAccessor = tmp;
   4.152 -        } else {
   4.153 -            // Otherwise fabricate one and propagate it up to the root
   4.154 -            tmp = reflectionFactory.newMethodAccessor(this);
   4.155 -            setMethodAccessor(tmp);
   4.156 -        }
   4.157 -
   4.158 -        return tmp;
   4.159 -    }
   4.160 -
   4.161 -    // Returns MethodAccessor for this Method object, not looking up
   4.162 -    // the chain to the root
   4.163 -    MethodAccessor getMethodAccessor() {
   4.164 -        return methodAccessor;
   4.165 -    }
   4.166 -
   4.167 -    // Sets the MethodAccessor for this Method object and
   4.168 -    // (recursively) its root
   4.169 -    void setMethodAccessor(MethodAccessor accessor) {
   4.170 -        methodAccessor = accessor;
   4.171 -        // Propagate up
   4.172 -        if (root != null) {
   4.173 -            root.setMethodAccessor(accessor);
   4.174 -        }
   4.175 -    }
   4.176 -
   4.177      /**
   4.178       * @throws NullPointerException {@inheritDoc}
   4.179       * @since 1.5
   4.180 @@ -682,26 +589,14 @@
   4.181          if (annotationClass == null)
   4.182              throw new NullPointerException();
   4.183  
   4.184 -        return (T) declaredAnnotations().get(annotationClass);
   4.185 +        throw new UnsupportedOperationException();
   4.186      }
   4.187  
   4.188      /**
   4.189       * @since 1.5
   4.190       */
   4.191      public Annotation[] getDeclaredAnnotations()  {
   4.192 -        return AnnotationParser.toArray(declaredAnnotations());
   4.193 -    }
   4.194 -
   4.195 -    private transient Map<Class<? extends Annotation>, Annotation> declaredAnnotations;
   4.196 -
   4.197 -    private synchronized  Map<Class<? extends Annotation>, Annotation> declaredAnnotations() {
   4.198 -        if (declaredAnnotations == null) {
   4.199 -            declaredAnnotations = AnnotationParser.parseAnnotations(
   4.200 -                annotations, sun.misc.SharedSecrets.getJavaLangAccess().
   4.201 -                getConstantPool(getDeclaringClass()),
   4.202 -                getDeclaringClass());
   4.203 -        }
   4.204 -        return declaredAnnotations;
   4.205 +        throw new UnsupportedOperationException();
   4.206      }
   4.207  
   4.208      /**
   4.209 @@ -721,16 +616,7 @@
   4.210      public Object getDefaultValue() {
   4.211          if  (annotationDefault == null)
   4.212              return null;
   4.213 -        Class<?> memberType = AnnotationType.invocationHandlerReturnType(
   4.214 -            getReturnType());
   4.215 -        Object result = AnnotationParser.parseMemberValue(
   4.216 -            memberType, ByteBuffer.wrap(annotationDefault),
   4.217 -            sun.misc.SharedSecrets.getJavaLangAccess().
   4.218 -                getConstantPool(getDeclaringClass()),
   4.219 -            getDeclaringClass());
   4.220 -        if (result instanceof sun.reflect.annotation.ExceptionProxy)
   4.221 -            throw new AnnotationFormatError("Invalid default: " + this);
   4.222 -        return result;
   4.223 +        throw new UnsupportedOperationException();
   4.224      }
   4.225  
   4.226      /**
   4.227 @@ -754,14 +640,6 @@
   4.228          if (parameterAnnotations == null)
   4.229              return new Annotation[numParameters][0];
   4.230  
   4.231 -        Annotation[][] result = AnnotationParser.parseParameterAnnotations(
   4.232 -            parameterAnnotations,
   4.233 -            sun.misc.SharedSecrets.getJavaLangAccess().
   4.234 -                getConstantPool(getDeclaringClass()),
   4.235 -            getDeclaringClass());
   4.236 -        if (result.length != numParameters)
   4.237 -            throw new java.lang.annotation.AnnotationFormatError(
   4.238 -                "Parameter annotations don't match number of parameters");
   4.239 -        return result;
   4.240 +        throw new UnsupportedOperationException();
   4.241      }
   4.242  }
     5.1 --- a/emul/src/main/java/java/lang/reflect/Modifier.java	Tue Dec 04 14:08:19 2012 +0100
     5.2 +++ b/emul/src/main/java/java/lang/reflect/Modifier.java	Tue Dec 04 14:31:11 2012 +0100
     5.3 @@ -25,10 +25,6 @@
     5.4  
     5.5  package java.lang.reflect;
     5.6  
     5.7 -import java.security.AccessController;
     5.8 -import sun.reflect.LangReflectAccess;
     5.9 -import sun.reflect.ReflectionFactory;
    5.10 -
    5.11  /**
    5.12   * The Modifier class provides {@code static} methods and
    5.13   * constants to decode class and member access modifiers.  The sets of
    5.14 @@ -46,17 +42,6 @@
    5.15  public
    5.16  class Modifier {
    5.17  
    5.18 -    /*
    5.19 -     * Bootstrapping protocol between java.lang and java.lang.reflect
    5.20 -     *  packages
    5.21 -     */
    5.22 -    static {
    5.23 -        sun.reflect.ReflectionFactory factory =
    5.24 -            AccessController.doPrivileged(
    5.25 -                new ReflectionFactory.GetReflectionFactoryAction());
    5.26 -        factory.setLangReflectAccess(new java.lang.reflect.ReflectAccess());
    5.27 -    }
    5.28 -
    5.29      /**
    5.30       * Return {@code true} if the integer argument includes the
    5.31       * {@code public} modifier, {@code false} otherwise.