[jboss-cvs] javassist/src/main/javassist/bytecode/analysis ...
Jason Thomas Greene
jgreene at jboss.com
Mon Jun 16 16:25:10 EDT 2008
User: jgreene
Date: 08/06/16 16:25:10
Modified: src/main/javassist/bytecode/analysis Executor.java
Log:
Descriptor.toCtClass should never be used on a classinfo, unless it is an array
Revision Changes Path
1.3 +26 -7 javassist/src/main/javassist/bytecode/analysis/Executor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Executor.java
===================================================================
RCS file: /cvsroot/jboss/javassist/src/main/javassist/bytecode/analysis/Executor.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- Executor.java 28 May 2008 00:49:47 -0000 1.2
+++ Executor.java 16 Jun 2008 20:25:10 -0000 1.3
@@ -575,7 +575,7 @@
case 186:
throw new RuntimeException("Bad opcode 186");
case NEW:
- frame.push(typeFromDesc(constPool.getClassInfo(iter.u16bitAt(pos + 1))));
+ frame.push(resolveClassInfo(constPool.getClassInfo(iter.u16bitAt(pos + 1))));
break;
case NEWARRAY:
evalNewArray(pos, iter, frame);
@@ -705,7 +705,7 @@
Type type = zeroExtend(typeFromDesc(desc));
if (opcode == GETFIELD) {
- Type objectType = typeFromDesc(constPool.getFieldrefClassName(index));
+ Type objectType = resolveClassInfo(constPool.getFieldrefClassName(index));
verifyAssignable(objectType, simplePop(frame));
}
@@ -720,8 +720,8 @@
while (i > 0)
verifyAssignable(zeroExtend(types[--i]), simplePop(frame));
- String classDesc = constPool.getInterfaceMethodrefClassName(index);
- Type objectType = typeFromDesc(classDesc);
+ String classInfo = constPool.getInterfaceMethodrefClassName(index);
+ Type objectType = resolveClassInfo(classInfo);
verifyAssignable(objectType, simplePop(frame));
Type returnType = returnTypeFromDesc(desc);
@@ -738,7 +738,7 @@
verifyAssignable(zeroExtend(types[--i]), simplePop(frame));
if (opcode != INVOKESTATIC) {
- Type objectType = typeFromDesc(constPool.getMethodrefClassName(index));
+ Type objectType = resolveClassInfo(constPool.getMethodrefClassName(index));
verifyAssignable(objectType, simplePop(frame));
}
@@ -825,7 +825,7 @@
private void evalNewObjectArray(int pos, CodeIterator iter, Frame frame) throws BadBytecode {
// Convert to x[] format
- Type type = typeFromDesc(constPool.getClassInfo(iter.u16bitAt(pos + 1)));
+ Type type = resolveClassInfo(constPool.getClassInfo(iter.u16bitAt(pos + 1)));
String name = type.getCtClass().getName();
int opcode = iter.byteAt(pos);
int dimensions;
@@ -851,7 +851,7 @@
verifyAssignable(type, simplePop(frame));
if (opcode == PUTFIELD) {
- Type objectType = typeFromDesc(constPool.getFieldrefClassName(index));
+ Type objectType = resolveClassInfo(constPool.getFieldrefClassName(index));
verifyAssignable(objectType, simplePop(frame));
}
}
@@ -991,6 +991,25 @@
frame.setLocal(index + 1, Type.TOP);
}
+ private Type resolveClassInfo(String info) throws BadBytecode {
+ CtClass clazz = null;
+ try {
+ if (info.charAt(0) == '[') {
+ clazz = Descriptor.toCtClass(info, classPool);
+ } else {
+ clazz = classPool.get(info);
+ }
+
+ } catch (NotFoundException e) {
+ throw new BadBytecode("Could not find class in descriptor [pos = " + lastPos + "]: " + e.getMessage());
+ }
+
+ if (clazz == null)
+ throw new BadBytecode("Could not obtain type for descriptor [pos = " + lastPos + "]: " + info);
+
+ return Type.get(clazz);
+ }
+
private Type typeFromDesc(String desc) throws BadBytecode {
CtClass clazz = null;
try {
More information about the jboss-cvs-commits
mailing list