aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/javassist/ClassPool.java
diff options
context:
space:
mode:
authorchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2008-07-04 09:17:50 +0000
committerchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2008-07-04 09:17:50 +0000
commitd331ba6fb6826f0f231451a429178d18ee87c082 (patch)
treed5f306b115b463c56731fc92de28c394f2c013ed /src/main/javassist/ClassPool.java
parent50da9b9f3bbd626662d78ae5499ac112fbe816c6 (diff)
downloadjavassist-d331ba6fb6826f0f231451a429178d18ee87c082.tar.gz
javassist-d331ba6fb6826f0f231451a429178d18ee87c082.zip
added ClassPool.getCtClass() and fixed related bugs.
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@449 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
Diffstat (limited to 'src/main/javassist/ClassPool.java')
-rw-r--r--src/main/javassist/ClassPool.java30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/main/javassist/ClassPool.java b/src/main/javassist/ClassPool.java
index 3bab74ae..2db2009a 100644
--- a/src/main/javassist/ClassPool.java
+++ b/src/main/javassist/ClassPool.java
@@ -441,6 +441,33 @@ public class ClassPool {
}
/**
+ * Returns a <code>CtClass</code> object with the given name.
+ * This is almost equivalent to <code>get(String)</code> except
+ * that classname can be an array-type "descriptor" (an encoded
+ * type name) such as <code>[Ljava/lang/Object;</code>.
+ *
+ * <p>Using this method is not recommended; this method should be
+ * used only to obtain the <code>CtClass</code> object
+ * with a name returned from <code>getClassInfo</code> in
+ * <code>javassist.bytecode.ClassPool</code>. <code>getClassInfo</code>
+ * returns a fully-qualified class name but, if the class is an array
+ * type, it returns a descriptor.
+ *
+ * @param classname a fully-qualified class name or a descriptor
+ * representing an array type.
+ * @see #get(String)
+ * @see javassist.bytecode.ConstPool#getClassInfo(int)
+ * @see javassist.bytecode.Descriptor#toCtClass(String, ClassPool)
+ * @since 3.8.1
+ */
+ public CtClass getCtClass(String classname) throws NotFoundException {
+ if (classname.charAt(0) == '[')
+ return Descriptor.toCtClass(classname, this);
+ else
+ return get(classname);
+ }
+
+ /**
* @param useCache false if the cached CtClass must be ignored.
* @param searchParent false if the parent class pool is not searched.
* @return null if the class could not be found.
@@ -463,8 +490,9 @@ public class ClassPool {
clazz = createCtClass(classname, useCache);
if (clazz != null) {
+ // clazz.getName() != classname if classname is "[L<name>;".
if (useCache)
- cacheCtClass(classname, clazz, false);
+ cacheCtClass(clazz.getName(), clazz, false);
return clazz;
}