--- old/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/ClassNode.java Fri Oct 27 09:24:31 2017
+++ new/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/ClassNode.java Fri Oct 27 09:24:31 2017
@@ -67,6 +67,7 @@
import jdk.internal.org.objectweb.asm.ClassVisitor;
import jdk.internal.org.objectweb.asm.FieldVisitor;
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.TypePath;
@@ -127,6 +128,11 @@
public String sourceDebug;
/**
+ * Module information. May be null.
+ */
+ public ModuleNode module;
+
+ /**
* The internal name of the enclosing class of the class. May be
* null.
*/
@@ -221,7 +227,7 @@
* If a subclass calls this constructor.
*/
public ClassNode() {
- this(Opcodes.ASM5);
+ this(Opcodes.ASM6);
if (getClass() != ClassNode.class) {
throw new IllegalStateException();
}
@@ -232,7 +238,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}.
*/
public ClassNode(final int api) {
super(api);
@@ -267,6 +273,12 @@
}
@Override
+ public ModuleVisitor visitModule(final String name, final int access,
+ final String version) {
+ return module = new ModuleNode(name, access, version);
+ }
+
+ @Override
public void visitOuterClass(final String owner, final String name,
final String desc) {
outerClass = owner;
@@ -358,11 +370,16 @@
* API than the given version.
*
* @param api
- * an ASM API version. Must be one of {@link Opcodes#ASM4} or
- * {@link Opcodes#ASM5}.
+ * an ASM API version. Must be one of {@link Opcodes#ASM4},
+ * {@link Opcodes#ASM5} or {@link Opcodes#ASM6}.
*/
public void check(final int api) {
- if (api == Opcodes.ASM4) {
+ if (api < Opcodes.ASM6) {
+ if (module != null) {
+ throw new RuntimeException();
+ }
+ }
+ if (api < Opcodes.ASM5) {
if (visibleTypeAnnotations != null
&& visibleTypeAnnotations.size() > 0) {
throw new RuntimeException();
@@ -371,13 +388,32 @@
&& invisibleTypeAnnotations.size() > 0) {
throw new RuntimeException();
}
- for (FieldNode f : fields) {
- f.check(api);
- }
- for (MethodNode m : methods) {
- m.check(api);
- }
}
+ // checks attributes
+ int i, n;
+ n = visibleAnnotations == null ? 0 : visibleAnnotations.size();
+ for (i = 0; i < n; ++i) {
+ visibleAnnotations.get(i).check(api);
+ }
+ n = invisibleAnnotations == null ? 0 : invisibleAnnotations.size();
+ for (i = 0; i < n; ++i) {
+ invisibleAnnotations.get(i).check(api);
+ }
+ n = visibleTypeAnnotations == null ? 0 : visibleTypeAnnotations.size();
+ for (i = 0; i < n; ++i) {
+ visibleTypeAnnotations.get(i).check(api);
+ }
+ n = invisibleTypeAnnotations == null ? 0 : invisibleTypeAnnotations
+ .size();
+ for (i = 0; i < n; ++i) {
+ invisibleTypeAnnotations.get(i).check(api);
+ }
+ for (FieldNode f : fields) {
+ f.check(api);
+ }
+ for (MethodNode m : methods) {
+ m.check(api);
+ }
}
/**
@@ -395,6 +431,10 @@
if (sourceFile != null || sourceDebug != null) {
cv.visitSource(sourceFile, sourceDebug);
}
+ // visits module
+ if (module != null) {
+ module.accept(cv);
+ }
// visits outer class
if (outerClass != null) {
cv.visitOuterClass(outerClass, outerMethod, outerMethodDesc);