When I check if the instance of StoredCredential is null
if(storedCredential != null){
//do something
}
Netbeans 7.1 shows the following warning:
bad operand types for binary operator '=='
first type: com.blah.dbcore.mypublic.beans.StoredCredential
second type: <nulltype>
It compiles correctly and throws no RuntimeExceptions, but Netbeans still shows the warning. Checking if the instance is not null, with '!=', gives the same error.
The following code does the same thing, but is a lot less clear:
if (!(storedCredential instanceof StoredCredential)) {
//do something
}
Netbeans has no problem with this expression.
Because it has no problem compiling, I'm assuming there is something wrong with the way I added the .jar containing the class to the library. This is the only problem I'm having with this jar though, no other class in this .jar gives me this problem.
I've had this issue, too. Also, where I tried to pass an instance of the problem class into a method which accepted an Object as a parameter, I got the following error:
required: String,Object
found: String,SomeClass
reason: actual argument SomeClass cannot be converted to Object by method invocation conversion
Turned out the compiler was unable to determine the correct type of my class.
My class (let's call it com.blah.lib.SomeClass) was in one NB project (let's call it Project 1) and extended a class in a 3rd party jar, which was a library for Project 1.
Another NB project (let's call it Project 2) depended on Project 1 and used com.blah.lib.SomeClass, but did not have the 3rd party jar in its libs, so when compiling Project 2, the compiler was unable to determine the full inheritance of com.blah.lib.SomeClass.
So the solution was to add the 3rd party jar to Project 2's libraries, too.
I know this is years old, but I thought I'd post this answer in case it helps anyone else Googling the issue in the future.
Netbeans is telling you that at that point in the program, storedCredential
cannot possibly be null. This probably means that you already called a method or accessed a data member on storedCredential
earlier in that method.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.