@Test public void testAccept_invalidSignature() { String invalidSignature = "-"; SignatureReader signatureReader = new SignatureReader(invalidSignature); SignatureVisitor signatureVisitor = new SignatureVisitor(Opcodes.ASM7) {}; Executable acceptVisitor = () -> signatureReader.accept(signatureVisitor); assertThrows(IllegalArgumentException.class, acceptVisitor); }
public void accept(final SignatureVisitor signatureVistor) { String signature = this.signatureValue; int length = signature.length(); int offset; char currentChar; if (signature.charAt(0) == '<') { offset = 2; do { int classBoundStartOffset = signature.indexOf(':', offset); signatureVistor.visitFormalTypeParameter( signature.substring(offset - 1, classBoundStartOffset)); offset = classBoundStartOffset + 1; currentChar = signature.charAt(offset); if (currentChar == 'L' || currentChar == '[' || currentChar == 'T') { offset = parseType(signature, offset, signatureVistor.visitClassBound()); } while ((currentChar = signature.charAt(offset++)) == ':') { offset = parseType(signature, offset, signatureVistor.visitInterfaceBound()); } } while (currentChar != '>'); } else { offset = 0; } if (signature.charAt(offset) == '(') { offset++; while (signature.charAt(offset) != ')') { offset = parseType(signature, offset, signatureVistor.visitParameterType()); } offset = parseType(signature, offset + 1, signatureVistor.visitReturnType()); while (offset < length) { offset = parseType(signature, offset + 1, signatureVistor.visitExceptionType()); } } else { offset = parseType(signature, offset, signatureVistor.visitSuperclass()); while (offset < length) { offset = parseType(signature, offset, signatureVistor.visitInterface()); } } }
SignatureReader { public void accept(final SignatureVisitor signatureVistor) { String signature = this.signatureValue; int length = signature.length(); int offset; char currentChar; if (signature.charAt(0) == '<') { offset = 2; do { int classBoundStartOffset = signature.indexOf(':', offset); signatureVistor.visitFormalTypeParameter( signature.substring(offset - 1, classBoundStartOffset)); offset = classBoundStartOffset + 1; currentChar = signature.charAt(offset); if (currentChar == 'L' || currentChar == '[' || currentChar == 'T') { offset = parseType(signature, offset, signatureVistor.visitClassBound()); } while ((currentChar = signature.charAt(offset++)) == ':') { offset = parseType(signature, offset, signatureVistor.visitInterfaceBound()); } } while (currentChar != '>'); } else { offset = 0; } if (signature.charAt(offset) == '(') { offset++; while (signature.charAt(offset) != ')') { offset = parseType(signature, offset, signatureVistor.visitParameterType()); } offset = parseType(signature, offset + 1, signatureVistor.visitReturnType()); while (offset < length) { offset = parseType(signature, offset + 1, signatureVistor.visitExceptionType()); } } else { offset = parseType(signature, offset, signatureVistor.visitSuperclass()); while (offset < length) { offset = parseType(signature, offset, signatureVistor.visitInterface()); } } } }
SignatureReader { public void accept(final SignatureVisitor signatureVistor) { String signature = this.signatureValue; int length = signature.length(); int offset; char currentChar; if (signature.charAt(0) == '<') { offset = 2; do { int classBoundStartOffset = signature.indexOf(':', offset); signatureVistor.visitFormalTypeParameter( signature.substring(offset - 1, classBoundStartOffset)); offset = classBoundStartOffset + 1; currentChar = signature.charAt(offset); if (currentChar == 'L' || currentChar == '[' || currentChar == 'T') { offset = parseType(signature, offset, signatureVistor.visitClassBound()); } while ((currentChar = signature.charAt(offset++)) == ':') { offset = parseType(signature, offset, signatureVistor.visitInterfaceBound()); } } while (currentChar != '>'); } else { offset = 0; } if (signature.charAt(offset) == '(') { offset++; while (signature.charAt(offset) != ')') { offset = parseType(signature, offset, signatureVistor.visitParameterType()); } offset = parseType(signature, offset + 1, signatureVistor.visitReturnType()); while (offset < length) { offset = parseType(signature, offset + 1, signatureVistor.visitExceptionType()); } } else { offset = parseType(signature, offset, signatureVistor.visitSuperclass()); while (offset < length) { offset = parseType(signature, offset, signatureVistor.visitInterface()); } } } SignatureReader(final String signature); }
SignatureReader { public void accept(final SignatureVisitor signatureVistor) { String signature = this.signatureValue; int length = signature.length(); int offset; char currentChar; if (signature.charAt(0) == '<') { offset = 2; do { int classBoundStartOffset = signature.indexOf(':', offset); signatureVistor.visitFormalTypeParameter( signature.substring(offset - 1, classBoundStartOffset)); offset = classBoundStartOffset + 1; currentChar = signature.charAt(offset); if (currentChar == 'L' || currentChar == '[' || currentChar == 'T') { offset = parseType(signature, offset, signatureVistor.visitClassBound()); } while ((currentChar = signature.charAt(offset++)) == ':') { offset = parseType(signature, offset, signatureVistor.visitInterfaceBound()); } } while (currentChar != '>'); } else { offset = 0; } if (signature.charAt(offset) == '(') { offset++; while (signature.charAt(offset) != ')') { offset = parseType(signature, offset, signatureVistor.visitParameterType()); } offset = parseType(signature, offset + 1, signatureVistor.visitReturnType()); while (offset < length) { offset = parseType(signature, offset + 1, signatureVistor.visitExceptionType()); } } else { offset = parseType(signature, offset, signatureVistor.visitSuperclass()); while (offset < length) { offset = parseType(signature, offset, signatureVistor.visitInterface()); } } } SignatureReader(final String signature); void accept(final SignatureVisitor signatureVistor); void acceptType(final SignatureVisitor signatureVisitor); }
SignatureReader { public void accept(final SignatureVisitor signatureVistor) { String signature = this.signatureValue; int length = signature.length(); int offset; char currentChar; if (signature.charAt(0) == '<') { offset = 2; do { int classBoundStartOffset = signature.indexOf(':', offset); signatureVistor.visitFormalTypeParameter( signature.substring(offset - 1, classBoundStartOffset)); offset = classBoundStartOffset + 1; currentChar = signature.charAt(offset); if (currentChar == 'L' || currentChar == '[' || currentChar == 'T') { offset = parseType(signature, offset, signatureVistor.visitClassBound()); } while ((currentChar = signature.charAt(offset++)) == ':') { offset = parseType(signature, offset, signatureVistor.visitInterfaceBound()); } } while (currentChar != '>'); } else { offset = 0; } if (signature.charAt(offset) == '(') { offset++; while (signature.charAt(offset) != ')') { offset = parseType(signature, offset, signatureVistor.visitParameterType()); } offset = parseType(signature, offset + 1, signatureVistor.visitReturnType()); while (offset < length) { offset = parseType(signature, offset + 1, signatureVistor.visitExceptionType()); } } else { offset = parseType(signature, offset, signatureVistor.visitSuperclass()); while (offset < length) { offset = parseType(signature, offset, signatureVistor.visitInterface()); } } } SignatureReader(final String signature); void accept(final SignatureVisitor signatureVistor); void acceptType(final SignatureVisitor signatureVisitor);  }