private int addClass_(String clazz) { int ret; if((ret = lookupClass(clazz)) != -1) return ret; // Already in CP adjustSize(); ConstantClass c = new ConstantClass(addUtf8(clazz)); ret = index; constants[index++] = c; class_table.put(clazz, new Index(ret)); return ret; }
public void visitConstantClass(ConstantClass constant) { stack.push(constant); constant.accept(visitor); stack.pop(); }
/** @return dereferenced string */ public String getBytes(ConstantPool cp) { return (String)getConstantValue(cp); }
public void visitConstantClass(ConstantClass obj){ if (obj.getTag() != Constants.CONSTANT_Class){ throw new ClassConstraintException("Wrong constant tag in '"+tostring(obj)+"'."); } checkIndex(obj, obj.getNameIndex(), CONST_Utf8); } public void visitConstantFieldref(ConstantFieldref obj){
/** * Initialize from another object. */ public ConstantClass(ConstantClass c) { this(c.getNameIndex()); }
/** * Initialize from another object. */ public ConstantClass(ConstantClass c) { this(c.getNameIndex()); }
public void visitConstantClass(ConstantClass obj){ if (obj.getTag() != Constants.CONSTANT_Class){ throw new ClassConstraintException("Wrong constant tag in '"+tostring(obj)+"'."); } checkIndex(obj, obj.getNameIndex(), CONST_Utf8); } public void visitConstantFieldref(ConstantFieldref obj){
/** This method casually visits ConstantClass references. */ public void visitConstantClass(ConstantClass obj){ Constant c = cp.getConstant(obj.getNameIndex()); if (c instanceof ConstantUtf8){ //Ignore the case where it's not a ConstantUtf8 here, we'll find out later. String classname = ((ConstantUtf8) c).getBytes(); if (classname.startsWith(jc.getClassName().replace('.','/')+"$")){ hasInnerClass = true; } } } }
private int addClass_(String clazz) { int ret; if((ret = lookupClass(clazz)) != -1) return ret; // Already in CP adjustSize(); ConstantClass c = new ConstantClass(addUtf8(clazz)); ret = index; constants[index++] = c; class_table.put(clazz, new Index(ret)); return ret; }
/** @return dereferenced string */ public String getBytes(ConstantPool cp) { return (String)getConstantValue(cp); }
public void visitConstantClass(ConstantClass constant) { stack.push(constant); constant.accept(visitor); stack.pop(); }
/** This method casually visits ConstantClass references. */ public void visitConstantClass(ConstantClass obj){ Constant c = cp.getConstant(obj.getNameIndex()); if (c instanceof ConstantUtf8){ //Ignore the case where it's not a ConstantUtf8 here, we'll find out later. String classname = ((ConstantUtf8) c).getBytes(); if (classname.startsWith(jc.getClassName().replace('.','/')+"$")){ hasInnerClass = true; } } } }
/** * Read one constant from the given file, the type depends on a tag byte. * * @param file Input stream * @return Constant object */ static final Constant readConstant(DataInputStream file) throws IOException, ClassFormatException { byte b = file.readByte(); // Read tag byte switch(b) { case Constants.CONSTANT_Class: return new ConstantClass(file); case Constants.CONSTANT_Fieldref: return new ConstantFieldref(file); case Constants.CONSTANT_Methodref: return new ConstantMethodref(file); case Constants.CONSTANT_InterfaceMethodref: return new ConstantInterfaceMethodref(file); case Constants.CONSTANT_String: return new ConstantString(file); case Constants.CONSTANT_Integer: return new ConstantInteger(file); case Constants.CONSTANT_Float: return new ConstantFloat(file); case Constants.CONSTANT_Long: return new ConstantLong(file); case Constants.CONSTANT_Double: return new ConstantDouble(file); case Constants.CONSTANT_NameAndType: return new ConstantNameAndType(file); case Constants.CONSTANT_Utf8: return new ConstantUtf8(file); default: throw new ClassFormatException("Invalid byte tag in constant pool: " + b); } } }
ConstantUtf8 name = (ConstantUtf8)cp.getConstant(cl.getNameIndex(), Constants.CONSTANT_Utf8); name.setBytes(class_name.replace('.', '/'));
/** * Read one constant from the given file, the type depends on a tag byte. * * @param file Input stream * @return Constant object */ static final Constant readConstant(DataInputStream file) throws IOException, ClassFormatException { byte b = file.readByte(); // Read tag byte switch(b) { case Constants.CONSTANT_Class: return new ConstantClass(file); case Constants.CONSTANT_Fieldref: return new ConstantFieldref(file); case Constants.CONSTANT_Methodref: return new ConstantMethodref(file); case Constants.CONSTANT_InterfaceMethodref: return new ConstantInterfaceMethodref(file); case Constants.CONSTANT_String: return new ConstantString(file); case Constants.CONSTANT_Integer: return new ConstantInteger(file); case Constants.CONSTANT_Float: return new ConstantFloat(file); case Constants.CONSTANT_Long: return new ConstantLong(file); case Constants.CONSTANT_Double: return new ConstantDouble(file); case Constants.CONSTANT_NameAndType: return new ConstantNameAndType(file); case Constants.CONSTANT_Utf8: return new ConstantUtf8(file); default: throw new ClassFormatException("Invalid byte tag in constant pool: " + b); } } }
ConstantUtf8 name = (ConstantUtf8)cp.getConstant(cl.getNameIndex(), Constants.CONSTANT_Utf8); name.setBytes(class_name.replace('.', '/'));
case Constants.CONSTANT_Class: i = ((ConstantClass)c).getNameIndex(); break; case Constants.CONSTANT_String: i = ((ConstantString)c).getStringIndex(); break; default:
case Constants.CONSTANT_Class: i = ((ConstantClass)c).getNameIndex(); break; case Constants.CONSTANT_String: i = ((ConstantString)c).getStringIndex(); break; default:
} else if(c instanceof ConstantClass) { ConstantClass s = (ConstantClass)c; ConstantUtf8 u8 = (ConstantUtf8)constants[s.getNameIndex()]; ConstantNameAndType n = (ConstantNameAndType)constants[m.getNameAndTypeIndex()]; ConstantUtf8 u8 = (ConstantUtf8)constants[clazz.getNameIndex()]; String class_name = u8.getBytes().replace('/', '.');
} else if(c instanceof ConstantClass) { ConstantClass s = (ConstantClass)c; ConstantUtf8 u8 = (ConstantUtf8)constants[s.getNameIndex()]; ConstantNameAndType n = (ConstantNameAndType)constants[m.getNameAndTypeIndex()]; ConstantUtf8 u8 = (ConstantUtf8)constants[clazz.getNameIndex()]; String class_name = u8.getBytes().replace('/', '.');