[jboss-cvs] JBossAS SVN: r94922 - in projects/jboss-reflect/trunk/src/main/java/org/jboss: reflect/plugins and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Oct 15 02:47:07 EDT 2009
Author: alesj
Date: 2009-10-15 02:47:07 -0400 (Thu, 15 Oct 2009)
New Revision: 94922
Modified:
projects/jboss-reflect/trunk/src/main/java/org/jboss/classadapter/plugins/BasicClassAdapter.java
projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/ArrayInfoImpl.java
projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/ClassInfoImpl.java
projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistTypeInfo.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
projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/spi/DelegateClassInfo.java
projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/spi/PrimitiveInfo.java
projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/spi/TypeInfo.java
Log:
[JBREFLECT-61]; add getCL to TypeInfo.
Modified: projects/jboss-reflect/trunk/src/main/java/org/jboss/classadapter/plugins/BasicClassAdapter.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/java/org/jboss/classadapter/plugins/BasicClassAdapter.java 2009-10-15 06:20:21 UTC (rev 94921)
+++ projects/jboss-reflect/trunk/src/main/java/org/jboss/classadapter/plugins/BasicClassAdapter.java 2009-10-15 06:47:07 UTC (rev 94922)
@@ -67,6 +67,6 @@
@SuppressWarnings("deprecation")
public ClassLoader getClassLoader()
{
- return classInfo.getType().getClassLoader();
+ return classInfo.getClassLoader();
}
}
Modified: projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/ArrayInfoImpl.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/ArrayInfoImpl.java 2009-10-15 06:20:21 UTC (rev 94921)
+++ projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/ArrayInfoImpl.java 2009-10-15 06:47:07 UTC (rev 94922)
@@ -94,7 +94,7 @@
try
{
TypeInfoFactory tif = SerializationHelper.getTypeInfoFactory();
- annotatedElement = tif.getTypeInfo(name, componentType.getType().getClassLoader()).getType();
+ annotatedElement = tif.getTypeInfo(name, componentType.getClassLoader()).getType();
}
catch (Throwable t)
{
Modified: projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/ClassInfoImpl.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/ClassInfoImpl.java 2009-10-15 06:20:21 UTC (rev 94921)
+++ projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/ClassInfoImpl.java 2009-10-15 06:47:07 UTC (rev 94922)
@@ -33,7 +33,6 @@
import org.jboss.reflect.spi.FieldInfo;
import org.jboss.reflect.spi.InterfaceInfo;
import org.jboss.reflect.spi.MethodInfo;
-import org.jboss.reflect.spi.ModifierInfo;
import org.jboss.reflect.spi.PackageInfo;
import org.jboss.reflect.spi.TypeInfo;
import org.jboss.reflect.spi.TypeInfoFactory;
@@ -475,7 +474,12 @@
{
return (Class<? extends Object>) annotatedElement;
}
-
+
+ public ClassLoader getClassLoader()
+ {
+ return getType().getClassLoader();
+ }
+
public Object convertValue(Object value) throws Throwable
{
return ValueConvertor.convertValue(getType(), value);
Modified: projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistTypeInfo.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistTypeInfo.java 2009-10-15 06:20:21 UTC (rev 94921)
+++ projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistTypeInfo.java 2009-10-15 06:47:07 UTC (rev 94922)
@@ -64,6 +64,9 @@
/** The serialVersionUID */
private static final long serialVersionUID = -5072033691434335775L;
+ /** The get classloader permission */
+ private static final RuntimePermission GET_CLASSLOADER_PERMISSION = new RuntimePermission("getClassLoader");
+
/** The factory */
private JavassistTypeInfoFactoryImpl factory;
@@ -169,6 +172,17 @@
return clazz;
}
+ public ClassLoader getClassLoader()
+ {
+ // looks like Javassist ClassPool::getClassLoader
+ // doesn't check for security, so we should
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkPermission(GET_CLASSLOADER_PERMISSION);
+
+ return JavassistUtil.getClassLoader(ctClass);
+ }
+
public ClassInfo getSuperclass()
{
if (isInterface())
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-15 06:20:21 UTC (rev 94921)
+++ projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistTypeInfoFactoryImpl.java 2009-10-15 06:47:07 UTC (rev 94922)
@@ -601,7 +601,7 @@
public MutableClassInfo createNewMutableClass(String name, ClassInfo superClass)
{
- CtClass clazz = poolFactory.getPoolForLoader(superClass.getType().getClassLoader()).makeClass(name, JavassistUtil.toCtClass(superClass));
+ CtClass clazz = poolFactory.getPoolForLoader(superClass.getClassLoader()).makeClass(name, JavassistUtil.toCtClass(superClass));
return new JavassistTypeInfo(this, clazz, null);
}
@@ -613,7 +613,7 @@
public MutableClassInfo createNewMutableInterface(String name, ClassInfo superClass)
{
- CtClass clazz = poolFactory.getPoolForLoader(superClass.getType().getClassLoader()).makeInterface(name, JavassistUtil.toCtClass(superClass));
+ CtClass clazz = poolFactory.getPoolForLoader(superClass.getClassLoader()).makeInterface(name, JavassistUtil.toCtClass(superClass));
return new JavassistTypeInfo(this, clazz, null);
}
}
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-15 06:20:21 UTC (rev 94921)
+++ projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistUtil.java 2009-10-15 06:47:07 UTC (rev 94922)
@@ -137,7 +137,6 @@
return classes;
}
-
public static CtClass toCtClass(ClassInfo clazz)
{
if(clazz instanceof JavassistTypeInfo)
@@ -146,7 +145,7 @@
{
try
{
- ClassLoader classLoader = clazz.getType().getClassLoader();
+ ClassLoader classLoader = clazz.getClassLoader();
ClassPool classPool = JavassistTypeInfoFactoryImpl.getPoolFactory().getPoolForLoader(classLoader);
return classPool.get(clazz.getName());
}
@@ -166,7 +165,9 @@
}
return clazzes;
}
-
-
+ public static ClassLoader getClassLoader(CtClass ctClass)
+ {
+ return ctClass.getClassPool().getClassLoader();
+ }
}
Modified: projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/spi/DelegateClassInfo.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/spi/DelegateClassInfo.java 2009-10-15 06:20:21 UTC (rev 94921)
+++ projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/spi/DelegateClassInfo.java 2009-10-15 06:47:07 UTC (rev 94922)
@@ -249,6 +249,11 @@
return delegate.getType();
}
+ public ClassLoader getClassLoader()
+ {
+ return delegate.getClassLoader();
+ }
+
@Override
public boolean isAnnotation()
{
Modified: projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/spi/PrimitiveInfo.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/spi/PrimitiveInfo.java 2009-10-15 06:20:21 UTC (rev 94921)
+++ projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/spi/PrimitiveInfo.java 2009-10-15 06:47:07 UTC (rev 94922)
@@ -34,6 +34,7 @@
* TODO JBREFLECT-4 fix the introspection assumption
* @author <a href="mailto:bill at jboss.org">Bill Burke</a>
* @author <a href="mailto:adrian at jboss.org">Adrian Brock</a>
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
*/
public class PrimitiveInfo extends AbstractTypeInfo
{
@@ -217,7 +218,12 @@
{
return type;
}
-
+
+ public ClassLoader getClassLoader()
+ {
+ return type.getClassLoader();
+ }
+
public Object convertValue(Object value) throws Throwable
{
Object progressResult = ValueConvertor.progressValue(type, value);
Modified: projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/spi/TypeInfo.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/spi/TypeInfo.java 2009-10-15 06:20:21 UTC (rev 94921)
+++ projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/spi/TypeInfo.java 2009-10-15 06:47:07 UTC (rev 94922)
@@ -53,8 +53,16 @@
*/
@Deprecated
Class<?> getType();
-
+
/**
+ * Get the classloader for this class info.
+ * Delay type creation if possible.
+ *
+ * @return class info's classloader
+ */
+ ClassLoader getClassLoader();
+
+ /**
* Convert a value
*
* @param value the original value
More information about the jboss-cvs-commits
mailing list