Internal change PiperOrigin-RevId: 171209823
diff --git a/src/java_tools/buildjar/java/com/google/devtools/build/java/bazel/BazelJavaCompiler.java b/src/java_tools/buildjar/java/com/google/devtools/build/java/bazel/BazelJavaCompiler.java index cecf2e0..dd19c7c 100644 --- a/src/java_tools/buildjar/java/com/google/devtools/build/java/bazel/BazelJavaCompiler.java +++ b/src/java_tools/buildjar/java/com/google/devtools/build/java/bazel/BazelJavaCompiler.java
@@ -20,9 +20,6 @@ import java.io.InputStream; import java.io.OutputStream; import java.io.Writer; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLClassLoader; import java.nio.charset.Charset; import java.util.List; import java.util.Locale; @@ -63,28 +60,11 @@ private static final Class<? extends JavaCompiler> JAVA_COMPILER_CLASS = getJavaCompilerClass(); - private static class LangtoolsClassLoader extends URLClassLoader { - - public LangtoolsClassLoader() throws MalformedURLException { - super( - new URL[] {getLangtoolsJar().toURI().toURL()}, - // We use the bootstrap classloader (null) as the parent classloader - // instead of the default "system" class loader; we intentionally do - // not consult the classpath. This way the class path is not - // polluted, we reduce the risk of having multiple langtools on the - // classpath, and langtools.jar is only opened if this method is - // called. And this will reduce problems for automated java - // dependency analysis, which other teams are trying to do. - null); - } - } - private static Class<? extends JavaCompiler> getJavaCompilerClass() { try { - ClassLoader cl = new LangtoolsClassLoader(); - return getJavaCompilerClass(cl); + return getJavaCompilerClass(BazelJavaCompiler.class.getClassLoader()); } catch (Exception e) { - throw new RuntimeException("Cannot get java compiler", e); + throw new LinkageError("Cannot get Java compiler", e); } }