Skip to content

Commit

Permalink
Clean up obsolete logic related to bundled annotation processors
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 605684312
Change-Id: I3fad36c5079e192ef5779949a61de90ef9d5af7c
  • Loading branch information
cushon authored and copybara-github committed Feb 9, 2024
1 parent 808886c commit 5ff7c61
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -418,10 +418,14 @@ private static synchronized BootClassPathCachingFileManager getMatchingBootFileM
}

/**
* When Bazel invokes JavaBuilder, it puts javac.jar on the bootstrap class path and
* JavaBuilder_deploy.jar on the user class path. We need Error Prone to be available on the
* annotation processor path, but we want to mask out any other classes to minimize class version
* skew.
* Ensure that classes that appear in the API between JavaBuilder and plugins are consistently
* loaded by the same classloader. 'Plugins' here means both annotation processors and Error Prone
* plugins. The annotation processor API is defined in the JDK and doesn't require any special
* handling, since the versions in the system classloader will always be loaded preferentially.
* For Error Prone plugins, we want to ensure that classes in the API are loaded from the same
* classloader as JavaBuilder, but that other classes referenced by plugins are loaded from the
* processor classpath to avoid plugins seeing stale versions of classes from the releases
* JavaBuilder jar.
*/
@Trusted
private static class ClassloaderMaskingFileManager extends JavacFileManager {
Expand Down Expand Up @@ -455,11 +459,8 @@ protected Class<?> findClass(String name) throws ClassNotFoundException {
if (name.startsWith("com.google.errorprone.")
|| name.startsWith("com.google.common.collect.")
|| name.startsWith("com.google.common.base.")
|| name.startsWith("com.google.common.graph.")
|| name.startsWith("com.google.common.regex.")
|| name.startsWith("org.checkerframework.errorprone.dataflow.")
|| name.startsWith("com.sun.source.")
|| name.startsWith("com.sun.tools.")
|| name.startsWith("com.google.devtools.build.buildjar.javac.statistics.")) {
return Class.forName(name);
}
Expand Down

0 comments on commit 5ff7c61

Please sign in to comment.