public void addAttribute(String attributeName, ClassFormatOutput info) { if (attribute_info == null) attribute_info = new Attributes(1); CONSTANT_Utf8_info autf = addUtf8Entry(attributeName); int index = autf.getIndex(); attribute_info.addEntry(new AttributeEntry(index, info)); }
/** Add a string entry */ private int addCodeUtf8(String value) { CONSTANT_Utf8_info sutf = addUtf8Entry(value); int index = sutf.setAsCode(); if (index == 0) { // code string is already being used as string CONSTANT_Utf8_info eutf = addExtraUtf8(value); eutf.setAsCode(); // ensure the replace will happen index = eutf.getIndex(); sutf.setAlternative(index); } return index; }
/** @see ClassHolder#addMember */ public ClassMember addMember(String simpleName, String descriptor, int modifier) { if (SanityManager.DEBUG) { if (descriptor.startsWith("(")) { if (method_info != null) { if (method_info.find(simpleName, descriptor) != null) { SanityManager.THROWASSERT("Method already exists " + simpleName + " " + descriptor); } } } else { if (field_info != null) { if (field_info.find(simpleName, descriptor) != null) { SanityManager.THROWASSERT("Field already exists " + simpleName + " " + descriptor); } } } } CONSTANT_Utf8_info utf = addUtf8Entry(simpleName); int nameIndex = utf.getIndex(); int descriptorIndex = addUtf8Entry(descriptor).getIndex(); ClassMember item = new ClassMember(this, modifier, nameIndex, descriptorIndex); MemberTable mt; if (descriptor.startsWith("(")) { mt = method_info; if (mt == null) mt = method_info = new MemberTable(0); } else { mt = field_info; if (mt == null) mt = field_info = new MemberTable(0); } mt.addEntry(item); return item; }