@Test public void testVisit_nonJavaIdentifierClassNamePost15() { CheckClassAdapter checkClassAdapter = new CheckClassAdapter(null); Executable visit = () -> checkClassAdapter.visit(V1_5, 0, "class name", null, "java/lang/Object", null); assertDoesNotThrow(visit); }
@Override public void visit( final int version, final int access, final String name, final String signature, final String superName, final String[] interfaces) { if (visitCalled) { throw new IllegalStateException("visit must be called only once"); } visitCalled = true; checkState(); checkAccess( access, Opcodes.ACC_PUBLIC | Opcodes.ACC_FINAL | Opcodes.ACC_SUPER | Opcodes.ACC_INTERFACE | Opcodes.ACC_ABSTRACT | Opcodes.ACC_SYNTHETIC | Opcodes.ACC_ANNOTATION | Opcodes.ACC_ENUM | Opcodes.ACC_DEPRECATED | Opcodes.ACC_MODULE); if (name == null) { throw new IllegalArgumentException("Illegal class name (null)"); } if (!name.endsWith("package-info") && !name.endsWith("module-info")) { CheckMethodAdapter.checkInternalName(version, name, "class name"); } if ("java/lang/Object".equals(name)) { if (superName != null) { throw new IllegalArgumentException( "The super class name of the Object class must be 'null'"); } } else if (name.endsWith("module-info")) { if (superName != null) { throw new IllegalArgumentException( "The super class name of a module-info class must be 'null'"); } } else { CheckMethodAdapter.checkInternalName(version, superName, "super class name"); } if (signature != null) { checkClassSignature(signature); } if ((access & Opcodes.ACC_INTERFACE) != 0 && !"java/lang/Object".equals(superName)) { throw new IllegalArgumentException( "The super class name of interfaces must be 'java/lang/Object'"); } if (interfaces != null) { for (int i = 0; i < interfaces.length; ++i) { CheckMethodAdapter.checkInternalName( version, interfaces[i], "interface name at index " + i); } } this.version = version; super.visit(version, access, name, signature, superName, interfaces); }
CheckClassAdapter extends ClassVisitor { @Override public void visit( final int version, final int access, final String name, final String signature, final String superName, final String[] interfaces) { if (visitCalled) { throw new IllegalStateException("visit must be called only once"); } visitCalled = true; checkState(); checkAccess( access, Opcodes.ACC_PUBLIC | Opcodes.ACC_FINAL | Opcodes.ACC_SUPER | Opcodes.ACC_INTERFACE | Opcodes.ACC_ABSTRACT | Opcodes.ACC_SYNTHETIC | Opcodes.ACC_ANNOTATION | Opcodes.ACC_ENUM | Opcodes.ACC_DEPRECATED | Opcodes.ACC_MODULE); if (name == null) { throw new IllegalArgumentException("Illegal class name (null)"); } if (!name.endsWith("package-info") && !name.endsWith("module-info")) { CheckMethodAdapter.checkInternalName(version, name, "class name"); } if ("java/lang/Object".equals(name)) { if (superName != null) { throw new IllegalArgumentException( "The super class name of the Object class must be 'null'"); } } else if (name.endsWith("module-info")) { if (superName != null) { throw new IllegalArgumentException( "The super class name of a module-info class must be 'null'"); } } else { CheckMethodAdapter.checkInternalName(version, superName, "super class name"); } if (signature != null) { checkClassSignature(signature); } if ((access & Opcodes.ACC_INTERFACE) != 0 && !"java/lang/Object".equals(superName)) { throw new IllegalArgumentException( "The super class name of interfaces must be 'java/lang/Object'"); } if (interfaces != null) { for (int i = 0; i < interfaces.length; ++i) { CheckMethodAdapter.checkInternalName( version, interfaces[i], "interface name at index " + i); } } this.version = version; super.visit(version, access, name, signature, superName, interfaces); } }
CheckClassAdapter extends ClassVisitor { @Override public void visit( final int version, final int access, final String name, final String signature, final String superName, final String[] interfaces) { if (visitCalled) { throw new IllegalStateException("visit must be called only once"); } visitCalled = true; checkState(); checkAccess( access, Opcodes.ACC_PUBLIC | Opcodes.ACC_FINAL | Opcodes.ACC_SUPER | Opcodes.ACC_INTERFACE | Opcodes.ACC_ABSTRACT | Opcodes.ACC_SYNTHETIC | Opcodes.ACC_ANNOTATION | Opcodes.ACC_ENUM | Opcodes.ACC_DEPRECATED | Opcodes.ACC_MODULE); if (name == null) { throw new IllegalArgumentException("Illegal class name (null)"); } if (!name.endsWith("package-info") && !name.endsWith("module-info")) { CheckMethodAdapter.checkInternalName(version, name, "class name"); } if ("java/lang/Object".equals(name)) { if (superName != null) { throw new IllegalArgumentException( "The super class name of the Object class must be 'null'"); } } else if (name.endsWith("module-info")) { if (superName != null) { throw new IllegalArgumentException( "The super class name of a module-info class must be 'null'"); } } else { CheckMethodAdapter.checkInternalName(version, superName, "super class name"); } if (signature != null) { checkClassSignature(signature); } if ((access & Opcodes.ACC_INTERFACE) != 0 && !"java/lang/Object".equals(superName)) { throw new IllegalArgumentException( "The super class name of interfaces must be 'java/lang/Object'"); } if (interfaces != null) { for (int i = 0; i < interfaces.length; ++i) { CheckMethodAdapter.checkInternalName( version, interfaces[i], "interface name at index " + i); } } this.version = version; super.visit(version, access, name, signature, superName, interfaces); } CheckClassAdapter(final ClassVisitor classVisitor);  CheckClassAdapter(final ClassVisitor classVisitor, final boolean checkDataFlow); protected  CheckClassAdapter(
      final int api, final ClassVisitor classVisitor, final boolean checkDataFlow); }
CheckClassAdapter extends ClassVisitor { @Override public void visit( final int version, final int access, final String name, final String signature, final String superName, final String[] interfaces) { if (visitCalled) { throw new IllegalStateException("visit must be called only once"); } visitCalled = true; checkState(); checkAccess( access, Opcodes.ACC_PUBLIC | Opcodes.ACC_FINAL | Opcodes.ACC_SUPER | Opcodes.ACC_INTERFACE | Opcodes.ACC_ABSTRACT | Opcodes.ACC_SYNTHETIC | Opcodes.ACC_ANNOTATION | Opcodes.ACC_ENUM | Opcodes.ACC_DEPRECATED | Opcodes.ACC_MODULE); if (name == null) { throw new IllegalArgumentException("Illegal class name (null)"); } if (!name.endsWith("package-info") && !name.endsWith("module-info")) { CheckMethodAdapter.checkInternalName(version, name, "class name"); } if ("java/lang/Object".equals(name)) { if (superName != null) { throw new IllegalArgumentException( "The super class name of the Object class must be 'null'"); } } else if (name.endsWith("module-info")) { if (superName != null) { throw new IllegalArgumentException( "The super class name of a module-info class must be 'null'"); } } else { CheckMethodAdapter.checkInternalName(version, superName, "super class name"); } if (signature != null) { checkClassSignature(signature); } if ((access & Opcodes.ACC_INTERFACE) != 0 && !"java/lang/Object".equals(superName)) { throw new IllegalArgumentException( "The super class name of interfaces must be 'java/lang/Object'"); } if (interfaces != null) { for (int i = 0; i < interfaces.length; ++i) { CheckMethodAdapter.checkInternalName( version, interfaces[i], "interface name at index " + i); } } this.version = version; super.visit(version, access, name, signature, superName, interfaces); } CheckClassAdapter(final ClassVisitor classVisitor);  CheckClassAdapter(final ClassVisitor classVisitor, final boolean checkDataFlow); protected  CheckClassAdapter(
      final int api, final ClassVisitor classVisitor, final boolean checkDataFlow); @Override void visit(
      final int version,
      final int access,
      final String name,
      final String signature,
      final String superName,
      final String[] interfaces); @Override void visitSource(final String file, final String debug); @Override ModuleVisitor visitModule(final String name, final int access, final String version); @Override void visitNestHost(final String nestHost); @Override void visitNestMember(final String nestMember); @Override void visitOuterClass(final String owner, final String name, final String descriptor); @Override void visitInnerClass(
      final String name, final String outerName, final String innerName, final int access); @Override FieldVisitor visitField(
      final int access,
      final String name,
      final String descriptor,
      final String signature,
      final Object value); @Override MethodVisitor visitMethod(
      final int access,
      final String name,
      final String descriptor,
      final String signature,
      final String[] exceptions); @Override AnnotationVisitor visitAnnotation(final String descriptor, final boolean visible); @Override AnnotationVisitor visitTypeAnnotation(
      final int typeRef, final TypePath typePath, final String descriptor, final boolean visible); @Override void visitAttribute(final Attribute attribute); @Override void visitEnd(); static void checkClassSignature(final String signature); static void checkMethodSignature(final String signature); static void checkFieldSignature(final String signature); static void main(final String[] args); static void verify(
      final ClassReader classReader, final boolean printResults, final PrintWriter printWriter); static void verify(
      final ClassReader classReader,
      final ClassLoader loader,
      final boolean printResults,
      final PrintWriter printWriter); }
CheckClassAdapter extends ClassVisitor { @Override public void visit( final int version, final int access, final String name, final String signature, final String superName, final String[] interfaces) { if (visitCalled) { throw new IllegalStateException("visit must be called only once"); } visitCalled = true; checkState(); checkAccess( access, Opcodes.ACC_PUBLIC | Opcodes.ACC_FINAL | Opcodes.ACC_SUPER | Opcodes.ACC_INTERFACE | Opcodes.ACC_ABSTRACT | Opcodes.ACC_SYNTHETIC | Opcodes.ACC_ANNOTATION | Opcodes.ACC_ENUM | Opcodes.ACC_DEPRECATED | Opcodes.ACC_MODULE); if (name == null) { throw new IllegalArgumentException("Illegal class name (null)"); } if (!name.endsWith("package-info") && !name.endsWith("module-info")) { CheckMethodAdapter.checkInternalName(version, name, "class name"); } if ("java/lang/Object".equals(name)) { if (superName != null) { throw new IllegalArgumentException( "The super class name of the Object class must be 'null'"); } } else if (name.endsWith("module-info")) { if (superName != null) { throw new IllegalArgumentException( "The super class name of a module-info class must be 'null'"); } } else { CheckMethodAdapter.checkInternalName(version, superName, "super class name"); } if (signature != null) { checkClassSignature(signature); } if ((access & Opcodes.ACC_INTERFACE) != 0 && !"java/lang/Object".equals(superName)) { throw new IllegalArgumentException( "The super class name of interfaces must be 'java/lang/Object'"); } if (interfaces != null) { for (int i = 0; i < interfaces.length; ++i) { CheckMethodAdapter.checkInternalName( version, interfaces[i], "interface name at index " + i); } } this.version = version; super.visit(version, access, name, signature, superName, interfaces); } CheckClassAdapter(final ClassVisitor classVisitor);  CheckClassAdapter(final ClassVisitor classVisitor, final boolean checkDataFlow); protected  CheckClassAdapter(
      final int api, final ClassVisitor classVisitor, final boolean checkDataFlow); @Override void visit(
      final int version,
      final int access,
      final String name,
      final String signature,
      final String superName,
      final String[] interfaces); @Override void visitSource(final String file, final String debug); @Override ModuleVisitor visitModule(final String name, final int access, final String version); @Override void visitNestHost(final String nestHost); @Override void visitNestMember(final String nestMember); @Override void visitOuterClass(final String owner, final String name, final String descriptor); @Override void visitInnerClass(
      final String name, final String outerName, final String innerName, final int access); @Override FieldVisitor visitField(
      final int access,
      final String name,
      final String descriptor,
      final String signature,
      final Object value); @Override MethodVisitor visitMethod(
      final int access,
      final String name,
      final String descriptor,
      final String signature,
      final String[] exceptions); @Override AnnotationVisitor visitAnnotation(final String descriptor, final boolean visible); @Override AnnotationVisitor visitTypeAnnotation(
      final int typeRef, final TypePath typePath, final String descriptor, final boolean visible); @Override void visitAttribute(final Attribute attribute); @Override void visitEnd(); static void checkClassSignature(final String signature); static void checkMethodSignature(final String signature); static void checkFieldSignature(final String signature); static void main(final String[] args); static void verify(
      final ClassReader classReader, final boolean printResults, final PrintWriter printWriter); static void verify(
      final ClassReader classReader,
      final ClassLoader loader,
      final boolean printResults,
      final PrintWriter printWriter);  }