[jboss-cvs] JBossAS SVN: r104801 - 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
Fri May 14 11:23:38 EDT 2010
Author: kabir.khan at jboss.com
Date: 2010-05-14 11:23:38 -0400 (Fri, 14 May 2010)
New Revision: 104801
Modified:
projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistTypeInfo.java
Log:
[JBREFLECT-124] More optimizations
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 2010-05-14 15:16:04 UTC (rev 104800)
+++ projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistTypeInfo.java 2010-05-14 15:23:38 UTC (rev 104801)
@@ -222,19 +222,27 @@
public ClassInfo getSuperclass()
{
- if (isInterface())
- return null;
- try
+ if (superClass == ClassInfoImpl.UNKNOWN_CLASS)
{
- CtClass superclass = ctClass.getSuperclass();
- if (superclass == null)
- return null;
- return (ClassInfo) factory.getTypeInfo(superclass);
+ if (isInterface())
+ this.superClass = null;
+ else
+ {
+ try
+ {
+ CtClass superclass = ctClass.getSuperclass();
+ if (superclass == null)
+ this.superClass = null;
+ else
+ this.superClass = (ClassInfo) factory.getTypeInfo(superclass);
+ }
+ catch (NotFoundException e)
+ {
+ throw JavassistTypeInfoFactoryImpl.raiseClassNotFound(ctClass.getClassFile2().getSuperclass() + " from " + ctClass.getName() + " in pool " + ctClass.getClassPool(), e);
+ }
+ }
}
- catch (NotFoundException e)
- {
- throw JavassistTypeInfoFactoryImpl.raiseClassNotFound(ctClass.getClassFile2().getSuperclass() + " from " + ctClass.getName() + " in pool " + ctClass.getClassPool(), e);
- }
+ return superClass;
}
public ClassInfo getGenericSuperclass()
@@ -257,22 +265,30 @@
return genericSuperClass;
}
+ private transient volatile ClassInfo superClass = ClassInfoImpl.UNKNOWN_CLASS;
+
+ private transient volatile InterfaceInfo[] interfaces = ClassInfoImpl.UNKNOWN_INTERFACES;
+
public InterfaceInfo[] getInterfaces()
{
- try
+ if (interfaces == ClassInfoImpl.UNKNOWN_INTERFACES)
{
- CtClass[] interfaces = ctClass.getInterfaces();
- if (interfaces == null || interfaces.length == 0)
- return null;
- InterfaceInfo[] result = new InterfaceInfo[interfaces.length];
- for (int i = 0; i < result.length; ++i)
- result[i] = (InterfaceInfo) factory.getTypeInfo(interfaces[i]);
- return result;
+ try
+ {
+ CtClass[] ifaces = ctClass.getInterfaces();
+ if (ifaces == null || ifaces.length == 0)
+ return null;
+ InterfaceInfo[] result = new InterfaceInfo[ifaces.length];
+ for (int i = 0; i < result.length; ++i)
+ result[i] = (InterfaceInfo) factory.getTypeInfo(ifaces[i]);
+ interfaces = result;
+ }
+ catch (NotFoundException e)
+ {
+ throw JavassistTypeInfoFactoryImpl.raiseClassNotFound("for interfaces of " + getName(), e);
+ }
}
- catch (NotFoundException e)
- {
- throw JavassistTypeInfoFactoryImpl.raiseClassNotFound("for interfaces of " + getName(), e);
- }
+ return interfaces;
}
public InterfaceInfo[] getGenericInterfaces()
More information about the jboss-cvs-commits
mailing list