< prev index next >

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

Print this page

        

*** 270,279 **** --- 270,289 ---- * The type of CONSTANT_InvokeDynamic constant pool items. */ static final int INDY = 18; /** + * The type of CONSTANT_Module constant pool items. + */ + static final int MODULE = 19; + + /** + * The type of CONSTANT_Package constant pool items. + */ + static final int PACKAGE = 20; + + /** * 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;
*** 1159,1168 **** --- 1169,1222 ---- public int newClass(final String value) { return newClassItem(value).index; } /** + * Adds a module name to the constant pool. + * + * 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 module name + * @return the index of a new or already existing module reference item. + */ + public int newModule(String value) { + key2.set(MODULE, value, null, null); + Item result = get(key2); + if (result == null) { + pool.put12(MODULE, newUTF8(value)); + result = new Item(index++, key2); + put(result); + } + return result.index; + } + + /** + * Adds a package name to the constant pool. + * + * 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 package. + * @return the index of a new or already existing package reference item. + */ + public int newPackage(String value) { + key2.set(PACKAGE, value, null, null); + Item result = get(key2); + if (result == null) { + pool.put12(PACKAGE, newUTF8(value)); + result = new Item(index++, key2); + put(result); + } + return result.index; + } + + /** * 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> *
< prev index next >