aboutsummaryrefslogtreecommitdiff
path: root/src/lombok/eclipse
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@tipit.to>2009-06-28 05:50:51 +0200
committerReinier Zwitserloot <reinier@tipit.to>2009-06-28 05:50:51 +0200
commit19f1b265931737a28760ccfe0200b4721f545989 (patch)
tree8bba739cf2d232c3fc4a21e7eb4ba86e63e8f71f /src/lombok/eclipse
parentdc7d0cacf5c12201fb51a8758e3fcca385cc583c (diff)
downloadlombok-19f1b265931737a28760ccfe0200b4721f545989.tar.gz
lombok-19f1b265931737a28760ccfe0200b4721f545989.tar.bz2
lombok-19f1b265931737a28760ccfe0200b4721f545989.zip
Rolled our own ServiceLoader, because its not part of java 1.5.
Diffstat (limited to 'src/lombok/eclipse')
-rw-r--r--src/lombok/eclipse/HandlerLibrary.java27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/lombok/eclipse/HandlerLibrary.java b/src/lombok/eclipse/HandlerLibrary.java
index 37610a33..6ee2baaa 100644
--- a/src/lombok/eclipse/HandlerLibrary.java
+++ b/src/lombok/eclipse/HandlerLibrary.java
@@ -8,9 +8,8 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
-import java.util.ServiceConfigurationError;
-import java.util.ServiceLoader;
+import lombok.Lombok;
import lombok.core.AnnotationValues;
import lombok.core.PrintAST;
import lombok.core.SpiLoadUtil;
@@ -58,7 +57,13 @@ public class HandlerLibrary {
}
@SuppressWarnings("unchecked") private static void loadAnnotationHandlers(HandlerLibrary lib) {
- Iterator<EclipseAnnotationHandler> it = ServiceLoader.load(EclipseAnnotationHandler.class).iterator();
+ Iterator<EclipseAnnotationHandler> it;
+ try {
+ it = SpiLoadUtil.findServices(EclipseAnnotationHandler.class);
+ } catch ( Throwable t ) {
+ throw Lombok.sneakyThrow(t);
+ }
+
while ( it.hasNext() ) {
try {
EclipseAnnotationHandler<?> handler = it.next();
@@ -69,19 +74,24 @@ public class HandlerLibrary {
Eclipse.error(null, "Duplicate handlers for annotation type: " + container.annotationClass.getName());
}
lib.typeLibrary.addType(container.annotationClass.getName());
- } catch ( ServiceConfigurationError e ) {
- Eclipse.error(null, "Can't load Lombok annotation handler for eclipse: ", e);
+ } catch ( Throwable t ) {
+ Eclipse.error(null, "Can't load Lombok annotation handler for eclipse: ", t);
}
}
}
private static void loadVisitorHandlers(HandlerLibrary lib) {
- Iterator<EclipseASTVisitor> it = ServiceLoader.load(EclipseASTVisitor.class).iterator();
+ Iterator<EclipseASTVisitor> it;
+ try {
+ it = SpiLoadUtil.findServices(EclipseASTVisitor.class);
+ } catch ( Throwable t ) {
+ throw Lombok.sneakyThrow(t);
+ }
while ( it.hasNext() ) {
try {
lib.visitorHandlers.add(it.next());
- } catch ( ServiceConfigurationError e ) {
- Eclipse.error(null, "Can't load Lombok visitor handler for eclipse: ", e);
+ } catch ( Throwable t ) {
+ Eclipse.error(null, "Can't load Lombok visitor handler for eclipse: ", t);
}
}
}
@@ -105,7 +115,6 @@ public class HandlerLibrary {
try {
handled |= container.handle(annotation, annotationNode);
} catch ( AnnotationValueDecodeFail fail ) {
- fail.printStackTrace(); //TODO debug!
fail.owner.setError(fail.getMessage(), fail.idx);
} catch ( Throwable t ) {
Eclipse.error(ast, String.format("Lombok annotation handler %s failed", container.handler.getClass()), t);