-
Notifications
You must be signed in to change notification settings - Fork 9
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
NullPointerException processing (ternary) conditional inside String concatenation when branches have different types #6
Comments
Thanks for the bug report! Could you try to minimize the testcase? |
I can reproduce a similar bug with a single line in an arbitrary Java file:
This is totally valid in Java. In this case, I get a ClassCastException instead:
In this particular case it looks like it's just CheckerFramework that's crashing, so maybe this is best treated as a CheckerFramework bug? Again, I'm not sure. I'm going to see if I can figure out how to get an NPE instead like in the original code. |
I'm actually not sure how to reproduce the NPE outside of the environment, so hopefully the other error combined with link to the app code is enough of a lead |
I'm not sure if this error is coming from SPARTA or CheckerFramework, so please feel free to move this if it's not SPARTA-specific. I put it here because I tried it with the NullnessChecker and it didn't happen, but it might happen with other checkers, too.
I'm annotating a very small existing application. Without any annotations, it fails with a NullPointerException when I run SPARTA. I've localized the failure to one line:
Interestingly, this entire expression type-checks as a String, but the inner conditional doesn't. You can assign it to Object:
Otherwise, since seconds is an integer, you can't assign the result to a String.
So out of curiosity, I tried changing it so that the inner piece typechecks as a String:
This resolves the error.
Here's an abbreviated stack trace:
You can find the application here. I've already changed that line, so if you want to reproduce it you'll have to change it back. SPARTA is already integrated with gradle if you run this from the top directory:
You can edit build.gradle to swap in other checkers.
The text was updated successfully, but these errors were encountered: