diff options
author | Reinier Zwitserloot <reinier@tipit.to> | 2009-12-23 03:34:15 +0100 |
---|---|---|
committer | Reinier Zwitserloot <reinier@tipit.to> | 2009-12-23 03:34:15 +0100 |
commit | f9264b78e47262cd285e9c219954a5c5120cb25e (patch) | |
tree | c07f0a277f2bb9a7ed675d29e340de861c2bc3b9 /src | |
parent | 55bed99c90553d91b20c289629b62030bb286610 (diff) | |
download | lombok-f9264b78e47262cd285e9c219954a5c5120cb25e.tar.gz lombok-f9264b78e47262cd285e9c219954a5c5120cb25e.tar.bz2 lombok-f9264b78e47262cd285e9c219954a5c5120cb25e.zip |
HandlerLibrary now uses the proper context.
Diffstat (limited to 'src')
-rw-r--r-- | src/core/lombok/core/SpiLoadUtil.java | 6 | ||||
-rw-r--r-- | src/core/lombok/eclipse/HandlerLibrary.java | 4 |
2 files changed, 6 insertions, 4 deletions
diff --git a/src/core/lombok/core/SpiLoadUtil.java b/src/core/lombok/core/SpiLoadUtil.java index c068bf61..143cba13 100644 --- a/src/core/lombok/core/SpiLoadUtil.java +++ b/src/core/lombok/core/SpiLoadUtil.java @@ -90,7 +90,8 @@ public class SpiLoadUtil { * @param loader The classloader object to use to both the spi discovery files, as well as the loader to use * to make the returned instances. */ - public static <C> Iterable<C> findServices(final Class<C> target, final ClassLoader loader) throws IOException { + public static <C> Iterable<C> findServices(final Class<C> target, ClassLoader loader) throws IOException { + if (loader == null) loader = ClassLoader.getSystemClassLoader(); Enumeration<URL> resources = loader.getResources("META-INF/services/" + target.getName()); final Set<String> entries = new LinkedHashSet<String>(); while (resources.hasMoreElements()) { @@ -99,6 +100,7 @@ public class SpiLoadUtil { } final Iterator<String> names = entries.iterator(); + final ClassLoader fLoader = loader; return new Iterable<C> () { @Override public Iterator<C> iterator() { return new Iterator<C>() { @@ -108,7 +110,7 @@ public class SpiLoadUtil { @Override public C next() { try { - return target.cast(Class.forName(names.next(), true, loader).newInstance()); + return target.cast(Class.forName(names.next(), true, fLoader).newInstance()); } catch (Throwable t) { throw Lombok.sneakyThrow(t); } diff --git a/src/core/lombok/eclipse/HandlerLibrary.java b/src/core/lombok/eclipse/HandlerLibrary.java index 36c41504..1be01459 100644 --- a/src/core/lombok/eclipse/HandlerLibrary.java +++ b/src/core/lombok/eclipse/HandlerLibrary.java @@ -96,7 +96,7 @@ public class HandlerLibrary { /** Uses SPI Discovery to find implementations of {@link EclipseAnnotationHandler}. */ @SuppressWarnings("unchecked") private static void loadAnnotationHandlers(HandlerLibrary lib) { try { - for (EclipseAnnotationHandler<?> handler : SpiLoadUtil.findServices(EclipseAnnotationHandler.class)) { + for (EclipseAnnotationHandler<?> handler : SpiLoadUtil.findServices(EclipseAnnotationHandler.class, EclipseAnnotationHandler.class.getClassLoader())) { try { Class<? extends Annotation> annotationClass = SpiLoadUtil.findAnnotationClass(handler.getClass(), EclipseAnnotationHandler.class); @@ -117,7 +117,7 @@ public class HandlerLibrary { /** Uses SPI Discovery to find implementations of {@link EclipseASTVisitor}. */ private static void loadVisitorHandlers(HandlerLibrary lib) { try { - for (EclipseASTVisitor visitor : SpiLoadUtil.findServices(EclipseASTVisitor.class)) { + for (EclipseASTVisitor visitor : SpiLoadUtil.findServices(EclipseASTVisitor.class, EclipseASTVisitor.class.getClassLoader())) { lib.visitorHandlers.add(visitor); } } catch (Throwable t) { |