From c944f7ab91da8e9b3a1c8bc98cf7aae32bfbb086 Mon Sep 17 00:00:00 2001 From: chiba Date: Fri, 8 Jul 2011 09:10:34 +0000 Subject: [PATCH] fixed JASSIST-138 git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@585 30ef5769-5b8d-40dd-aea6-55b5d6557bb3 --- src/main/javassist/bytecode/ConstPool.java | 22 +++++++++++++++++++ .../javassist/bytecode/analysis/Executor.java | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/main/javassist/bytecode/ConstPool.java b/src/main/javassist/bytecode/ConstPool.java index bba4175d..a04ba128 100644 --- a/src/main/javassist/bytecode/ConstPool.java +++ b/src/main/javassist/bytecode/ConstPool.java @@ -214,6 +214,28 @@ public final class ConstPool { return Descriptor.toJavaName(getUtf8Info(c.name)); } + /** + * Reads CONSTANT_Class_info structure + * at the given index. + * + * @return the descriptor of the type specified + * by name_index. + * @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 name_index field of the * CONSTANT_NameAndType_info structure diff --git a/src/main/javassist/bytecode/analysis/Executor.java b/src/main/javassist/bytecode/analysis/Executor.java index 33c54b75..f53e98bf 100644 --- a/src/main/javassist/bytecode/analysis/Executor.java +++ b/src/main/javassist/bytecode/analysis/Executor.java @@ -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)); -- 2.39.5