--- old/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/CheckClassAdapter.java Fri Oct 27 09:24:51 2017 +++ new/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/CheckClassAdapter.java Fri Oct 27 09:24:50 2017 @@ -73,6 +73,7 @@ import jdk.internal.org.objectweb.asm.FieldVisitor; import jdk.internal.org.objectweb.asm.Label; import jdk.internal.org.objectweb.asm.MethodVisitor; +import jdk.internal.org.objectweb.asm.ModuleVisitor; import jdk.internal.org.objectweb.asm.Opcodes; import jdk.internal.org.objectweb.asm.Type; import jdk.internal.org.objectweb.asm.TypePath; @@ -181,6 +182,11 @@ private boolean end; /** + * true if the visitModule method has been called. + */ + private boolean module; + + /** * The already visited labels. This map associate Integer values to Label * keys. */ @@ -363,7 +369,7 @@ * If a subclass calls this constructor. */ public CheckClassAdapter(final ClassVisitor cv, final boolean checkDataFlow) { - this(Opcodes.ASM5, cv, checkDataFlow); + this(Opcodes.ASM6, cv, checkDataFlow); if (getClass() != CheckClassAdapter.class) { throw new IllegalStateException(); } @@ -374,7 +380,7 @@ * * @param api * the ASM API version implemented by this visitor. Must be one - * of {@link Opcodes#ASM4} or {@link Opcodes#ASM5}. + * of {@link Opcodes#ASM4}, {@link Opcodes#ASM5} or {@link Opcodes#ASM6}. * @param cv * the class visitor to which this adapter must delegate calls. * @param checkDataFlow @@ -407,8 +413,12 @@ + Opcodes.ACC_SUPER + Opcodes.ACC_INTERFACE + Opcodes.ACC_ABSTRACT + Opcodes.ACC_SYNTHETIC + Opcodes.ACC_ANNOTATION + Opcodes.ACC_ENUM - + Opcodes.ACC_DEPRECATED + 0x40000); // ClassWriter.ACC_SYNTHETIC_ATTRIBUTE - if (name == null || !name.endsWith("package-info")) { + + Opcodes.ACC_DEPRECATED + Opcodes.ACC_MODULE + + 0x40000); // ClassWriter.ACC_SYNTHETIC_ATTRIBUTE + if (name == null) { + throw new IllegalArgumentException("Illegal class name (null)"); + } + if (!name.endsWith("package-info")) { CheckMethodAdapter.checkInternalName(name, "class name"); } if ("java/lang/Object".equals(name)) { @@ -449,6 +459,22 @@ super.visitSource(file, debug); } + @Override + public ModuleVisitor visitModule(String name, int access, String version) { + checkState(); + if (module) { + throw new IllegalStateException( + "visitModule can be called only once."); + } + module = true; + if (name == null) { + throw new IllegalArgumentException("Illegal module name (null)"); + } + checkAccess(access, Opcodes.ACC_OPEN | Opcodes.ACC_SYNTHETIC); + return new CheckModuleAdapter(super.visitModule(name, access, version), + (access & Opcodes.ACC_OPEN) != 0); + } + @Override public void visitOuterClass(final String owner, final String name, final String desc) {