|
28 | 28 | import java.io.StringReader;
|
29 | 29 | import java.util.ArrayList;
|
30 | 30 | import java.util.List;
|
| 31 | +import java.util.stream.Stream; |
31 | 32 |
|
32 | 33 | import org.codehaus.plexus.compiler.CompilerMessage;
|
33 | 34 | import org.codehaus.plexus.util.Os;
|
34 | 35 | import org.junit.jupiter.api.Test;
|
| 36 | +import org.junit.jupiter.params.ParameterizedTest; |
| 37 | +import org.junit.jupiter.params.provider.Arguments; |
| 38 | +import org.junit.jupiter.params.provider.MethodSource; |
35 | 39 |
|
36 | 40 | import static org.hamcrest.MatcherAssert.assertThat;
|
37 | 41 | import static org.hamcrest.Matchers.hasSize;
|
@@ -775,19 +779,73 @@ public void testJava7Error() throws Exception {
|
775 | 779 | assertThat(message2.getEndLine(), is(3));
|
776 | 780 | }
|
777 | 781 |
|
778 |
| - @Test |
779 |
| - public void testBugParade() throws Exception { |
780 |
| - String out = "An exception has occurred in the compiler (1.7.0_80). " |
781 |
| - + "Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport) after checking the Bug Parade for duplicates. " |
782 |
| - + "Include your program and the following diagnostic in your report. Thank you." + EOL |
783 |
| - + "com.sun.tools.javac.code.Symbol$CompletionFailure: class file for java.util.Optional not found"; |
| 782 | + @ParameterizedTest(name = "{0}") |
| 783 | + @MethodSource("testBugParade_args") |
| 784 | + public void testBugParade(String jdkAndLocale, String stackTraceHeader) throws Exception { |
| 785 | + String out = stackTraceHeader + "\tat com.sun.tools.javac.comp.MemberEnter.baseEnv(MemberEnter.java:1388)\n" |
| 786 | + + "\tat com.sun.tools.javac.comp.MemberEnter.complete(MemberEnter.java:1046)\n" |
| 787 | + + "\tat com.sun.tools.javac.code.Symbol.complete(Symbol.java:574)\n" |
| 788 | + + "\tat com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:1037)\n" |
| 789 | + + "\tat com.sun.tools.javac.code.Symbol$ClassSymbol.flags(Symbol.java:973)\n" |
| 790 | + + "\tat com.sun.tools.javac.code.Symbol$ClassSymbol.getKind(Symbol.java:1101)\n" |
| 791 | + + "\tat com.sun.tools.javac.code.Kinds.kindName(Kinds.java:162)\n" |
| 792 | + + "\tat com.sun.tools.javac.comp.Check.duplicateError(Check.java:329)\n" |
| 793 | + + "\tat com.sun.tools.javac.comp.Check.checkUnique(Check.java:3435)\n" |
| 794 | + + "\tat com.sun.tools.javac.comp.Enter.visitTypeParameter(Enter.java:454)\n" |
| 795 | + + "\tat com.sun.tools.javac.tree.JCTree$JCTypeParameter.accept(JCTree.java:2224)\n" |
| 796 | + + "\tat com.sun.tools.javac.comp.Enter.classEnter(Enter.java:258)\n" |
| 797 | + + "\tat com.sun.tools.javac.comp.Enter.classEnter(Enter.java:272)\n" |
| 798 | + + "\tat com.sun.tools.javac.comp.Enter.visitClassDef(Enter.java:418)\n" |
| 799 | + + "\tat com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:693)\n" |
| 800 | + + "\tat com.sun.tools.javac.comp.Enter.classEnter(Enter.java:258)\n" |
| 801 | + + "\tat com.sun.tools.javac.comp.Enter.classEnter(Enter.java:272)\n" |
| 802 | + + "\tat com.sun.tools.javac.comp.Enter.visitTopLevel(Enter.java:334)\n" |
| 803 | + + "\tat com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:518)\n" |
| 804 | + + "\tat com.sun.tools.javac.comp.Enter.classEnter(Enter.java:258)\n" |
| 805 | + + "\tat com.sun.tools.javac.comp.Enter.classEnter(Enter.java:272)\n" |
| 806 | + + "\tat com.sun.tools.javac.comp.Enter.complete(Enter.java:486)\n" |
| 807 | + + "\tat com.sun.tools.javac.comp.Enter.main(Enter.java:471)\n" |
| 808 | + + "\tat com.sun.tools.javac.main.JavaCompiler.enterTrees(JavaCompiler.java:982)\n" |
| 809 | + + "\tat com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:857)\n" |
| 810 | + + "\tat com.sun.tools.javac.main.Main.compile(Main.java:523)\n" |
| 811 | + + "\tat com.sun.tools.javac.main.Main.compile(Main.java:381)\n" |
| 812 | + + "\tat com.sun.tools.javac.main.Main.compile(Main.java:370)\n" |
| 813 | + + "\tat com.sun.tools.javac.main.Main.compile(Main.java:361)\n" |
| 814 | + + "\tat com.sun.tools.javac.Main.compile(Main.java:56)\n" |
| 815 | + + "\tat com.sun.tools.javac.Main.main(Main.java:42)\n"; |
784 | 816 |
|
785 | 817 | List<CompilerMessage> compilerErrors =
|
786 | 818 | JavacCompiler.parseModernStream(4, new BufferedReader(new StringReader(out)));
|
787 | 819 |
|
788 | 820 | assertThat(compilerErrors, notNullValue());
|
789 |
| - |
790 | 821 | assertThat(compilerErrors.size(), is(1));
|
| 822 | + // Parser retains stack trace header |
| 823 | + assertThat(compilerErrors.get(0).getMessage(), startsWith(stackTraceHeader)); |
| 824 | + } |
| 825 | + |
| 826 | + private static Stream<Arguments> testBugParade_args() { |
| 827 | + return Stream.of( |
| 828 | + Arguments.of( |
| 829 | + "JDK 8 English", |
| 830 | + "An exception has occurred in the compiler ({0}). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport) after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report. Thank you."), |
| 831 | + Arguments.of( |
| 832 | + "JDK 8 Japanese", |
| 833 | + "コンパイラで例外が発生しました({0})。Bug Paradeで重複がないかをご確認のうえ、Java Developer Connection (http://java.sun.com/webapps/bugreport)でbugの登録をお願いいたします。レポートには、そのプログラムと下記の診断内容を含めてください。ご協力ありがとうございます。"), |
| 834 | + Arguments.of( |
| 835 | + "JDK 8 Chinese", |
| 836 | + "编译器 ({0}) 中出现异常错误。 如果在 Bug Parade 中没有找到该错误, 请在 Java Developer Connection (http://java.sun.com/webapps/bugreport) 中建立 Bug。请在报告中附上您的程序和以下诊断信息。谢谢。"), |
| 837 | + Arguments.of( |
| 838 | + "JDK 21 English", |
| 839 | + "An exception has occurred in the compiler ({0}). Please file a bug against the Java compiler via the Java bug reporting page (https://bugreport.java.com) after checking the Bug Database (https://bugs.java.com) for duplicates. Include your program, the following diagnostic, and the parameters passed to the Java compiler in your report. Thank you."), |
| 840 | + Arguments.of( |
| 841 | + "JDK 21 Japanese", |
| 842 | + "コンパイラで例外が発生しました({0})。バグ・データベース(https://bugs.java.com)で重複がないかをご確認のうえ、Javaのバグ・レポート・ページ(https://bugreport.java.com)から、Javaコンパイラに対するバグの登録をお願いいたします。レポートには、該当のプログラム、次の診断内容、およびJavaコンパイラに渡されたパラメータをご入力ください。ご協力ありがとうございます。"), |
| 843 | + Arguments.of( |
| 844 | + "JDK 21 Chinese", |
| 845 | + "编译器 ({0}) 中出现异常错误。如果在 Bug Database (https://bugs.java.com) 中没有找到有关该错误的 Java 编译器 Bug,请通过 Java Bug 报告页 (https://bugreport.java.com) 提交 Java 编译器 Bug。请在报告中附上您的程序、以下诊断信息以及传递到 Java 编译器的参数。谢谢。"), |
| 846 | + Arguments.of( |
| 847 | + "JDK 21 German", |
| 848 | + "Im Compiler ({0}) ist eine Ausnahme aufgetreten. Erstellen Sie auf der Java-Seite zum Melden von Bugs (https://bugreport.java.com) einen Bugbericht, nachdem Sie die Bugdatenbank (https://bugs.java.com) auf Duplikate geprüft haben. Geben Sie in Ihrem Bericht Ihr Programm, die folgende Diagnose und die Parameter an, die Sie dem Java-Compiler übergeben haben. Vielen Dank.")); |
791 | 849 | }
|
792 | 850 |
|
793 | 851 | @Test
|
|
0 commit comments