@@ -812,7 +812,9 @@ private static Stream<Arguments> testStackTraceWithUnknownHeader_args() {
812
812
Arguments .of (
813
813
"modified out of resources error header" ,
814
814
SYSTEM_OUT_OF_RESOURCES_ERROR_HEADERS [0 ].replaceAll ("resources" , "memory" )),
815
- Arguments .of ("modified I/O error header" , IO_ERROR_HEADERS [0 ].replaceAll ("input/output" , "I/O" )));
815
+ Arguments .of ("modified I/O error header" , IO_ERROR_HEADERS [0 ].replaceAll ("input/output" , "I/O" )),
816
+ Arguments .of (
817
+ "modified plugin error header" , PLUGIN_ERROR_HEADERS [0 ].replaceAll ("uncaught" , "unhandled" )));
816
818
}
817
819
818
820
@ ParameterizedTest (name = "{0}" )
@@ -977,6 +979,46 @@ private static Stream<Arguments> testIOError_args() {
977
979
Arguments .of ("JDK 21 German" , IO_ERROR_HEADERS [6 ]));
978
980
}
979
981
982
+ @ ParameterizedTest (name = "{0}" )
983
+ @ MethodSource ("testPluginError_args" )
984
+ public void testPluginError (String jdkAndLocale , String stackTraceHeader ) throws Exception {
985
+ String stackTraceWithHeader = UNIDENTIFIED_LOG_LINES + stackTraceHeader + stackTracePluginError ;
986
+
987
+ List <CompilerMessage > compilerMessages =
988
+ JavacCompiler .parseModernStream (4 , new BufferedReader (new StringReader (stackTraceWithHeader )));
989
+
990
+ assertThat (compilerMessages , notNullValue ());
991
+ assertThat (compilerMessages , hasSize (1 ));
992
+
993
+ String message = compilerMessages .get (0 ).getMessage ().replaceAll (EOL , "\n " );
994
+ // Parser retains stack trace header
995
+ assertThat (message , startsWith (stackTraceHeader ));
996
+ assertThat (message , endsWith (stackTracePluginError ));
997
+ }
998
+
999
+ private static final String stackTracePluginError =
1000
+ "A plugin threw an uncaught exception.\n " + "Consult the following stack trace for details.\n "
1001
+ + "java.lang.NoSuchMethodError: com.sun.tools.javac.util.JavacMessages.add(Lcom/sun/tools/javac/util/JavacMessages$ResourceBundleHelper;)V\n "
1002
+ + "\t at com.google.errorprone.BaseErrorProneJavaCompiler.setupMessageBundle(BaseErrorProneJavaCompiler.java:202)\n "
1003
+ + "\t at com.google.errorprone.ErrorProneJavacPlugin.init(ErrorProneJavacPlugin.java:40)\n "
1004
+ + "\t at com.sun.tools.javac.main.Main.compile(Main.java:470)\n "
1005
+ + "\t at com.sun.tools.javac.main.Main.compile(Main.java:381)\n "
1006
+ + "\t at com.sun.tools.javac.main.Main.compile(Main.java:370)\n "
1007
+ + "\t at com.sun.tools.javac.main.Main.compile(Main.java:361)\n "
1008
+ + "\t at com.sun.tools.javac.Main.compile(Main.java:56)\n "
1009
+ + "\t at com.sun.tools.javac.Main.main(Main.java:42)\n " ;
1010
+
1011
+ private static Stream <Arguments > testPluginError_args () {
1012
+ return Stream .of (
1013
+ Arguments .of ("JDK 8 English" , PLUGIN_ERROR_HEADERS [0 ]),
1014
+ Arguments .of ("JDK 8 Japanese" , PLUGIN_ERROR_HEADERS [1 ]),
1015
+ Arguments .of ("JDK 8 Chinese" , PLUGIN_ERROR_HEADERS [2 ]),
1016
+ Arguments .of ("JDK 21 English" , PLUGIN_ERROR_HEADERS [3 ]),
1017
+ Arguments .of ("JDK 21 Japanese" , PLUGIN_ERROR_HEADERS [4 ]),
1018
+ Arguments .of ("JDK 21 Chinese" , PLUGIN_ERROR_HEADERS [5 ]),
1019
+ Arguments .of ("JDK 21 German" , PLUGIN_ERROR_HEADERS [6 ]));
1020
+ }
1021
+
980
1022
@ Test
981
1023
public void testNonAnchoredWarning () throws IOException {
982
1024
final String error = "warning: [options] bootstrap class path not set in conjunction with -source 1.6" + EOL
0 commit comments