From bf5199ea3d2c7eade3c44553e0c37ad8c3610605 Mon Sep 17 00:00:00 2001 From: Stephan Schroevers Date: Thu, 30 Jun 2022 13:30:03 +0200 Subject: [PATCH] Fix build-time Refaster template loading (#121) When using the system classloader, `RefasterCheckTest` is able to successfully load the Refaster templates from the classpath, causing the tests to pass. However, when during a build the Java compiler loads `RefasterCheck`, the templates on the annotation processor classpath are _not_ exposed through the system classloader. --- .../java/tech/picnic/errorprone/bugpatterns/RefasterCheck.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/RefasterCheck.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/RefasterCheck.java index da291334..93698286 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/RefasterCheck.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/RefasterCheck.java @@ -195,7 +195,7 @@ public final class RefasterCheck extends BugChecker implements CompilationUnitTr private static ImmutableSet getClassPathResources() { try { - return ClassPath.from(ClassLoader.getSystemClassLoader()).getResources(); + return ClassPath.from(RefasterCheck.class.getClassLoader()).getResources(); } catch (IOException e) { throw new UncheckedIOException("Failed to scan classpath for resources", e); }