mirror of
https://github.com/openjdk/jdk7u.git
synced 2025-12-15 14:45:34 -06:00
7077389: Reflection classes do not build with javac -Xlint:all -Werror
Reviewed-by: darcy
This commit is contained in:
parent
8e1787f7ac
commit
f08f6a0154
@ -33,6 +33,7 @@ PACKAGE = java.lang
|
||||
LIBRARY = java
|
||||
PRODUCT = java
|
||||
SUBDIRS_MAKEFLAGS += JAVAC_MAX_WARNINGS=true
|
||||
JAVAC_MAX_WARNINGS=true
|
||||
include $(BUILDDIR)/common/Defs.gmk
|
||||
|
||||
# windows compiler flags
|
||||
|
||||
@ -474,10 +474,10 @@ class Array {
|
||||
* Private
|
||||
*/
|
||||
|
||||
private static native Object newArray(Class componentType, int length)
|
||||
private static native Object newArray(Class<?> componentType, int length)
|
||||
throws NegativeArraySizeException;
|
||||
|
||||
private static native Object multiNewArray(Class componentType,
|
||||
private static native Object multiNewArray(Class<?> componentType,
|
||||
int[] dimensions)
|
||||
throws IllegalArgumentException, NegativeArraySizeException;
|
||||
|
||||
|
||||
@ -28,15 +28,14 @@ package java.lang.reflect;
|
||||
import sun.reflect.CallerSensitive;
|
||||
import sun.reflect.ConstructorAccessor;
|
||||
import sun.reflect.Reflection;
|
||||
import sun.reflect.annotation.AnnotationParser;
|
||||
import sun.reflect.generics.repository.ConstructorRepository;
|
||||
import sun.reflect.generics.factory.CoreReflectionFactory;
|
||||
import sun.reflect.generics.factory.GenericsFactory;
|
||||
import sun.reflect.generics.scope.ConstructorScope;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.Map;
|
||||
import sun.reflect.annotation.AnnotationParser;
|
||||
import java.lang.annotation.AnnotationFormatError;
|
||||
import java.lang.reflect.Modifier;
|
||||
|
||||
/**
|
||||
* {@code Constructor} provides information about, and access to, a single
|
||||
@ -191,6 +190,7 @@ public final
|
||||
* <cite>The Java™ Virtual Machine Specification</cite>
|
||||
* @since 1.5
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public TypeVariable<Constructor<T>>[] getTypeParameters() {
|
||||
if (getSignature() != null) {
|
||||
return (TypeVariable<Constructor<T>>[])getGenericInfo().getTypeParameters();
|
||||
@ -209,7 +209,7 @@ public final
|
||||
* represents
|
||||
*/
|
||||
public Class<?>[] getParameterTypes() {
|
||||
return (Class<?>[]) parameterTypes.clone();
|
||||
return parameterTypes.clone();
|
||||
}
|
||||
|
||||
|
||||
@ -258,7 +258,7 @@ public final
|
||||
* constructor this object represents
|
||||
*/
|
||||
public Class<?>[] getExceptionTypes() {
|
||||
return (Class<?>[])exceptionTypes.clone();
|
||||
return exceptionTypes.clone();
|
||||
}
|
||||
|
||||
|
||||
@ -523,7 +523,9 @@ public final
|
||||
if (ca == null) {
|
||||
ca = acquireConstructorAccessor();
|
||||
}
|
||||
return (T) ca.newInstance(initargs);
|
||||
@SuppressWarnings("unchecked")
|
||||
T inst = (T) ca.newInstance(initargs);
|
||||
return inst;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1107,6 +1107,7 @@ class Field extends AccessibleObject implements Member {
|
||||
* @throws NullPointerException {@inheritDoc}
|
||||
* @since 1.5
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
|
||||
if (annotationClass == null)
|
||||
throw new NullPointerException();
|
||||
|
||||
@ -199,6 +199,7 @@ public final
|
||||
* <cite>The Java™ Virtual Machine Specification</cite>
|
||||
* @since 1.5
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public TypeVariable<Method>[] getTypeParameters() {
|
||||
if (getGenericSignature() != null)
|
||||
return (TypeVariable<Method>[])getGenericInfo().getTypeParameters();
|
||||
@ -257,7 +258,7 @@ public final
|
||||
* represents
|
||||
*/
|
||||
public Class<?>[] getParameterTypes() {
|
||||
return (Class<?>[]) parameterTypes.clone();
|
||||
return parameterTypes.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -306,7 +307,7 @@ public final
|
||||
* method this object represents
|
||||
*/
|
||||
public Class<?>[] getExceptionTypes() {
|
||||
return (Class<?>[]) exceptionTypes.clone();
|
||||
return exceptionTypes.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -826,6 +826,6 @@ public class Proxy implements java.io.Serializable {
|
||||
return ih;
|
||||
}
|
||||
|
||||
private static native Class defineClass0(ClassLoader loader, String name,
|
||||
byte[] b, int off, int len);
|
||||
private static native Class<?> defineClass0(ClassLoader loader, String name,
|
||||
byte[] b, int off, int len);
|
||||
}
|
||||
|
||||
@ -382,7 +382,7 @@ class AccessorGenerator implements ClassFileConstants {
|
||||
/** Returns class name in "internal" form (i.e., '/' separators
|
||||
instead of '.') */
|
||||
protected static String getClassName
|
||||
(Class c, boolean addPrefixAndSuffixForNonPrimitiveTypes)
|
||||
(Class<?> c, boolean addPrefixAndSuffixForNonPrimitiveTypes)
|
||||
{
|
||||
if (c.isPrimitive()) {
|
||||
if (c == Boolean.TYPE) {
|
||||
@ -490,7 +490,7 @@ class AccessorGenerator implements ClassFileConstants {
|
||||
}
|
||||
}
|
||||
|
||||
protected short indexForPrimitiveType(Class type) {
|
||||
protected short indexForPrimitiveType(Class<?> type) {
|
||||
if (type == Boolean.TYPE) {
|
||||
return booleanIdx;
|
||||
} else if (type == Byte.TYPE) {
|
||||
@ -511,7 +511,7 @@ class AccessorGenerator implements ClassFileConstants {
|
||||
throw new InternalError("Should have found primitive type");
|
||||
}
|
||||
|
||||
protected short ctorIndexForPrimitiveType(Class type) {
|
||||
protected short ctorIndexForPrimitiveType(Class<?> type) {
|
||||
if (type == Boolean.TYPE) {
|
||||
return booleanCtorIdx;
|
||||
} else if (type == Byte.TYPE) {
|
||||
@ -534,7 +534,7 @@ class AccessorGenerator implements ClassFileConstants {
|
||||
|
||||
/** Returns true for widening or identity conversions for primitive
|
||||
types only */
|
||||
protected static boolean canWidenTo(Class type, Class otherType) {
|
||||
protected static boolean canWidenTo(Class<?> type, Class<?> otherType) {
|
||||
if (!type.isPrimitive()) {
|
||||
return false;
|
||||
}
|
||||
@ -609,8 +609,8 @@ class AccessorGenerator implements ClassFileConstants {
|
||||
called and returned true. */
|
||||
protected static void emitWideningBytecodeForPrimitiveConversion
|
||||
(ClassFileAssembler cb,
|
||||
Class fromType,
|
||||
Class toType)
|
||||
Class<?> fromType,
|
||||
Class<?> toType)
|
||||
{
|
||||
// Note that widening conversions for integral types (i.e., "b2s",
|
||||
// "s2i") are no-ops since values on the Java stack are
|
||||
@ -650,7 +650,7 @@ class AccessorGenerator implements ClassFileConstants {
|
||||
// Otherwise, was identity or no-op conversion. Fall through.
|
||||
}
|
||||
|
||||
protected short unboxingMethodForPrimitiveType(Class primType) {
|
||||
protected short unboxingMethodForPrimitiveType(Class<?> primType) {
|
||||
if (primType == Boolean.TYPE) {
|
||||
return booleanUnboxIdx;
|
||||
} else if (primType == Byte.TYPE) {
|
||||
@ -671,7 +671,7 @@ class AccessorGenerator implements ClassFileConstants {
|
||||
throw new InternalError("Illegal primitive type " + primType.getName());
|
||||
}
|
||||
|
||||
protected static final Class[] primitiveTypes = new Class[] {
|
||||
protected static final Class<?>[] primitiveTypes = new Class<?>[] {
|
||||
Boolean.TYPE,
|
||||
Byte.TYPE,
|
||||
Character.TYPE,
|
||||
@ -683,11 +683,11 @@ class AccessorGenerator implements ClassFileConstants {
|
||||
};
|
||||
|
||||
/** We don't consider "Void" to be a primitive type */
|
||||
protected static boolean isPrimitive(Class c) {
|
||||
protected static boolean isPrimitive(Class<?> c) {
|
||||
return (c.isPrimitive() && c != Void.TYPE);
|
||||
}
|
||||
|
||||
protected int typeSizeInStackSlots(Class c) {
|
||||
protected int typeSizeInStackSlots(Class<?> c) {
|
||||
if (c == Void.TYPE) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -32,9 +32,9 @@ import java.lang.reflect.Constructor;
|
||||
bootstrapping. */
|
||||
|
||||
class BootstrapConstructorAccessorImpl extends ConstructorAccessorImpl {
|
||||
private final Constructor constructor;
|
||||
private final Constructor<?> constructor;
|
||||
|
||||
BootstrapConstructorAccessorImpl(Constructor c) {
|
||||
BootstrapConstructorAccessorImpl(Constructor<?> c) {
|
||||
this.constructor = c;
|
||||
}
|
||||
|
||||
|
||||
@ -51,8 +51,8 @@ class ClassDefiner {
|
||||
than would otherwise be possible, decreasing run-time
|
||||
footprint. </P>
|
||||
*/
|
||||
static Class defineClass(String name, byte[] bytes, int off, int len,
|
||||
final ClassLoader parentClassLoader)
|
||||
static Class<?> defineClass(String name, byte[] bytes, int off, int len,
|
||||
final ClassLoader parentClassLoader)
|
||||
{
|
||||
ClassLoader newLoader = AccessController.doPrivileged(
|
||||
new PrivilegedAction<ClassLoader>() {
|
||||
|
||||
@ -34,8 +34,8 @@ import java.lang.reflect.*;
|
||||
public class ConstantPool {
|
||||
// Number of entries in this constant pool (= maximum valid constant pool index)
|
||||
public int getSize() { return getSize0 (constantPoolOop); }
|
||||
public Class getClassAt (int index) { return getClassAt0 (constantPoolOop, index); }
|
||||
public Class getClassAtIfLoaded (int index) { return getClassAtIfLoaded0 (constantPoolOop, index); }
|
||||
public Class<?> getClassAt (int index) { return getClassAt0 (constantPoolOop, index); }
|
||||
public Class<?> getClassAtIfLoaded (int index) { return getClassAtIfLoaded0 (constantPoolOop, index); }
|
||||
// Returns either a Method or Constructor.
|
||||
// Static initializers are returned as Method objects.
|
||||
public Member getMethodAt (int index) { return getMethodAt0 (constantPoolOop, index); }
|
||||
@ -64,8 +64,8 @@ public class ConstantPool {
|
||||
private Object constantPoolOop;
|
||||
|
||||
private native int getSize0 (Object constantPoolOop);
|
||||
private native Class getClassAt0 (Object constantPoolOop, int index);
|
||||
private native Class getClassAtIfLoaded0 (Object constantPoolOop, int index);
|
||||
private native Class<?> getClassAt0 (Object constantPoolOop, int index);
|
||||
private native Class<?> getClassAtIfLoaded0 (Object constantPoolOop, int index);
|
||||
private native Member getMethodAt0 (Object constantPoolOop, int index);
|
||||
private native Member getMethodAtIfLoaded0(Object constantPoolOop, int index);
|
||||
private native Field getFieldAt0 (Object constantPoolOop, int index);
|
||||
|
||||
@ -25,7 +25,6 @@
|
||||
|
||||
package sun.reflect;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
@ -53,7 +52,7 @@ class Label {
|
||||
final short patchBCI;
|
||||
final int stackDepth;
|
||||
}
|
||||
private List/*<PatchInfo>*/ patches = new ArrayList();
|
||||
private List<PatchInfo> patches = new ArrayList<>();
|
||||
|
||||
public Label() {
|
||||
}
|
||||
@ -67,8 +66,7 @@ class Label {
|
||||
}
|
||||
|
||||
public void bind() {
|
||||
for (Iterator iter = patches.iterator(); iter.hasNext(); ) {
|
||||
PatchInfo patch = (PatchInfo) iter.next();
|
||||
for (PatchInfo patch : patches){
|
||||
short curBCI = patch.asm.getLength();
|
||||
short offset = (short) (curBCI - patch.instrBCI);
|
||||
patch.asm.emitShort(patch.patchBCI, offset);
|
||||
|
||||
@ -25,10 +25,8 @@
|
||||
|
||||
package sun.reflect;
|
||||
|
||||
import java.lang.reflect.*;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import sun.misc.Unsafe;
|
||||
|
||||
/** Generator for sun.reflect.MethodAccessor and
|
||||
sun.reflect.ConstructorAccessor objects using bytecodes to
|
||||
@ -50,11 +48,11 @@ class MethodAccessorGenerator extends AccessorGenerator {
|
||||
private static volatile int constructorSymnum = 0;
|
||||
private static volatile int serializationConstructorSymnum = 0;
|
||||
|
||||
private Class declaringClass;
|
||||
private Class[] parameterTypes;
|
||||
private Class returnType;
|
||||
private boolean isConstructor;
|
||||
private boolean forSerialization;
|
||||
private Class<?> declaringClass;
|
||||
private Class<?>[] parameterTypes;
|
||||
private Class<?> returnType;
|
||||
private boolean isConstructor;
|
||||
private boolean forSerialization;
|
||||
|
||||
private short targetMethodRef;
|
||||
private short invokeIdx;
|
||||
@ -67,11 +65,11 @@ class MethodAccessorGenerator extends AccessorGenerator {
|
||||
}
|
||||
|
||||
/** This routine is not thread-safe */
|
||||
public MethodAccessor generateMethod(Class declaringClass,
|
||||
String name,
|
||||
Class[] parameterTypes,
|
||||
Class returnType,
|
||||
Class[] checkedExceptions,
|
||||
public MethodAccessor generateMethod(Class<?> declaringClass,
|
||||
String name,
|
||||
Class<?>[] parameterTypes,
|
||||
Class<?> returnType,
|
||||
Class<?>[] checkedExceptions,
|
||||
int modifiers)
|
||||
{
|
||||
return (MethodAccessor) generate(declaringClass,
|
||||
@ -86,9 +84,9 @@ class MethodAccessorGenerator extends AccessorGenerator {
|
||||
}
|
||||
|
||||
/** This routine is not thread-safe */
|
||||
public ConstructorAccessor generateConstructor(Class declaringClass,
|
||||
Class[] parameterTypes,
|
||||
Class[] checkedExceptions,
|
||||
public ConstructorAccessor generateConstructor(Class<?> declaringClass,
|
||||
Class<?>[] parameterTypes,
|
||||
Class<?>[] checkedExceptions,
|
||||
int modifiers)
|
||||
{
|
||||
return (ConstructorAccessor) generate(declaringClass,
|
||||
@ -104,11 +102,11 @@ class MethodAccessorGenerator extends AccessorGenerator {
|
||||
|
||||
/** This routine is not thread-safe */
|
||||
public SerializationConstructorAccessorImpl
|
||||
generateSerializationConstructor(Class declaringClass,
|
||||
Class[] parameterTypes,
|
||||
Class[] checkedExceptions,
|
||||
generateSerializationConstructor(Class<?> declaringClass,
|
||||
Class<?>[] parameterTypes,
|
||||
Class<?>[] checkedExceptions,
|
||||
int modifiers,
|
||||
Class targetConstructorClass)
|
||||
Class<?> targetConstructorClass)
|
||||
{
|
||||
return (SerializationConstructorAccessorImpl)
|
||||
generate(declaringClass,
|
||||
@ -123,15 +121,15 @@ class MethodAccessorGenerator extends AccessorGenerator {
|
||||
}
|
||||
|
||||
/** This routine is not thread-safe */
|
||||
private MagicAccessorImpl generate(final Class declaringClass,
|
||||
private MagicAccessorImpl generate(final Class<?> declaringClass,
|
||||
String name,
|
||||
Class[] parameterTypes,
|
||||
Class returnType,
|
||||
Class[] checkedExceptions,
|
||||
Class<?>[] parameterTypes,
|
||||
Class<?> returnType,
|
||||
Class<?>[] checkedExceptions,
|
||||
int modifiers,
|
||||
boolean isConstructor,
|
||||
boolean forSerialization,
|
||||
Class serializationTargetClass)
|
||||
Class<?> serializationTargetClass)
|
||||
{
|
||||
ByteVector vec = ByteVectorFactory.create();
|
||||
asm = new ClassFileAssembler(vec);
|
||||
@ -340,7 +338,7 @@ class MethodAccessorGenerator extends AccessorGenerator {
|
||||
// Output class information for non-primitive parameter types
|
||||
nonPrimitiveParametersBaseIdx = add(asm.cpi(), S2);
|
||||
for (int i = 0; i < parameterTypes.length; i++) {
|
||||
Class c = parameterTypes[i];
|
||||
Class<?> c = parameterTypes[i];
|
||||
if (!isPrimitive(c)) {
|
||||
asm.emitConstantPoolUTF8(getClassName(c, false));
|
||||
asm.emitConstantPoolClass(asm.cpi());
|
||||
@ -403,10 +401,8 @@ class MethodAccessorGenerator extends AccessorGenerator {
|
||||
0,
|
||||
bytes.length,
|
||||
declaringClass.getClassLoader()).newInstance();
|
||||
} catch (InstantiationException e) {
|
||||
throw (InternalError)
|
||||
new InternalError().initCause(e);
|
||||
} catch (IllegalAccessException e) {
|
||||
} catch (InstantiationException |
|
||||
IllegalAccessException e) {
|
||||
throw (InternalError)
|
||||
new InternalError().initCause(e);
|
||||
}
|
||||
@ -530,7 +526,7 @@ class MethodAccessorGenerator extends AccessorGenerator {
|
||||
byte count = 1; // both invokeinterface opcode's "count" as well as
|
||||
// num args of other invoke bytecodes
|
||||
for (int i = 0; i < parameterTypes.length; i++) {
|
||||
Class paramType = parameterTypes[i];
|
||||
Class<?> paramType = parameterTypes[i];
|
||||
count += (byte) typeSizeInStackSlots(paramType);
|
||||
if (nextParamLabel != null) {
|
||||
nextParamLabel.bind();
|
||||
@ -577,7 +573,7 @@ class MethodAccessorGenerator extends AccessorGenerator {
|
||||
nextParamLabel = new Label();
|
||||
|
||||
for (int j = 0; j < primitiveTypes.length; j++) {
|
||||
Class c = primitiveTypes[j];
|
||||
Class<?> c = primitiveTypes[j];
|
||||
if (canWidenTo(c, paramType)) {
|
||||
if (l != null) {
|
||||
l.bind();
|
||||
|
||||
@ -31,11 +31,11 @@ import java.lang.reflect.*;
|
||||
afterward, switches to bytecode-based implementation */
|
||||
|
||||
class NativeConstructorAccessorImpl extends ConstructorAccessorImpl {
|
||||
private final Constructor c;
|
||||
private final Constructor<?> c;
|
||||
private DelegatingConstructorAccessorImpl parent;
|
||||
private int numInvocations;
|
||||
|
||||
NativeConstructorAccessorImpl(Constructor c) {
|
||||
NativeConstructorAccessorImpl(Constructor<?> c) {
|
||||
this.c = c;
|
||||
}
|
||||
|
||||
@ -61,7 +61,7 @@ class NativeConstructorAccessorImpl extends ConstructorAccessorImpl {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
private static native Object newInstance0(Constructor c, Object[] args)
|
||||
private static native Object newInstance0(Constructor<?> c, Object[] args)
|
||||
throws InstantiationException,
|
||||
IllegalArgumentException,
|
||||
InvocationTargetException;
|
||||
|
||||
@ -26,7 +26,6 @@
|
||||
package sun.reflect;
|
||||
|
||||
import java.lang.reflect.*;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ -39,18 +38,18 @@ public class Reflection {
|
||||
view, where they are sensitive or they may contain VM-internal objects.
|
||||
These Maps are updated very rarely. Rather than synchronize on
|
||||
each access, we use copy-on-write */
|
||||
private static volatile Map<Class,String[]> fieldFilterMap;
|
||||
private static volatile Map<Class,String[]> methodFilterMap;
|
||||
private static volatile Map<Class<?>,String[]> fieldFilterMap;
|
||||
private static volatile Map<Class<?>,String[]> methodFilterMap;
|
||||
|
||||
static {
|
||||
Map<Class,String[]> map = new HashMap<Class,String[]>();
|
||||
Map<Class<?>,String[]> map = new HashMap<Class<?>,String[]>();
|
||||
map.put(Reflection.class,
|
||||
new String[] {"fieldFilterMap", "methodFilterMap"});
|
||||
map.put(System.class, new String[] {"security"});
|
||||
map.put(Class.class, new String[] {"classLoader"});
|
||||
fieldFilterMap = map;
|
||||
|
||||
methodFilterMap = new HashMap<Class,String[]>();
|
||||
methodFilterMap = new HashMap<>();
|
||||
}
|
||||
|
||||
/** Returns the class of the caller of the method calling this method,
|
||||
@ -86,18 +85,18 @@ public class Reflection {
|
||||
to compatibility reasons; see 4471811. Only the values of the
|
||||
low 13 bits (i.e., a mask of 0x1FFF) are guaranteed to be
|
||||
valid. */
|
||||
private static native int getClassAccessFlags(Class c);
|
||||
private static native int getClassAccessFlags(Class<?> c);
|
||||
|
||||
/** A quick "fast-path" check to try to avoid getCallerClass()
|
||||
calls. */
|
||||
public static boolean quickCheckMemberAccess(Class memberClass,
|
||||
public static boolean quickCheckMemberAccess(Class<?> memberClass,
|
||||
int modifiers)
|
||||
{
|
||||
return Modifier.isPublic(getClassAccessFlags(memberClass) & modifiers);
|
||||
}
|
||||
|
||||
public static void ensureMemberAccess(Class currentClass,
|
||||
Class memberClass,
|
||||
public static void ensureMemberAccess(Class<?> currentClass,
|
||||
Class<?> memberClass,
|
||||
Object target,
|
||||
int modifiers)
|
||||
throws IllegalAccessException
|
||||
@ -116,13 +115,13 @@ public class Reflection {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean verifyMemberAccess(Class currentClass,
|
||||
public static boolean verifyMemberAccess(Class<?> currentClass,
|
||||
// Declaring class of field
|
||||
// or method
|
||||
Class memberClass,
|
||||
Class<?> memberClass,
|
||||
// May be NULL in case of statics
|
||||
Object target,
|
||||
int modifiers)
|
||||
Object target,
|
||||
int modifiers)
|
||||
{
|
||||
// Verify that currentClass can access a field, method, or
|
||||
// constructor of memberClass, where that member's access bits are
|
||||
@ -177,7 +176,7 @@ public class Reflection {
|
||||
|
||||
if (Modifier.isProtected(modifiers)) {
|
||||
// Additional test for protected members: JLS 6.6.2
|
||||
Class targetClass = (target == null ? memberClass : target.getClass());
|
||||
Class<?> targetClass = (target == null ? memberClass : target.getClass());
|
||||
if (targetClass != currentClass) {
|
||||
if (!gotIsSameClassPackage) {
|
||||
isSameClassPackage = isSameClassPackage(currentClass, memberClass);
|
||||
@ -194,7 +193,7 @@ public class Reflection {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean isSameClassPackage(Class c1, Class c2) {
|
||||
private static boolean isSameClassPackage(Class<?> c1, Class<?> c2) {
|
||||
return isSameClassPackage(c1.getClassLoader(), c1.getName(),
|
||||
c2.getClassLoader(), c2.getName());
|
||||
}
|
||||
@ -249,8 +248,8 @@ public class Reflection {
|
||||
}
|
||||
}
|
||||
|
||||
static boolean isSubclassOf(Class queryClass,
|
||||
Class ofClass)
|
||||
static boolean isSubclassOf(Class<?> queryClass,
|
||||
Class<?> ofClass)
|
||||
{
|
||||
while (queryClass != null) {
|
||||
if (queryClass == ofClass) {
|
||||
@ -262,31 +261,31 @@ public class Reflection {
|
||||
}
|
||||
|
||||
// fieldNames must contain only interned Strings
|
||||
public static synchronized void registerFieldsToFilter(Class containingClass,
|
||||
public static synchronized void registerFieldsToFilter(Class<?> containingClass,
|
||||
String ... fieldNames) {
|
||||
fieldFilterMap =
|
||||
registerFilter(fieldFilterMap, containingClass, fieldNames);
|
||||
}
|
||||
|
||||
// methodNames must contain only interned Strings
|
||||
public static synchronized void registerMethodsToFilter(Class containingClass,
|
||||
public static synchronized void registerMethodsToFilter(Class<?> containingClass,
|
||||
String ... methodNames) {
|
||||
methodFilterMap =
|
||||
registerFilter(methodFilterMap, containingClass, methodNames);
|
||||
}
|
||||
|
||||
private static Map<Class,String[]> registerFilter(Map<Class,String[]> map,
|
||||
Class containingClass, String ... names) {
|
||||
private static Map<Class<?>,String[]> registerFilter(Map<Class<?>,String[]> map,
|
||||
Class<?> containingClass, String ... names) {
|
||||
if (map.get(containingClass) != null) {
|
||||
throw new IllegalArgumentException
|
||||
("Filter already registered: " + containingClass);
|
||||
}
|
||||
map = new HashMap<Class,String[]>(map);
|
||||
map = new HashMap<Class<?>,String[]>(map);
|
||||
map.put(containingClass, names);
|
||||
return map;
|
||||
}
|
||||
|
||||
public static Field[] filterFields(Class containingClass,
|
||||
public static Field[] filterFields(Class<?> containingClass,
|
||||
Field[] fields) {
|
||||
if (fieldFilterMap == null) {
|
||||
// Bootstrapping
|
||||
@ -295,7 +294,7 @@ public class Reflection {
|
||||
return (Field[])filter(fields, fieldFilterMap.get(containingClass));
|
||||
}
|
||||
|
||||
public static Method[] filterMethods(Class containingClass, Method[] methods) {
|
||||
public static Method[] filterMethods(Class<?> containingClass, Method[] methods) {
|
||||
if (methodFilterMap == null) {
|
||||
// Bootstrapping
|
||||
return methods;
|
||||
|
||||
@ -174,7 +174,7 @@ public class ReflectionFactory {
|
||||
}
|
||||
}
|
||||
|
||||
public ConstructorAccessor newConstructorAccessor(Constructor c) {
|
||||
public ConstructorAccessor newConstructorAccessor(Constructor<?> c) {
|
||||
checkInitted();
|
||||
|
||||
Class<?> declaringClass = c.getDeclaringClass();
|
||||
@ -263,14 +263,14 @@ public class ReflectionFactory {
|
||||
|
||||
/** Creates a new java.lang.reflect.Constructor. Access checks as
|
||||
per java.lang.reflect.AccessibleObject are not overridden. */
|
||||
public Constructor newConstructor(Class<?> declaringClass,
|
||||
Class<?>[] parameterTypes,
|
||||
Class<?>[] checkedExceptions,
|
||||
int modifiers,
|
||||
int slot,
|
||||
String signature,
|
||||
byte[] annotations,
|
||||
byte[] parameterAnnotations)
|
||||
public Constructor<?> newConstructor(Class<?> declaringClass,
|
||||
Class<?>[] parameterTypes,
|
||||
Class<?>[] checkedExceptions,
|
||||
int modifiers,
|
||||
int slot,
|
||||
String signature,
|
||||
byte[] annotations,
|
||||
byte[] parameterAnnotations)
|
||||
{
|
||||
return langReflectAccess().newConstructor(declaringClass,
|
||||
parameterTypes,
|
||||
@ -294,13 +294,13 @@ public class ReflectionFactory {
|
||||
|
||||
/** Gets the ConstructorAccessor object for a
|
||||
java.lang.reflect.Constructor */
|
||||
public ConstructorAccessor getConstructorAccessor(Constructor c) {
|
||||
public ConstructorAccessor getConstructorAccessor(Constructor<?> c) {
|
||||
return langReflectAccess().getConstructorAccessor(c);
|
||||
}
|
||||
|
||||
/** Sets the ConstructorAccessor object for a
|
||||
java.lang.reflect.Constructor */
|
||||
public void setConstructorAccessor(Constructor c,
|
||||
public void setConstructorAccessor(Constructor<?> c,
|
||||
ConstructorAccessor accessor)
|
||||
{
|
||||
langReflectAccess().setConstructorAccessor(c, accessor);
|
||||
@ -341,8 +341,8 @@ public class ReflectionFactory {
|
||||
* @param constructorToCall the constructor to call
|
||||
* @return an accessible constructor
|
||||
*/
|
||||
public Constructor newConstructorForSerialization
|
||||
(Class<?> classToInstantiate, Constructor constructorToCall)
|
||||
public Constructor<?> newConstructorForSerialization
|
||||
(Class<?> classToInstantiate, Constructor<?> constructorToCall)
|
||||
{
|
||||
// Fast path
|
||||
if (constructorToCall.getDeclaringClass() == classToInstantiate) {
|
||||
@ -391,18 +391,18 @@ public class ReflectionFactory {
|
||||
constructorToCall.getExceptionTypes(),
|
||||
constructorToCall.getModifiers(),
|
||||
constructorToCall.getDeclaringClass());
|
||||
Constructor c = newConstructor(constructorToCall.getDeclaringClass(),
|
||||
constructorToCall.getParameterTypes(),
|
||||
constructorToCall.getExceptionTypes(),
|
||||
constructorToCall.getModifiers(),
|
||||
langReflectAccess().
|
||||
getConstructorSlot(constructorToCall),
|
||||
langReflectAccess().
|
||||
getConstructorSignature(constructorToCall),
|
||||
langReflectAccess().
|
||||
getConstructorAnnotations(constructorToCall),
|
||||
langReflectAccess().
|
||||
getConstructorParameterAnnotations(constructorToCall));
|
||||
Constructor<?> c = newConstructor(constructorToCall.getDeclaringClass(),
|
||||
constructorToCall.getParameterTypes(),
|
||||
constructorToCall.getExceptionTypes(),
|
||||
constructorToCall.getModifiers(),
|
||||
langReflectAccess().
|
||||
getConstructorSlot(constructorToCall),
|
||||
langReflectAccess().
|
||||
getConstructorSignature(constructorToCall),
|
||||
langReflectAccess().
|
||||
getConstructorAnnotations(constructorToCall),
|
||||
langReflectAccess().
|
||||
getConstructorParameterAnnotations(constructorToCall));
|
||||
setConstructorAccessor(c, acc);
|
||||
c.setAccessible(true);
|
||||
return c;
|
||||
@ -666,9 +666,7 @@ public class ReflectionFactory {
|
||||
try {
|
||||
inflationThreshold = Integer.parseInt(val);
|
||||
} catch (NumberFormatException e) {
|
||||
throw (RuntimeException)
|
||||
new RuntimeException("Unable to parse property sun.reflect.inflationThreshold").
|
||||
initCause(e);
|
||||
throw new RuntimeException("Unable to parse property sun.reflect.inflationThreshold", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@ import java.lang.reflect.Modifier;
|
||||
|
||||
class UnsafeFieldAccessorFactory {
|
||||
static FieldAccessor newFieldAccessor(Field field, boolean override) {
|
||||
Class type = field.getType();
|
||||
Class<?> type = field.getType();
|
||||
boolean isStatic = Modifier.isStatic(field.getModifiers());
|
||||
boolean isFinal = Modifier.isFinal(field.getModifiers());
|
||||
boolean isVolatile = Modifier.isVolatile(field.getModifiers());
|
||||
|
||||
@ -216,6 +216,7 @@ public class AnnotationParser {
|
||||
* TypeNotPresentException if a referenced annotation type is not
|
||||
* available at runtime
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private static Annotation parseAnnotation(ByteBuffer buf,
|
||||
ConstantPool constPool,
|
||||
Class<?> container,
|
||||
@ -238,7 +239,7 @@ public class AnnotationParser {
|
||||
annotationClass = (Class<? extends Annotation>)parseSig(sig, container);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
// support obsolete early jsr175 format class files
|
||||
annotationClass = constPool.getClassAt(typeIndex);
|
||||
annotationClass = (Class<? extends Annotation>)constPool.getClassAt(typeIndex);
|
||||
}
|
||||
} catch (NoClassDefFoundError e) {
|
||||
if (exceptionOnMissingAnnotationClass)
|
||||
@ -298,7 +299,7 @@ public class AnnotationParser {
|
||||
Class<? extends Annotation> type, Map<String, Object> memberValues)
|
||||
{
|
||||
return (Annotation) Proxy.newProxyInstance(
|
||||
type.getClassLoader(), new Class[] { type },
|
||||
type.getClassLoader(), new Class<?>[] { type },
|
||||
new AnnotationInvocationHandler(type, memberValues));
|
||||
}
|
||||
|
||||
@ -329,6 +330,7 @@ public class AnnotationParser {
|
||||
* The member must be of the indicated type. If it is not, this
|
||||
* method returns an AnnotationTypeMismatchExceptionProxy.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Object parseMemberValue(Class<?> memberType,
|
||||
ByteBuffer buf,
|
||||
ConstantPool constPool,
|
||||
@ -453,6 +455,7 @@ public class AnnotationParser {
|
||||
* u2 const_name_index;
|
||||
* } enum_const_value;
|
||||
*/
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
private static Object parseEnumValue(Class<? extends Enum> enumType, ByteBuffer buf,
|
||||
ConstantPool constPool,
|
||||
Class<?> container) {
|
||||
@ -475,7 +478,7 @@ public class AnnotationParser {
|
||||
return Enum.valueOf(enumType, constName);
|
||||
} catch(IllegalArgumentException e) {
|
||||
return new EnumConstantNotPresentExceptionProxy(
|
||||
(Class<? extends Enum>)enumType, constName);
|
||||
(Class<? extends Enum<?>>)enumType, constName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -493,6 +496,7 @@ public class AnnotationParser {
|
||||
* If the array values do not match arrayType, an
|
||||
* AnnotationTypeMismatchExceptionProxy will be returned.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private static Object parseArray(Class<?> arrayType,
|
||||
ByteBuffer buf,
|
||||
ConstantPool constPool,
|
||||
@ -521,7 +525,7 @@ public class AnnotationParser {
|
||||
} else if (componentType == Class.class) {
|
||||
return parseClassArray(length, buf, constPool, container);
|
||||
} else if (componentType.isEnum()) {
|
||||
return parseEnumArray(length, (Class<? extends Enum>)componentType, buf,
|
||||
return parseEnumArray(length, (Class<? extends Enum<?>>)componentType, buf,
|
||||
constPool, container);
|
||||
} else {
|
||||
assert componentType.isAnnotation();
|
||||
@ -721,7 +725,7 @@ public class AnnotationParser {
|
||||
return typeMismatch ? exceptionProxy(tag) : result;
|
||||
}
|
||||
|
||||
private static Object parseEnumArray(int length, Class<? extends Enum> enumType,
|
||||
private static Object parseEnumArray(int length, Class<? extends Enum<?>> enumType,
|
||||
ByteBuffer buf,
|
||||
ConstantPool constPool,
|
||||
Class<?> container) {
|
||||
|
||||
@ -24,7 +24,6 @@
|
||||
*/
|
||||
|
||||
package sun.reflect.annotation;
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* ExceptionProxy for EnumConstantNotPresentException.
|
||||
@ -34,10 +33,10 @@ import java.lang.annotation.*;
|
||||
*/
|
||||
public class EnumConstantNotPresentExceptionProxy extends ExceptionProxy {
|
||||
private static final long serialVersionUID = -604662101303187330L;
|
||||
Class<? extends Enum> enumType;
|
||||
Class<? extends Enum<?>> enumType;
|
||||
String constName;
|
||||
|
||||
public EnumConstantNotPresentExceptionProxy(Class<? extends Enum> enumType,
|
||||
public EnumConstantNotPresentExceptionProxy(Class<? extends Enum<?>> enumType,
|
||||
String constName) {
|
||||
this.enumType = enumType;
|
||||
this.constName = constName;
|
||||
|
||||
@ -176,7 +176,7 @@ public class TypeVariableImpl<D extends GenericDeclaration>
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof TypeVariable &&
|
||||
o.getClass() == TypeVariableImpl.class) {
|
||||
TypeVariable that = (TypeVariable) o;
|
||||
TypeVariable<?> that = (TypeVariable<?>) o;
|
||||
|
||||
GenericDeclaration thatDecl = that.getGenericDeclaration();
|
||||
String thatName = that.getName();
|
||||
|
||||
@ -89,8 +89,8 @@ public abstract class AbstractScope<D extends GenericDeclaration>
|
||||
* @return the requested type variable, if found
|
||||
*/
|
||||
public TypeVariable<?> lookup(String name) {
|
||||
TypeVariable[] tas = getRecvr().getTypeParameters();
|
||||
for (TypeVariable/*<?>*/ tv : tas) {
|
||||
TypeVariable<?>[] tas = getRecvr().getTypeParameters();
|
||||
for (TypeVariable<?> tv : tas) {
|
||||
if (tv.getName().equals(name)) {return tv;}
|
||||
}
|
||||
return getEnclosingScope().lookup(name);
|
||||
|
||||
@ -32,10 +32,10 @@ import java.lang.reflect.Constructor;
|
||||
* This class represents the scope containing the type variables of
|
||||
* a constructor.
|
||||
*/
|
||||
public class ConstructorScope extends AbstractScope<Constructor> {
|
||||
public class ConstructorScope extends AbstractScope<Constructor<?>> {
|
||||
|
||||
// constructor is private to enforce use of factory method
|
||||
private ConstructorScope(Constructor c){
|
||||
private ConstructorScope(Constructor<?> c){
|
||||
super(c);
|
||||
}
|
||||
|
||||
@ -61,7 +61,7 @@ public class ConstructorScope extends AbstractScope<Constructor> {
|
||||
* @param m - A Constructor whose scope we want to obtain
|
||||
* @return The type-variable scope for the constructor m
|
||||
*/
|
||||
public static ConstructorScope make(Constructor c) {
|
||||
public static ConstructorScope make(Constructor<?> c) {
|
||||
return new ConstructorScope(c);
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,5 +52,5 @@ public class ClassSignature implements Signature {
|
||||
public ClassTypeSignature getSuperclass(){return superclass;}
|
||||
public ClassTypeSignature[] getSuperInterfaces(){return superInterfaces;}
|
||||
|
||||
public void accept(Visitor v){v.visitClassSignature(this);}
|
||||
public void accept(Visitor<?> v){v.visitClassSignature(this);}
|
||||
}
|
||||
|
||||
@ -57,5 +57,5 @@ public class MethodTypeSignature implements Signature {
|
||||
public ReturnType getReturnType(){return returnType;}
|
||||
public FieldTypeSignature[] getExceptionTypes(){return exceptionTypes;}
|
||||
|
||||
public void accept(Visitor v){v.visitMethodTypeSignature(this);}
|
||||
public void accept(Visitor<?> v){v.visitMethodTypeSignature(this);}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user