[jboss-cvs] JBossAS SVN: r95144 - projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Oct 19 17:17:52 EDT 2009
Author: alesj
Date: 2009-10-19 17:17:52 -0400 (Mon, 19 Oct 2009)
New Revision: 95144
Modified:
projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistTypeInfoFactoryImpl.java
projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistUtil.java
Log:
Generify.
Modified: projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistTypeInfoFactoryImpl.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistTypeInfoFactoryImpl.java 2009-10-19 20:38:15 UTC (rev 95143)
+++ projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistTypeInfoFactoryImpl.java 2009-10-19 21:17:52 UTC (rev 95144)
@@ -186,11 +186,10 @@
}
}
- protected Object instantiate(CtClass ctClass, Class<?> clazz)
+ protected TypeInfo instantiate(CtClass ctClass, Class<?> clazz)
{
try
{
-
if (ctClass.isArray())
{
TypeInfo componentType = getTypeInfo(ctClass.getComponentType());
@@ -225,7 +224,6 @@
return enumInfo;
}
-
return new JavassistTypeInfo(this, ctClass, clazz);
}
catch (NotFoundException e)
@@ -245,20 +243,7 @@
@Override
public Object get(String name, ClassLoader cl) throws ClassNotFoundException
{
- if (name == null)
- throw new IllegalArgumentException("Null name");
- if (cl == null)
- throw new IllegalArgumentException("Null classloader");
- try
- {
- CtClass clazz = poolFactory.getPoolForLoader(cl).get(name);
-
- return get(clazz, null);
- }
- catch(NotFoundException nfe)
- {
- throw new ClassNotFoundException(nfe.getMessage());
- }
+ return get(name, cl, null);
}
/**
@@ -266,20 +251,20 @@
*
* @param name the name
* @param cl the classloader
- * @param clazz
+ * @param clazz the class
* @return the info
* @throws ClassNotFoundException when the class cannot be found
*/
- public Object get(String name, ClassLoader cl, Class<?> clazz) throws ClassNotFoundException
+ public TypeInfo get(String name, ClassLoader cl, Class<?> clazz) throws ClassNotFoundException
{
if (name == null)
throw new IllegalArgumentException("Null name");
if (cl == null)
throw new IllegalArgumentException("Null classloader");
+
try
{
CtClass ctClass = poolFactory.getPoolForLoader(cl).get(name);
-
return get(ctClass, clazz);
}
catch(NotFoundException nfe)
@@ -297,7 +282,7 @@
*/
@SuppressWarnings("unchecked")
@Override
- public Object get(Class clazz)
+ public TypeInfo get(Class clazz)
{
try
{
@@ -317,21 +302,23 @@
* Get the information for a class
*
* @param ctClass the class
+ * @param clazz the class
* @return the info
*/
- public Object get(CtClass ctClass, Class<?> clazz)
+ @SuppressWarnings("unchecked")
+ public TypeInfo get(CtClass ctClass, Class<?> clazz)
{
if (ctClass == null)
throw new IllegalArgumentException("Null class");
if(ctClass instanceof CtPrimitiveType)
return instantiate(ctClass, clazz);
- Map<String, WeakReference<Object>> classLoaderCache = getClassLoaderCache(ctClass.getClassPool().getClassLoader());
+ Map<String, WeakReference<TypeInfo>> classLoaderCache = getClassLoaderCache(ctClass.getClassPool().getClassLoader());
- WeakReference<Object> weak = (WeakReference<Object>) classLoaderCache.get(ctClass.getName());
+ WeakReference<TypeInfo> weak = classLoaderCache.get(ctClass.getName());
if (weak != null)
{
- Object result = weak.get();
+ TypeInfo result = weak.get();
if (result != null)
{
if(compare(ctClass, (ClassInfo) result))
@@ -343,9 +330,9 @@
}
}
- Object result = instantiate(ctClass, clazz);
+ TypeInfo result = instantiate(ctClass, clazz);
- weak = new WeakReference<Object>(result);
+ weak = new WeakReference<TypeInfo>(result);
classLoaderCache.put(ctClass.getName(), weak);
// we just ignore generate(..) since it doesnt do anything atm
@@ -360,7 +347,7 @@
* @param ctClass the ctClass
* @return the typeinfo
*/
- TypeInfo getTypeInfo(CtClass ctClass)
+ protected TypeInfo getTypeInfo(CtClass ctClass)
{
try
{
@@ -470,14 +457,14 @@
if (number.getPhase() != NumberInfo.Phase.COMPLETE)
{
number.initializing();
- number.setDelegate((TypeInfo)get(clazz));
+ number.setDelegate(get(clazz));
}
return number;
}
}
}
- return (TypeInfo) get(clazz);
+ return get(clazz);
}
public TypeInfo getTypeInfo(String name, ClassLoader cl) throws ClassNotFoundException
@@ -501,7 +488,7 @@
if (number.getPhase() != NumberInfo.Phase.COMPLETE)
{
number.initializing();
- number.setDelegate((TypeInfo)get(Class.forName(name, false, cl)));
+ number.setDelegate(get(Class.forName(name, false, cl)));
}
return number;
}
Modified: projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistUtil.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistUtil.java 2009-10-19 20:38:15 UTC (rev 95143)
+++ projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistUtil.java 2009-10-19 21:17:52 UTC (rev 95144)
@@ -157,10 +157,10 @@
}
}
- public static TypeInfo toTypeInfo(CtClass clazz)
+ public static TypeInfo toTypeInfo(CtClass ctClass)
{
JavassistTypeInfoFactoryImpl impl = JavassistTypeInfoFactory.delegate;
- return impl.getTypeInfo(clazz);
+ return impl.get(ctClass, null);
}
public static CtClass[] toCtClass(ClassInfo[] classes)
More information about the jboss-cvs-commits
mailing list