< prev index next >

src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/ClassNode.java

Print this page
rev 47452 : imported patch jdk-new-asmv6.patch

*** 65,74 **** --- 65,75 ---- import jdk.internal.org.objectweb.asm.AnnotationVisitor; import jdk.internal.org.objectweb.asm.Attribute; 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; /** * A node that represents a class.
*** 125,134 **** --- 126,140 ---- * compiled elements of the class. May be <tt>null</tt>. */ public String sourceDebug; /** + * Module information. May be <tt>null</tt>. + */ + public ModuleNode module; + + /** * The internal name of the enclosing class of the class. May be * <tt>null</tt>. */ public String outerClass;
*** 219,229 **** * * @throws IllegalStateException * If a subclass calls this constructor. */ public ClassNode() { ! this(Opcodes.ASM5); if (getClass() != ClassNode.class) { throw new IllegalStateException(); } } --- 225,235 ---- * * @throws IllegalStateException * If a subclass calls this constructor. */ public ClassNode() { ! this(Opcodes.ASM6); if (getClass() != ClassNode.class) { throw new IllegalStateException(); } }
*** 230,240 **** /** * Constructs a new {@link ClassNode}. * * @param api * the ASM API version implemented by this visitor. Must be one ! * of {@link Opcodes#ASM4} or {@link Opcodes#ASM5}. */ public ClassNode(final int api) { super(api); this.interfaces = new ArrayList<String>(); this.innerClasses = new ArrayList<InnerClassNode>(); --- 236,246 ---- /** * Constructs a new {@link ClassNode}. * * @param api * the ASM API version implemented by this visitor. Must be one ! * of {@link Opcodes#ASM4}, {@link Opcodes#ASM5} or {@link Opcodes#ASM6}. */ public ClassNode(final int api) { super(api); this.interfaces = new ArrayList<String>(); this.innerClasses = new ArrayList<InnerClassNode>();
*** 265,274 **** --- 271,286 ---- sourceFile = file; sourceDebug = debug; } @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; outerMethod = name; outerMethodDesc = desc;
*** 356,386 **** * This methods checks that this node, and all its nodes recursively, do not * contain elements that were introduced in more recent versions of the ASM * API than the given version. * * @param api ! * an ASM API version. Must be one of {@link Opcodes#ASM4} or ! * {@link Opcodes#ASM5}. */ public void check(final int api) { ! if (api == Opcodes.ASM4) { if (visibleTypeAnnotations != null && visibleTypeAnnotations.size() > 0) { throw new RuntimeException(); } if (invisibleTypeAnnotations != null && invisibleTypeAnnotations.size() > 0) { throw new RuntimeException(); } for (FieldNode f : fields) { f.check(api); } for (MethodNode m : methods) { m.check(api); } } - } /** * Makes the given class visitor visit this class. * * @param cv --- 368,422 ---- * This methods checks that this node, and all its nodes recursively, do not * contain elements that were introduced in more recent versions of the ASM * API than the given version. * * @param api ! * 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.ASM6) { ! if (module != null) { ! throw new RuntimeException(); ! } ! } ! if (api < Opcodes.ASM5) { if (visibleTypeAnnotations != null && visibleTypeAnnotations.size() > 0) { throw new RuntimeException(); } if (invisibleTypeAnnotations != null && invisibleTypeAnnotations.size() > 0) { throw new RuntimeException(); } + } + // 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); } } /** * Makes the given class visitor visit this class. * * @param cv
*** 393,402 **** --- 429,442 ---- cv.visit(version, access, name, signature, superName, interfaces); // visits source 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); } // visits attributes
< prev index next >