From 881bef1e58f773299c2b1b28fdd8db84fdd9d863 Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Mon, 20 Jan 2025 19:36:01 +0100 Subject: [PATCH] Fixing tests. --- .../jshell/tool/resources/PREVIEW_DEFAULT.jsh | 1 - .../langtools/jdk/jshell/ConsoleToolTest.java | 16 +++---- .../javac/ImplicitClass/ImplicitImports.java | 43 ------------------- .../tools/javac/diags/examples.not-yet.txt | 1 + .../javac/diags/examples/ImplicitClass.java | 1 - 5 files changed, 9 insertions(+), 53 deletions(-) diff --git a/src/jdk.jshell/share/classes/jdk/jshell/tool/resources/PREVIEW_DEFAULT.jsh b/src/jdk.jshell/share/classes/jdk/jshell/tool/resources/PREVIEW_DEFAULT.jsh index 975d12155352b..4644ac8638657 100644 --- a/src/jdk.jshell/share/classes/jdk/jshell/tool/resources/PREVIEW_DEFAULT.jsh +++ b/src/jdk.jshell/share/classes/jdk/jshell/tool/resources/PREVIEW_DEFAULT.jsh @@ -1,2 +1 @@ import module java.base; -import static java.io.IO.*; diff --git a/test/langtools/jdk/jshell/ConsoleToolTest.java b/test/langtools/jdk/jshell/ConsoleToolTest.java index 0af85a6186297..5fa48d55bd4ea 100644 --- a/test/langtools/jdk/jshell/ConsoleToolTest.java +++ b/test/langtools/jdk/jshell/ConsoleToolTest.java @@ -60,31 +60,31 @@ public void testOutput() { public void testIO() { test(new String[] {"--enable-preview"}, a -> {assertCommandWithOutputAndTerminal(a, - "java.io.IO.readln(\"%%s\");\ninput", //newline automatically appended + "java.lang.IO.readln(\"%%s\");\ninput", //newline automatically appended "$1 ==> \"input\"", """ - \u0005java.io.IO.readln(\"%%s\"); + \u0005java.lang.IO.readln(\"%%s\"); %%sinput """);}, a -> {assertCommandWithOutputAndTerminal(a, - "java.io.IO.readln();\ninput!", //newline automatically appended + "java.lang.IO.readln();\ninput!", //newline automatically appended "$2 ==> \"input!\"", """ - \u0005java.io.IO.readln(); + \u0005java.lang.IO.readln(); input! """);}, a -> {assertCommandWithOutputAndTerminal(a, - "java.io.IO.println(\"Hello, World!\");", + "java.lang.IO.println(\"Hello, World!\");", "", """ - \u0005java.io.IO.println(\"Hello, World!\"); + \u0005java.lang.IO.println(\"Hello, World!\"); Hello, World! """);}, a -> {assertCommandWithOutputAndTerminal(a, - "java.io.IO.println();", + "java.lang.IO.println();", "", """ - \u0005java.io.IO.println(); + \u0005java.lang.IO.println(); """);} ); diff --git a/test/langtools/tools/javac/ImplicitClass/ImplicitImports.java b/test/langtools/tools/javac/ImplicitClass/ImplicitImports.java index 1362864d8fe10..683a035d27b7c 100644 --- a/test/langtools/tools/javac/ImplicitClass/ImplicitImports.java +++ b/test/langtools/tools/javac/ImplicitClass/ImplicitImports.java @@ -131,49 +131,6 @@ public static void main(String... args) { } } - @Test - public void testImplicitSimpleIOImport(Path base) throws Exception { - Path current = base.resolve("."); - - Path patchClasses = prepareIOPatch(current); - - Path src = current.resolve("src"); - Path classes = current.resolve("classes"); - tb.writeFile(src.resolve("Test.java"), - """ - public static void main(String... args) { - println("Hello, World!"); - } - """); - - Files.createDirectories(classes); - - new JavacTask(tb) - .options("--enable-preview", "--release", SOURCE_VERSION, - "--patch-module", "java.base=" + patchClasses) - .outdir(classes) - .files(tb.findJavaFiles(src)) - .run(Task.Expect.SUCCESS) - .writeAll(); - - var out = new JavaTask(tb) - .classpath(classes.toString()) - .className("Test") - .vmOptions("--enable-preview", - "--patch-module", "java.base=" + patchClasses) - .run() - .writeAll() - .getOutputLines(Task.OutputKind.STDOUT); - - var expectedOut = List.of("Hello, World!"); - - if (!Objects.equals(expectedOut, out)) { - throw new AssertionError("Incorrect Output, expected: " + expectedOut + - ", actual: " + out); - - } - } - @Test public void testNoImplicitImportsForOrdinaryClasses(Path base) throws Exception { Path current = base.resolve("."); diff --git a/test/langtools/tools/javac/diags/examples.not-yet.txt b/test/langtools/tools/javac/diags/examples.not-yet.txt index 39bcec336544e..04a8b9b1a68af 100644 --- a/test/langtools/tools/javac/diags/examples.not-yet.txt +++ b/test/langtools/tools/javac/diags/examples.not-yet.txt @@ -120,6 +120,7 @@ compiler.warn.illegal.char.for.encoding compiler.warn.incubating.modules # requires adjusted classfile compiler.warn.invalid.archive.file compiler.warn.invalid.utf8.in.classfile # bad class file +compiler.warn.is.preview # difficult to produce reliably despite future changes to java.base compiler.warn.is.preview.reflective # difficult to produce reliably despite future changes to java.base compiler.warn.output.file.clash # this warning is not generated on Linux compiler.warn.override.bridge diff --git a/test/langtools/tools/javac/diags/examples/ImplicitClass.java b/test/langtools/tools/javac/diags/examples/ImplicitClass.java index 30285293b1836..dfba19e8c88a4 100644 --- a/test/langtools/tools/javac/diags/examples/ImplicitClass.java +++ b/test/langtools/tools/javac/diags/examples/ImplicitClass.java @@ -23,7 +23,6 @@ // key: compiler.misc.feature.implicit.classes // key: compiler.warn.preview.feature.use.plural -// key: compiler.warn.is.preview // options: -source ${jdk.version} --enable-preview -Xlint:preview public static void main(String... args) {