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
equality between Java enums is not handled correctly #534
Comments
Thanks for reporting this. Is |
@jeremydubreil Status is a normal very basic enum. Here is the main part in case you need it: public enum Status {
OK(0),
MISSING_ACTION(12),
MISSING_CHANNEL_ID(13),
MISSING_PROPERTY_ID(14),
MISSING_PAYLOAD_VALUE(15),
public final int code;
Status(int code) {
this.code = code;
}
} Hope it helps |
@jeremydubreil I encountered an identical false positive today. Any progress on this one? |
I looked a bit into this and can reproduce with the following example: enum Status {
OK(0),
MISSING_PROPERTY_ID(14);
public final int code;
Status(int code) {
this.code = code;
}
}
class IIdentifier {
public void getChannel() { }
}
class Message {
private final IIdentifier id = new IIdentifier();
public IIdentifier getId() {
return this.id;
}
public Status consistencyCheck() {
if(this.id == null) return Status.MISSING_PROPERTY_ID;
return Status.OK;
}
}
class Foo {
public Status route(Message msg) {
Status status = msg.consistencyCheck();
if (status == Status.OK) {
msg.getId().getChannel();
}
return status;
}
} If I make
So, in short, it seems that the support of Java enums could be improved. |
Hey guys,
I have a very simple class in Java with:
and then on another file I call
The problem is that Infer reports the call to msg.getId() as a null_dereference even though the consistencyCheck obviously states that such an state is not possible due to the Status.OK return value.
Let me know if you need more information and thanks a lot for the great tool :)
Infer version v0.9.2
OS: Mac OS X 10.11
The text was updated successfully, but these errors were encountered: