File tree Expand file tree Collapse file tree
plugin/src/main/scala/com/github/sbt/javaformatter Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -378,11 +378,20 @@ object JavaFormatter {
378378 output.contains(" NoClassDefFoundError: com/sun/tools/javac/tree/JCTree$JCAnyPattern" ) ||
379379 output.contains(" ClassNotFoundException: com.sun.tools.javac.tree.JCTree$JCAnyPattern" )
380380
381+ val olderFormatterOnNewerJdk =
382+ output.contains(" NoSuchMethodError" ) &&
383+ (output.contains(" com.sun.tools.javac." ) || output.contains(" jdk.compiler" ))
384+
381385 if (unsupportedClassVersion || missingNewerJavacClass) {
382386 Some (
383387 s " \n\n\n The forked google-java-format JVM appears to be running on an incompatible Java version. " +
384388 s " Either set the $JavaHomeEnvVar environment variable or -D $JavaHomeProperty=... to point the formatter to a compatible JDK, " +
385389 s " or lower the sbt setting ThisBuild / javafmtFormatterCompatibleJavaVersion to match the available Java runtime. \n\n\n " )
390+ } else if (olderFormatterOnNewerJdk) {
391+ Some (
392+ s " \n\n\n The selected google-java-format runtime appears to be too old for the Java version used to launch the formatter JVM. " +
393+ s " Try increasing the sbt setting ThisBuild / javafmtFormatterCompatibleJavaVersion, " +
394+ s " or point the formatter to an older compatible JDK via the $JavaHomeEnvVar environment variable or -D $JavaHomeProperty=.... \n\n\n " )
386395 } else {
387396 None
388397 }
You can’t perform that action at this time.
0 commit comments