Synchronize rules_java's DumpPlatformClassPath with the Bazel tree PiperOrigin-RevId: 494744399 Change-Id: If659780be04fb52f025910c30b433efcc52b5873
diff --git a/toolchains/DumpPlatformClassPath.java b/toolchains/DumpPlatformClassPath.java index e23ca53..0832853 100644 --- a/toolchains/DumpPlatformClassPath.java +++ b/toolchains/DumpPlatformClassPath.java
@@ -102,15 +102,25 @@ // initialized bootclasspath data back out. Context context = new Context(); - JavacTool.create() - .getTask( - /* out = */ null, - /* fileManager = */ null, - /* diagnosticListener = */ null, - /* options = */ Arrays.asList("--system", String.valueOf(targetJavabase)), - /* classes = */ null, - /* compilationUnits = */ null, - context); + try { + JavacTool.create() + .getTask( + /* out = */ null, + /* fileManager = */ null, + /* diagnosticListener = */ null, + /* options = */ Arrays.asList("--system", String.valueOf(targetJavabase)), + /* classes = */ null, + /* compilationUnits = */ null, + context); + } catch (IllegalArgumentException e) { + throw new IllegalArgumentException( + String.format( + "Failed to collect system class path. Please ensure that the configured Java runtime" + + " ('%s') is a complete JDK. There are known issues with Homebrew versions of" + + " the Java runtime.", + targetJavabase.toRealPath()), + e); + } StandardJavaFileManager fileManager = (StandardJavaFileManager) context.get(JavaFileManager.class);