mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8308753: Class-File API transition to Preview
Reviewed-by: ihse, mchung, vromero
This commit is contained in:
parent
b9df827adc
commit
2b00ac0d02
681 changed files with 7518 additions and 6502 deletions
|
@ -26,22 +26,18 @@
|
|||
* @bug 8192920 8204588 8246774 8248843 8268869 8235876
|
||||
* @summary Test source launcher
|
||||
* @library /tools/lib
|
||||
* @enablePreview
|
||||
* @modules jdk.compiler/com.sun.tools.javac.api
|
||||
* jdk.compiler/com.sun.tools.javac.launcher
|
||||
* 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
|
||||
* java.base/jdk.internal.module
|
||||
* @build toolbox.JavaTask toolbox.JavacTask toolbox.TestRunner toolbox.ToolBox
|
||||
* @run main SourceLauncherTest
|
||||
*/
|
||||
|
||||
import jdk.internal.classfile.*;
|
||||
import jdk.internal.classfile.attribute.ModuleResolutionAttribute;
|
||||
import java.lang.classfile.*;
|
||||
import java.lang.classfile.attribute.ModuleResolutionAttribute;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
@ -543,7 +539,7 @@ public class SourceLauncherTest extends TestRunner {
|
|||
"error: can't find main(String[]) method in class: NoMain");
|
||||
}
|
||||
|
||||
@Test
|
||||
//@Test temporary disabled as enabled preview allows no-param main
|
||||
public void testMainBadParams(Path base) throws IOException {
|
||||
tb.writeJavaFiles(base,
|
||||
"class BadParams { public static void main() { } }");
|
||||
|
@ -551,7 +547,7 @@ public class SourceLauncherTest extends TestRunner {
|
|||
"error: can't find main(String[]) method in class: BadParams");
|
||||
}
|
||||
|
||||
@Test
|
||||
//@Test temporary disabled as enabled preview allows non-public main
|
||||
public void testMainNotPublic(Path base) throws IOException {
|
||||
tb.writeJavaFiles(base,
|
||||
"class NotPublic { static void main(String... args) { } }");
|
||||
|
@ -559,7 +555,7 @@ public class SourceLauncherTest extends TestRunner {
|
|||
"error: can't find main(String[]) method in class: NotPublic");
|
||||
}
|
||||
|
||||
@Test
|
||||
//@Test temporary disabled as enabled preview allows non-static main
|
||||
public void testMainNotStatic(Path base) throws IOException {
|
||||
tb.writeJavaFiles(base,
|
||||
"class NotStatic { public void main(String... args) { } }");
|
||||
|
@ -720,9 +716,9 @@ public class SourceLauncherTest extends TestRunner {
|
|||
}
|
||||
//where:
|
||||
private static void markModuleAsIncubator(Path moduleInfoFile) throws Exception {
|
||||
ClassModel cf = Classfile.of().parse(moduleInfoFile);
|
||||
ClassModel cf = ClassFile.of().parse(moduleInfoFile);
|
||||
ModuleResolutionAttribute newAttr = ModuleResolutionAttribute.of(WARN_INCUBATING);
|
||||
byte[] newBytes = Classfile.of().transform(cf, ClassTransform.dropping(ce -> ce instanceof Attributes)
|
||||
byte[] newBytes = ClassFile.of().transform(cf, ClassTransform.dropping(ce -> ce instanceof Attributes)
|
||||
.andThen(ClassTransform.endHandler(classBuilder -> classBuilder.with(newAttr))));
|
||||
try (OutputStream out = Files.newOutputStream(moduleInfoFile)) {
|
||||
out.write(newBytes);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue