Skip to content

Commit

Permalink
Resolved errors in run.javac mode
Browse files Browse the repository at this point in the history
+ SuperAfterStatementsTest: new excuse JavacBug8207032
+ MarkdownCommentsTest
  - pass suitable arguments to javac and java
  - initialize reporting options only in one place (setUp())
  - remove unrelated errors for better comparison
  - fine tune problem severities for better comparison with javac
+ ModuleCompilationTests
  - adjust to current error messages from javac
+ RecordPatternTest: 1 EclipseWarningConfiguredAsError
  • Loading branch information
stephan-herrmann committed Sep 3, 2024
1 parent e16dab9 commit 5b382de
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 87 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1169,7 +1169,7 @@ Excuse excuseFor(JavacCompiler compiler) {
JavacBug8204534 = RUN_JAVAC ? // https://bugs.openjdk.java.net/browse/JDK-8204534
new JavacHasABug(MismatchType.EclipseErrorsJavacNone, ClassFileConstants.JDK11, 0000) : null,
JavacBug8207032 = RUN_JAVAC ? // https://bugs.openjdk.java.net/browse/JDK-8207032
new JavacHasABug(MismatchType.EclipseErrorsJavacNone) : null,
new JavacHasABug(MismatchType.EclipseErrorsJavacNone, ClassFileConstants.JDK11, 0000) : null,
JavacBug8044196 = RUN_JAVAC ? // likely https://bugs.openjdk.java.net/browse/JDK-8044196, intermittently masked by https://bugs.openjdk.java.net/browse/JDK-8029161
new JavacHasABug(MismatchType.EclipseErrorsJavacNone, ClassFileConstants.JDK9, 0000, true) : null,
JavacBug6337964 = RUN_JAVAC ? // https://bugs.eclipse.org/bugs/show_bug.cgi?id=112433
Expand All @@ -1184,7 +1184,10 @@ Excuse excuseFor(JavacCompiler compiler) {
new JavacBug8226510(" --release 12 --enable-preview -Xlint:-preview") : null,
JavacBug8299416 = RUN_JAVAC ? // https://bugs.openjdk.java.net/browse/JDK-8299416
new JavacBugExtraJavacOptionsPlusMismatch(" --release 20 --enable-preview -Xlint:-preview",
MismatchType.EclipseErrorsJavacNone| MismatchType.EclipseErrorsJavacWarnings) : null;
MismatchType.EclipseErrorsJavacNone| MismatchType.EclipseErrorsJavacWarnings) : null,
JavacBug8336255 = RUN_JAVAC ? // https://bugs.openjdk.org/browse/JDK-8336255
new JavacBugExtraJavacOptionsPlusMismatch(" --release 23 --enable-preview -Xlint:-preview",
MismatchType.JavacErrorsEclipseNone) : null;

// bugs that have been fixed but that we've not identified
public static JavacHasABug
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,17 @@
@SuppressWarnings({ "unchecked", "rawtypes" })
public class MarkdownCommentsTest extends JavadocTest {

String docCommentSupport = CompilerOptions.ENABLED;
String reportInvalidJavadoc = CompilerOptions.ERROR;
String reportMissingJavadocDescription = CompilerOptions.ALL_STANDARD_TAGS;
String reportInvalidJavadocVisibility = CompilerOptions.PRIVATE;
String reportMissingJavadocTags = CompilerOptions.ERROR;
String reportMissingJavadocComments = null;
String reportMissingJavadocCommentsVisibility = null;
String reportDeprecation = CompilerOptions.ERROR;
private static final JavacTestOptions JAVAC_TEST_OPTIONS = new JavacTestOptions("--enable-preview -source 23 -Xlint:-preview -Xdoclint");
private static final String[] VMARGS = new String[] {"--enable-preview"};

String docCommentSupport;
String reportInvalidJavadoc;
String reportMissingJavadocDescription;
String reportInvalidJavadocVisibility;
String reportMissingJavadocTags;
String reportMissingJavadocComments;
String reportMissingJavadocCommentsVisibility;
String reportDeprecation;
String processAnnotations = null;
String reportJavadocDeprecation = null;

Expand Down Expand Up @@ -105,7 +108,32 @@ protected void setUp() throws Exception {
this.reportMissingJavadocComments = CompilerOptions.IGNORE;
this.reportMissingJavadocCommentsVisibility = CompilerOptions.PUBLIC;
this.reportDeprecation = CompilerOptions.ERROR;
this.reportInvalidJavadoc = CompilerOptions.ERROR;
this.reportMissingJavadocDescription = CompilerOptions.ALL_STANDARD_TAGS;
}

@Override
protected void runConformTest(String[] testFiles, String expectedOutput) {
runConformTest(testFiles, expectedOutput, getCompilerOptions(), VMARGS, JAVAC_TEST_OPTIONS);
}
@Override
protected void runNegativeTest(String[] testFiles, String expectedErrors) {
Runner runner = new Runner();
runner.testFiles = testFiles;
runner.expectedCompilerLog = expectedErrors;
runner.customOptions = getCompilerOptions();
runner.vmArguments = VMARGS;
runner.javacTestOptions = JAVAC_TEST_OPTIONS;
runner.runNegativeTest();
}

void runWarningTest(String[] testFiles, String expectedWarnings) {
this.reportInvalidJavadoc = CompilerOptions.WARNING;
Runner runner = new Runner();
runner.testFiles = testFiles;
runner.expectedCompilerLog = expectedWarnings;
runner.vmArguments = VMARGS;
runner.javacTestOptions = JAVAC_TEST_OPTIONS;
runner.runWarningTest();
}

public void test001() {
Expand All @@ -125,53 +153,41 @@ public int sample(String[] params) {
" /// @param parameters array of String\n" +
" ^^^^^^^^^^\n" +
"Javadoc: Parameter parameters is not declared\n" +
"----------\n",
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
"----------\n");
}
public void test002() {
this.runNegativeTest(new String[] { "X.java", """
this.runWarningTest(new String[] { "X.java", """
public class X {
///
/// @param params
///
public void sample(String[] params) {
public int sample(String[] params) {
return 42;
}
public static void main(String... args) {}
}
""", },

"----------\n" +
"1. ERROR in X.java (at line 3)\n" +
"1. WARNING in X.java (at line 3)\n" +
" /// @param params\n" +
" ^^^^^^\n" +
"Javadoc: Description expected after this reference\n" +
"----------\n" +
"2. ERROR in X.java (at line 6)\n" +
" return 42;\n" +
" ^^^^^^^^^^\n" +
"Void methods cannot return a value\n" +
"----------\n",
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
"----------\n");
}
public void test003() {
this.runNegativeTest(new String[] { "X.java", """
this.runConformTest(new String[] { "X.java", """
public class X {
///
/// @param params array of String
///
public void sample(String[] params) {
public int sample(String[] params) {
return 42;
}
public static void main(String... args) {}
}
""", },

"----------\n" +
"1. ERROR in X.java (at line 6)\n" +
" return 42;\n" +
" ^^^^^^^^^^\n" +
"Void methods cannot return a value\n" +
"----------\n",
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
"");
}
public void test004() {
this.runNegativeTest(new String[] { "X.java", """
Expand All @@ -180,7 +196,7 @@ public class X {
/// @see #method()
///
public void sample() {
return "";
return;
}
}
""", },
Expand All @@ -190,34 +206,22 @@ public void sample() {
" /// @see #method()\n" +
" ^^^^^^\n" +
"Javadoc: The method method() is undefined for the type X\n" +
"----------\n" +
"2. ERROR in X.java (at line 6)\n" +
" return \"\";\n" +
" ^^^^^^^^^^\n" +
"Void methods cannot return a value\n" +
"----------\n",
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
"----------\n");
}
public void test005() {
this.runNegativeTest(new String[] { "X.java", """
this.runConformTest(new String[] { "X.java", """
public class X {
///
/// @see #method()
///
public void sample() {
return "";
return;
}
protected void method() {}
public static void main(String... args) {}
}
""", },

"----------\n" +
"1. ERROR in X.java (at line 6)\n" +
" return \"\";\n" +
" ^^^^^^^^^^\n" +
"Void methods cannot return a value\n" +
"----------\n",
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
"");
}
public void test006() {
this.runConformTest(new String[] { "X.java",
Expand All @@ -230,10 +234,7 @@ public static void main(String[] arguments) {
protected static void method() {}
}
""", },
"Hello",
getCompilerOptions(),
new String[]{"--enable-preview"}
);
"Hello");
}
public void test007() {
this.runNegativeTest(new String[] { "X.java",
Expand All @@ -251,8 +252,7 @@ public static void main(String[] arguments) {
" /// @see #method()\n" +
" ^^^^^^\n" +
"Javadoc: The method method() is undefined for the type X\n" +
"----------\n",
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
"----------\n");
}
public void test008() {
this.runNegativeTest(new String[] { "X.java",
Expand All @@ -270,8 +270,7 @@ public static void main(String[] arguments) {
" /// @see #method()\n" +
" ^^^^^^\n" +
"Javadoc: The method method() is undefined for the type X\n" +
"----------\n",
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
"----------\n");
}
public void test009() {
this.runNegativeTest(new String[] { "X.java",
Expand All @@ -289,8 +288,7 @@ public static void main(String[] arguments) {
" //// @see #method()\n" +
" ^^^^^^\n" +
"Javadoc: The method method() is undefined for the type X\n" +
"----------\n",
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
"----------\n");
}
public void test010() {
String bkup = this.reportMissingJavadocTags;
Expand Down Expand Up @@ -352,7 +350,7 @@ public void test012() {
String bkup = this.reportMissingJavadocTags;
try {
this.reportJavadocDeprecation = CompilerOptions.ERROR;
this.runNegativeTest(new String[] { "X.java",
this.runWarningTest(new String[] { "X.java",
"""
public class X {
/// Some text here without the necessary tags for main method
Expand All @@ -365,12 +363,11 @@ public static void main(String[] arguments) {
}
""", },
"----------\n" +
"1. ERROR in X.java (at line 3)\n" +
"1. WARNING in X.java (at line 3)\n" +
" /// @param arguments\n" +
" ^^^^^^^^^\n" +
"Javadoc: Description expected after this reference\n" +
"----------\n",
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
"----------\n");
} finally {
this.reportMissingJavadocTags = bkup;
}
Expand Down Expand Up @@ -439,7 +436,7 @@ public static void main(String[] arguments) {
public void test015() {
String bkup = this.reportMissingJavadocTags;
try {
this.reportMissingJavadocTags = CompilerOptions.ERROR;
this.reportMissingJavadocTags = CompilerOptions.IGNORE;
this.runNegativeTest(new String[] { "X.java",
"""
public class X {
Expand All @@ -456,16 +453,15 @@ public static void main() {
" /// Reference to an invalid type [Strings]\n" +
" ^^^^^^^\n" +
"Javadoc: Strings cannot be resolved to a type\n" +
"----------\n",
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
"----------\n");
} finally {
this.reportMissingJavadocTags = bkup;
}
}
public void test016() {
String bkup = this.reportMissingJavadocTags;
try {
this.reportMissingJavadocTags = CompilerOptions.ERROR;
this.reportMissingJavadocTags = CompilerOptions.IGNORE;
this.runNegativeTest(new String[] { "X.java",
"""
public class X {
Expand All @@ -482,16 +478,15 @@ public static void main() {
" /// Reference to an invalid type [java.langs.Strings]\n" +
" ^^^^^^^^^^^^^^^^^^\n" +
"Javadoc: java.langs cannot be resolved to a type\n" +
"----------\n",
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
"----------\n");
} finally {
this.reportMissingJavadocTags = bkup;
}
}
public void test017() {
String bkup = this.reportMissingJavadocTags;
try {
this.reportMissingJavadocTags = CompilerOptions.ERROR;
this.reportMissingJavadocTags = CompilerOptions.IGNORE;
this.runNegativeTest(new String[] { "X.java",
"""
public class X {
Expand All @@ -513,16 +508,15 @@ public static void main() {
" /// Reference to an invalid type [Strings] [java.langs.Strings]\n" +
" ^^^^^^^^^^^^^^^^^^\n" +
"Javadoc: java.langs cannot be resolved to a type\n" +
"----------\n",
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
"----------\n");
} finally {
this.reportMissingJavadocTags = bkup;
}
}
public void test018() {
String bkup = this.reportMissingJavadocTags;
try {
this.reportMissingJavadocTags = CompilerOptions.ERROR;
this.reportMissingJavadocTags = CompilerOptions.IGNORE;
this.runNegativeTest(new String[] { "X.java",
"""
public class X {
Expand All @@ -539,8 +533,7 @@ public static void main() {
" /// Reference to an invalid type [Strings][java.langs.Strings]\n" +
" ^^^^^^^^^^^^^^^^^^\n" +
"Javadoc: java.langs cannot be resolved to a type\n" +
"----------\n",
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
"----------\n");
} finally {
this.reportMissingJavadocTags = bkup;
}
Expand All @@ -565,8 +558,7 @@ public static void main(String[] args) {
" /// Reference to an invalid method in a valid type [charArray()][java.lang.String#toCharArrays()]\n" +
" ^^^^^^^^^^^^\n" +
"Javadoc: The method toCharArrays() is undefined for the type String\n" +
"----------\n",
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
"----------\n");
} finally {
this.reportMissingJavadocTags = bkup;
}
Expand All @@ -591,8 +583,7 @@ public static void main(String[] args) {
" /// Reference to an invalid method in a valid type [\\[\\]][java.lang.String#toCharArrays()]\n" +
" ^^^^^^^^^^^^\n" +
"Javadoc: The method toCharArrays() is undefined for the type String\n" +
"----------\n",
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
"----------\n");
} finally {
this.reportMissingJavadocTags = bkup;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ public void test015() {
"The type p.X is not accessible\n" +
"----------\n" +
"1 problem (1 error)\n",
"cannot be resolved",
"does not read it",
OUTPUT_DIR + File.separator + out,
JavacTestOptions.JavacHasABug.JavacBug8207032);
}
Expand Down Expand Up @@ -1274,7 +1274,7 @@ public void test024() {
buffer,
"",
"option -bootclasspath not supported at compliance level 9 and above\n",
"not allowed"); // when specifying -bootclasspath javac answers: "option --boot-class-path not allowed with target 1.9" (two bugs)
"option --boot-class-path cannot be used together with --release"); // error message has changed between versions, name of option plus reason for illegality can be questioned
}
public void test025() {
File outputDirectory = new File(OUTPUT_DIR);
Expand Down Expand Up @@ -5426,7 +5426,7 @@ public void testBug522472b() {
"The import x.y.z cannot be resolved\n" +
"----------\n" +
"3 problems (3 errors)\n",
"package conflict");
"reads package x.y.z from both");
}
public void testBug522472d() {
File outputDirectory = new File(OUTPUT_DIR);
Expand Down Expand Up @@ -5502,7 +5502,7 @@ public void testBug522472d() {
"The package x.y.z is accessible from more than one module: mod.one, mod.one.a\n" +
"----------\n" +
"3 problems (3 errors)\n",
"conflict");
"reads package x.y.z from both");
}
public void testIssue2357_001() throws Exception {
File outputDirectory = new File(OUTPUT_DIR);
Expand Down
Loading

0 comments on commit 5b382de

Please sign in to comment.