[jboss-cvs] JBossAS SVN: r95135 - 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 15:02:16 EDT 2009
Author: alesj
Date: 2009-10-19 15:02:15 -0400 (Mon, 19 Oct 2009)
New Revision: 95135
Modified:
projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistTypeInfoFactory.java
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:
Allow for TypeInfo creation via existing CtClass.
Modified: projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistTypeInfoFactory.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistTypeInfoFactory.java 2009-10-19 18:51:56 UTC (rev 95134)
+++ projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistTypeInfoFactory.java 2009-10-19 19:02:15 UTC (rev 95135)
@@ -21,13 +21,13 @@
*/
package org.jboss.reflect.plugins.javassist;
-import java.lang.reflect.Type;
-
import org.jboss.reflect.spi.ClassInfo;
import org.jboss.reflect.spi.MutableClassInfo;
+import org.jboss.reflect.spi.MutableTypeInfoFactory;
import org.jboss.reflect.spi.TypeInfo;
-import org.jboss.reflect.spi.MutableTypeInfoFactory;
+import java.lang.reflect.Type;
+
/**
* An javassist type factory that uses a static delegate.<p>
*
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 18:51:56 UTC (rev 95134)
+++ projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistTypeInfoFactoryImpl.java 2009-10-19 19:02:15 UTC (rev 95135)
@@ -21,18 +21,6 @@
*/
package org.jboss.reflect.plugins.javassist;
-import java.lang.annotation.Annotation;
-import java.lang.ref.WeakReference;
-import java.lang.reflect.Type;
-import java.util.Map;
-
-import javassist.CtClass;
-import javassist.CtField;
-import javassist.CtMember;
-import javassist.CtMethod;
-import javassist.CtPrimitiveType;
-import javassist.NotFoundException;
-
import org.jboss.reflect.plugins.AnnotationAttributeImpl;
import org.jboss.reflect.plugins.AnnotationHelper;
import org.jboss.reflect.plugins.AnnotationValueFactory;
@@ -51,6 +39,18 @@
import org.jboss.util.JBossStringBuilder;
import org.jboss.util.collection.WeakClassCache;
+import java.lang.annotation.Annotation;
+import java.lang.ref.WeakReference;
+import java.lang.reflect.Type;
+import java.util.Map;
+
+import javassist.CtClass;
+import javassist.CtField;
+import javassist.CtMember;
+import javassist.CtMethod;
+import javassist.CtPrimitiveType;
+import javassist.NotFoundException;
+
/**
* A javassist type factory.
* TODO: need to fix the cl stuff
@@ -360,12 +360,13 @@
* @param ctClass the ctClass
* @return the typeinfo
*/
- protected TypeInfo getTypeInfo(CtClass ctClass)
+ TypeInfo getTypeInfo(CtClass ctClass)
{
try
{
String name = convertName(ctClass);
- return getTypeInfo(name, null);
+ ClassLoader cl = JavassistUtil.getClassLoader(ctClass);
+ return getTypeInfo(name, cl);
}
catch (ClassNotFoundException e)
{
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 18:51:56 UTC (rev 95134)
+++ projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistUtil.java 2009-10-19 19:02:15 UTC (rev 95135)
@@ -21,10 +21,11 @@
*/
package org.jboss.reflect.plugins.javassist;
+import org.jboss.reflect.spi.ClassInfo;
+import org.jboss.reflect.spi.TypeInfo;
+
import java.lang.reflect.Array;
-import org.jboss.reflect.spi.ClassInfo;
-
import javassist.CannotCompileException;
import javassist.ClassPool;
import javassist.CtClass;
@@ -155,7 +156,13 @@
}
}
}
-
+
+ public static TypeInfo toTypeInfo(CtClass clazz)
+ {
+ JavassistTypeInfoFactoryImpl impl = JavassistTypeInfoFactory.delegate;
+ return impl.getTypeInfo(clazz);
+ }
+
public static CtClass[] toCtClass(ClassInfo[] classes)
{
CtClass[] clazzes = new CtClass[classes.length];
@@ -168,6 +175,7 @@
static ClassLoader getClassLoader(CtClass ctClass)
{
- return ctClass.getClassPool().getClassLoader();
+ ClassPool pool = ctClass.getClassPool();
+ return (pool != null) ? pool.getClassLoader() : null;
}
}
More information about the jboss-cvs-commits
mailing list