Skip to content
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

Sneaky Throws Not Correctly Detected for Anonymous Inner Class #74

Closed
danielsomerfield opened this issue Jan 29, 2015 · 3 comments
Closed
Assignees
Labels
Milestone

Comments

@danielsomerfield
Copy link

There is a particular case with an anonymous inner class that the plugin appears not to correctly detect that the @SneakyThrows annotation should handle the thrown exception.

package bugReport;
import lombok.SneakyThrows;
import java.io.IOException;
public class BugReport {
    private IInner inner;

    //@SneakyThrows(IOException.class)
    public BugReport() {
         inner = new IInner() {
             @SneakyThrows(IOException.class)
             @Override
             public IInner doSomething() {
                 throw new IOException();
             }
        };
    }

    interface IInner {
        public IInner doSomething() throws IOException;
    }
}

If you uncomment the sneaky throws, it will compile in Intellij, but it will fail in javac with the following message: ...exception java.io.IOException is never thrown in body of corresponding try statement.

@mplushnikov mplushnikov added the bug label Feb 5, 2015
@mplushnikov mplushnikov self-assigned this Feb 5, 2015
mplushnikov pushed a commit that referenced this issue Feb 6, 2015
… handler

and fixed Sneaky Throws Not Correctly Detected for Anonymous Inner Class #74
@mplushnikov
Copy link
Owner

I've reimplemented @SneakyThrow hander to fix this kind of error, but it will work only in Intellij version 14.0 and greater.

@mplushnikov mplushnikov added this to the 0.9 milestone Feb 6, 2015
@mplushnikov
Copy link
Owner

Version 0.9.0 of plugin is available now

@danielsomerfield
Copy link
Author

Looks great! Thanks for the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants