/** * Checks a class signature. * * @param signature * a string containing the signature that must be checked. */ public static void checkClassSignature(final String signature) { // ClassSignature: // FormalTypeParameters? ClassTypeSignature ClassTypeSignature* int pos = 0; if (getChar(signature, 0) == '<') { pos = checkFormalTypeParameters(signature, pos); } pos = checkClassTypeSignature(signature, pos); while (getChar(signature, pos) == 'L') { pos = checkClassTypeSignature(signature, pos); } if (pos != signature.length()) { throw new IllegalArgumentException(signature + ": error at index " + pos); } }
/** * Checks a class signature. * * @param signature a string containing the signature that must be checked. */ public static void checkClassSignature(final String signature) { // From https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.7.9.1: // ClassSignature: // [TypeParameters] SuperclassSignature SuperinterfaceSignature* // SuperclassSignature: // ClassTypeSignature // SuperinterfaceSignature: // ClassTypeSignature int pos = 0; if (getChar(signature, 0) == '<') { pos = checkTypeParameters(signature, pos); } pos = checkClassTypeSignature(signature, pos); while (getChar(signature, pos) == 'L') { pos = checkClassTypeSignature(signature, pos); } if (pos != signature.length()) { throw new IllegalArgumentException(signature + ERROR_AT + pos); } }
/** * Checks a class signature. * * @param signature a string containing the signature that must be checked. */ public static void checkClassSignature(final String signature) { // From https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.7.9.1: // ClassSignature: // [TypeParameters] SuperclassSignature SuperinterfaceSignature* // SuperclassSignature: // ClassTypeSignature // SuperinterfaceSignature: // ClassTypeSignature int pos = 0; if (getChar(signature, 0) == '<') { pos = checkTypeParameters(signature, pos); } pos = checkClassTypeSignature(signature, pos); while (getChar(signature, pos) == 'L') { pos = checkClassTypeSignature(signature, pos); } if (pos != signature.length()) { throw new IllegalArgumentException(signature + ERROR_AT + pos); } }
/** * Checks a reference 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 checkReferenceTypeSignature(final String signature, final int pos) { // From https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.7.9.1: // ReferenceTypeSignature: // ClassTypeSignature // TypeVariableSignature // ArrayTypeSignature // ArrayTypeSignature: // [ JavaTypeSignature switch (getChar(signature, pos)) { case 'L': return checkClassTypeSignature(signature, pos); case '[': return checkJavaTypeSignature(signature, pos + 1); default: return checkTypeVariableSignature(signature, pos); } }
/** * Checks a field 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 checkFieldTypeSignature(final String signature, int pos) { // FieldTypeSignature: // ClassTypeSignature | ArrayTypeSignature | TypeVariableSignature // // ArrayTypeSignature: // [ TypeSignature switch (getChar(signature, pos)) { case 'L': return checkClassTypeSignature(signature, pos); case '[': return checkTypeSignature(signature, pos + 1); default: return checkTypeVariableSignature(signature, pos); } }
/** * Checks a reference 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 checkReferenceTypeSignature(final String signature, final int pos) { // From https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.7.9.1: // ReferenceTypeSignature: // ClassTypeSignature // TypeVariableSignature // ArrayTypeSignature // ArrayTypeSignature: // [ JavaTypeSignature switch (getChar(signature, pos)) { case 'L': return checkClassTypeSignature(signature, pos); case '[': return checkJavaTypeSignature(signature, pos + 1); default: return checkTypeVariableSignature(signature, pos); } }
++pos; if (getChar(signature, pos) == 'L') { pos = checkClassTypeSignature(signature, pos); } else { pos = checkTypeVariableSignature(signature, pos);
++pos; if (getChar(signature, pos) == 'L') { pos = checkClassTypeSignature(signature, pos); } else { pos = checkTypeVariableSignature(signature, pos);
++pos; if (getChar(signature, pos) == 'L') { pos = checkClassTypeSignature(signature, pos); } else { pos = checkTypeVariableSignature(signature, pos);