]> source.dussan.org Git - javassist.git/commitdiff
fixed JASSIST-138
authorchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>
Fri, 8 Jul 2011 09:10:34 +0000 (09:10 +0000)
committerchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>
Fri, 8 Jul 2011 09:10:34 +0000 (09:10 +0000)
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@585 30ef5769-5b8d-40dd-aea6-55b5d6557bb3

src/main/javassist/bytecode/ConstPool.java
src/main/javassist/bytecode/analysis/Executor.java

index bba4175d88423d7bafff0d9ef82c909906ac9e7e..a04ba1284589734228e81c0e1fa5a5c5cada1f19 100644 (file)
@@ -214,6 +214,28 @@ public final class ConstPool {
             return Descriptor.toJavaName(getUtf8Info(c.name));
     }
 
+    /**
+     * Reads <code>CONSTANT_Class_info</code> structure
+     * at the given index.
+     *
+     * @return  the descriptor of the type specified
+     *          by <code>name_index</code>.
+     * @see javassist.ClassPool#getCtClass(String)
+     * @since 3.15
+     */
+    public String getClassInfoByDescriptor(int index) {
+        ClassInfo c = (ClassInfo)getItem(index);
+        if (c == null)
+            return null;
+        else {
+            String className = getUtf8Info(c.name);
+            if (className.charAt(0) == '[')
+                return className;
+            else
+                return Descriptor.of(className);
+        }
+    }
+
     /**
      * Reads the <code>name_index</code> field of the
      * <code>CONSTANT_NameAndType_info</code> structure
index 33c54b75f4c122a1cdd623543b6e5e766ae2d3f5..f53e98bfca649f14a7547e4aaab7cf59538b729b 100644 (file)
@@ -596,7 +596,7 @@ public class Executor implements Opcode {
                 break;
             case CHECKCAST:
                 verifyAssignable(Type.OBJECT, simplePop(frame));
-                frame.push(typeFromDesc(constPool.getClassInfo(iter.u16bitAt(pos + 1))));
+                frame.push(typeFromDesc(constPool.getClassInfoByDescriptor(iter.u16bitAt(pos + 1))));
                 break;
             case INSTANCEOF:
                 verifyAssignable(Type.OBJECT, simplePop(frame));