aboutsummaryrefslogtreecommitdiff
path: root/src/share/classes/sun/reflect
diff options
context:
space:
mode:
authormartin <none@none>2008-03-10 15:07:09 -0700
committermartin <none@none>2008-03-10 15:07:09 -0700
commitcbc2edc7a946bf18b459ebf1fae69afda031b3e3 (patch)
treea21c1658e4ccfa792abe194177aebe7bd8c29733 /src/share/classes/sun/reflect
parent6eadddac51da90fca2e9e96bfdc121af15abe9f6 (diff)
6600143: Remove another 450 unnecessary casts
Reviewed-by: alanb, iris, lmalvent, bristor, peterjones, darcy, wetmore
Diffstat (limited to 'src/share/classes/sun/reflect')
-rw-r--r--src/share/classes/sun/reflect/ClassDefiner.java6
-rw-r--r--src/share/classes/sun/reflect/MethodAccessorGenerator.java9
-rw-r--r--src/share/classes/sun/reflect/ReflectionFactory.java33
-rw-r--r--src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java4
-rw-r--r--src/share/classes/sun/reflect/misc/MethodUtil.java36
5 files changed, 44 insertions, 44 deletions
diff --git a/src/share/classes/sun/reflect/ClassDefiner.java b/src/share/classes/sun/reflect/ClassDefiner.java
index 63a4e2af4..91efcfffe 100644
--- a/src/share/classes/sun/reflect/ClassDefiner.java
+++ b/src/share/classes/sun/reflect/ClassDefiner.java
@@ -54,9 +54,9 @@ class ClassDefiner {
static Class defineClass(String name, byte[] bytes, int off, int len,
final ClassLoader parentClassLoader)
{
- ClassLoader newLoader = (ClassLoader)
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
+ ClassLoader newLoader = AccessController.doPrivileged(
+ new PrivilegedAction<ClassLoader>() {
+ public ClassLoader run() {
return new DelegatingClassLoader(parentClassLoader);
}
});
diff --git a/src/share/classes/sun/reflect/MethodAccessorGenerator.java b/src/share/classes/sun/reflect/MethodAccessorGenerator.java
index 3b62e2df8..fd72a6e1c 100644
--- a/src/share/classes/sun/reflect/MethodAccessorGenerator.java
+++ b/src/share/classes/sun/reflect/MethodAccessorGenerator.java
@@ -392,11 +392,12 @@ class MethodAccessorGenerator extends AccessorGenerator {
// same namespace as the target class. Since the generated code
// is privileged anyway, the protection domain probably doesn't
// matter.
- return (MagicAccessorImpl)
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
+ return AccessController.doPrivileged(
+ new PrivilegedAction<MagicAccessorImpl>() {
+ public MagicAccessorImpl run() {
try {
- return ClassDefiner.defineClass
+ return (MagicAccessorImpl)
+ ClassDefiner.defineClass
(generatedName,
bytes,
0,
diff --git a/src/share/classes/sun/reflect/ReflectionFactory.java b/src/share/classes/sun/reflect/ReflectionFactory.java
index 30a1ac47c..54dc717f6 100644
--- a/src/share/classes/sun/reflect/ReflectionFactory.java
+++ b/src/share/classes/sun/reflect/ReflectionFactory.java
@@ -84,8 +84,8 @@ public class ReflectionFactory {
* <code>AccessController.doPrivileged</code>.
*/
public static final class GetReflectionFactoryAction
- implements PrivilegedAction {
- public Object run() {
+ implements PrivilegedAction<ReflectionFactory> {
+ public ReflectionFactory run() {
return getReflectionFactory();
}
}
@@ -164,7 +164,7 @@ public class ReflectionFactory {
public ConstructorAccessor newConstructorAccessor(Constructor c) {
checkInitted();
- Class declaringClass = c.getDeclaringClass();
+ Class<?> declaringClass = c.getDeclaringClass();
if (Modifier.isAbstract(declaringClass.getModifiers())) {
return new InstantiationExceptionConstructorAccessorImpl(null);
}
@@ -204,9 +204,9 @@ public class ReflectionFactory {
/** Creates a new java.lang.reflect.Field. Access checks as per
java.lang.reflect.AccessibleObject are not overridden. */
- public Field newField(Class declaringClass,
+ public Field newField(Class<?> declaringClass,
String name,
- Class type,
+ Class<?> type,
int modifiers,
int slot,
String signature,
@@ -223,11 +223,11 @@ public class ReflectionFactory {
/** Creates a new java.lang.reflect.Method. Access checks as per
java.lang.reflect.AccessibleObject are not overridden. */
- public Method newMethod(Class declaringClass,
+ public Method newMethod(Class<?> declaringClass,
String name,
- Class[] parameterTypes,
- Class returnType,
- Class[] checkedExceptions,
+ Class<?>[] parameterTypes,
+ Class<?> returnType,
+ Class<?>[] checkedExceptions,
int modifiers,
int slot,
String signature,
@@ -250,9 +250,9 @@ 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,
+ public Constructor newConstructor(Class<?> declaringClass,
+ Class<?>[] parameterTypes,
+ Class<?>[] checkedExceptions,
int modifiers,
int slot,
String signature,
@@ -310,7 +310,7 @@ public class ReflectionFactory {
/** Makes a copy of the passed constructor. The returned
constructor is a "child" of the passed one; see the comments
in Constructor.java for details. */
- public Constructor copyConstructor(Constructor arg) {
+ public <T> Constructor<T> copyConstructor(Constructor<T> arg) {
return langReflectAccess().copyConstructor(arg);
}
@@ -321,7 +321,7 @@ public class ReflectionFactory {
//
public Constructor newConstructorForSerialization
- (Class classToInstantiate, Constructor constructorToCall)
+ (Class<?> classToInstantiate, Constructor constructorToCall)
{
// Fast path
if (constructorToCall.getDeclaringClass() == classToInstantiate) {
@@ -366,8 +366,9 @@ public class ReflectionFactory {
run, before the system properties are set up. */
private static void checkInitted() {
if (initted) return;
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
+ AccessController.doPrivileged(
+ new PrivilegedAction<Void>() {
+ public Void run() {
// Tests to ensure the system properties table is fully
// initialized. This is needed because reflection code is
// called very early in the initialization process (before
diff --git a/src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java b/src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java
index 45147dc51..56f1bad4b 100644
--- a/src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java
+++ b/src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java
@@ -273,8 +273,8 @@ class AnnotationInvocationHandler implements InvocationHandler, Serializable {
private Method[] getMemberMethods() {
if (memberMethods == null) {
final Method[] mm = type.getDeclaredMethods();
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
+ AccessController.doPrivileged(new PrivilegedAction<Void>() {
+ public Void run() {
AccessibleObject.setAccessible(mm, true);
return null;
}
diff --git a/src/share/classes/sun/reflect/misc/MethodUtil.java b/src/share/classes/sun/reflect/misc/MethodUtil.java
index b36993337..9c1bfbea4 100644
--- a/src/share/classes/sun/reflect/misc/MethodUtil.java
+++ b/src/share/classes/sun/reflect/misc/MethodUtil.java
@@ -67,7 +67,7 @@ public final class MethodUtil extends SecureClassLoader {
super();
}
- public static Method getMethod(Class cls, String name, Class[] args)
+ public static Method getMethod(Class<?> cls, String name, Class[] args)
throws NoSuchMethodException {
ReflectUtil.checkPackageAccess(cls);
return cls.getMethod(name, args);
@@ -89,7 +89,7 @@ public final class MethodUtil extends SecureClassLoader {
if (System.getSecurityManager() == null) {
return cls.getMethods();
}
- Map sigs = new HashMap();
+ Map<Signature, Method> sigs = new HashMap<Signature, Method>();
while (cls != null) {
boolean done = getInternalPublicMethods(cls, sigs);
if (done) {
@@ -98,14 +98,14 @@ public final class MethodUtil extends SecureClassLoader {
getInterfaceMethods(cls, sigs);
cls = cls.getSuperclass();
}
- Collection c = sigs.values();
- return (Method[]) c.toArray(new Method[c.size()]);
+ return sigs.values().toArray(new Method[sigs.size()]);
}
/*
* Process the immediate interfaces of this class or interface.
*/
- private static void getInterfaceMethods(Class cls, Map sigs) {
+ private static void getInterfaceMethods(Class cls,
+ Map<Signature, Method> sigs) {
Class[] intfs = cls.getInterfaces();
for (int i=0; i < intfs.length; i++) {
Class intf = intfs[i];
@@ -120,7 +120,8 @@ public final class MethodUtil extends SecureClassLoader {
*
* Process the methods in this class or interface
*/
- private static boolean getInternalPublicMethods(Class cls, Map sigs) {
+ private static boolean getInternalPublicMethods(Class cls,
+ Map<Signature, Method> sigs) {
Method[] methods = null;
try {
/*
@@ -178,7 +179,7 @@ public final class MethodUtil extends SecureClassLoader {
return done;
}
- private static void addMethod(Map sigs, Method method) {
+ private static void addMethod(Map<Signature, Method> sigs, Method method) {
Signature signature = new Signature(method);
if (!sigs.containsKey(signature)) {
sigs.put(signature, method);
@@ -186,7 +187,7 @@ public final class MethodUtil extends SecureClassLoader {
/*
* Superclasses beat interfaces.
*/
- Method old = (Method)sigs.get(signature);
+ Method old = sigs.get(signature);
if (old.getDeclaringClass().isInterface()) {
sigs.put(signature, method);
}
@@ -280,17 +281,15 @@ public final class MethodUtil extends SecureClassLoader {
}
private static Method getTrampoline() {
- Method tramp = null;
-
try {
- tramp = (Method) AccessController.doPrivileged(new PrivilegedExceptionAction() {
- public Object run() throws Exception {
- Class[] types;
- Class t = getTrampolineClass();
- Method b;
-
- types = new Class[] {Method.class, Object.class, Object[].class};
- b = t.getDeclaredMethod("invoke", types);
+ return AccessController.doPrivileged(
+ new PrivilegedExceptionAction<Method>() {
+ public Method run() throws Exception {
+ Class<?> t = getTrampolineClass();
+ Class[] types = {
+ Method.class, Object.class, Object[].class
+ };
+ Method b = t.getDeclaredMethod("invoke", types);
((AccessibleObject)b).setAccessible(true);
return b;
}
@@ -298,7 +297,6 @@ public final class MethodUtil extends SecureClassLoader {
} catch (Exception e) {
throw new InternalError("bouncer cannot be found");
}
- return tramp;
}