Skip to content

Commit

Permalink
Fixed #73 SneakyThrows without parameter did not default to Throwable…
Browse files Browse the repository at this point in the history
….class

Added tests for SneakyThrows
  • Loading branch information
rspilker committed Dec 2, 2009
1 parent d2fc0df commit 1f4fb2f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/core/lombok/javac/handlers/HandleSneakyThrows.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;

import lombok.SneakyThrows;
import lombok.core.AnnotationValues;
Expand All @@ -52,9 +53,9 @@ public class HandleSneakyThrows implements JavacAnnotationHandler<SneakyThrows>
@Override public boolean handle(AnnotationValues<SneakyThrows> annotation, JCAnnotation ast, JavacNode annotationNode) {
markAnnotationAsProcessed(annotationNode, SneakyThrows.class);
Collection<String> exceptionNames = annotation.getRawExpressions("value");

List<JCExpression> memberValuePairs = ast.getArguments();
if (memberValuePairs == null || memberValuePairs.size() == 0) return false;
if (exceptionNames.isEmpty()) {
exceptionNames = Collections.singleton("java.lang.Throwable");
}

java.util.List<String> exceptions = new ArrayList<String>();
for (String exception : exceptionNames) {
Expand Down
17 changes: 17 additions & 0 deletions test/delombok/resource/after/SneakyThrowsPlain.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class SneakyThrowsPlain {
public void test() {
try {
System.out.println("test1");
} catch (java.lang.Throwable $ex) {
throw lombok.Lombok.sneakyThrow($ex);
}
}

public void test2() {
try {
System.out.println("test2");
} catch (java.lang.Throwable $ex) {
throw lombok.Lombok.sneakyThrow($ex);
}
}
}
10 changes: 10 additions & 0 deletions test/delombok/resource/before/SneakyThrowsPlain.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import lombok.SneakyThrows;
class SneakyThrowsPlain {
@lombok.SneakyThrows public void test() {
System.out.println("test1");
}

@SneakyThrows public void test2() {
System.out.println("test2");
}
}

0 comments on commit 1f4fb2f

Please sign in to comment.