8308753: Class-File API transition to Preview

Reviewed-by: ihse, mchung, vromero
This commit is contained in:
Adam Sotona 2023-12-04 07:07:57 +00:00
parent b9df827adc
commit 2b00ac0d02
681 changed files with 7518 additions and 6502 deletions

View file

@ -26,13 +26,9 @@
* @bug 8159602 8170549 8171255 8171322 8254023
* @summary Test annotations on module declaration.
* @library /tools/lib
* @enablePreview
* @modules jdk.compiler/com.sun.tools.javac.api
* jdk.compiler/com.sun.tools.javac.main
* java.base/jdk.internal.classfile
* java.base/jdk.internal.classfile.attribute
* java.base/jdk.internal.classfile.constantpool
* java.base/jdk.internal.classfile.instruction
* java.base/jdk.internal.classfile.components
* java.base/jdk.internal.classfile.impl
* @build toolbox.ToolBox toolbox.JavacTask ModuleTestBase
* @run main AnnotationsOnModules
@ -56,9 +52,9 @@ import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.ModuleElement;
import javax.lang.model.element.TypeElement;
import jdk.internal.classfile.*;
import jdk.internal.classfile.Classfile;
import jdk.internal.classfile.attribute.*;
import java.lang.classfile.*;
import java.lang.classfile.ClassFile;
import java.lang.classfile.attribute.*;
import toolbox.JavacTask;
import toolbox.Task;
import toolbox.Task.OutputKind;
@ -89,7 +85,7 @@ public class AnnotationsOnModules extends ModuleTestBase {
.run()
.writeAll();
ClassModel cf = Classfile.of().parse(modulePath.resolve("m1x").resolve("module-info.class"));
ClassModel cf = ClassFile.of().parse(modulePath.resolve("m1x").resolve("module-info.class"));
RuntimeVisibleAnnotationsAttribute annotations = cf.findAttribute(Attributes.RUNTIME_VISIBLE_ANNOTATIONS).orElse(null);
if (annotations == null || annotations.annotations().size() != 1) {
@ -143,7 +139,7 @@ public class AnnotationsOnModules extends ModuleTestBase {
throw new AssertionError("Output is not empty. Expected no output and no warnings.");
}
ClassModel cf = Classfile.of().parse(modulePath.resolve("A").resolve("module-info.class"));
ClassModel cf = ClassFile.of().parse(modulePath.resolve("A").resolve("module-info.class"));
RuntimeVisibleAnnotationsAttribute annotations = cf.findAttribute(Attributes.RUNTIME_VISIBLE_ANNOTATIONS).orElse(null);
if (annotations != null && annotations.annotations().size() > 0) {
@ -194,7 +190,7 @@ public class AnnotationsOnModules extends ModuleTestBase {
throw new AssertionError("Expected output not found. Expected: " + expected);
}
ClassModel cf = Classfile.of().parse(modulePath.resolve("A").resolve("module-info.class"));
ClassModel cf = ClassFile.of().parse(modulePath.resolve("A").resolve("module-info.class"));
RuntimeVisibleAnnotationsAttribute annotations = cf.findAttribute(Attributes.RUNTIME_VISIBLE_ANNOTATIONS).orElse(null);
if (annotations == null ) {
@ -317,7 +313,7 @@ public class AnnotationsOnModules extends ModuleTestBase {
.run()
.writeAll();
ClassModel cf = Classfile.of().parse(modulePath.resolve("m1x").resolve("module-info.class"));
ClassModel cf = ClassFile.of().parse(modulePath.resolve("m1x").resolve("module-info.class"));
RuntimeInvisibleAnnotationsAttribute annotations = cf.findAttribute(Attributes.RUNTIME_INVISIBLE_ANNOTATIONS).orElse(null);
if (annotations == null || annotations.annotations().size() != 1) {
@ -359,7 +355,7 @@ public class AnnotationsOnModules extends ModuleTestBase {
.run()
.writeAll();
ClassModel cf = Classfile.of().parse(modulePath.resolve("B").resolve("module-info.class"));
ClassModel cf = ClassFile.of().parse(modulePath.resolve("B").resolve("module-info.class"));
RuntimeInvisibleAnnotationsAttribute annotations = cf.findAttribute(Attributes.RUNTIME_INVISIBLE_ANNOTATIONS).orElse(null);
if (annotations == null ) {
@ -434,7 +430,7 @@ public class AnnotationsOnModules extends ModuleTestBase {
.run()
.writeAll();
ClassModel cf = Classfile.of().parse(classes.resolve("m1x").resolve("module-info.class"));
ClassModel cf = ClassFile.of().parse(classes.resolve("m1x").resolve("module-info.class"));
RuntimeInvisibleAnnotationsAttribute invisibleAnnotations = cf.findAttribute(Attributes.RUNTIME_INVISIBLE_ANNOTATIONS).orElse(null);
if (invisibleAnnotations == null) {