/** * Adds a new CONSTANT_NameAndType_info to the constant pool of this symbol table. * * @param index the constant pool index of the new Symbol. * @param name a field or method name. * @param descriptor a field or method descriptor. */ private void addConstantNameAndType(final int index, final String name, final String descriptor) { final int tag = Symbol.CONSTANT_NAME_AND_TYPE_TAG; add(new Entry(index, tag, name, descriptor, hash(tag, name, descriptor))); }
@Override public void visitUse(final String service) { usesIndex.putShort(symbolTable.addConstantClass(service).index); usesCount++; }
@Override public void visitPackage(final String packaze) { packageIndex.putShort(symbolTable.addConstantPackage(packaze).index); packageCount++; }
/** * Sets this CurrentFrame to the input stack map frame of the next "current" instruction, i.e. the * instruction just after the given one. It is assumed that the value of this object when this * method is called is the stack map frame status just before the given instruction is executed. */ @Override void execute( final int opcode, final int arg, final Symbol symbolArg, final SymbolTable symbolTable) { super.execute(opcode, arg, symbolArg, symbolTable); Frame successor = new Frame(null); merge(symbolTable, successor, 0); copyFrom(successor); } }
@Override public void visitExport(final String packaze, final int access, final String... modules) { exports.putShort(symbolTable.addConstantPackage(packaze).index).putShort(access); if (modules == null) { exports.putShort(0); } else { exports.putShort(modules.length); for (String module : modules) { exports.putShort(symbolTable.addConstantModule(module).index); } } exportsCount++; }
@Override public void visitRequire(final String module, final int access, final String version) { requires .putShort(symbolTable.addConstantModule(module).index) .putShort(access) .putShort(version == null ? 0 : symbolTable.addConstantUtf8(version)); requiresCount++; }
/** * Returns a reference to the type of an exception, in a 'throws' clause of a method. * * @param exceptionIndex the index of an exception in a 'throws' clause of a method. * @return a reference to the type of the given exception. */ public static TypeReference newExceptionReference(final int exceptionIndex) { return new TypeReference((THROWS << 24) | (exceptionIndex << 8)); }
/** * Adds a CONSTANT_String_info to the constant pool of this symbol table. Does nothing if the * constant pool already contains a similar item. * * @param value a string. * @return a new or already existing Symbol with the given value. */ Symbol addConstantString(final String value) { return addConstantUtf8Reference(Symbol.CONSTANT_STRING_TAG, value); }
/** * Visit an implementation of a service. * * @param service the internal name of the service. * @param providers the internal names of the implementations of the service (there is at least * one provider). */ public void visitProvide(final String service, final String... providers) { if (mv != null) { mv.visitProvide(service, providers); } }
/** * Visits the end of the module. This method, which is the last one to be called, is used to * inform the visitor that everything have been visited. */ public void visitEnd() { if (mv != null) { mv.visitEnd(); } } }
/** * Adds a CONSTANT_Integer_info to the constant pool of this symbol table. Does nothing if the * constant pool already contains a similar item. * * @param value an int. * @return a new or already existing Symbol with the given value. */ Symbol addConstantInteger(final int value) { return addConstantInteger(Symbol.CONSTANT_INTEGER_TAG, value); }
/** * Adds a new CONSTANT_String_info to the constant pool of this symbol table. * * @param index the constant pool index of the new Symbol. * @param value a string. */ private void addConstantUtf8(final int index, final String value) { add(new Entry(index, Symbol.CONSTANT_UTF8_TAG, value, hash(Symbol.CONSTANT_UTF8_TAG, value))); }
@Override public void visitOpen(final String packaze, final int access, final String... modules) { opens.putShort(symbolTable.addConstantPackage(packaze).index).putShort(access); if (modules == null) { opens.putShort(0); } else { opens.putShort(modules.length); for (String module : modules) { opens.putShort(symbolTable.addConstantModule(module).index); } } opensCount++; }
@Override public void visitProvide(final String service, final String... providers) { provides.putShort(symbolTable.addConstantClass(service).index); provides.putShort(providers.length); for (String provider : providers) { provides.putShort(symbolTable.addConstantClass(provider).index); } providesCount++; }
/** * Returns a reference to the super class or to an interface of the 'implements' clause of a * class. * * @param itfIndex the index of an interface in the 'implements' clause of a class, or -1 to * reference the super class of the class. * @return a reference to the given super type of a class. */ public static TypeReference newSuperTypeReference(final int itfIndex) { return new TypeReference((CLASS_EXTENDS << 24) | ((itfIndex & 0xFFFF) << 8)); }
/** * Adds a CONSTANT_Module_info to the constant pool of this symbol table. Does nothing if the * constant pool already contains a similar item. * * @param moduleName a fully qualified name (using dots) of a module. * @return a new or already existing Symbol with the given value. */ Symbol addConstantModule(final String moduleName) { return addConstantUtf8Reference(Symbol.CONSTANT_MODULE_TAG, moduleName); }
/** * Adds a new CONSTANT_Double_info to the constant pool of this symbol table. * * @param index the constant pool index of the new Symbol. * @param tag one of {@link Symbol#CONSTANT_LONG_TAG} or {@link Symbol#CONSTANT_DOUBLE_TAG}. * @param value a long or double. */ private void addConstantLong(final int index, final int tag, final long value) { add(new Entry(index, tag, value, hash(tag, value))); }
/** * Returns a reference to the type of a formal parameter of a method. * * @param paramIndex the formal parameter index. * @return a reference to the type of the given method formal parameter. */ public static TypeReference newFormalParameterReference(final int paramIndex) { return new TypeReference((METHOD_FORMAL_PARAMETER << 24) | (paramIndex << 16)); }
/** * Adds a new CONSTANT_Integer_info or CONSTANT_Float_info to the constant pool of this symbol * table. * * @param index the constant pool index of the new Symbol. * @param tag one of {@link Symbol#CONSTANT_INTEGER_TAG} or {@link Symbol#CONSTANT_FLOAT_TAG}. * @param value an int or float. */ private void addConstantInteger(final int index, final int tag, final int value) { add(new Entry(index, tag, value, hash(tag, value))); }
/** * Adds a new CONSTANT_Class_info, CONSTANT_String_info, CONSTANT_MethodType_info, * CONSTANT_Module_info or CONSTANT_Package_info to the constant pool of this symbol table. * * @param index the constant pool index of the new Symbol. * @param tag one of {@link Symbol#CONSTANT_CLASS_TAG}, {@link Symbol#CONSTANT_STRING_TAG}, {@link * Symbol#CONSTANT_METHOD_TYPE_TAG}, {@link Symbol#CONSTANT_MODULE_TAG} or {@link * Symbol#CONSTANT_PACKAGE_TAG}. * @param value an internal class name, an arbitrary string, a method descriptor, a module or a * package name, depending on tag. */ private void addConstantUtf8Reference(final int index, final int tag, final String value) { add(new Entry(index, tag, value, hash(tag, value))); }