src/share/classes/jdk/internal/org/objectweb/asm/ClassWriter.java

Print this page

        

*** 93,108 **** * @see #ClassWriter(int) */ public static final int COMPUTE_FRAMES = 2; /** ! * Pseudo access flag to distinguish between the synthetic attribute and ! * the synthetic access flag. */ static final int ACC_SYNTHETIC_ATTRIBUTE = 0x40000; /** * The type of instructions without any argument. */ static final int NOARG_INSN = 0; /** --- 93,114 ---- * @see #ClassWriter(int) */ public static final int COMPUTE_FRAMES = 2; /** ! * Pseudo access flag to distinguish between the synthetic attribute and the ! * synthetic access flag. */ static final int ACC_SYNTHETIC_ATTRIBUTE = 0x40000; /** + * Factor to convert from ACC_SYNTHETIC_ATTRIBUTE to Opcode.ACC_SYNTHETIC. + */ + static final int TO_ACC_SYNTHETIC = ACC_SYNTHETIC_ATTRIBUTE + / Opcodes.ACC_SYNTHETIC; + + /** * The type of instructions without any argument. */ static final int NOARG_INSN = 0; /**
*** 265,276 **** */ static final int INDY = 18; /** * The base value for all CONSTANT_MethodHandle constant pool items. ! * Internally, ASM store the 9 variations of CONSTANT_MethodHandle into ! * 9 different items. */ static final int HANDLE_BASE = 20; /** * Normal type Item stored in the ClassWriter {@link ClassWriter#typeTable}, --- 271,282 ---- */ static final int INDY = 18; /** * The base value for all CONSTANT_MethodHandle constant pool items. ! * Internally, ASM store the 9 variations of CONSTANT_MethodHandle into 9 ! * different items. */ static final int HANDLE_BASE = 20; /** * Normal type Item stored in the ClassWriter {@link ClassWriter#typeTable},
*** 293,305 **** * constant pool items in the ClassWriter constant pool's hash table. */ static final int TYPE_MERGED = 32; /** ! * The type of BootstrapMethods items. These items are stored in a ! * special class attribute named BootstrapMethods and ! * not in the constant pool. */ static final int BSM = 33; /** * The class reader from which this class writer was constructed, if any. --- 299,310 ---- * constant pool items in the ClassWriter constant pool's hash table. */ static final int TYPE_MERGED = 32; /** ! * The type of BootstrapMethods items. These items are stored in a special ! * class attribute named BootstrapMethods and not in the constant pool. */ static final int BSM = 33; /** * The class reader from which this class writer was constructed, if any.
*** 354,367 **** /** * A type table used to temporarily store internal names that will not * necessarily be stored in the constant pool. This type table is used by * the control flow and data flow analysis algorithm used to compute stack * map frames from scratch. This array associates to each index <tt>i</tt> ! * the Item whose index is <tt>i</tt>. All Item objects stored in this ! * array are also stored in the {@link #items} hash table. These two arrays ! * allow to retrieve an Item from its index or, conversely, to get the index ! * of an Item from its value. Each Item stores an internal name in its * {@link Item#strVal1} field. */ Item[] typeTable; /** --- 359,372 ---- /** * A type table used to temporarily store internal names that will not * necessarily be stored in the constant pool. This type table is used by * the control flow and data flow analysis algorithm used to compute stack * map frames from scratch. This array associates to each index <tt>i</tt> ! * the Item whose index is <tt>i</tt>. All Item objects stored in this array ! * are also stored in the {@link #items} hash table. These two arrays allow ! * to retrieve an Item from its index or, conversely, to get the index of an ! * Item from its value. Each Item stores an internal name in its * {@link Item#strVal1} field. */ Item[] typeTable; /**
*** 439,448 **** --- 444,463 ---- * The runtime invisible annotations of this class. */ private AnnotationWriter ianns; /** + * The runtime visible type annotations of this class. + */ + private AnnotationWriter tanns; + + /** + * The runtime invisible type annotations of this class. + */ + private AnnotationWriter itanns; + + /** * The non standard attributes of this class. */ private Attribute attrs; /**
*** 466,485 **** ByteVector bootstrapMethods; /** * The fields of this class. These fields are stored in a linked list of * {@link FieldWriter} objects, linked to each other by their ! * {@link FieldWriter#fv} field. This field stores the first element of ! * this list. */ FieldWriter firstField; /** * The fields of this class. These fields are stored in a linked list of * {@link FieldWriter} objects, linked to each other by their ! * {@link FieldWriter#fv} field. This field stores the last element of ! * this list. */ FieldWriter lastField; /** * The methods of this class. These methods are stored in a linked list of --- 481,500 ---- ByteVector bootstrapMethods; /** * The fields of this class. These fields are stored in a linked list of * {@link FieldWriter} objects, linked to each other by their ! * {@link FieldWriter#fv} field. This field stores the first element of this ! * list. */ FieldWriter firstField; /** * The fields of this class. These fields are stored in a linked list of * {@link FieldWriter} objects, linked to each other by their ! * {@link FieldWriter#fv} field. This field stores the last element of this ! * list. */ FieldWriter lastField; /** * The methods of this class. These methods are stored in a linked list of
*** 490,501 **** MethodWriter firstMethod; /** * The methods of this class. These methods are stored in a linked list of * {@link MethodWriter} objects, linked to each other by their ! * {@link MethodWriter#mv} field. This field stores the last element of ! * this list. */ MethodWriter lastMethod; /** * <tt>true</tt> if the maximum stack size and number of local variables --- 505,516 ---- MethodWriter firstMethod; /** * The methods of this class. These methods are stored in a linked list of * {@link MethodWriter} objects, linked to each other by their ! * {@link MethodWriter#mv} field. This field stores the last element of this ! * list. */ MethodWriter lastMethod; /** * <tt>true</tt> if the maximum stack size and number of local variables
*** 611,625 **** // ------------------------------------------------------------------------ /** * Constructs a new {@link ClassWriter} object. * ! * @param flags option flags that can be used to modify the default behavior ! * of this class. See {@link #COMPUTE_MAXS}, {@link #COMPUTE_FRAMES}. */ public ClassWriter(final int flags) { ! super(Opcodes.ASM4); index = 1; pool = new ByteVector(); items = new Item[256]; threshold = (int) (0.75d * items.length); key = new Item(); --- 626,642 ---- // ------------------------------------------------------------------------ /** * Constructs a new {@link ClassWriter} object. * ! * @param flags ! * option flags that can be used to modify the default behavior ! * of this class. See {@link #COMPUTE_MAXS}, ! * {@link #COMPUTE_FRAMES}. */ public ClassWriter(final int flags) { ! super(Opcodes.ASM5); index = 1; pool = new ByteVector(); items = new Item[256]; threshold = (int) (0.75d * items.length); key = new Item();
*** 633,662 **** /** * Constructs a new {@link ClassWriter} object and enables optimizations for * "mostly add" bytecode transformations. These optimizations are the * following: * ! * <ul> <li>The constant pool from the original class is copied as is in the ! * new class, which saves time. New constant pool entries will be added at ! * the end if necessary, but unused constant pool entries <i>won't be ! * removed</i>.</li> <li>Methods that are not transformed are copied as is ! * in the new class, directly from the original class bytecode (i.e. without ! * emitting visit events for all the method instructions), which saves a ! * <i>lot</i> of time. Untransformed methods are detected by the fact that ! * the {@link ClassReader} receives {@link MethodVisitor} objects that come ! * from a {@link ClassWriter} (and not from any other {@link ClassVisitor} ! * instance).</li> </ul> * ! * @param classReader the {@link ClassReader} used to read the original ! * class. It will be used to copy the entire constant pool from the * original class and also to copy other fragments of original * bytecode where applicable. ! * @param flags option flags that can be used to modify the default behavior ! * of this class. <i>These option flags do not affect methods that ! * are copied as is in the new class. This means that the maximum ! * stack size nor the stack frames will be computed for these ! * methods</i>. See {@link #COMPUTE_MAXS}, {@link #COMPUTE_FRAMES}. */ public ClassWriter(final ClassReader classReader, final int flags) { this(flags); classReader.copyPool(this); this.cr = classReader; --- 650,685 ---- /** * Constructs a new {@link ClassWriter} object and enables optimizations for * "mostly add" bytecode transformations. These optimizations are the * following: * ! * <ul> ! * <li>The constant pool from the original class is copied as is in the new ! * class, which saves time. New constant pool entries will be added at the ! * end if necessary, but unused constant pool entries <i>won't be ! * removed</i>.</li> ! * <li>Methods that are not transformed are copied as is in the new class, ! * directly from the original class bytecode (i.e. without emitting visit ! * events for all the method instructions), which saves a <i>lot</i> of ! * time. Untransformed methods are detected by the fact that the ! * {@link ClassReader} receives {@link MethodVisitor} objects that come from ! * a {@link ClassWriter} (and not from any other {@link ClassVisitor} ! * instance).</li> ! * </ul> * ! * @param classReader ! * the {@link ClassReader} used to read the original class. It ! * will be used to copy the entire constant pool from the * original class and also to copy other fragments of original * bytecode where applicable. ! * @param flags ! * option flags that can be used to modify the default behavior ! * of this class. <i>These option flags do not affect methods ! * that are copied as is in the new class. This means that the ! * maximum stack size nor the stack frames will be computed for ! * these methods</i>. See {@link #COMPUTE_MAXS}, ! * {@link #COMPUTE_FRAMES}. */ public ClassWriter(final ClassReader classReader, final int flags) { this(flags); classReader.copyPool(this); this.cr = classReader;
*** 665,682 **** // ------------------------------------------------------------------------ // Implementation of the ClassVisitor abstract class // ------------------------------------------------------------------------ @Override ! public final void visit( ! final int version, ! final int access, ! final String name, ! final String signature, ! final String superName, ! final String[] interfaces) ! { this.version = version; this.access = access; this.name = newClass(name); thisName = name; if (ClassReader.SIGNATURES && signature != null) { --- 688,700 ---- // ------------------------------------------------------------------------ // Implementation of the ClassVisitor abstract class // ------------------------------------------------------------------------ @Override ! public final void visit(final int version, final int access, ! final String name, final String signature, final String superName, ! final String[] interfaces) { this.version = version; this.access = access; this.name = newClass(name); thisName = name; if (ClassReader.SIGNATURES && signature != null) {
*** 701,726 **** sourceDebug = new ByteVector().putUTF8(debug); } } @Override ! public final void visitOuterClass( ! final String owner, ! final String name, ! final String desc) ! { enclosingMethodOwner = newClass(owner); if (name != null && desc != null) { enclosingMethod = newNameType(name, desc); } } @Override ! public final AnnotationVisitor visitAnnotation( ! final String desc, ! final boolean visible) ! { if (!ClassReader.ANNOTATIONS) { return null; } ByteVector bv = new ByteVector(); // write type, and reserve space for values count --- 719,739 ---- sourceDebug = new ByteVector().putUTF8(debug); } } @Override ! public final void visitOuterClass(final String owner, final String name, ! final String desc) { enclosingMethodOwner = newClass(owner); if (name != null && desc != null) { enclosingMethod = newNameType(name, desc); } } @Override ! public final AnnotationVisitor visitAnnotation(final String desc, ! final boolean visible) { if (!ClassReader.ANNOTATIONS) { return null; } ByteVector bv = new ByteVector(); // write type, and reserve space for values count
*** 735,756 **** } return aw; } @Override public final void visitAttribute(final Attribute attr) { attr.next = attrs; attrs = attr; } @Override ! public final void visitInnerClass( ! final String name, ! final String outerName, ! final String innerName, ! final int access) ! { if (innerClasses == null) { innerClasses = new ByteVector(); } ++innerClassesCount; innerClasses.putShort(name == null ? 0 : newClass(name)); --- 748,788 ---- } return aw; } @Override + public final AnnotationVisitor visitTypeAnnotation(int typeRef, + TypePath typePath, final String desc, final boolean visible) { + if (!ClassReader.ANNOTATIONS) { + return null; + } + ByteVector bv = new ByteVector(); + // write target_type and target_info + AnnotationWriter.putTarget(typeRef, typePath, bv); + // write type, and reserve space for values count + bv.putShort(newUTF8(desc)).putShort(0); + AnnotationWriter aw = new AnnotationWriter(this, true, bv, bv, + bv.length - 2); + if (visible) { + aw.next = tanns; + tanns = aw; + } else { + aw.next = itanns; + itanns = aw; + } + return aw; + } + + @Override public final void visitAttribute(final Attribute attr) { attr.next = attrs; attrs = attr; } @Override ! public final void visitInnerClass(final String name, ! final String outerName, final String innerName, final int access) { if (innerClasses == null) { innerClasses = new ByteVector(); } ++innerClassesCount; innerClasses.putShort(name == null ? 0 : newClass(name));
*** 758,793 **** innerClasses.putShort(innerName == null ? 0 : newUTF8(innerName)); innerClasses.putShort(access); } @Override ! public final FieldVisitor visitField( ! final int access, ! final String name, ! final String desc, ! final String signature, ! final Object value) ! { return new FieldWriter(this, access, name, desc, signature, value); } @Override ! public final MethodVisitor visitMethod( ! final int access, ! final String name, ! final String desc, ! final String signature, ! final String[] exceptions) ! { ! return new MethodWriter(this, ! access, ! name, ! desc, ! signature, ! exceptions, ! computeMaxs, ! computeFrames); } @Override public final void visitEnd() { } --- 790,809 ---- innerClasses.putShort(innerName == null ? 0 : newUTF8(innerName)); innerClasses.putShort(access); } @Override ! public final FieldVisitor visitField(final int access, final String name, ! final String desc, final String signature, final Object value) { return new FieldWriter(this, access, name, desc, signature, value); } @Override ! public final MethodVisitor visitMethod(final int access, final String name, ! final String desc, final String signature, final String[] exceptions) { ! return new MethodWriter(this, access, name, desc, signature, ! exceptions, computeMaxs, computeFrames); } @Override public final void visitEnd() { }
*** 800,810 **** * Returns the bytecode of the class that was build with this class writer. * * @return the bytecode of the class that was build with this class writer. */ public byte[] toByteArray() { ! if (index > Short.MAX_VALUE) { throw new RuntimeException("Class file too large!"); } // computes the real size of the bytecode of this class int size = 24 + 2 * interfaceCount; int nbFields = 0; --- 816,826 ---- * Returns the bytecode of the class that was build with this class writer. * * @return the bytecode of the class that was build with this class writer. */ public byte[] toByteArray() { ! if (index > 0xFFFF) { throw new RuntimeException("Class file too large!"); } // computes the real size of the bytecode of this class int size = 24 + 2 * interfaceCount; int nbFields = 0;
*** 820,831 **** ++nbMethods; size += mb.getSize(); mb = (MethodWriter) mb.mv; } int attributeCount = 0; ! if (bootstrapMethods != null) { // we put it as first argument in order ! // to improve a bit ClassReader.copyBootstrapMethods ++attributeCount; size += 8 + bootstrapMethods.length; newUTF8("BootstrapMethods"); } if (ClassReader.SIGNATURES && signature != 0) { --- 836,848 ---- ++nbMethods; size += mb.getSize(); mb = (MethodWriter) mb.mv; } int attributeCount = 0; ! if (bootstrapMethods != null) { ! // we put it as first attribute in order to improve a bit ! // ClassReader.copyBootstrapMethods ++attributeCount; size += 8 + bootstrapMethods.length; newUTF8("BootstrapMethods"); } if (ClassReader.SIGNATURES && signature != 0) {
*** 851,867 **** if ((access & Opcodes.ACC_DEPRECATED) != 0) { ++attributeCount; size += 6; newUTF8("Deprecated"); } ! if ((access & Opcodes.ACC_SYNTHETIC) != 0 ! && ((version & 0xFFFF) < Opcodes.V1_5 || (access & ACC_SYNTHETIC_ATTRIBUTE) != 0)) ! { ++attributeCount; size += 6; newUTF8("Synthetic"); } if (innerClasses != null) { ++attributeCount; size += 8 + innerClasses.length; newUTF8("InnerClasses"); } --- 868,885 ---- if ((access & Opcodes.ACC_DEPRECATED) != 0) { ++attributeCount; size += 6; newUTF8("Deprecated"); } ! if ((access & Opcodes.ACC_SYNTHETIC) != 0) { ! if ((version & 0xFFFF) < Opcodes.V1_5 ! || (access & ACC_SYNTHETIC_ATTRIBUTE) != 0) { ++attributeCount; size += 6; newUTF8("Synthetic"); } + } if (innerClasses != null) { ++attributeCount; size += 8 + innerClasses.length; newUTF8("InnerClasses"); }
*** 873,882 **** --- 891,910 ---- if (ClassReader.ANNOTATIONS && ianns != null) { ++attributeCount; size += 8 + ianns.getSize(); newUTF8("RuntimeInvisibleAnnotations"); } + if (ClassReader.ANNOTATIONS && tanns != null) { + ++attributeCount; + size += 8 + tanns.getSize(); + newUTF8("RuntimeVisibleTypeAnnotations"); + } + if (ClassReader.ANNOTATIONS && itanns != null) { + ++attributeCount; + size += 8 + itanns.getSize(); + newUTF8("RuntimeInvisibleTypeAnnotations"); + } if (attrs != null) { attributeCount += attrs.getCount(); size += attrs.getSize(this, null, 0, -1, -1); } size += pool.length;
*** 883,895 **** // allocates a byte vector of this size, in order to avoid unnecessary // arraycopy operations in the ByteVector.enlarge() method ByteVector out = new ByteVector(size); out.putInt(0xCAFEBABE).putInt(version); out.putShort(index).putByteArray(pool.data, 0, pool.length); ! int mask = Opcodes.ACC_DEPRECATED ! | ClassWriter.ACC_SYNTHETIC_ATTRIBUTE ! | ((access & ClassWriter.ACC_SYNTHETIC_ATTRIBUTE) / (ClassWriter.ACC_SYNTHETIC_ATTRIBUTE / Opcodes.ACC_SYNTHETIC)); out.putShort(access & ~mask).putShort(name).putShort(superName); out.putShort(interfaceCount); for (int i = 0; i < interfaceCount; ++i) { out.putShort(interfaces[i]); } --- 911,922 ---- // allocates a byte vector of this size, in order to avoid unnecessary // arraycopy operations in the ByteVector.enlarge() method ByteVector out = new ByteVector(size); out.putInt(0xCAFEBABE).putInt(version); out.putShort(index).putByteArray(pool.data, 0, pool.length); ! int mask = Opcodes.ACC_DEPRECATED | ACC_SYNTHETIC_ATTRIBUTE ! | ((access & ACC_SYNTHETIC_ATTRIBUTE) / TO_ACC_SYNTHETIC); out.putShort(access & ~mask).putShort(name).putShort(superName); out.putShort(interfaceCount); for (int i = 0; i < interfaceCount; ++i) { out.putShort(interfaces[i]); }
*** 904,916 **** while (mb != null) { mb.put(out); mb = (MethodWriter) mb.mv; } out.putShort(attributeCount); ! if (bootstrapMethods != null) { // should be the first class attribute ? out.putShort(newUTF8("BootstrapMethods")); ! out.putInt(bootstrapMethods.length + 2).putShort(bootstrapMethodsCount); out.putByteArray(bootstrapMethods.data, 0, bootstrapMethods.length); } if (ClassReader.SIGNATURES && signature != 0) { out.putShort(newUTF8("Signature")).putInt(2).putShort(signature); } --- 931,944 ---- while (mb != null) { mb.put(out); mb = (MethodWriter) mb.mv; } out.putShort(attributeCount); ! if (bootstrapMethods != null) { out.putShort(newUTF8("BootstrapMethods")); ! out.putInt(bootstrapMethods.length + 2).putShort( ! bootstrapMethodsCount); out.putByteArray(bootstrapMethods.data, 0, bootstrapMethods.length); } if (ClassReader.SIGNATURES && signature != 0) { out.putShort(newUTF8("Signature")).putInt(2).putShort(signature); }
*** 927,941 **** out.putShort(enclosingMethodOwner).putShort(enclosingMethod); } if ((access & Opcodes.ACC_DEPRECATED) != 0) { out.putShort(newUTF8("Deprecated")).putInt(0); } ! if ((access & Opcodes.ACC_SYNTHETIC) != 0 ! && ((version & 0xFFFF) < Opcodes.V1_5 || (access & ACC_SYNTHETIC_ATTRIBUTE) != 0)) ! { out.putShort(newUTF8("Synthetic")).putInt(0); } if (innerClasses != null) { out.putShort(newUTF8("InnerClasses")); out.putInt(innerClasses.length + 2).putShort(innerClassesCount); out.putByteArray(innerClasses.data, 0, innerClasses.length); } --- 955,970 ---- out.putShort(enclosingMethodOwner).putShort(enclosingMethod); } if ((access & Opcodes.ACC_DEPRECATED) != 0) { out.putShort(newUTF8("Deprecated")).putInt(0); } ! if ((access & Opcodes.ACC_SYNTHETIC) != 0) { ! if ((version & 0xFFFF) < Opcodes.V1_5 ! || (access & ACC_SYNTHETIC_ATTRIBUTE) != 0) { out.putShort(newUTF8("Synthetic")).putInt(0); } + } if (innerClasses != null) { out.putShort(newUTF8("InnerClasses")); out.putInt(innerClasses.length + 2).putShort(innerClassesCount); out.putByteArray(innerClasses.data, 0, innerClasses.length); }
*** 945,954 **** --- 974,991 ---- } if (ClassReader.ANNOTATIONS && ianns != null) { out.putShort(newUTF8("RuntimeInvisibleAnnotations")); ianns.put(out); } + if (ClassReader.ANNOTATIONS && tanns != null) { + out.putShort(newUTF8("RuntimeVisibleTypeAnnotations")); + tanns.put(out); + } + if (ClassReader.ANNOTATIONS && itanns != null) { + out.putShort(newUTF8("RuntimeInvisibleTypeAnnotations")); + itanns.put(out); + } if (attrs != null) { attrs.put(this, null, 0, -1, -1, out); } if (invalidFrames) { ClassWriter cw = new ClassWriter(COMPUTE_FRAMES);
*** 964,974 **** /** * Adds a number or string constant to the constant pool of the class being * build. Does nothing if the constant pool already contains a similar item. * ! * @param cst the value of the constant to be added to the constant pool. * This parameter must be an {@link Integer}, a {@link Float}, a * {@link Long}, a {@link Double}, a {@link String} or a * {@link Type}. * @return a new or already existing constant item with the given value. */ --- 1001,1012 ---- /** * Adds a number or string constant to the constant pool of the class being * build. Does nothing if the constant pool already contains a similar item. * ! * @param cst ! * the value of the constant to be added to the constant pool. * This parameter must be an {@link Integer}, a {@link Float}, a * {@link Long}, a {@link Double}, a {@link String} or a * {@link Type}. * @return a new or already existing constant item with the given value. */
*** 1000,1015 **** } else if (cst instanceof String) { return newString((String) cst); } else if (cst instanceof Type) { Type t = (Type) cst; int s = t.getSort(); ! if (s == Type.ARRAY) { ! return newClassItem(t.getDescriptor()); ! } else if (s == Type.OBJECT) { return newClassItem(t.getInternalName()); ! } else { // s == Type.METHOD return newMethodTypeItem(t.getDescriptor()); } } else if (cst instanceof Handle) { Handle h = (Handle) cst; return newHandleItem(h.tag, h.owner, h.name, h.desc); } else { --- 1038,1053 ---- } else if (cst instanceof String) { return newString((String) cst); } else if (cst instanceof Type) { Type t = (Type) cst; int s = t.getSort(); ! if (s == Type.OBJECT) { return newClassItem(t.getInternalName()); ! } else if (s == Type.METHOD) { return newMethodTypeItem(t.getDescriptor()); + } else { // s == primitive type or array + return newClassItem(t.getDescriptor()); } } else if (cst instanceof Handle) { Handle h = (Handle) cst; return newHandleItem(h.tag, h.owner, h.name, h.desc); } else {
*** 1021,1031 **** * Adds a number or string constant to the constant pool of the class being * build. Does nothing if the constant pool already contains a similar item. * <i>This method is intended for {@link Attribute} sub classes, and is * normally not needed by class generators or adapters.</i> * ! * @param cst the value of the constant to be added to the constant pool. * This parameter must be an {@link Integer}, a {@link Float}, a * {@link Long}, a {@link Double} or a {@link String}. * @return the index of a new or already existing constant item with the * given value. */ --- 1059,1070 ---- * Adds a number or string constant to the constant pool of the class being * build. Does nothing if the constant pool already contains a similar item. * <i>This method is intended for {@link Attribute} sub classes, and is * normally not needed by class generators or adapters.</i> * ! * @param cst ! * the value of the constant to be added to the constant pool. * This parameter must be an {@link Integer}, a {@link Float}, a * {@link Long}, a {@link Double} or a {@link String}. * @return the index of a new or already existing constant item with the * given value. */
*** 1037,1047 **** * Adds an UTF8 string to the constant pool of the class being build. Does * nothing if the constant pool already contains a similar item. <i>This * method is intended for {@link Attribute} sub classes, and is normally not * needed by class generators or adapters.</i> * ! * @param value the String value. * @return the index of a new or already existing UTF8 item. */ public int newUTF8(final String value) { key.set(UTF8, value, null, null); Item result = get(key); --- 1076,1087 ---- * Adds an UTF8 string to the constant pool of the class being build. Does * nothing if the constant pool already contains a similar item. <i>This * method is intended for {@link Attribute} sub classes, and is normally not * needed by class generators or adapters.</i> * ! * @param value ! * the String value. * @return the index of a new or already existing UTF8 item. */ public int newUTF8(final String value) { key.set(UTF8, value, null, null); Item result = get(key);
*** 1057,1067 **** * Adds a class reference to the constant pool of the class being build. * Does nothing if the constant pool already contains a similar item. * <i>This method is intended for {@link Attribute} sub classes, and is * normally not needed by class generators or adapters.</i> * ! * @param value the internal name of the class. * @return a new or already existing class reference item. */ Item newClassItem(final String value) { key2.set(CLASS, value, null, null); Item result = get(key2); --- 1097,1108 ---- * Adds a class reference to the constant pool of the class being build. * Does nothing if the constant pool already contains a similar item. * <i>This method is intended for {@link Attribute} sub classes, and is * normally not needed by class generators or adapters.</i> * ! * @param value ! * the internal name of the class. * @return a new or already existing class reference item. */ Item newClassItem(final String value) { key2.set(CLASS, value, null, null); Item result = get(key2);
*** 1077,1087 **** * Adds a class reference to the constant pool of the class being build. * Does nothing if the constant pool already contains a similar item. * <i>This method is intended for {@link Attribute} sub classes, and is * normally not needed by class generators or adapters.</i> * ! * @param value the internal name of the class. * @return the index of a new or already existing class reference item. */ public int newClass(final String value) { return newClassItem(value).index; } --- 1118,1129 ---- * Adds a class reference to the constant pool of the class being build. * Does nothing if the constant pool already contains a similar item. * <i>This method is intended for {@link Attribute} sub classes, and is * normally not needed by class generators or adapters.</i> * ! * @param value ! * the internal name of the class. * @return the index of a new or already existing class reference item. */ public int newClass(final String value) { return newClassItem(value).index; }
*** 1090,1100 **** * Adds a method type reference to the constant pool of the class being * build. Does nothing if the constant pool already contains a similar item. * <i>This method is intended for {@link Attribute} sub classes, and is * normally not needed by class generators or adapters.</i> * ! * @param methodDesc method descriptor of the method type. * @return a new or already existing method type reference item. */ Item newMethodTypeItem(final String methodDesc) { key2.set(MTYPE, methodDesc, null, null); Item result = get(key2); --- 1132,1143 ---- * Adds a method type reference to the constant pool of the class being * build. Does nothing if the constant pool already contains a similar item. * <i>This method is intended for {@link Attribute} sub classes, and is * normally not needed by class generators or adapters.</i> * ! * @param methodDesc ! * method descriptor of the method type. * @return a new or already existing method type reference item. */ Item newMethodTypeItem(final String methodDesc) { key2.set(MTYPE, methodDesc, null, null); Item result = get(key2);
*** 1110,1120 **** * Adds a method type reference to the constant pool of the class being * build. Does nothing if the constant pool already contains a similar item. * <i>This method is intended for {@link Attribute} sub classes, and is * normally not needed by class generators or adapters.</i> * ! * @param methodDesc method descriptor of the method type. * @return the index of a new or already existing method type reference * item. */ public int newMethodType(final String methodDesc) { return newMethodTypeItem(methodDesc).index; --- 1153,1164 ---- * Adds a method type reference to the constant pool of the class being * build. Does nothing if the constant pool already contains a similar item. * <i>This method is intended for {@link Attribute} sub classes, and is * normally not needed by class generators or adapters.</i> * ! * @param methodDesc ! * method descriptor of the method type. * @return the index of a new or already existing method type reference * item. */ public int newMethodType(final String methodDesc) { return newMethodTypeItem(methodDesc).index;
*** 1124,1225 **** * Adds a handle to the constant pool of the class being build. Does nothing * if the constant pool already contains a similar item. <i>This method is * intended for {@link Attribute} sub classes, and is normally not needed by * class generators or adapters.</i> * ! * @param tag the kind of this handle. Must be {@link Opcodes#H_GETFIELD}, * {@link Opcodes#H_GETSTATIC}, {@link Opcodes#H_PUTFIELD}, * {@link Opcodes#H_PUTSTATIC}, {@link Opcodes#H_INVOKEVIRTUAL}, ! * {@link Opcodes#H_INVOKESTATIC}, {@link Opcodes#H_INVOKESPECIAL}, * {@link Opcodes#H_NEWINVOKESPECIAL} or * {@link Opcodes#H_INVOKEINTERFACE}. ! * @param owner the internal name of the field or method owner class. ! * @param name the name of the field or method. ! * @param desc the descriptor of the field or method. * @return a new or an already existing method type reference item. */ ! Item newHandleItem( ! final int tag, ! final String owner, ! final String name, ! final String desc) ! { key4.set(HANDLE_BASE + tag, owner, name, desc); Item result = get(key4); if (result == null) { if (tag <= Opcodes.H_PUTSTATIC) { put112(HANDLE, tag, newField(owner, name, desc)); } else { ! put112(HANDLE, tag, newMethod(owner, ! name, ! desc, tag == Opcodes.H_INVOKEINTERFACE)); } result = new Item(index++, key4); put(result); } return result; } /** ! * Adds a handle to the constant pool of the class being ! * build. Does nothing if the constant pool already contains a similar item. ! * <i>This method is intended for {@link Attribute} sub classes, and is ! * normally not needed by class generators or adapters.</i> * ! * @param tag the kind of this handle. Must be {@link Opcodes#H_GETFIELD}, * {@link Opcodes#H_GETSTATIC}, {@link Opcodes#H_PUTFIELD}, * {@link Opcodes#H_PUTSTATIC}, {@link Opcodes#H_INVOKEVIRTUAL}, ! * {@link Opcodes#H_INVOKESTATIC}, {@link Opcodes#H_INVOKESPECIAL}, * {@link Opcodes#H_NEWINVOKESPECIAL} or * {@link Opcodes#H_INVOKEINTERFACE}. ! * @param owner the internal name of the field or method owner class. ! * @param name the name of the field or method. ! * @param desc the descriptor of the field or method. * @return the index of a new or already existing method type reference * item. */ ! public int newHandle( ! final int tag, ! final String owner, ! final String name, ! final String desc) ! { return newHandleItem(tag, owner, name, desc).index; } /** * Adds an invokedynamic reference to the constant pool of the class being * build. Does nothing if the constant pool already contains a similar item. * <i>This method is intended for {@link Attribute} sub classes, and is * normally not needed by class generators or adapters.</i> * ! * @param name name of the invoked method. ! * @param desc descriptor of the invoke method. ! * @param bsm the bootstrap method. ! * @param bsmArgs the bootstrap method constant arguments. * * @return a new or an already existing invokedynamic type reference item. */ ! Item newInvokeDynamicItem( ! final String name, ! final String desc, ! final Handle bsm, ! final Object... bsmArgs) ! { // cache for performance ByteVector bootstrapMethods = this.bootstrapMethods; if (bootstrapMethods == null) { bootstrapMethods = this.bootstrapMethods = new ByteVector(); } int position = bootstrapMethods.length; // record current position int hashCode = bsm.hashCode(); ! bootstrapMethods.putShort(newHandle(bsm.tag, ! bsm.owner, ! bsm.name, bsm.desc)); int argsLength = bsmArgs.length; bootstrapMethods.putShort(argsLength); --- 1168,1269 ---- * Adds a handle to the constant pool of the class being build. Does nothing * if the constant pool already contains a similar item. <i>This method is * intended for {@link Attribute} sub classes, and is normally not needed by * class generators or adapters.</i> * ! * @param tag ! * the kind of this handle. Must be {@link Opcodes#H_GETFIELD}, * {@link Opcodes#H_GETSTATIC}, {@link Opcodes#H_PUTFIELD}, * {@link Opcodes#H_PUTSTATIC}, {@link Opcodes#H_INVOKEVIRTUAL}, ! * {@link Opcodes#H_INVOKESTATIC}, ! * {@link Opcodes#H_INVOKESPECIAL}, * {@link Opcodes#H_NEWINVOKESPECIAL} or * {@link Opcodes#H_INVOKEINTERFACE}. ! * @param owner ! * the internal name of the field or method owner class. ! * @param name ! * the name of the field or method. ! * @param desc ! * the descriptor of the field or method. * @return a new or an already existing method type reference item. */ ! Item newHandleItem(final int tag, final String owner, final String name, ! final String desc) { key4.set(HANDLE_BASE + tag, owner, name, desc); Item result = get(key4); if (result == null) { if (tag <= Opcodes.H_PUTSTATIC) { put112(HANDLE, tag, newField(owner, name, desc)); } else { ! put112(HANDLE, ! tag, ! newMethod(owner, name, desc, tag == Opcodes.H_INVOKEINTERFACE)); } result = new Item(index++, key4); put(result); } return result; } /** ! * Adds a handle to the constant pool of the class being build. Does nothing ! * if the constant pool already contains a similar item. <i>This method is ! * intended for {@link Attribute} sub classes, and is normally not needed by ! * class generators or adapters.</i> * ! * @param tag ! * the kind of this handle. Must be {@link Opcodes#H_GETFIELD}, * {@link Opcodes#H_GETSTATIC}, {@link Opcodes#H_PUTFIELD}, * {@link Opcodes#H_PUTSTATIC}, {@link Opcodes#H_INVOKEVIRTUAL}, ! * {@link Opcodes#H_INVOKESTATIC}, ! * {@link Opcodes#H_INVOKESPECIAL}, * {@link Opcodes#H_NEWINVOKESPECIAL} or * {@link Opcodes#H_INVOKEINTERFACE}. ! * @param owner ! * the internal name of the field or method owner class. ! * @param name ! * the name of the field or method. ! * @param desc ! * the descriptor of the field or method. * @return the index of a new or already existing method type reference * item. */ ! public int newHandle(final int tag, final String owner, final String name, ! final String desc) { return newHandleItem(tag, owner, name, desc).index; } /** * Adds an invokedynamic reference to the constant pool of the class being * build. Does nothing if the constant pool already contains a similar item. * <i>This method is intended for {@link Attribute} sub classes, and is * normally not needed by class generators or adapters.</i> * ! * @param name ! * name of the invoked method. ! * @param desc ! * descriptor of the invoke method. ! * @param bsm ! * the bootstrap method. ! * @param bsmArgs ! * the bootstrap method constant arguments. * * @return a new or an already existing invokedynamic type reference item. */ ! Item newInvokeDynamicItem(final String name, final String desc, ! final Handle bsm, final Object... bsmArgs) { // cache for performance ByteVector bootstrapMethods = this.bootstrapMethods; if (bootstrapMethods == null) { bootstrapMethods = this.bootstrapMethods = new ByteVector(); } int position = bootstrapMethods.length; // record current position int hashCode = bsm.hashCode(); ! bootstrapMethods.putShort(newHandle(bsm.tag, bsm.owner, bsm.name, bsm.desc)); int argsLength = bsmArgs.length; bootstrapMethods.putShort(argsLength);
*** 1277,1314 **** * Adds an invokedynamic reference to the constant pool of the class being * build. Does nothing if the constant pool already contains a similar item. * <i>This method is intended for {@link Attribute} sub classes, and is * normally not needed by class generators or adapters.</i> * ! * @param name name of the invoked method. ! * @param desc descriptor of the invoke method. ! * @param bsm the bootstrap method. ! * @param bsmArgs the bootstrap method constant arguments. * ! * @return the index of a new or already existing invokedynamic ! * reference item. */ ! public int newInvokeDynamic( ! final String name, ! final String desc, ! final Handle bsm, ! final Object... bsmArgs) ! { return newInvokeDynamicItem(name, desc, bsm, bsmArgs).index; } /** * Adds a field reference to the constant pool of the class being build. * Does nothing if the constant pool already contains a similar item. * ! * @param owner the internal name of the field's owner class. ! * @param name the field's name. ! * @param desc the field's descriptor. * @return a new or already existing field reference item. */ ! Item newFieldItem(final String owner, final String name, final String desc) ! { key3.set(FIELD, owner, name, desc); Item result = get(key3); if (result == null) { put122(FIELD, newClass(owner), newNameType(name, desc)); result = new Item(index++, key3); --- 1321,1360 ---- * Adds an invokedynamic reference to the constant pool of the class being * build. Does nothing if the constant pool already contains a similar item. * <i>This method is intended for {@link Attribute} sub classes, and is * normally not needed by class generators or adapters.</i> * ! * @param name ! * name of the invoked method. ! * @param desc ! * descriptor of the invoke method. ! * @param bsm ! * the bootstrap method. ! * @param bsmArgs ! * the bootstrap method constant arguments. * ! * @return the index of a new or already existing invokedynamic reference ! * item. */ ! public int newInvokeDynamic(final String name, final String desc, ! final Handle bsm, final Object... bsmArgs) { return newInvokeDynamicItem(name, desc, bsm, bsmArgs).index; } /** * Adds a field reference to the constant pool of the class being build. * Does nothing if the constant pool already contains a similar item. * ! * @param owner ! * the internal name of the field's owner class. ! * @param name ! * the field's name. ! * @param desc ! * the field's descriptor. * @return a new or already existing field reference item. */ ! Item newFieldItem(final String owner, final String name, final String desc) { key3.set(FIELD, owner, name, desc); Item result = get(key3); if (result == null) { put122(FIELD, newClass(owner), newNameType(name, desc)); result = new Item(index++, key3);
*** 1321,1356 **** * Adds a field reference to the constant pool of the class being build. * Does nothing if the constant pool already contains a similar item. * <i>This method is intended for {@link Attribute} sub classes, and is * normally not needed by class generators or adapters.</i> * ! * @param owner the internal name of the field's owner class. ! * @param name the field's name. ! * @param desc the field's descriptor. * @return the index of a new or already existing field reference item. */ ! public int newField(final String owner, final String name, final String desc) ! { return newFieldItem(owner, name, desc).index; } /** * Adds a method reference to the constant pool of the class being build. * Does nothing if the constant pool already contains a similar item. * ! * @param owner the internal name of the method's owner class. ! * @param name the method's name. ! * @param desc the method's descriptor. ! * @param itf <tt>true</tt> if <tt>owner</tt> is an interface. * @return a new or already existing method reference item. */ ! Item newMethodItem( ! final String owner, ! final String name, ! final String desc, ! final boolean itf) ! { int type = itf ? IMETH : METH; key3.set(type, owner, name, desc); Item result = get(key3); if (result == null) { put122(type, newClass(owner), newNameType(name, desc)); --- 1367,1404 ---- * Adds a field reference to the constant pool of the class being build. * Does nothing if the constant pool already contains a similar item. * <i>This method is intended for {@link Attribute} sub classes, and is * normally not needed by class generators or adapters.</i> * ! * @param owner ! * the internal name of the field's owner class. ! * @param name ! * the field's name. ! * @param desc ! * the field's descriptor. * @return the index of a new or already existing field reference item. */ ! public int newField(final String owner, final String name, final String desc) { return newFieldItem(owner, name, desc).index; } /** * Adds a method reference to the constant pool of the class being build. * Does nothing if the constant pool already contains a similar item. * ! * @param owner ! * the internal name of the method's owner class. ! * @param name ! * the method's name. ! * @param desc ! * the method's descriptor. ! * @param itf ! * <tt>true</tt> if <tt>owner</tt> is an interface. * @return a new or already existing method reference item. */ ! Item newMethodItem(final String owner, final String name, ! final String desc, final boolean itf) { int type = itf ? IMETH : METH; key3.set(type, owner, name, desc); Item result = get(key3); if (result == null) { put122(type, newClass(owner), newNameType(name, desc));
*** 1364,1393 **** * Adds a method reference to the constant pool of the class being build. * Does nothing if the constant pool already contains a similar item. * <i>This method is intended for {@link Attribute} sub classes, and is * normally not needed by class generators or adapters.</i> * ! * @param owner the internal name of the method's owner class. ! * @param name the method's name. ! * @param desc the method's descriptor. ! * @param itf <tt>true</tt> if <tt>owner</tt> is an interface. * @return the index of a new or already existing method reference item. */ ! public int newMethod( ! final String owner, ! final String name, ! final String desc, ! final boolean itf) ! { return newMethodItem(owner, name, desc, itf).index; } /** * Adds an integer to the constant pool of the class being build. Does * nothing if the constant pool already contains a similar item. * ! * @param value the int value. * @return a new or already existing int item. */ Item newInteger(final int value) { key.set(value); Item result = get(key); --- 1412,1442 ---- * Adds a method reference to the constant pool of the class being build. * Does nothing if the constant pool already contains a similar item. * <i>This method is intended for {@link Attribute} sub classes, and is * normally not needed by class generators or adapters.</i> * ! * @param owner ! * the internal name of the method's owner class. ! * @param name ! * the method's name. ! * @param desc ! * the method's descriptor. ! * @param itf ! * <tt>true</tt> if <tt>owner</tt> is an interface. * @return the index of a new or already existing method reference item. */ ! public int newMethod(final String owner, final String name, ! final String desc, final boolean itf) { return newMethodItem(owner, name, desc, itf).index; } /** * Adds an integer to the constant pool of the class being build. Does * nothing if the constant pool already contains a similar item. * ! * @param value ! * the int value. * @return a new or already existing int item. */ Item newInteger(final int value) { key.set(value); Item result = get(key);
*** 1401,1411 **** /** * Adds a float to the constant pool of the class being build. Does nothing * if the constant pool already contains a similar item. * ! * @param value the float value. * @return a new or already existing float item. */ Item newFloat(final float value) { key.set(value); Item result = get(key); --- 1450,1461 ---- /** * Adds a float to the constant pool of the class being build. Does nothing * if the constant pool already contains a similar item. * ! * @param value ! * the float value. * @return a new or already existing float item. */ Item newFloat(final float value) { key.set(value); Item result = get(key);
*** 1419,1429 **** /** * Adds a long to the constant pool of the class being build. Does nothing * if the constant pool already contains a similar item. * ! * @param value the long value. * @return a new or already existing long item. */ Item newLong(final long value) { key.set(value); Item result = get(key); --- 1469,1480 ---- /** * Adds a long to the constant pool of the class being build. Does nothing * if the constant pool already contains a similar item. * ! * @param value ! * the long value. * @return a new or already existing long item. */ Item newLong(final long value) { key.set(value); Item result = get(key);
*** 1438,1448 **** /** * Adds a double to the constant pool of the class being build. Does nothing * if the constant pool already contains a similar item. * ! * @param value the double value. * @return a new or already existing double item. */ Item newDouble(final double value) { key.set(value); Item result = get(key); --- 1489,1500 ---- /** * Adds a double to the constant pool of the class being build. Does nothing * if the constant pool already contains a similar item. * ! * @param value ! * the double value. * @return a new or already existing double item. */ Item newDouble(final double value) { key.set(value); Item result = get(key);
*** 1457,1467 **** /** * Adds a string to the constant pool of the class being build. Does nothing * if the constant pool already contains a similar item. * ! * @param value the String value. * @return a new or already existing string item. */ private Item newString(final String value) { key2.set(STR, value, null, null); Item result = get(key2); --- 1509,1520 ---- /** * Adds a string to the constant pool of the class being build. Does nothing * if the constant pool already contains a similar item. * ! * @param value ! * the String value. * @return a new or already existing string item. */ private Item newString(final String value) { key2.set(STR, value, null, null); Item result = get(key2);
*** 1477,1488 **** * Adds a name and type to the constant pool of the class being build. Does * nothing if the constant pool already contains a similar item. <i>This * method is intended for {@link Attribute} sub classes, and is normally not * needed by class generators or adapters.</i> * ! * @param name a name. ! * @param desc a type descriptor. * @return the index of a new or already existing name and type item. */ public int newNameType(final String name, final String desc) { return newNameTypeItem(name, desc).index; } --- 1530,1543 ---- * Adds a name and type to the constant pool of the class being build. Does * nothing if the constant pool already contains a similar item. <i>This * method is intended for {@link Attribute} sub classes, and is normally not * needed by class generators or adapters.</i> * ! * @param name ! * a name. ! * @param desc ! * a type descriptor. * @return the index of a new or already existing name and type item. */ public int newNameType(final String name, final String desc) { return newNameTypeItem(name, desc).index; }
*** 1489,1500 **** /** * Adds a name and type to the constant pool of the class being build. Does * nothing if the constant pool already contains a similar item. * ! * @param name a name. ! * @param desc a type descriptor. * @return a new or already existing name and type item. */ Item newNameTypeItem(final String name, final String desc) { key2.set(NAME_TYPE, name, desc, null); Item result = get(key2); --- 1544,1557 ---- /** * Adds a name and type to the constant pool of the class being build. Does * nothing if the constant pool already contains a similar item. * ! * @param name ! * a name. ! * @param desc ! * a type descriptor. * @return a new or already existing name and type item. */ Item newNameTypeItem(final String name, final String desc) { key2.set(NAME_TYPE, name, desc, null); Item result = get(key2);
*** 1508,1518 **** /** * Adds the given internal name to {@link #typeTable} and returns its index. * Does nothing if the type table already contains this internal name. * ! * @param type the internal name to be added to the type table. * @return the index of this internal name in the type table. */ int addType(final String type) { key.set(TYPE_NORMAL, type, null, null); Item result = get(key); --- 1565,1576 ---- /** * Adds the given internal name to {@link #typeTable} and returns its index. * Does nothing if the type table already contains this internal name. * ! * @param type ! * the internal name to be added to the type table. * @return the index of this internal name in the type table. */ int addType(final String type) { key.set(TYPE_NORMAL, type, null, null); Item result = get(key);
*** 1525,1537 **** /** * Adds the given "uninitialized" type to {@link #typeTable} and returns its * index. This method is used for UNINITIALIZED types, made of an internal * name and a bytecode offset. * ! * @param type the internal name to be added to the type table. ! * @param offset the bytecode offset of the NEW instruction that created ! * this UNINITIALIZED type value. * @return the index of this internal name in the type table. */ int addUninitializedType(final String type, final int offset) { key.type = TYPE_UNINIT; key.intVal = offset; --- 1583,1597 ---- /** * Adds the given "uninitialized" type to {@link #typeTable} and returns its * index. This method is used for UNINITIALIZED types, made of an internal * name and a bytecode offset. * ! * @param type ! * the internal name to be added to the type table. ! * @param offset ! * the bytecode offset of the NEW instruction that created this ! * UNINITIALIZED type value. * @return the index of this internal name in the type table. */ int addUninitializedType(final String type, final int offset) { key.type = TYPE_UNINIT; key.intVal = offset;
*** 1545,1555 **** } /** * Adds the given Item to {@link #typeTable}. * ! * @param item the value to be added to the type table. * @return the added Item, which a new Item instance with the same value as * the given Item. */ private Item addType(final Item item) { ++typeCount; --- 1605,1616 ---- } /** * Adds the given Item to {@link #typeTable}. * ! * @param item ! * the value to be added to the type table. * @return the added Item, which a new Item instance with the same value as * the given Item. */ private Item addType(final Item item) { ++typeCount;
*** 1571,1582 **** * Returns the index of the common super type of the two given types. This * method calls {@link #getCommonSuperClass} and caches the result in the * {@link #items} hash table to speedup future calls with the same * parameters. * ! * @param type1 index of an internal name in {@link #typeTable}. ! * @param type2 index of an internal name in {@link #typeTable}. * @return the index of the common super type of the two given types. */ int getMergedType(final int type1, final int type2) { key2.type = TYPE_MERGED; key2.longVal = type1 | (((long) type2) << 32); --- 1632,1645 ---- * Returns the index of the common super type of the two given types. This * method calls {@link #getCommonSuperClass} and caches the result in the * {@link #items} hash table to speedup future calls with the same * parameters. * ! * @param type1 ! * index of an internal name in {@link #typeTable}. ! * @param type2 ! * index of an internal name in {@link #typeTable}. * @return the index of the common super type of the two given types. */ int getMergedType(final int type1, final int type2) { key2.type = TYPE_MERGED; key2.longVal = type1 | (((long) type2) << 32);
*** 1592,1615 **** return result.intVal; } /** * Returns the common super type of the two given types. The default ! * implementation of this method <i>loads<i> the two given classes and uses * the java.lang.Class methods to find the common super class. It can be * overridden to compute this common super type in other ways, in particular * without actually loading any class, or to take into account the class * that is currently being generated by this ClassWriter, which can of * course not be loaded since it is under construction. * ! * @param type1 the internal name of a class. ! * @param type2 the internal name of another class. * @return the internal name of the common super class of the two given * classes. */ ! protected String getCommonSuperClass(final String type1, final String type2) ! { Class<?> c, d; ClassLoader classLoader = getClass().getClassLoader(); try { c = Class.forName(type1.replace('/', '.'), false, classLoader); d = Class.forName(type2.replace('/', '.'), false, classLoader); --- 1655,1679 ---- return result.intVal; } /** * Returns the common super type of the two given types. The default ! * implementation of this method <i>loads</i> the two given classes and uses * the java.lang.Class methods to find the common super class. It can be * overridden to compute this common super type in other ways, in particular * without actually loading any class, or to take into account the class * that is currently being generated by this ClassWriter, which can of * course not be loaded since it is under construction. * ! * @param type1 ! * the internal name of a class. ! * @param type2 ! * the internal name of another class. * @return the internal name of the common super class of the two given * classes. */ ! protected String getCommonSuperClass(final String type1, final String type2) { Class<?> c, d; ClassLoader classLoader = getClass().getClassLoader(); try { c = Class.forName(type1.replace('/', '.'), false, classLoader); d = Class.forName(type2.replace('/', '.'), false, classLoader);
*** 1634,1644 **** /** * Returns the constant pool's hash table item which is equal to the given * item. * ! * @param key a constant pool item. * @return the constant pool's hash table item which is equal to the given * item, or <tt>null</tt> if there is no such item. */ private Item get(final Item key) { Item i = items[key.hashCode % items.length]; --- 1698,1709 ---- /** * Returns the constant pool's hash table item which is equal to the given * item. * ! * @param key ! * a constant pool item. * @return the constant pool's hash table item which is equal to the given * item, or <tt>null</tt> if there is no such item. */ private Item get(final Item key) { Item i = items[key.hashCode % items.length];
*** 1650,1660 **** /** * Puts the given item in the constant pool's hash table. The hash table * <i>must</i> not already contains this item. * ! * @param i the item to be added to the constant pool's hash table. */ private void put(final Item i) { if (index + typeCount > threshold) { int ll = items.length; int nl = ll * 2 + 1; --- 1715,1726 ---- /** * Puts the given item in the constant pool's hash table. The hash table * <i>must</i> not already contains this item. * ! * @param i ! * the item to be added to the constant pool's hash table. */ private void put(final Item i) { if (index + typeCount > threshold) { int ll = items.length; int nl = ll * 2 + 1;
*** 1678,1701 **** } /** * Puts one byte and two shorts into the constant pool. * ! * @param b a byte. ! * @param s1 a short. ! * @param s2 another short. */ private void put122(final int b, final int s1, final int s2) { pool.put12(b, s1).putShort(s2); } /** * Puts two bytes and one short into the constant pool. * ! * @param b1 a byte. ! * @param b2 another byte. ! * @param s a short. */ private void put112(final int b1, final int b2, final int s) { pool.put11(b1, b2).putShort(s); } } --- 1744,1773 ---- } /** * Puts one byte and two shorts into the constant pool. * ! * @param b ! * a byte. ! * @param s1 ! * a short. ! * @param s2 ! * another short. */ private void put122(final int b, final int s1, final int s2) { pool.put12(b, s1).putShort(s2); } /** * Puts two bytes and one short into the constant pool. * ! * @param b1 ! * a byte. ! * @param b2 ! * another byte. ! * @param s ! * a short. */ private void put112(final int b1, final int b2, final int s) { pool.put11(b1, b2).putShort(s); } }