[jboss-cvs] JBossAS SVN: r71279 - in projects/aop/trunk/aop/src: main/org/jboss/aop/reflection and 5 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Mar 25 18:56:03 EDT 2008
Author: kabir.khan at jboss.com
Date: 2008-03-25 18:56:03 -0400 (Tue, 25 Mar 2008)
New Revision: 71279
Modified:
projects/aop/trunk/aop/src/main/org/jboss/aop/Dispatcher.java
projects/aop/trunk/aop/src/main/org/jboss/aop/reflection/ReflectionAspect.java
projects/aop/trunk/aop/src/main/org/jboss/aop/standalone/Compiler.java
projects/aop/trunk/aop/src/main/org/jboss/aop/standalone/InstrumentationAdapter.java
projects/aop/trunk/aop/src/main/org/jboss/aop/standalone/Package.java
projects/aop/trunk/aop/src/main/org/jboss/aop/standalone/StandaloneClassPool.java
projects/aop/trunk/aop/src/main/org/jboss/aop/standalone/SystemClassLoader.java
projects/aop/trunk/aop/src/main/org/jboss/aop/standalone/XmlReport.java
projects/aop/trunk/aop/src/main/org/jboss/aop/util/ClassInfoMethodHashing.java
projects/aop/trunk/aop/src/main/org/jboss/aop/util/MethodHashing.java
projects/aop/trunk/aop/src/main/org/jboss/aop/util/logging/AOPLogger.java
projects/aop/trunk/aop/src/main/org/jboss/aspects/ThreadbasedAspect.java
projects/aop/trunk/aop/src/test/org/jboss/test/aop/ejb3dependencies/TestAnnotationRepository.java
Log:
Add generics
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/Dispatcher.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/Dispatcher.java 2008-03-25 22:20:57 UTC (rev 71278)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/Dispatcher.java 2008-03-25 22:56:03 UTC (rev 71279)
@@ -46,7 +46,7 @@
public static final String OID = "OID";
public static final Dispatcher singleton = new Dispatcher();
- Map targetMap = new ConcurrentHashMap();
+ Map<Object, Object> targetMap = new ConcurrentHashMap<Object, Object>();
public boolean isRegistered(Object oid)
@@ -112,8 +112,8 @@
MethodInvocation methodInvocation = (MethodInvocation) invocation;
// For non-advised methods, we can only do public method invocations
long methodHash = methodInvocation.getMethodHash();
- HashMap methodMap = ClassProxyFactory.getMethodMap(target.getClass());
- MethodPersistentReference ref = (MethodPersistentReference)methodMap.get(new Long(methodHash));
+ HashMap<Long, MethodPersistentReference> methodMap = ClassProxyFactory.getMethodMap(target.getClass());
+ MethodPersistentReference ref = methodMap.get(new Long(methodHash));
Method method = (Method)ref.get();
Object[] args = methodInvocation.getArguments();
try
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/reflection/ReflectionAspect.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/reflection/ReflectionAspect.java 2008-03-25 22:20:57 UTC (rev 71278)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/reflection/ReflectionAspect.java 2008-03-25 22:56:03 UTC (rev 71279)
@@ -48,7 +48,6 @@
import java.security.PrivilegedExceptionAction;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -261,7 +260,7 @@
{
Object targetObject = invocation.getTargetObject();
- return interceptGetDeclaredMethods((Class) targetObject);
+ return interceptGetDeclaredMethods((Class<?>) targetObject);
}
/**
@@ -278,7 +277,7 @@
{
Object targetObject = invocation.getTargetObject();
- return interceptGetDeclaredMethods((Class) targetObject);
+ return interceptGetDeclaredMethods((Class<?>) targetObject);
}
/**
@@ -296,7 +295,7 @@
Object targetObject = invocation.getTargetObject();
Object[] args = invocation.getArguments();
- return interceptGetDeclaredMethod((Class) targetObject, args);
+ return interceptGetDeclaredMethod((Class<?>) targetObject, args);
}
/**
@@ -314,7 +313,7 @@
Object targetObject = invocation.getTargetObject();
Object[] args = invocation.getArguments();
- return interceptGetDeclaredMethod((Class) targetObject, args);
+ return interceptGetDeclaredMethod((Class<?>) targetObject, args);
}
/**
@@ -331,7 +330,7 @@
{
Object targetObject = invocation.getTargetObject();
- return interceptGetMethods((Class) targetObject);
+ return interceptGetMethods((Class<?>) targetObject);
}
/**
@@ -348,7 +347,7 @@
{
Object targetObject = invocation.getTargetObject();
- return interceptGetMethods((Class) targetObject);
+ return interceptGetMethods((Class<?>) targetObject);
}
/**
@@ -366,7 +365,7 @@
Object targetObject = invocation.getTargetObject();
Object[] args = invocation.getArguments();
- return interceptGetMethod((Class) targetObject, args);
+ return interceptGetMethod((Class<?>) targetObject, args);
}
/**
@@ -384,7 +383,7 @@
Object targetObject = invocation.getTargetObject();
Object[] args = invocation.getArguments();
- return interceptGetMethod((Class) targetObject, args);
+ return interceptGetMethod((Class<?>) targetObject, args);
}
/**
@@ -401,7 +400,7 @@
{
Object targetObject = invocation.getTargetObject();
- return interceptGetInterfaces((Class) targetObject);
+ return interceptGetInterfaces((Class<?>) targetObject);
}
/**
@@ -418,7 +417,7 @@
{
Object targetObject = invocation.getTargetObject();
- return interceptGetInterfaces((Class) targetObject);
+ return interceptGetInterfaces((Class<?>) targetObject);
}
/**
@@ -434,7 +433,7 @@
{
Object targetObject = invocation.getTargetObject();
- return interceptGetDeclaredClasses((Class) targetObject);
+ return interceptGetDeclaredClasses((Class<?>) targetObject);
}
/**
@@ -450,7 +449,7 @@
{
Object targetObject = invocation.getTargetObject();
- return interceptGetDeclaredClasses((Class) targetObject);
+ return interceptGetDeclaredClasses((Class<?>) targetObject);
}
/**
@@ -467,7 +466,7 @@
{
Object targetObject = invocation.getTargetObject();
- return interceptGetClasses((Class) targetObject);
+ return interceptGetClasses((Class<?>) targetObject);
}
/**
@@ -483,7 +482,7 @@
public final Object interceptGetClasses(MethodCalledByMethodInvocation invocation) throws Throwable
{
Object targetObject = invocation.getTargetObject();
- return interceptGetClasses((Class) targetObject);
+ return interceptGetClasses((Class<?>) targetObject);
}
/**
@@ -499,7 +498,7 @@
{
Object targetObject = invocation.getTargetObject();
- return interceptGetDeclaredFields((Class) targetObject);
+ return interceptGetDeclaredFields((Class<?>) targetObject);
}
/**
@@ -515,7 +514,7 @@
{
Object targetObject = invocation.getTargetObject();
- return interceptGetDeclaredFields((Class) targetObject);
+ return interceptGetDeclaredFields((Class<?>) targetObject);
}
/**
@@ -532,7 +531,7 @@
Object targetObject = invocation.getTargetObject();
Object[] args = invocation.getArguments();
- return interceptGetDeclaredField((Class) targetObject, args);
+ return interceptGetDeclaredField((Class<?>) targetObject, args);
}
/**
@@ -548,7 +547,7 @@
{
Object targetObject = invocation.getTargetObject();
Object[] args = invocation.getArguments();
- return interceptGetDeclaredField((Class) targetObject, args);
+ return interceptGetDeclaredField((Class<?>) targetObject, args);
}
/**
@@ -701,7 +700,7 @@
* @return The new instance
* @throws Throwable
*/
- protected Object interceptConstructor(Invocation invocation, Constructor constructor, Object[] args) throws Throwable
+ protected Object interceptConstructor(Invocation invocation, Constructor<?> constructor, Object[] args) throws Throwable
{
return invokeOriginalChainIfExists(invocation, constructor, args);
}
@@ -765,13 +764,13 @@
Object targetObject,
Object[] args) throws Throwable
{
- Class reflectionClass = targetObject.getClass();
+ Class<?> reflectionClass = targetObject.getClass();
if (reflectionClass.equals(Class.class))
{
//For our purposes Class.newInstance() can be made into a call to the empty constructor
- Constructor constructor = ((Class) targetObject).getConstructor(new Class[0]);
+ Constructor<?> constructor = ((Class<?>) targetObject).getConstructor(new Class[0]);
return interceptConstructor(invocation, constructor, args);
}
else if (reflectionClass.equals(Constructor.class))
@@ -794,7 +793,7 @@
constructorArgs = (Object[]) args[0];
}
- Constructor constructor = (Constructor) targetObject;
+ Constructor<?> constructor = (Constructor<?>) targetObject;
return interceptConstructor(invocation, constructor, constructorArgs);
}
}
@@ -816,10 +815,10 @@
return invocation.invokeNext();
}
- private Class[] interceptGetInterfaces(Class clazz)
+ private Class<?>[] interceptGetInterfaces(Class<?> clazz)
{
- Class[] interfaces = clazz.getInterfaces();
- ArrayList cleanedInterfaces = new ArrayList(interfaces.length);
+ Class<?>[] interfaces = clazz.getInterfaces();
+ ArrayList<Class<?>> cleanedInterfaces = new ArrayList<Class<?>>(interfaces.length);
for (int i = 0; i < interfaces.length; i++)
{
@@ -829,7 +828,7 @@
}
}
- return (Class[]) cleanedInterfaces.toArray(new Class[cleanedInterfaces.size()]);
+ return cleanedInterfaces.toArray(new Class[cleanedInterfaces.size()]);
}
private Object interceptFieldSet(Invocation invocation, Method reflectionMethod, Object targetObject, Object[] args) throws Throwable
@@ -856,7 +855,7 @@
return invocation.invokeNext();
}
- private Method[] interceptGetDeclaredMethods(Class clazz)
+ private Method[] interceptGetDeclaredMethods(Class<?> clazz)
{
ClassAdvisor advisor = AspectManager.instance().getAdvisorIfAdvised(clazz);
@@ -868,7 +867,7 @@
{
Object[] advisedMethods = advisor.getAdvisedMethods().getValues();
- ArrayList methods = new ArrayList(advisedMethods.length);
+ ArrayList<Method> methods = new ArrayList<Method>(advisedMethods.length);
for (int i = 0; i < advisedMethods.length; i++)
{
@@ -879,11 +878,11 @@
}
}
- return (Method[]) methods.toArray(new Method[methods.size()]);
+ return methods.toArray(new Method[methods.size()]);
}
}
- private Method interceptGetDeclaredMethod(Class clazz, Object[] args) throws NoSuchMethodException
+ private Method interceptGetDeclaredMethod(Class<?> clazz, Object[] args) throws NoSuchMethodException
{
ClassAdvisor advisor = AspectManager.instance().getAdvisorIfAdvised(clazz);
@@ -923,10 +922,10 @@
return true;
}
- private Method[] interceptGetMethods(Class clazz)
+ private Method[] interceptGetMethods(Class<?> clazz)
{
- ArrayList methods = new ArrayList();
+ ArrayList<Method> methods = new ArrayList<Method>();
//These are the methods that have already been added. Since we are
//using Class.getDeclaredMethods(), we don't want to add super
@@ -964,13 +963,13 @@
clazz = clazz.getSuperclass();
}
- return (Method[]) methods.toArray(new Method[methods.size()]);
+ return methods.toArray(new Method[methods.size()]);
}
- private Method interceptGetMethod(Class clazz, Object[] args) throws NoSuchMethodException
+ private Method interceptGetMethod(Class<?> clazz, Object[] args) throws NoSuchMethodException
{
Method method = clazz.getMethod((String) args[0], (Class[]) args[1]);
- Class declaringClass = method.getDeclaringClass();
+ Class<?> declaringClass = method.getDeclaringClass();
while (clazz != null)
{
@@ -1005,7 +1004,7 @@
}
- private Field[] interceptGetDeclaredFields(Class clazz)
+ private Field[] interceptGetDeclaredFields(Class<?> clazz)
{
ClassAdvisor advisor = AspectManager.instance().getAdvisorIfAdvised(clazz);
@@ -1017,7 +1016,7 @@
{
Field[] advisedFields = advisor.getAdvisedFields();
- ArrayList fields = new ArrayList(advisedFields.length);
+ ArrayList<Field> fields = new ArrayList<Field>(advisedFields.length);
for (int i = 0; i < advisedFields.length; i++)
{
@@ -1028,7 +1027,7 @@
}
}
- return (Field[]) fields.toArray(new Field[fields.size()]);
+ return fields.toArray(new Field[fields.size()]);
}
}
@@ -1037,28 +1036,28 @@
* JRockit does, so make it got through the same cleaning procedure
* here
*/
- private Class[] interceptGetClasses(Class clazz) throws Throwable
+ private Class<?>[] interceptGetClasses(Class<?> clazz) throws Throwable
{
- Class[] classes = clazz.getClasses();
+ Class<?>[] classes = clazz.getClasses();
return cleanClasses(classes);
}
- private Class[] interceptGetDeclaredClasses(Class clazz) throws Throwable
+ private Class<?>[] interceptGetDeclaredClasses(Class<?> clazz) throws Throwable
{
- Class[] classes = getDeclaredClasses(clazz);
+ Class<?>[] classes = getDeclaredClasses(clazz);
return cleanClasses(classes);
}
- private Class[] cleanClasses(Class[] classes)
+ private Class<?>[] cleanClasses(Class<?>[] classes)
{
- ArrayList clazzes = new ArrayList();
+ ArrayList<Class<?>> clazzes = new ArrayList<Class<?>>();
for (int i = 0; i < classes.length; i++)
{
- Class innerClass = classes[i];
+ Class<?> innerClass = classes[i];
//Check if implements Untransformable
- Class[] interfaces = classes[i].getInterfaces();
+ Class<?>[] interfaces = classes[i].getInterfaces();
boolean implUntransformable = false;
for (int j = 0; j < interfaces.length; j++)
@@ -1074,7 +1073,7 @@
{
//Check if class implements Invocation at any stage
boolean isInvocationImpl = false;
- Class superclass = innerClass.getSuperclass();
+ Class<?> superclass = innerClass.getSuperclass();
while (superclass != null)
{
@@ -1098,10 +1097,10 @@
}
}
- return (Class[]) clazzes.toArray(new Class[clazzes.size()]);
+ return clazzes.toArray(new Class<?>[clazzes.size()]);
}
- private Field interceptGetDeclaredField(Class clazz, Object[] args) throws NoSuchFieldException
+ private Field interceptGetDeclaredField(Class<?> clazz, Object[] args) throws NoSuchFieldException
{
ClassAdvisor advisor = AspectManager.instance().getAdvisorIfAdvised(clazz);
@@ -1135,14 +1134,14 @@
* For now we don't bother attempting to use optimized invocations since we
* are using reflection anyway
*/
- private Object invokeOriginalChainIfExists(Invocation invocation, Constructor constructor, Object[] args) throws Throwable
+ private Object invokeOriginalChainIfExists(Invocation invocation, Constructor<?> constructor, Object[] args) throws Throwable
{
//Try to attach to the caller chain
if (invocation instanceof MethodCalledByConstructorInvocation)
{
MethodCalledByConstructorInvocation inv = (MethodCalledByConstructorInvocation) invocation;
- Constructor callingCon = inv.getCalling();
- Class callingClass = callingCon.getDeclaringClass();
+ Constructor<?> callingCon = inv.getCalling();
+ Class<?> callingClass = callingCon.getDeclaringClass();
if (isAdvised(callingClass))
{
ClassAdvisor advisor = AspectManager.instance().getAdvisor(callingClass);
@@ -1151,10 +1150,10 @@
int index = advisor.getConstructorIndex(callingCon);
if (index >= 0)
{
- HashMap calledClassesMap = advisor.getConCalledByConInterceptors()[index];
+ HashMap<String, TLongObjectHashMap> calledClassesMap = advisor.getConCalledByConInterceptors()[index];
if (calledClassesMap != null)
{
- TLongObjectHashMap calledCons = (TLongObjectHashMap) calledClassesMap.get(constructor.getDeclaringClass().getName());
+ TLongObjectHashMap calledCons = calledClassesMap.get(constructor.getDeclaringClass().getName());
if (calledCons != null)
{
long calledHash = MethodHashing.constructorHash(constructor);
@@ -1182,6 +1181,7 @@
long callingMethodHash = MethodHashing.calculateHash(callingMethod);
long calledHash = MethodHashing.constructorHash(constructor);
+ @SuppressWarnings("unchecked")
HashMap calledClassesMap = (HashMap) advisor.getConCalledByMethodInterceptors().get(callingMethodHash);
if (calledClassesMap != null)
{
@@ -1203,7 +1203,7 @@
}
//Try to attach to chain on target object
- Class calledClass = constructor.getDeclaringClass();
+ Class<?> calledClass = constructor.getDeclaringClass();
if (isAdvised(calledClass))
{
ClassAdvisor advisor = AspectManager.instance().getAdvisor(constructor.getDeclaringClass());
@@ -1235,7 +1235,7 @@
//Try to attach to chain on target object
ClassAdvisor advisor = AspectManager.instance().getAdvisor(field.getDeclaringClass());
- Class calledClass = field.getDeclaringClass();
+ Class<?> calledClass = field.getDeclaringClass();
if (isAdvised(calledClass))
{
if (advisor != null && advisor.hasAspects())
@@ -1264,7 +1264,7 @@
//Try to attach to chain on target object
ClassAdvisor advisor = AspectManager.instance().getAdvisor(field.getDeclaringClass());
- Class calledClass = field.getDeclaringClass();
+ Class<?> calledClass = field.getDeclaringClass();
if (isAdvised(calledClass))
{
if (advisor != null && advisor.hasAspects())
@@ -1292,8 +1292,8 @@
if (invocation instanceof MethodCalledByConstructorInvocation)
{
MethodCalledByConstructorInvocation inv = (MethodCalledByConstructorInvocation) invocation;
- Constructor callingCon = inv.getCalling();
- Class callingClass = callingCon.getDeclaringClass();
+ Constructor<?> callingCon = inv.getCalling();
+ Class<?> callingClass = callingCon.getDeclaringClass();
if (isAdvised(callingClass))
{
ClassAdvisor advisor = AspectManager.instance().getAdvisor(callingClass);
@@ -1302,10 +1302,10 @@
int index = advisor.getConstructorIndex(callingCon);
if (index >= 0)
{
- HashMap calledClassesMap = advisor.getMethodCalledByConInterceptors()[index];
+ HashMap<String, TLongObjectHashMap> calledClassesMap = advisor.getMethodCalledByConInterceptors()[index];
if (calledClassesMap != null)
{
- TLongObjectHashMap calledMethods = (TLongObjectHashMap) calledClassesMap.get(method.getDeclaringClass().getName());
+ TLongObjectHashMap calledMethods = calledClassesMap.get(method.getDeclaringClass().getName());
if (calledMethods != null)
{
long calledHash = MethodHashing.calculateHash(method);
@@ -1335,6 +1335,7 @@
long callingMethodHash = MethodHashing.calculateHash(callingMethod);
long calledHash = MethodHashing.calculateHash(method);
+ @SuppressWarnings("unchecked")
HashMap calledClassesMap = (HashMap) advisor.getMethodCalledByMethodInterceptors().get(callingMethodHash);
if (calledClassesMap != null)
{
@@ -1360,9 +1361,9 @@
return invocation.invokeNext();
}
- private boolean isAdvised(Class clazz)
+ private boolean isAdvised(Class<?> clazz)
{
- Class[] interfaces = clazz.getInterfaces();
+ Class<?>[] interfaces = clazz.getInterfaces();
for (int i = 0; i < interfaces.length; i++)
{
@@ -1373,7 +1374,7 @@
}
//Is this recursive check needed
- Class superClass = clazz.getSuperclass();
+ Class<?> superClass = clazz.getSuperclass();
if (superClass != null)
{
return isAdvised(superClass);
@@ -1387,16 +1388,16 @@
*/
class GetMethodsAlreadyFound
{
- HashMap methodMap = new HashMap();
+ HashMap<String, ArrayList<Method>> methodMap = new HashMap<String, ArrayList<Method>>();
public void addMethod(Method m)
{
String methodName = m.getName();
- ArrayList methods = (ArrayList) methodMap.get(methodName);
+ ArrayList<Method> methods = methodMap.get(methodName);
if (methods == null)
{
- methods = new ArrayList();
+ methods = new ArrayList<Method>();
methodMap.put(methodName, methods);
}
@@ -1405,19 +1406,18 @@
public boolean existsMethod(Method method)
{
- ArrayList methods = (ArrayList) methodMap.get(method.getName());
+ ArrayList<Method> methods = methodMap.get(method.getName());
if (methods == null)
{
return false;
}
- Class[] methodParamTypes = method.getParameterTypes();
+ Class<?>[] methodParamTypes = method.getParameterTypes();
- for (Iterator it = methods.iterator(); it.hasNext();)
+ for (Method found : methods)
{
- Method found = (Method) it.next();
- Class[] foundParamTypes = found.getParameterTypes();
+ Class<?>[] foundParamTypes = found.getParameterTypes();
if (methodParamTypes.length == foundParamTypes.length)
{
@@ -1444,35 +1444,35 @@
private interface SecurityAction
{
- Method[] getDeclaredMethods(Class clazz);
- Field[] getDeclaredFields(Class clazz);
- Class[] getDeclaredClasses(Class clazz);
- Field getDeclaredField(Class clazz, String name) throws NoSuchFieldException;
- Method getDeclaredMethod(Class clazz, String name, Class[] paramTypes) throws NoSuchMethodException;
+ Method[] getDeclaredMethods(Class<?> clazz);
+ Field[] getDeclaredFields(Class<?> clazz);
+ Class<?>[] getDeclaredClasses(Class<?> clazz);
+ Field getDeclaredField(Class<?> clazz, String name) throws NoSuchFieldException;
+ Method getDeclaredMethod(Class<?> clazz, String name, Class<?>[] paramTypes) throws NoSuchMethodException;
SecurityAction NON_PRIVILEGED = new SecurityAction()
{
- public Field[] getDeclaredFields(Class clazz)
+ public Field[] getDeclaredFields(Class<?> clazz)
{
return clazz.getDeclaredFields();
}
- public Method[] getDeclaredMethods(Class clazz)
+ public Method[] getDeclaredMethods(Class<?> clazz)
{
return clazz.getDeclaredMethods();
}
- public Class[] getDeclaredClasses(Class clazz)
+ public Class<?>[] getDeclaredClasses(Class<?> clazz)
{
return clazz.getDeclaredClasses();
}
- public Field getDeclaredField(Class clazz, String name) throws NoSuchFieldException
+ public Field getDeclaredField(Class<?> clazz, String name) throws NoSuchFieldException
{
return clazz.getDeclaredField(name);
}
- public Method getDeclaredMethod(Class clazz, String name, Class[] paramTypes) throws NoSuchMethodException
+ public Method getDeclaredMethod(Class<?> clazz, String name, Class<?>[] paramTypes) throws NoSuchMethodException
{
return clazz.getDeclaredMethod(name, paramTypes);
}
@@ -1481,42 +1481,42 @@
SecurityAction PRIVILEGED = new SecurityAction()
{
- public Field[] getDeclaredFields(final Class clazz)
+ public Field[] getDeclaredFields(final Class<?> clazz)
{
- return (Field[])AccessController.doPrivileged(new PrivilegedAction(){
- public Object run()
+ return AccessController.doPrivileged(new PrivilegedAction<Field[]>(){
+ public Field[] run()
{
return clazz.getDeclaredFields();
}
});
}
- public Method[] getDeclaredMethods(final Class clazz)
+ public Method[] getDeclaredMethods(final Class<?> clazz)
{
- return (Method[])AccessController.doPrivileged(new PrivilegedAction(){
- public Object run()
+ return AccessController.doPrivileged(new PrivilegedAction<Method[]>(){
+ public Method[] run()
{
return clazz.getDeclaredMethods();
}
});
}
- public Class[] getDeclaredClasses(final Class clazz)
+ public Class<?>[] getDeclaredClasses(final Class<?> clazz)
{
- return (Class[])AccessController.doPrivileged(new PrivilegedAction(){
- public Object run()
+ return AccessController.doPrivileged(new PrivilegedAction<Class<?>[]>(){
+ public Class<?>[] run()
{
return clazz.getDeclaredClasses();
}
});
}
- public Field getDeclaredField(final Class clazz, final String name) throws NoSuchFieldException
+ public Field getDeclaredField(final Class<?> clazz, final String name) throws NoSuchFieldException
{
try
{
- return (Field)AccessController.doPrivileged(new PrivilegedExceptionAction(){
- public Object run() throws Exception
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<Field>(){
+ public Field run() throws Exception
{
return clazz.getDeclaredField(name);
}
@@ -1533,12 +1533,12 @@
}
}
- public Method getDeclaredMethod(final Class clazz, final String name, final Class[] paramTypes) throws NoSuchMethodException
+ public Method getDeclaredMethod(final Class<?> clazz, final String name, final Class<?>[] paramTypes) throws NoSuchMethodException
{
try
{
- return (Method)AccessController.doPrivileged(new PrivilegedExceptionAction(){
- public Object run() throws Exception
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<Method>(){
+ public Method run() throws Exception
{
return clazz.getDeclaredMethod(name, paramTypes);
}
@@ -1557,7 +1557,7 @@
};
}
- private static Method[] getDeclaredMethods(Class clazz)
+ private static Method[] getDeclaredMethods(Class<?> clazz)
{
if (System.getSecurityManager() == null)
{
@@ -1569,7 +1569,7 @@
}
}
- private static Field[] getDeclaredFields(Class clazz)
+ private static Field[] getDeclaredFields(Class<?> clazz)
{
if (System.getSecurityManager() == null)
{
@@ -1581,7 +1581,7 @@
}
}
- private static Class[] getDeclaredClasses(Class clazz)
+ private static Class<?>[] getDeclaredClasses(Class<?> clazz)
{
if (System.getSecurityManager() == null)
{
@@ -1593,7 +1593,7 @@
}
}
- private static Field getDeclaredField(Class clazz, String name) throws NoSuchFieldException
+ private static Field getDeclaredField(Class<?> clazz, String name) throws NoSuchFieldException
{
if (System.getSecurityManager() == null)
{
@@ -1605,7 +1605,7 @@
}
}
- private static Method getDeclaredMethod(Class clazz, String name, Class[] paramTypes) throws NoSuchMethodException
+ private static Method getDeclaredMethod(Class<?> clazz, String name, Class<?>[] paramTypes) throws NoSuchMethodException
{
if (System.getSecurityManager() == null)
{
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/standalone/Compiler.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/standalone/Compiler.java 2008-03-25 22:20:57 UTC (rev 71278)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/standalone/Compiler.java 2008-03-25 22:56:03 UTC (rev 71279)
@@ -35,7 +35,6 @@
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.StringTokenizer;
import javassist.bytecode.ClassFile;
@@ -43,8 +42,6 @@
import org.jboss.aop.AspectManager;
import org.jboss.aop.Deployment;
import org.jboss.aop.instrument.TransformationException;
-import org.jboss.aop.util.logging.AOPLogger;
-import org.jboss.logging.Logger;
/**
* takes jar or class files and adds needed jboss bytecode
@@ -54,7 +51,6 @@
*/
public class Compiler
{
- private static final Logger logger = AOPLogger.getLogger(Compiler.class);
private FileFilter classFileFilter = new FileFilter()
{
public boolean accept(File pathname)
@@ -123,8 +119,8 @@
System.exit(1);
return;
}
- ArrayList paths = new ArrayList();
- ArrayList files = new ArrayList();
+ ArrayList<URL> paths = new ArrayList<URL>();
+ ArrayList<File> files = new ArrayList<File>();
boolean report = false;
for (int i = 0; i < args.length; i++)
{
@@ -187,7 +183,7 @@
}
- URL[] urls = (URL[]) paths.toArray(new URL[paths.size()]);
+ URL[] urls = paths.toArray(new URL[paths.size()]);
loader = new URLClassLoader(urls, Thread.currentThread().getContextClassLoader());
Thread.currentThread().setContextClassLoader(loader);
@@ -202,7 +198,7 @@
{
for (int i = 0; i < files.size(); i++)
{
- File f = (File) files.get(i);
+ File f = files.get(i);
loadFile(f);
}
FileOutputStream reportFile = new FileOutputStream("aop-report.xml");
@@ -214,7 +210,7 @@
//Add all the classes to compile
for (int i = 0 ; i < files.size() ; i++)
{
- File f = (File)files.get(i);
+ File f = files.get(i);
if (f.isDirectory())
{
addDirectory(f);
@@ -230,16 +226,15 @@
}
//Compile each class
- for (Iterator it = classesToCompile.keySet().iterator() ; it.hasNext() ; )
+ for (String className : classesToCompile.keySet())
{
- String className = (String)it.next();
- CompilerClassInfo info = (CompilerClassInfo)classesToCompile.get(className);
+ CompilerClassInfo info = classesToCompile.get(className);
compileFile(info);
}
}
}
- private HashMap classesToCompile = new HashMap();
+ private HashMap<String, CompilerClassInfo> classesToCompile = new HashMap<String, CompilerClassInfo>();
private void addDirectory(File dir) throws Exception
{
@@ -288,7 +283,7 @@
return cf;
}
- private void addFilesFromSourcePathFile(ArrayList files, String sourcePathFile)
+ private void addFilesFromSourcePathFile(ArrayList<File> files, String sourcePathFile)
{
BufferedReader reader = null;
@@ -327,7 +322,7 @@
DataInputStream is = new DataInputStream(new FileInputStream(file));
ClassFile cf = new ClassFile(is);
is.close();
- Class clazz = loader.loadClass(cf.getName());
+ Class<?> clazz = loader.loadClass(cf.getName());
if (org.jboss.aop.Advised.class.isAssignableFrom(clazz))
{
Field f = clazz.getDeclaredField("aop$classAdvisor$aop");
@@ -347,7 +342,7 @@
if (info.getSuperClassName() != null)
{
- CompilerClassInfo superInfo = (CompilerClassInfo)classesToCompile.get(info.getSuperClassName());
+ CompilerClassInfo superInfo = classesToCompile.get(info.getSuperClassName());
if (superInfo != null)
{
compileFile(superInfo);
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/standalone/InstrumentationAdapter.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/standalone/InstrumentationAdapter.java 2008-03-25 22:20:57 UTC (rev 71278)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/standalone/InstrumentationAdapter.java 2008-03-25 22:56:03 UTC (rev 71279)
@@ -56,7 +56,7 @@
* @param clazz the clazz to be redefined.
* @param classCode the new byte code implementation of <code>clazz</code>.
*/
- public synchronized void registerChange(Class clazz, byte[] classCode)
+ public synchronized void registerChange(Class<?> clazz, byte[] classCode)
{
ClassDefinition classDef = new ClassDefinition(clazz, classCode);
this.classDefinitions.add(classDef);
@@ -70,7 +70,7 @@
public synchronized void hotSwap()
{
ClassDefinition[] definitions = new ClassDefinition[this.classDefinitions.size()];
- definitions = (ClassDefinition[]) this.classDefinitions.toArray(definitions);
+ definitions = this.classDefinitions.toArray(definitions);
try
{
instrumentation.redefineClasses(definitions);
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/standalone/Package.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/standalone/Package.java 2008-03-25 22:20:57 UTC (rev 71278)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/standalone/Package.java 2008-03-25 22:56:03 UTC (rev 71279)
@@ -24,6 +24,7 @@
import org.jboss.aop.Advisor;
import org.jboss.aop.AspectManager;
+import java.lang.ref.WeakReference;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
@@ -38,8 +39,8 @@
public class Package implements java.io.Serializable
{
static final long serialVersionUID = 6188655039267365373L;
- public HashMap advisors = new HashMap();
- public HashMap packages = new HashMap();
+ public HashMap<String, Advisor> advisors = new HashMap<String, Advisor>();
+ public HashMap<String, Package> packages = new HashMap<String, Package>();
public String name;
public Package(String name)
@@ -47,7 +48,7 @@
this.name = name;
}
- static void parse(Class clazz, Package root)
+ static void parse(Class<?> clazz, Package root)
{
Advisor advisor = AspectManager.instance().findAdvisor(clazz);
StringTokenizer tokenizer = new StringTokenizer(clazz.getName(), ".");
@@ -56,7 +57,7 @@
String pkgName = tokenizer.nextToken();
if (tokenizer.hasMoreTokens())
{
- Package subpkg = (Package) root.packages.get(pkgName);
+ Package subpkg = root.packages.get(pkgName);
if (subpkg == null)
{
subpkg = new Package(pkgName);
@@ -73,12 +74,12 @@
public static Package aopClassMap()
{
- Map advisors = AspectManager.instance().getAdvisors();
- Iterator it = advisors.keySet().iterator();
+ Map<Class<?>, WeakReference<Advisor>> advisors = AspectManager.instance().getAdvisors();
+ Iterator<Class<?>> it = advisors.keySet().iterator();
Package root = new Package("classes");
while (it.hasNext())
{
- Class clazz = (Class) it.next();
+ Class<?> clazz = it.next();
parse(clazz, root);
}
return root;
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/standalone/StandaloneClassPool.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/standalone/StandaloneClassPool.java 2008-03-25 22:20:57 UTC (rev 71278)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/standalone/StandaloneClassPool.java 2008-03-25 22:56:03 UTC (rev 71279)
@@ -48,14 +48,12 @@
super(src, repository);
}
- //KAB: removed NotFoundException, IOException from throws clause, as
- //they are not defined by javassist.ClassPool
- public Class toClass(CtClass ctClass) throws CannotCompileException/*, NotFoundException, IOException*/
+ public Class<?> toClass(CtClass ctClass) throws CannotCompileException
{
try
{
byte[] b = ctClass.toBytecode();
- Class cl = Class.forName("java.lang.ClassLoader");
+ Class<?> cl = Class.forName("java.lang.ClassLoader");
java.lang.reflect.Method method
= cl.getDeclaredMethod("defineClass",
new Class[]{String.class, byte[].class,
@@ -63,7 +61,7 @@
method.setAccessible(true);
Object[] args = new Object[]{ctClass.getName(), b, new Integer(0),
new Integer(b.length)};
- Class clazz = (Class) method.invoke(getClassLoader(), args);
+ Class<?> clazz = (Class<?>) method.invoke(getClassLoader(), args);
method.setAccessible(false);
return clazz;
}
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/standalone/SystemClassLoader.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/standalone/SystemClassLoader.java 2008-03-25 22:20:57 UTC (rev 71278)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/standalone/SystemClassLoader.java 2008-03-25 22:56:03 UTC (rev 71279)
@@ -142,11 +142,11 @@
* @return the class
* @throws ClassNotFoundException when there is no class
*/
- public synchronized Class loadClass(String name, boolean resolve)
+ public synchronized Class<?> loadClass(String name, boolean resolve)
throws ClassNotFoundException
{
// Have we already loaded the class?
- Class clazz = findLoadedClass(name);
+ Class<?> clazz = findLoadedClass(name);
if (clazz != null)
{
if (resolve) resolveClass(clazz);
@@ -207,9 +207,9 @@
throws ClassNotFoundException, IOException
{
final String classFileName = name.replace('.', '/') + ".class";
- final URL url = (URL) AccessController.doPrivileged(new PrivilegedAction()
+ final URL url = AccessController.doPrivileged(new PrivilegedAction<URL>()
{
- public Object run()
+ public URL run()
{
return getParent().getResource(classFileName);
}
@@ -220,9 +220,9 @@
{
try
{
- in = (InputStream) AccessController.doPrivileged(new PrivilegedExceptionAction()
+ in = AccessController.doPrivileged(new PrivilegedExceptionAction<InputStream>()
{
- public Object run() throws Exception
+ public InputStream run() throws Exception
{
return url.openStream();
}
@@ -259,9 +259,9 @@
*/
try
{
- in = (InputStream) AccessController.doPrivileged(new PrivilegedExceptionAction()
+ in = AccessController.doPrivileged(new PrivilegedExceptionAction<InputStream>()
{
- public Object run() throws Exception
+ public InputStream run() throws Exception
{
String tmpdir = System.getProperty("java.io.tmpdir");
File aopdynclasses = new File(tmpdir, "aopdynclasses");
@@ -321,11 +321,11 @@
* @param resolve whether to resolve the class
* @returns the class
*/
- protected Class defineClassFromBytes(String name, ClassBytes bytes, boolean resolve)
+ protected Class<?> defineClassFromBytes(String name, ClassBytes bytes, boolean resolve)
{
definePackage(name);
byte[] b = bytes.bytes;
- Class clazz = defineClass(name, b, 0, b.length, bytes.protectionDomain);
+ Class<?> clazz = defineClass(name, b, 0, b.length, bytes.protectionDomain);
if (resolve) resolveClass(clazz);
return clazz;
}
@@ -358,7 +358,7 @@
* @return the class
* @throws ClassNotFoundException when there is no class
*/
- protected Class loadClassLocally(String name)
+ protected Class<?> loadClassLocally(String name)
throws ClassNotFoundException
{
try
@@ -379,7 +379,7 @@
* @return the class
* @throws ClassNotFoundException when there is no class
*/
- protected Class loadClassByDelegation(String name)
+ protected Class<?> loadClassByDelegation(String name)
throws ClassNotFoundException
{
// FIXME: Only works for Sun for now
@@ -401,8 +401,8 @@
try
{
// AspectManager
- Class clazz = loadClassLocally("org.jboss.aop.AspectManager");
- Class[] transformSig = {ClassLoader.class, String.class,
+ Class<?> clazz = loadClassLocally("org.jboss.aop.AspectManager");
+ Class<?>[] transformSig = {ClassLoader.class, String.class,
Class.class, ProtectionDomain.class, byte[].class};
transform = clazz.getMethod("transform", transformSig);
instance = clazz.getMethod("instance", new Class[0]);
@@ -527,10 +527,10 @@
// Install the aop configurations
try
{
- Enumeration enumeration = getParent().getResources("META-INF/jboss-aop.xml");
+ Enumeration<URL> enumeration = getParent().getResources("META-INF/jboss-aop.xml");
while (enumeration.hasMoreElements())
{
- URL url = (URL) enumeration.nextElement();
+ URL url = enumeration.nextElement();
deployXML.invoke(null, new Object[]{url});
}
}
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/standalone/XmlReport.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/standalone/XmlReport.java 2008-03-25 22:20:57 UTC (rev 71278)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/standalone/XmlReport.java 2008-03-25 22:56:03 UTC (rev 71279)
@@ -22,6 +22,8 @@
package org.jboss.aop.standalone;
import gnu.trove.TLongObjectHashMap;
+
+import org.jboss.aop.Advisor;
import org.jboss.aop.AspectManager;
import org.jboss.aop.CallerConstructorInfo;
import org.jboss.aop.CallerMethodInfo;
@@ -95,12 +97,12 @@
}
}
- protected static String simpleType(Class type)
+ protected static String simpleType(Class<?> type)
{
- Class ret = type;
+ Class<?> ret = type;
if (ret.isArray())
{
- Class arr = ret;
+ Class<?> arr = ret;
String array = "";
while (arr.isArray())
{
@@ -114,23 +116,23 @@
public static void outputPackage(int indent, PrintWriter pw, Package root)
{
- Iterator it = root.packages.entrySet().iterator();
- while (it.hasNext())
+ Iterator<Map.Entry<String, Package>> it1 = root.packages.entrySet().iterator();
+ while (it1.hasNext())
{
- Map.Entry entry = (Map.Entry) it.next();
- String pkgName = (String) entry.getKey();
+ Map.Entry<String, Package> entry = it1.next();
+ String pkgName = entry.getKey();
indenter(pw, indent);
pw.println("<package name=\"" + pkgName + "\">");
- Package p = (Package) entry.getValue();
+ Package p = entry.getValue();
outputPackage(indent + 1, pw, p);
indenter(pw, indent);
pw.println("</package>");
}
- it = root.advisors.entrySet().iterator();
- while (it.hasNext())
+ Iterator<Map.Entry<String, Advisor>> it2 = root.advisors.entrySet().iterator();
+ while (it2.hasNext())
{
- Map.Entry entry = (Map.Entry) it.next();
- String classname = (String) entry.getKey();
+ Map.Entry<String, Advisor> entry = it2.next();
+ String classname = entry.getKey();
indenter(pw, indent);
pw.println("<class name=\"" + classname + "\">");
ClassAdvisor advisor = (ClassAdvisor) entry.getValue();
@@ -142,7 +144,7 @@
public static void outputAdvisor(int indent, PrintWriter pw, ClassAdvisor advisor, String baseName)
{
- ArrayList introductions = advisor.getInterfaceIntroductions();
+ ArrayList<InterfaceIntroduction> introductions = advisor.getInterfaceIntroductions();
if (introductions != null && introductions.size() > 0)
{
indenter(pw, indent);
@@ -150,12 +152,12 @@
indent++;
for (int i = 0; i < introductions.size(); i++)
{
- InterfaceIntroduction pointcut = (InterfaceIntroduction) introductions.get(i);
+ InterfaceIntroduction pointcut = introductions.get(i);
indenter(pw, indent);
pw.println("<introduction classExpr=\"" + pointcut.getClassExpr() + "\">");
indent++;
String[] intfs = pointcut.getInterfaces();
- ArrayList mixins = pointcut.getMixins();
+ ArrayList<InterfaceIntroduction.Mixin> mixins = pointcut.getMixins();
if (intfs != null && intfs.length > 0)
{
@@ -171,7 +173,7 @@
//Show mixins
for (int j = 0; j < mixins.size(); j++)
{
- InterfaceIntroduction.Mixin mixin = (InterfaceIntroduction.Mixin) mixins.get(j);
+ InterfaceIntroduction.Mixin mixin = mixins.get(j);
String[] mixifs = mixin.getInterfaces();
for (int k = 0; k < mixifs.length; k++)
@@ -198,10 +200,10 @@
indent++;
for (int i = 0; i < advisor.getConstructors().length; i++)
{
- Constructor con = advisor.getConstructors()[i];
+ Constructor<?> con = advisor.getConstructors()[i];
Interceptor[] chain = advisor.getConstructorInfos()[i].getInterceptors();
- HashMap methodCallers = advisor.getMethodCalledByConInterceptors()[i];
- HashMap conCallers = advisor.getConCalledByConInterceptors()[i];
+ HashMap<String, TLongObjectHashMap> methodCallers = advisor.getMethodCalledByConInterceptors()[i];
+ HashMap<String, TLongObjectHashMap> conCallers = advisor.getConCalledByConInterceptors()[i];
if ((chain != null && chain.length > 0) || methodCallers != null || conCallers != null)
{
@@ -275,7 +277,9 @@
{
long key = keys[i];
MethodInfo method = (MethodInfo) advisor.getMethodInterceptors().get(key);
+ @SuppressWarnings("unchecked")
HashMap methodCallers = (HashMap) advisor.getMethodCalledByMethodInterceptors().get(key);
+ @SuppressWarnings("unchecked")
HashMap conCallers = (HashMap) advisor.getConCalledByMethodInterceptors().get(key);
if (method == null && methodCallers == null) continue;
if (method != null && methodCallers == null && (method.getInterceptors() == null || method.getInterceptors().length < 1)) continue;
@@ -309,15 +313,15 @@
}
- public static void outputMethodCallers(int indent, PrintWriter pw, HashMap called)
+ public static void outputMethodCallers(int indent, PrintWriter pw, HashMap<String, TLongObjectHashMap> called)
{
indenter(pw, indent);
pw.println("<method-callers>");
indent++;
- Iterator it = called.values().iterator();
+ Iterator<TLongObjectHashMap> it = called.values().iterator();
while (it.hasNext())
{
- TLongObjectHashMap map = (TLongObjectHashMap) it.next();
+ TLongObjectHashMap map = it.next();
Object[] values = map.getValues();
for (int i = 0; i < values.length; i++)
{
@@ -342,15 +346,15 @@
pw.println("</method-callers>");
}
- public static void outputConCallers(int indent, PrintWriter pw, HashMap called)
+ public static void outputConCallers(int indent, PrintWriter pw, HashMap<String, TLongObjectHashMap> called)
{
indenter(pw, indent);
pw.println("<constructor-callers>");
indent++;
- Iterator it = called.values().iterator();
+ Iterator<TLongObjectHashMap> it = called.values().iterator();
while (it.hasNext())
{
- TLongObjectHashMap map = (TLongObjectHashMap) it.next();
+ TLongObjectHashMap map = it.next();
Object[] values = map.getValues();
for (int i = 0; i < values.length; i++)
{
@@ -406,10 +410,8 @@
public static void outputUnboundBindings(int indent, PrintWriter pw)
{
boolean first = true;
- Iterator it = AspectManager.instance().getBindings().values().iterator();
- while (it.hasNext())
+ for (AdviceBinding binding : AspectManager.instance().getBindings().values())
{
- AdviceBinding binding = (AdviceBinding) it.next();
if (!binding.hasAdvisors())
{
if (first)
@@ -501,9 +503,9 @@
StringBuffer xml = new StringBuffer();
indent++;
- for (Iterator it = fieldMetaData.getFields(); it.hasNext();)
+ for (Iterator<String> it = fieldMetaData.getFields(); it.hasNext();)
{
- String field = (String) it.next();
+ String field = it.next();
org.jboss.aop.metadata.SimpleMetaData fieldData = fieldMetaData.getFieldMetaData(field);
indent++;
indent++;
@@ -537,9 +539,9 @@
StringBuffer xml = new StringBuffer();
indent++;
- for (Iterator it = constructorMetaData.getConstructors(); it.hasNext();)
+ for (Iterator<String> it = constructorMetaData.getConstructors(); it.hasNext();)
{
- String constructor = (String) it.next();
+ String constructor = it.next();
org.jboss.aop.metadata.SimpleMetaData constructorData = constructorMetaData.getConstructorMetaData(constructor);
indent++;
indent++;
@@ -573,9 +575,9 @@
StringBuffer xml = new StringBuffer();
indent++;
- for (Iterator it = methodMetaData.getMethods(); it.hasNext();)
+ for (Iterator<String> it = methodMetaData.getMethods(); it.hasNext();)
{
- String method = (String) it.next();
+ String method = it.next();
org.jboss.aop.metadata.SimpleMetaData methodData = methodMetaData.getMethodMetaData(method);
indent++;
indent++;
@@ -606,16 +608,16 @@
public static StringBuffer getMetadataXml(int indent, ClassAdvisor advisor, SimpleMetaData metadata)
{
StringWriter sw = new StringWriter();
- HashSet tags = metadata.tags();
+ HashSet<Object> tags = metadata.tags();
if (tags.size() == 0)
{
return null;
}
- for (Iterator tagsIt = tags.iterator(); tagsIt.hasNext();)
+ for (Iterator<Object> tagsIt = tags.iterator(); tagsIt.hasNext();)
{
String tag = (String) tagsIt.next();
- HashMap groupAttrs = metadata.tag(tag);
+ HashMap<Object, SimpleMetaData.MetaDataValue> groupAttrs = metadata.tag(tag);
indent++;
indenter(sw, indent);
@@ -628,14 +630,14 @@
}
boolean hasValues = false;
- for (Iterator attrsIt = groupAttrs.entrySet().iterator(); attrsIt.hasNext();)
+ for (Iterator<Map.Entry<Object, SimpleMetaData.MetaDataValue>> attrsIt = groupAttrs.entrySet().iterator(); attrsIt.hasNext();)
{
- Map.Entry entry = (Map.Entry) attrsIt.next();
+ Map.Entry<Object, SimpleMetaData.MetaDataValue> entry = attrsIt.next();
String attr = (String) entry.getKey();
if (!attr.equals(MetaDataResolver.EMPTY_TAG))
{
hasValues = true;
- SimpleMetaData.MetaDataValue value = (SimpleMetaData.MetaDataValue) entry.getValue();
+ SimpleMetaData.MetaDataValue value = entry.getValue();
indenter(sw, indent);
sw.write("<attribute name=\"" + attr + "\">" + "\r\n");
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/util/ClassInfoMethodHashing.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/util/ClassInfoMethodHashing.java 2008-03-25 22:20:57 UTC (rev 71278)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/util/ClassInfoMethodHashing.java 2008-03-25 22:56:03 UTC (rev 71279)
@@ -157,7 +157,7 @@
}
}
- private static void addDeclaredMethods(HashMap advised, ClassInfo superclass) throws Exception
+ private static void addDeclaredMethods(HashMap<Long, MethodInfo> advised, ClassInfo superclass) throws Exception
{
MethodInfo[] declaredMethods = superclass.getDeclaredMethods();
if (declaredMethods != null)
@@ -172,7 +172,7 @@
}
}
}
- private static void populateMethodTables(HashMap advised, ClassInfo superclass)
+ private static void populateMethodTables(HashMap<Long, MethodInfo> advised, ClassInfo superclass)
throws Exception
{
if (superclass == null) return;
@@ -182,16 +182,16 @@
addDeclaredMethods(advised, superclass);
}
- public static HashMap getMethodMap(ClassInfo clazz) throws Exception
+ public static HashMap<Long, MethodInfo> getMethodMap(ClassInfo clazz) throws Exception
{
- HashMap map = new HashMap();
+ HashMap<Long, MethodInfo> map = new HashMap<Long, MethodInfo>();
populateMethodTables(map, clazz);
return map;
}
- public static HashMap getDeclaredMethodMap(ClassInfo clazz) throws Exception
+ public static HashMap<Long, MethodInfo> getDeclaredMethodMap(ClassInfo clazz) throws Exception
{
- HashMap map = new HashMap();
+ HashMap<Long, MethodInfo> map = new HashMap<Long, MethodInfo>();
addDeclaredMethods(map, clazz);
return map;
}
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/util/MethodHashing.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/util/MethodHashing.java 2008-03-25 22:20:57 UTC (rev 71278)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/util/MethodHashing.java 2008-03-25 22:56:03 UTC (rev 71279)
@@ -46,20 +46,20 @@
// Constants -----------------------------------------------------
// Static --------------------------------------------------------
- static Map methodHashesByName = new WeakHashMap();
+ static Map<Class<?>, Map<String, Long>> methodHashesByName = new WeakHashMap<Class<?>, Map<String, Long>>();
- static Map methodHashesByClass = new WeakHashMap();
- static Map constructorHashesByClass = new WeakHashMap();
+ static Map<Class<?>, Map<Long, MethodPersistentReference>> methodHashesByClass = new WeakHashMap<Class<?>, Map<Long, MethodPersistentReference>>();
+ static Map<Class<?>, Map<Long, ConstructorPersistentReference>> constructorHashesByClass = new WeakHashMap<Class<?>, Map<Long, ConstructorPersistentReference>> ();
- public static Method findMethodByHash(Class clazz, long hash) throws Exception
+ public static Method findMethodByHash(Class<?> clazz, long hash) throws Exception
{
return findMethodByHash(clazz, new Long(hash));
}
- public static Method findMethodByHash(Class clazz, Long hash) throws Exception
+ public static Method findMethodByHash(Class<?> clazz, Long hash) throws Exception
{
- Map hashes = getMethodHashes(clazz);
- MethodPersistentReference ref = (MethodPersistentReference)hashes.get(hash);
+ Map<Long, MethodPersistentReference> hashes = getMethodHashes(clazz);
+ MethodPersistentReference ref = hashes.get(hash);
if (ref != null)
{
return ref.getMethod();
@@ -67,7 +67,7 @@
if (clazz.isInterface())
{
- final Class[] interfaces = clazz.getInterfaces() ;
+ final Class<?>[] interfaces = clazz.getInterfaces() ;
final int numInterfaces = interfaces.length ;
for(int count = 0 ; count < numInterfaces ; count++)
{
@@ -85,15 +85,15 @@
return null;
}
- public static Constructor findConstructorByHash(Class clazz, long hash) throws Exception
+ public static Constructor<?> findConstructorByHash(Class<?> clazz, long hash) throws Exception
{
return findConstructorByHash(clazz, new Long(hash));
}
- public static Constructor findConstructorByHash(Class clazz, Long hash) throws Exception
+ public static Constructor<?> findConstructorByHash(Class<?> clazz, Long hash) throws Exception
{
- Map hashes = getConstructorHashes(clazz);
- ConstructorPersistentReference ref = (ConstructorPersistentReference)hashes.get(hash);
+ Map<Long, ConstructorPersistentReference> hashes = getConstructorHashes(clazz);
+ ConstructorPersistentReference ref = hashes.get(hash);
if (ref != null)
{
return ref.getConstructor();
@@ -118,7 +118,7 @@
public static long methodHash(Method method)
throws Exception
{
- Class[] parameterTypes = method.getParameterTypes();
+ Class<?>[] parameterTypes = method.getParameterTypes();
StringBuffer methodDesc = new StringBuffer(method.getName()+"(");
for(int j = 0; j < parameterTypes.length; j++)
{
@@ -144,10 +144,10 @@
}
- public static long constructorHash(Constructor method)
+ public static long constructorHash(Constructor<?> method)
throws Exception
{
- Class[] parameterTypes = method.getParameterTypes();
+ Class<?>[] parameterTypes = method.getParameterTypes();
StringBuffer methodDesc = new StringBuffer(method.getName()+"(");
for(int j = 0; j < parameterTypes.length; j++)
{
@@ -158,7 +158,7 @@
return createHash(methodDesc.toString());
}
- static String getTypeString(Class cl)
+ static String getTypeString(Class<?> cl)
{
if (cl == Byte.TYPE)
{
@@ -205,20 +205,20 @@
*/
public static long calculateHash(Method method)
{
- Map methodHashes = (Map)methodHashesByName.get(method.getDeclaringClass());
+ Map<String, Long> methodHashes = methodHashesByName.get(method.getDeclaringClass());
if (methodHashes == null)
{
methodHashes = getInterfaceHashes(method.getDeclaringClass());
// Copy and add
- WeakHashMap newHashMap = new WeakHashMap();
+ WeakHashMap<Class<?>, Map<String, Long>> newHashMap = new WeakHashMap<Class<?>, Map<String, Long>>();
newHashMap.putAll(methodHashesByName);
newHashMap.put(method.getDeclaringClass(), methodHashes);
methodHashesByName = newHashMap;
}
- return ((Long)methodHashes.get(method.toString())).longValue();
+ return methodHashes.get(method.toString()).longValue();
}
@@ -229,11 +229,11 @@
* @return
* @deprecated I can't see why this would have any value to anybody apart from this class. It will be made private
*/
- public static Map getInterfaceHashes(Class intf)
+ public static Map<String, Long> getInterfaceHashes(Class<?> intf)
{
// Create method hashes
Method[] methods = SecurityActions.getDeclaredMethods(intf);
- HashMap map = new HashMap();
+ HashMap<String, Long> map = new HashMap<String, Long>();
for (int i = 0; i < methods.length; i++)
{
Method method = methods[i];
@@ -250,9 +250,9 @@
return map;
}
- private static Map getMethodHashes(Class clazz)
+ private static Map<Long, MethodPersistentReference> getMethodHashes(Class<?> clazz)
{
- Map methodHashes = (Map)methodHashesByClass.get(clazz);
+ Map<Long, MethodPersistentReference> methodHashes = methodHashesByClass.get(clazz);
if (methodHashes == null)
{
methodHashes = getMethodHashMap(clazz);
@@ -261,11 +261,11 @@
return methodHashes;
}
- private static Map getMethodHashMap(Class clazz)
+ private static Map<Long, MethodPersistentReference> getMethodHashMap(Class<?> clazz)
{
// Create method hashes
Method[] methods = SecurityActions.getDeclaredMethods(clazz);
- HashMap map = new HashMap();
+ HashMap<Long, MethodPersistentReference> map = new HashMap<Long, MethodPersistentReference>();
for (int i = 0; i < methods.length; i++)
{
try
@@ -282,9 +282,9 @@
return map;
}
- private static Map getConstructorHashes(Class clazz)
+ private static Map<Long, ConstructorPersistentReference> getConstructorHashes(Class<?> clazz)
{
- Map constructorHashes = (Map)constructorHashesByClass.get(clazz);
+ Map<Long, ConstructorPersistentReference> constructorHashes = constructorHashesByClass.get(clazz);
if (constructorHashes == null)
{
constructorHashes = getConstructorHashMap(clazz);
@@ -293,11 +293,11 @@
return constructorHashes;
}
- private static Map getConstructorHashMap(Class clazz)
+ private static Map<Long, ConstructorPersistentReference> getConstructorHashMap(Class<?> clazz)
{
// Create method hashes
- Constructor[] constructors = SecurityActions.getDeclaredConstructors(clazz);
- HashMap map = new HashMap();
+ Constructor<?>[] constructors = SecurityActions.getDeclaredConstructors(clazz);
+ HashMap<Long, ConstructorPersistentReference> map = new HashMap<Long, ConstructorPersistentReference>();
for (int i = 0; i < constructors.length; i++)
{
try
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/util/logging/AOPLogger.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/util/logging/AOPLogger.java 2008-03-25 22:20:57 UTC (rev 71278)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/util/logging/AOPLogger.java 2008-03-25 22:56:03 UTC (rev 71279)
@@ -53,12 +53,12 @@
return Logger.getLogger(name + "." + suffix);
}
- public static Logger getLogger(Class clazz)
+ public static Logger getLogger(Class<?> clazz)
{
return Logger.getLogger(clazz);
}
- public static Logger getLogger(Class clazz, String suffix)
+ public static Logger getLogger(Class<?> clazz, String suffix)
{
return Logger.getLogger(clazz.getName() + "." + suffix);
}
Modified: projects/aop/trunk/aop/src/main/org/jboss/aspects/ThreadbasedAspect.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aspects/ThreadbasedAspect.java 2008-03-25 22:20:57 UTC (rev 71278)
+++ projects/aop/trunk/aop/src/main/org/jboss/aspects/ThreadbasedAspect.java 2008-03-25 22:56:03 UTC (rev 71279)
@@ -33,7 +33,7 @@
*/
public class ThreadbasedAspect
{
- private ThreadLocal threadbased = new ThreadLocal();
+ private ThreadLocal<Object> threadbased = new ThreadLocal<Object>();
public Object access(FieldReadInvocation invocation) throws Throwable
{
Modified: projects/aop/trunk/aop/src/test/org/jboss/test/aop/ejb3dependencies/TestAnnotationRepository.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/ejb3dependencies/TestAnnotationRepository.java 2008-03-25 22:20:57 UTC (rev 71278)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/ejb3dependencies/TestAnnotationRepository.java 2008-03-25 22:56:03 UTC (rev 71279)
@@ -31,7 +31,7 @@
*/
public class TestAnnotationRepository extends AnnotationRepository
{
-
+ @SuppressWarnings("unchecked")
public Object resolveClassAnnotation(Class annotation)
{
return new AnnImpl("Clazz");
More information about the jboss-cvs-commits
mailing list