30 * not set in the access_flags.
31 * @bug 8175383
32 * @library /test/lib
33 * @modules java.base/jdk.internal.org.objectweb.asm
34 * @compile -XDignore.symbol.file ConstModule.java
35 * @run main ConstModule
36 */
37
38 public class ConstModule {
39
40 static final int ACC_MODULE = 0x8000;
41 static final boolean MODULE_TEST = true;
42 static final boolean PACKAGE_TEST = false;
43 static final boolean CFE_EXCEPTION = true;
44 static final boolean NCDFE_EXCEPTION = false;
45
46 public static void main(String[] args) throws Exception {
47
48 // Test that the JVM throws CFE for constant pool CONSTANT_Module type, for
49 // class file version 53, when ACC_MODULE is not set in the access_flags.
50 ConstModule.write_and_load(Opcodes.V1_9,
51 Opcodes.ACC_INTERFACE + Opcodes.ACC_ABSTRACT + Opcodes.ACC_SYNTHETIC,
52 "jdk.fooMod", "FooMod", MODULE_TEST, CFE_EXCEPTION);
53
54 // Test that the JVM throws NCDFE for constant pool CONSTANT_Module type,
55 // for class file version 53, when ACC_MODULE is set in the access_flags.
56 ConstModule.write_and_load(Opcodes.V1_9,
57 Opcodes.ACC_INTERFACE + Opcodes.ACC_ABSTRACT + Opcodes.ACC_SYNTHETIC + ACC_MODULE,
58 "jdk.fooModACC", "FooModACC", MODULE_TEST, NCDFE_EXCEPTION);
59
60 // Test that the JVM throws CFE for constant pool CONSTANT_Module type, for
61 // class file version 52, even when ACC_MODULE is set in the access_flags.
62 ConstModule.write_and_load(Opcodes.V1_8,
63 Opcodes.ACC_INTERFACE + Opcodes.ACC_ABSTRACT + Opcodes.ACC_SYNTHETIC + ACC_MODULE,
64 "jdk.fooModACC52", "FooModACC52", MODULE_TEST, CFE_EXCEPTION);
65
66 // Test that the JVM throws CFE for constant pool CONSTANT_Package type, for
67 // class file version 53, when ACC_MODULE is not set in the access_flags.
68 ConstModule.write_and_load(Opcodes.V1_9,
69 Opcodes.ACC_INTERFACE + Opcodes.ACC_ABSTRACT + Opcodes.ACC_SYNTHETIC,
70 "jdk.fooPkg", "FooPkg", PACKAGE_TEST, CFE_EXCEPTION);
71
72 // Test that the JVM throws NCDFE for constant pool CONSTANT_Package type,
73 // for class file version 53, when ACC_MODULE is set in the access_flags.
74 ConstModule.write_and_load(Opcodes.V1_9,
75 Opcodes.ACC_INTERFACE + Opcodes.ACC_ABSTRACT + Opcodes.ACC_SYNTHETIC + ACC_MODULE,
76 "jdk.fooModACC", "FooModACC", PACKAGE_TEST, NCDFE_EXCEPTION);
77
78 // Test that the JVM throws CFE for constant pool CONSTANT_Package type, for
79 // class file version 52, even when ACC_MODULE is set in the access_flags.
80 ConstModule.write_and_load(Opcodes.V1_8,
81 Opcodes.ACC_INTERFACE + Opcodes.ACC_ABSTRACT + Opcodes.ACC_SYNTHETIC + ACC_MODULE,
82 "jdk.fooModACC52", "FooModACC52", PACKAGE_TEST, CFE_EXCEPTION);
83
84 }
85
86 public static void write_and_load(int version,
87 int access_flags,
88 String attr,
89 String class_name,
90 boolean module_test,
91 boolean throwCFE) throws Exception {
92 ClassWriter cw = new ClassWriter(0);
93 cw.visit(version,
94 access_flags,
|
30 * not set in the access_flags.
31 * @bug 8175383
32 * @library /test/lib
33 * @modules java.base/jdk.internal.org.objectweb.asm
34 * @compile -XDignore.symbol.file ConstModule.java
35 * @run main ConstModule
36 */
37
38 public class ConstModule {
39
40 static final int ACC_MODULE = 0x8000;
41 static final boolean MODULE_TEST = true;
42 static final boolean PACKAGE_TEST = false;
43 static final boolean CFE_EXCEPTION = true;
44 static final boolean NCDFE_EXCEPTION = false;
45
46 public static void main(String[] args) throws Exception {
47
48 // Test that the JVM throws CFE for constant pool CONSTANT_Module type, for
49 // class file version 53, when ACC_MODULE is not set in the access_flags.
50 ConstModule.write_and_load(Opcodes.V9,
51 Opcodes.ACC_INTERFACE + Opcodes.ACC_ABSTRACT + Opcodes.ACC_SYNTHETIC,
52 "jdk.fooMod", "FooMod", MODULE_TEST, CFE_EXCEPTION);
53
54 // Test that the JVM throws NCDFE for constant pool CONSTANT_Module type,
55 // for class file version 53, when ACC_MODULE is set in the access_flags.
56 ConstModule.write_and_load(Opcodes.V9,
57 Opcodes.ACC_INTERFACE + Opcodes.ACC_ABSTRACT + Opcodes.ACC_SYNTHETIC + ACC_MODULE,
58 "jdk.fooModACC", "FooModACC", MODULE_TEST, NCDFE_EXCEPTION);
59
60 // Test that the JVM throws CFE for constant pool CONSTANT_Module type, for
61 // class file version 52, even when ACC_MODULE is set in the access_flags.
62 ConstModule.write_and_load(Opcodes.V1_8,
63 Opcodes.ACC_INTERFACE + Opcodes.ACC_ABSTRACT + Opcodes.ACC_SYNTHETIC + ACC_MODULE,
64 "jdk.fooModACC52", "FooModACC52", MODULE_TEST, CFE_EXCEPTION);
65
66 // Test that the JVM throws CFE for constant pool CONSTANT_Package type, for
67 // class file version 53, when ACC_MODULE is not set in the access_flags.
68 ConstModule.write_and_load(Opcodes.V9,
69 Opcodes.ACC_INTERFACE + Opcodes.ACC_ABSTRACT + Opcodes.ACC_SYNTHETIC,
70 "jdk.fooPkg", "FooPkg", PACKAGE_TEST, CFE_EXCEPTION);
71
72 // Test that the JVM throws NCDFE for constant pool CONSTANT_Package type,
73 // for class file version 53, when ACC_MODULE is set in the access_flags.
74 ConstModule.write_and_load(Opcodes.V9,
75 Opcodes.ACC_INTERFACE + Opcodes.ACC_ABSTRACT + Opcodes.ACC_SYNTHETIC + ACC_MODULE,
76 "jdk.fooModACC", "FooModACC", PACKAGE_TEST, NCDFE_EXCEPTION);
77
78 // Test that the JVM throws CFE for constant pool CONSTANT_Package type, for
79 // class file version 52, even when ACC_MODULE is set in the access_flags.
80 ConstModule.write_and_load(Opcodes.V1_8,
81 Opcodes.ACC_INTERFACE + Opcodes.ACC_ABSTRACT + Opcodes.ACC_SYNTHETIC + ACC_MODULE,
82 "jdk.fooModACC52", "FooModACC52", PACKAGE_TEST, CFE_EXCEPTION);
83
84 }
85
86 public static void write_and_load(int version,
87 int access_flags,
88 String attr,
89 String class_name,
90 boolean module_test,
91 boolean throwCFE) throws Exception {
92 ClassWriter cw = new ClassWriter(0);
93 cw.visit(version,
94 access_flags,
|