New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

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

Comments

Projects
None yet
1 participant
@lombokissues
Collaborator

lombokissues commented Jul 14, 2015

Migrated from Google Code (issue 30)

@lombokissues

This comment has been minimized.

Show comment
Hide comment
@lombokissues

lombokissues Jul 14, 2015

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)

Collaborator

lombokissues commented Jul 14, 2015

👤 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

This comment has been minimized.

Show comment
Hide comment
@lombokissues

lombokissues Jul 14, 2015

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.

Collaborator

lombokissues commented Jul 14, 2015

👤 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

This comment has been minimized.

Show comment
Hide comment
@lombokissues

lombokissues Jul 14, 2015

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.

Collaborator

lombokissues commented Jul 14, 2015

👤 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

This comment has been minimized.

Show comment
Hide comment
@lombokissues

lombokissues Jul 14, 2015

Collaborator

End of migration

Collaborator

lombokissues commented Jul 14, 2015

End of migration

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