AST exception fail on @SneakyThrows with try statement as first method statement. #103

Closed
lombokissues opened this Issue Jul 14, 2015 · 4 comments

Projects

None yet

1 participant

@lombokissues
Collaborator

Migrated from Google Code (issue 30)

@lombokissues
Collaborator

๐Ÿ‘ค reinierz ย  ๐Ÿ•— Aug 15, 2009 at 03:48 UTC

This code:

@ SneakyThrows(UnsupportedEncodingException.class)
private static byte[] hmacSha1(String signKey, String string) {
    try {
        Mac mac = Mac.getInstance(ENCODING_MAC_NAME);
        mac.init(new SecretKeySpec(signKey.getBytes(ENCODING), ENCODING_MAC_NAME));
        return mac.doFinal(string.getBytes(ENCODING));
    } catch ( NoSuchAlgorithmException e ) {
        throw new IllegalArgumentException("No such algorithm: " + 

ENCODING_MAC_NAME);
} catch ( InvalidKeyException e ) {
throw new IllegalArgumentException("Key not valid", e);
}
}

blows up the AST:

java.lang.IllegalArgumentException
at org.eclipse.jdt.core.dom.ASTNode.setSourceRange(ASTNode.java:2614)
at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:2613)
at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:2455)
at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:523)
at org.eclipse.jdt.core.dom.ASTConverter.buildBodyDeclarations(ASTConverter.java:179)
at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:2694)
at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1264)
at
org.eclipse.jdt.core.dom.CompilationUnitResolver.convert(CompilationUnitResolver.java:256)
at org.eclipse.jdt.core.dom.ASTParser.internalCreateAST(ASTParser.java:933)
at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:657)
at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider$1.run(ASTProvider.java:544)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.createAST(ASTProvider.java:537)
at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.getAST(ASTProvider.java:478)
at org.eclipse.jdt.ui.SharedASTProvider.getAST(SharedASTProvider.java:126)
at
org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$PartListenerGroup.calcu
lateASTandInform(SelectionListenerWithASTManager.java:169)
at
org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$3.run(SelectionListener
WithASTManager.java:154)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

@lombokissues
Collaborator

๐Ÿ‘ค reinierz ย  ๐Ÿ•— Sep 01, 2009 at 23:10 UTC

This, and many other issues with @ SneakyThrows, has been fixed in commit
cb4c8ca and will be rolled out in v0.8.4.

@lombokissues
Collaborator

๐Ÿ‘ค reinierz ย  ๐Ÿ•— Sep 02, 2009 at 22:12 UTC

Still wasn't quite working correctly. Another patch has been rolled in at
2b51cf8 and should be available in v0.8.5.

@lombokissues
Collaborator

End of migration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment