/** * Checks that the given string is a valid Java identifier. * * @param name the string to be checked. * @param msg a message to be used in case of error. */ static void checkIdentifier(final String name, final String msg) { checkIdentifier(name, 0, -1, msg); }
public void visitFormalTypeParameter(final String name) { if (type == TYPE_SIGNATURE || (state != EMPTY && state != FORMAL && state != BOUND)) { throw new IllegalStateException(); } CheckMethodAdapter.checkIdentifier(name, "formal type parameter"); state = FORMAL; if (sv != null) { sv.visitFormalTypeParameter(name); } }
public void visitInnerClassType(final String name) { if (state != CLASS_TYPE) { throw new IllegalStateException(); } CheckMethodAdapter.checkIdentifier(name, "inner class name"); if (sv != null) { sv.visitInnerClassType(name); } }
public void visitTypeVariable(final String name) { if (type != TYPE_SIGNATURE || state != EMPTY) { throw new IllegalStateException(); } CheckMethodAdapter.checkIdentifier(name, "type variable"); state = SIMPLE_TYPE; if (sv != null) { sv.visitTypeVariable(name); } }
slash = max; checkIdentifier(name, begin, slash, null); begin = slash + 1; } while (slash != max);
/** * Checks a type variable signature. * * @param signature a string containing the signature that must be checked. * @param pos index of first character to be checked. * @return the index of the first character after the checked part. */ private static int checkTypeVariableSignature( final String signature, int pos) { // TypeVariableSignature: // T Identifier ; pos = checkChar('T', signature, pos); pos = checkIdentifier(signature, pos); return checkChar(';', signature, pos); }
public void visitLocalVariable( final String name, final String desc, final String signature, final Label start, final Label end, final int index) { checkStartCode(); checkEndCode(); checkIdentifier(name, "name"); checkDesc(desc, false); checkLabel(start, true, "start label"); checkLabel(end, true, "end label"); checkUnsignedShort(index, "Invalid variable index"); int s = ((Integer) labels.get(start)).intValue(); int e = ((Integer) labels.get(end)).intValue(); if (e < s) { throw new IllegalArgumentException("Invalid start and end labels (end must be greater than start)"); } mv.visitLocalVariable(name, desc, signature, start, end, index); }
/** * Checks a class type signature. * * @param signature a string containing the signature that must be checked. * @param pos index of first character to be checked. * @return the index of the first character after the checked part. */ private static int checkClassTypeSignature(final String signature, int pos) { // ClassTypeSignature: // L Identifier ( / Identifier )* TypeArguments? ( . Identifier // TypeArguments? )* ; pos = checkChar('L', signature, pos); pos = checkIdentifier(signature, pos); while (getChar(signature, pos) == '/') { pos = checkIdentifier(signature, pos + 1); } if (getChar(signature, pos) == '<') { pos = checkTypeArguments(signature, pos); } while (getChar(signature, pos) == '.') { pos = checkIdentifier(signature, pos + 1); if (getChar(signature, pos) == '<') { pos = checkTypeArguments(signature, pos); } } return checkChar(';', signature, pos); }
/** * Checks a formal type parameter of a class or method signature. * * @param signature a string containing the signature that must be checked. * @param pos index of first character to be checked. * @return the index of the first character after the checked part. */ private static int checkFormalTypeParameter(final String signature, int pos) { // FormalTypeParameter: // Identifier : FieldTypeSignature? (: FieldTypeSignature)* pos = checkIdentifier(signature, pos); pos = checkChar(':', signature, pos); if ("L[T".indexOf(getChar(signature, pos)) != -1) { pos = checkFieldTypeSignature(signature, pos); } while (getChar(signature, pos) == ':') { pos = checkFieldTypeSignature(signature, pos + 1); } return pos; }
public void visitInnerClass( final String name, final String outerName, final String innerName, final int access) { checkState(); CheckMethodAdapter.checkInternalName(name, "class name"); if (outerName != null) { CheckMethodAdapter.checkInternalName(outerName, "outer class name"); } if (innerName != null) { CheckMethodAdapter.checkIdentifier(innerName, "inner class name"); } checkAccess(access, Opcodes.ACC_PUBLIC + Opcodes.ACC_PRIVATE + Opcodes.ACC_PROTECTED + Opcodes.ACC_STATIC + Opcodes.ACC_FINAL + Opcodes.ACC_INTERFACE + Opcodes.ACC_ABSTRACT + Opcodes.ACC_SYNTHETIC + Opcodes.ACC_ANNOTATION + Opcodes.ACC_ENUM); cv.visitInnerClass(name, outerName, innerName, access); }
public void visitFieldInsn( final int opcode, final String owner, final String name, final String desc) { checkStartCode(); checkEndCode(); checkOpcode(opcode, 4); checkInternalName(owner, "owner"); checkIdentifier(name, "name"); checkDesc(desc, false); mv.visitFieldInsn(opcode, owner, name, desc); }
public FieldVisitor visitField( final int access, final String name, final String desc, final String signature, final Object value) { checkState(); checkAccess(access, Opcodes.ACC_PUBLIC + Opcodes.ACC_PRIVATE + Opcodes.ACC_PROTECTED + Opcodes.ACC_STATIC + Opcodes.ACC_FINAL + Opcodes.ACC_VOLATILE + Opcodes.ACC_TRANSIENT + Opcodes.ACC_SYNTHETIC + Opcodes.ACC_ENUM + Opcodes.ACC_DEPRECATED); CheckMethodAdapter.checkIdentifier(name, "field name"); CheckMethodAdapter.checkDesc(desc, false); if (signature != null) { CheckMethodAdapter.checkFieldSignature(signature); } if (value != null) { CheckMethodAdapter.checkConstant(value); } FieldVisitor av = cv.visitField(access, name, desc, signature, value); return new CheckFieldAdapter(av); }
/** * Checks that the given string is a valid Java identifier. * * @param name the string to be checked. * @param msg a message to be used in case of error. */ static void checkIdentifier(final String name, final String msg) { checkIdentifier(name, 0, -1, msg); }
public void visitFormalTypeParameter(final String name) { if (type == TYPE_SIGNATURE || (state != EMPTY && state != FORMAL && state != BOUND)) { throw new IllegalStateException(); } CheckMethodAdapter.checkIdentifier(name, "formal type parameter"); state = FORMAL; if (sv != null) { sv.visitFormalTypeParameter(name); } }
public void visitTypeVariable(final String name) { if (type != TYPE_SIGNATURE || state != EMPTY) { throw new IllegalStateException(); } CheckMethodAdapter.checkIdentifier(name, "type variable"); state = SIMPLE_TYPE; if (sv != null) { sv.visitTypeVariable(name); } }
public void visitInnerClassType(final String name) { if (state != CLASS_TYPE) { throw new IllegalStateException(); } CheckMethodAdapter.checkIdentifier(name, "inner class name"); if (sv != null) { sv.visitInnerClassType(name); } }
/** * Checks a type variable signature. * * @param signature a string containing the signature that must be checked. * @param pos index of first character to be checked. * @return the index of the first character after the checked part. */ private static int checkTypeVariableSignature( final String signature, int pos) { // TypeVariableSignature: // T Identifier ; pos = checkChar('T', signature, pos); pos = checkIdentifier(signature, pos); return checkChar(';', signature, pos); }
/** * Checks a formal type parameter of a class or method signature. * * @param signature a string containing the signature that must be checked. * @param pos index of first character to be checked. * @return the index of the first character after the checked part. */ private static int checkFormalTypeParameter(final String signature, int pos) { // FormalTypeParameter: // Identifier : FieldTypeSignature? (: FieldTypeSignature)* pos = checkIdentifier(signature, pos); pos = checkChar(':', signature, pos); if ("L[T".indexOf(getChar(signature, pos)) != -1) { pos = checkFieldTypeSignature(signature, pos); } while (getChar(signature, pos) == ':') { pos = checkFieldTypeSignature(signature, pos + 1); } return pos; }
public void visitFieldInsn( final int opcode, final String owner, final String name, final String desc) { checkStartCode(); checkEndCode(); checkOpcode(opcode, 4); checkInternalName(owner, "owner"); checkIdentifier(name, "name"); checkDesc(desc, false); mv.visitFieldInsn(opcode, owner, name, desc); }
public void visitInnerClass( final String name, final String outerName, final String innerName, final int access) { checkState(); CheckMethodAdapter.checkInternalName(name, "class name"); if (outerName != null) { CheckMethodAdapter.checkInternalName(outerName, "outer class name"); } if (innerName != null) { CheckMethodAdapter.checkIdentifier(innerName, "inner class name"); } checkAccess(access, Opcodes.ACC_PUBLIC + Opcodes.ACC_PRIVATE + Opcodes.ACC_PROTECTED + Opcodes.ACC_STATIC + Opcodes.ACC_FINAL + Opcodes.ACC_INTERFACE + Opcodes.ACC_ABSTRACT + Opcodes.ACC_SYNTHETIC + Opcodes.ACC_ANNOTATION + Opcodes.ACC_ENUM); cv.visitInnerClass(name, outerName, innerName, access); }