1.1 --- a/emul/src/main/java/java/lang/reflect/Method.java Tue Dec 04 13:29:17 2012 +0100
1.2 +++ b/emul/src/main/java/java/lang/reflect/Method.java Tue Dec 04 14:31:11 2012 +0100
1.3 @@ -25,18 +25,7 @@
1.4
1.5 package java.lang.reflect;
1.6
1.7 -import sun.reflect.MethodAccessor;
1.8 -import sun.reflect.Reflection;
1.9 -import sun.reflect.generics.repository.MethodRepository;
1.10 -import sun.reflect.generics.factory.CoreReflectionFactory;
1.11 -import sun.reflect.generics.factory.GenericsFactory;
1.12 -import sun.reflect.generics.scope.MethodScope;
1.13 -import sun.reflect.annotation.AnnotationType;
1.14 -import sun.reflect.annotation.AnnotationParser;
1.15 import java.lang.annotation.Annotation;
1.16 -import java.lang.annotation.AnnotationFormatError;
1.17 -import java.nio.ByteBuffer;
1.18 -import java.util.Map;
1.19
1.20 /**
1.21 * A {@code Method} provides information about, and access to, a single method
1.22 @@ -72,12 +61,9 @@
1.23 private int modifiers;
1.24 // Generics and annotations support
1.25 private transient String signature;
1.26 - // generic info repository; lazily initialized
1.27 - private transient MethodRepository genericInfo;
1.28 private byte[] annotations;
1.29 private byte[] parameterAnnotations;
1.30 private byte[] annotationDefault;
1.31 - private volatile MethodAccessor methodAccessor;
1.32 // For sharing of MethodAccessors. This branching structure is
1.33 // currently only two levels deep (i.e., one root Method and
1.34 // potentially many Method objects pointing to it.)
1.35 @@ -87,23 +73,6 @@
1.36
1.37 private String getGenericSignature() {return signature;}
1.38
1.39 - // Accessor for factory
1.40 - private GenericsFactory getFactory() {
1.41 - // create scope and factory
1.42 - return CoreReflectionFactory.make(this, MethodScope.make(this));
1.43 - }
1.44 -
1.45 - // Accessor for generic info repository
1.46 - private MethodRepository getGenericInfo() {
1.47 - // lazily initialize repository if necessary
1.48 - if (genericInfo == null) {
1.49 - // create and cache generic info repository
1.50 - genericInfo = MethodRepository.make(getGenericSignature(),
1.51 - getFactory());
1.52 - }
1.53 - return genericInfo; //return cached repository
1.54 - }
1.55 -
1.56 /**
1.57 * Package-private constructor used by ReflectAccess to enable
1.58 * instantiation of these objects in Java code from the java.lang
1.59 @@ -151,8 +120,6 @@
1.60 exceptionTypes, modifiers, slot, signature,
1.61 annotations, parameterAnnotations, annotationDefault);
1.62 res.root = this;
1.63 - // Might as well eagerly propagate this if already present
1.64 - res.methodAccessor = methodAccessor;
1.65 return res;
1.66 }
1.67
1.68 @@ -199,10 +166,7 @@
1.69 * @since 1.5
1.70 */
1.71 public TypeVariable<Method>[] getTypeParameters() {
1.72 - if (getGenericSignature() != null)
1.73 - return (TypeVariable<Method>[])getGenericInfo().getTypeParameters();
1.74 - else
1.75 - return (TypeVariable<Method>[])new TypeVariable[0];
1.76 + throw new UnsupportedOperationException();
1.77 }
1.78
1.79 /**
1.80 @@ -240,9 +204,7 @@
1.81 * @since 1.5
1.82 */
1.83 public Type getGenericReturnType() {
1.84 - if (getGenericSignature() != null) {
1.85 - return getGenericInfo().getReturnType();
1.86 - } else { return getReturnType();}
1.87 + throw new UnsupportedOperationException();
1.88 }
1.89
1.90
1.91 @@ -287,10 +249,7 @@
1.92 * @since 1.5
1.93 */
1.94 public Type[] getGenericParameterTypes() {
1.95 - if (getGenericSignature() != null)
1.96 - return getGenericInfo().getParameterTypes();
1.97 - else
1.98 - return getParameterTypes();
1.99 + throw new UnsupportedOperationException();
1.100 }
1.101
1.102
1.103 @@ -331,12 +290,7 @@
1.104 * @since 1.5
1.105 */
1.106 public Type[] getGenericExceptionTypes() {
1.107 - Type[] result;
1.108 - if (getGenericSignature() != null &&
1.109 - ((result = getGenericInfo().getExceptionTypes()).length > 0))
1.110 - return result;
1.111 - else
1.112 - return getExceptionTypes();
1.113 + throw new UnsupportedOperationException();
1.114 }
1.115
1.116 /**
1.117 @@ -587,18 +541,7 @@
1.118 throws IllegalAccessException, IllegalArgumentException,
1.119 InvocationTargetException
1.120 {
1.121 - if (!override) {
1.122 - if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) {
1.123 - Class<?> caller = Reflection.getCallerClass(1);
1.124 -
1.125 - checkAccess(caller, clazz, obj, modifiers);
1.126 - }
1.127 - }
1.128 - MethodAccessor ma = methodAccessor; // read volatile
1.129 - if (ma == null) {
1.130 - ma = acquireMethodAccessor();
1.131 - }
1.132 - return ma.invoke(obj, args);
1.133 + throw new UnsupportedOperationException();
1.134 }
1.135
1.136 /**
1.137 @@ -638,42 +581,6 @@
1.138 return Modifier.isSynthetic(getModifiers());
1.139 }
1.140
1.141 - // NOTE that there is no synchronization used here. It is correct
1.142 - // (though not efficient) to generate more than one MethodAccessor
1.143 - // for a given Method. However, avoiding synchronization will
1.144 - // probably make the implementation more scalable.
1.145 - private MethodAccessor acquireMethodAccessor() {
1.146 - // First check to see if one has been created yet, and take it
1.147 - // if so
1.148 - MethodAccessor tmp = null;
1.149 - if (root != null) tmp = root.getMethodAccessor();
1.150 - if (tmp != null) {
1.151 - methodAccessor = tmp;
1.152 - } else {
1.153 - // Otherwise fabricate one and propagate it up to the root
1.154 - tmp = reflectionFactory.newMethodAccessor(this);
1.155 - setMethodAccessor(tmp);
1.156 - }
1.157 -
1.158 - return tmp;
1.159 - }
1.160 -
1.161 - // Returns MethodAccessor for this Method object, not looking up
1.162 - // the chain to the root
1.163 - MethodAccessor getMethodAccessor() {
1.164 - return methodAccessor;
1.165 - }
1.166 -
1.167 - // Sets the MethodAccessor for this Method object and
1.168 - // (recursively) its root
1.169 - void setMethodAccessor(MethodAccessor accessor) {
1.170 - methodAccessor = accessor;
1.171 - // Propagate up
1.172 - if (root != null) {
1.173 - root.setMethodAccessor(accessor);
1.174 - }
1.175 - }
1.176 -
1.177 /**
1.178 * @throws NullPointerException {@inheritDoc}
1.179 * @since 1.5
1.180 @@ -682,26 +589,14 @@
1.181 if (annotationClass == null)
1.182 throw new NullPointerException();
1.183
1.184 - return (T) declaredAnnotations().get(annotationClass);
1.185 + throw new UnsupportedOperationException();
1.186 }
1.187
1.188 /**
1.189 * @since 1.5
1.190 */
1.191 public Annotation[] getDeclaredAnnotations() {
1.192 - return AnnotationParser.toArray(declaredAnnotations());
1.193 - }
1.194 -
1.195 - private transient Map<Class<? extends Annotation>, Annotation> declaredAnnotations;
1.196 -
1.197 - private synchronized Map<Class<? extends Annotation>, Annotation> declaredAnnotations() {
1.198 - if (declaredAnnotations == null) {
1.199 - declaredAnnotations = AnnotationParser.parseAnnotations(
1.200 - annotations, sun.misc.SharedSecrets.getJavaLangAccess().
1.201 - getConstantPool(getDeclaringClass()),
1.202 - getDeclaringClass());
1.203 - }
1.204 - return declaredAnnotations;
1.205 + throw new UnsupportedOperationException();
1.206 }
1.207
1.208 /**
1.209 @@ -721,16 +616,7 @@
1.210 public Object getDefaultValue() {
1.211 if (annotationDefault == null)
1.212 return null;
1.213 - Class<?> memberType = AnnotationType.invocationHandlerReturnType(
1.214 - getReturnType());
1.215 - Object result = AnnotationParser.parseMemberValue(
1.216 - memberType, ByteBuffer.wrap(annotationDefault),
1.217 - sun.misc.SharedSecrets.getJavaLangAccess().
1.218 - getConstantPool(getDeclaringClass()),
1.219 - getDeclaringClass());
1.220 - if (result instanceof sun.reflect.annotation.ExceptionProxy)
1.221 - throw new AnnotationFormatError("Invalid default: " + this);
1.222 - return result;
1.223 + throw new UnsupportedOperationException();
1.224 }
1.225
1.226 /**
1.227 @@ -754,14 +640,6 @@
1.228 if (parameterAnnotations == null)
1.229 return new Annotation[numParameters][0];
1.230
1.231 - Annotation[][] result = AnnotationParser.parseParameterAnnotations(
1.232 - parameterAnnotations,
1.233 - sun.misc.SharedSecrets.getJavaLangAccess().
1.234 - getConstantPool(getDeclaringClass()),
1.235 - getDeclaringClass());
1.236 - if (result.length != numParameters)
1.237 - throw new java.lang.annotation.AnnotationFormatError(
1.238 - "Parameter annotations don't match number of parameters");
1.239 - return result;
1.240 + throw new UnsupportedOperationException();
1.241 }
1.242 }