/** * Returns the name of the class using this constant pool table. */ public String getClassName() { return getClassInfo(thisClassInfo); }
/** * Returns the super class name. */ public String getSuperclass() { if (cachedSuperclass == null) cachedSuperclass = constPool.getClassInfo(superClass); return cachedSuperclass; }
private static String classInfo(ConstPool pool, int index) { return "#" + index + " = Class " + pool.getClassInfo(index); }
/** * Returns the names of exceptions that the method may throw. */ public String[] getExceptions() { byte[] blist = info; int n = blist.length; if (n <= 2) return null; String[] elist = new String[n / 2 - 1]; int k = 0; for (int j = 2; j < n; j += 2) { int index = ((blist[j] & 0xff) << 8) | (blist[j + 1] & 0xff); elist[k++] = constPool.getClassInfo(index); } return elist; }
/** * Returns the name of the exception type that * this catch clause catches. */ public String type() { if (typeIndex == 0) return "java.lang.Throwable"; else return node.method.getConstPool().getClassInfo(typeIndex); } }
/** * Reads the <code>class_index</code> field of the * <code>CONSTANT_InterfaceMethodref_info</code> structure * at the given index. * * @return the name of the class at that <code>class_index</code>. */ public String getInterfaceMethodrefClassName(int index) { MemberrefInfo minfo = (MemberrefInfo)getItem(index); return getClassInfo(minfo.classIndex); }
private TypeData.ClassName toExceptionType(int exceptionType) { String type; if (exceptionType == 0) // for finally clauses type= "java.lang.Throwable"; else type = cpool.getClassInfo(exceptionType); return new TypeData.ClassName(type); }
/** * Returns the class name indicated * by <code>classes[nth].inner_class_info_index</code>. * * @return null or the class name. */ public String innerClass(int nth) { int i = innerClassIndex(nth); if (i == 0) return null; else return constPool.getClassInfo(i); }
/** * Returns the class name indicated * by <code>classes[nth].outer_class_info_index</code>. * * @return null or the class name. */ public String outerClass(int nth) { int i = outerClassIndex(nth); if (i == 0) return null; else return constPool.getClassInfo(i); }
/** * Reads the <code>class_index</code> field of the * <code>CONSTANT_Methodref_info</code> structure * at the given index. * * @return the name of the class at that <code>class_index</code>. */ public String getMethodrefClassName(int index) { MemberrefInfo minfo = (MemberrefInfo)getItem(index); if (minfo == null) return null; else return getClassInfo(minfo.classIndex); }
/** * Reads the <code>class_index</code> field of the * <code>CONSTANT_Fieldref_info</code> structure * at the given index. * * @return the name of the class at that <code>class_index</code>. */ public String getFieldrefClassName(int index) { FieldrefInfo f = (FieldrefInfo)getItem(index); if (f == null) return null; else return getClassInfo(f.classIndex); }
private int doMultiANewArray(int pos, byte[] code) { int i = ByteArray.readU16bit(code, pos + 1); int dim = code[pos + 3] & 0xff; stackTop -= dim - 1; String type = cpool.getClassInfo(i).replace('.', '/'); stackTypes[stackTop - 1] = new TypeData.ClassName(type); return 4; }
/** * Returns the name of the class specified by <code>class_index</code>. */ public String className() { return getConstPool().getClassInfo(classIndex()); }
/** * Returns the dimension of the created array. */ public int getDimension() { if (opcode == Opcode.NEWARRAY) return 1; else if (opcode == Opcode.ANEWARRAY || opcode == Opcode.MULTIANEWARRAY) { int index = iterator.u16bitAt(currentPos + 1); String desc = getConstPool().getClassInfo(index); return Descriptor.arrayDimension(desc) + (opcode == Opcode.ANEWARRAY ? 1 : 0); } else throw new RuntimeException("bad opcode: " + opcode); }
/** * Returns the <code>CtClass</code> object representing * the type specified by the cast. */ public CtClass getType() throws NotFoundException { ConstPool cp = getConstPool(); int pos = currentPos; int index = iterator.u16bitAt(pos + 1); String name = cp.getClassInfo(index); return thisClass.getClassPool().getCtClass(name); }
/** * Returns the <code>CtClass</code> object representing * the type name on the right hand side * of the instanceof operator. */ public CtClass getType() throws NotFoundException { ConstPool cp = getConstPool(); int pos = currentPos; int index = iterator.u16bitAt(pos + 1); String name = cp.getClassInfo(index); return thisClass.getClassPool().getCtClass(name); }
/** * Returns the type handled by the catch clause. * If this is a <code>finally</code> block, <code>null</code> is returned. */ public CtClass getType() throws NotFoundException { int type = etable.catchType(index); if (type == 0) return null; else { ConstPool cp = getConstPool(); String name = cp.getClassInfo(type); return thisClass.getClassPool().getCtClass(name); } }
private ConstPool compact0() { ConstPool cp = new ConstPool(thisclassname); thisClass = cp.getThisClassInfo(); String sc = getSuperclass(); if (sc != null) superClass = cp.addClassInfo(getSuperclass()); if (interfaces != null) { int n = interfaces.length; for (int i = 0; i < n; ++i) interfaces[i] = cp.addClassInfo(constPool.getClassInfo(interfaces[i])); } return cp; }
private void evalNewObjectArray(int pos, CodeIterator iter, Frame frame) throws BadBytecode { // Convert to x[] format Type type = resolveClassInfo(constPool.getClassInfo(iter.u16bitAt(pos + 1))); String name = type.getCtClass().getName(); int opcode = iter.byteAt(pos); int dimensions; if (opcode == MULTIANEWARRAY) { dimensions = iter.byteAt(pos + 3); } else { name = name + "[]"; dimensions = 1; } while (dimensions-- > 0) { verifyAssignable(Type.INTEGER, simplePop(frame)); } simplePush(getType(name), frame); }
private ExceptionInfo[] buildExceptionInfo(MethodInfo method) { ConstPool constPool = method.getConstPool(); ClassPool classes = clazz.getClassPool(); ExceptionTable table = method.getCodeAttribute().getExceptionTable(); ExceptionInfo[] exceptions = new ExceptionInfo[table.size()]; for (int i = 0; i < table.size(); i++) { int index = table.catchType(i); Type type; try { type = index == 0 ? Type.THROWABLE : Type.get(classes.get(constPool.getClassInfo(index))); } catch (NotFoundException e) { throw new IllegalStateException(e.getMessage()); } exceptions[i] = new ExceptionInfo(table.startPc(i), table.endPc(i), table.handlerPc(i), type); } return exceptions; }