Bug 244263 - [evaluations] NPE in primitiveWrapper != null
Summary: [evaluations] NPE in primitiveWrapper != null
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows Vista
: P3 normal (vote)
Target Milestone: 3.6 M1   Edit
Assignee: Darin Wright CLA
QA Contact:
URL:
Whiteboard:
Keywords: bugday
: 262019 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-08-14 21:50 EDT by Rafael Chaves CLA
Modified: 2009-07-30 09:50 EDT (History)
3 users (show)

See Also:
Michael_Rennie: review+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rafael Chaves CLA 2008-08-14 21:50:36 EDT
Version: 3.4.0 
Build id: I20080530-1730
Windows or Linux
java.version=1.6.0_03

See the test case below:

public class Test
{
    public static void main(String[] args)
    {
        Boolean foo = null; // #1
        System.out.println( foo ); // #2
    }
}

If you put a conditional breakpoint on the line marked as #2 with the following expression: 

foo != null

You will get an error dialog saying a NullPointerException was encountered when invoking booleanValue(), which is bogus.

Trying to evaluate the same expression via Display view will result in the same NPE. This seems to happen for any of the primitive wrappers.

Workaround is to use the following expression instead:

!(foo == null)
Comment 1 Rafael Chaves CLA 2008-10-16 01:55:12 EDT
I was hoping this would be an easy fix, given that it is easily reproducible. Has anyone looked into this? Any plans of addressing it for 3.5?
Comment 2 Michael Rennie CLA 2008-10-16 09:01:13 EDT
No-one has looked into this yet, as our instruction compiler code is very touchy :)

Contributions are always welcome.
Comment 3 Darin Wright CLA 2009-06-17 15:12:28 EDT
*** Bug 262019 has been marked as a duplicate of this bug. ***
Comment 4 Darin Wright CLA 2009-06-17 15:13:43 EDT
Looks like the evaluation is attempting to unbox expressions for primitive wrappers when using the != operator (which results in an NPE since the object is null and can't be unboxed).
Comment 5 Darin Wright CLA 2009-07-28 17:03:28 EDT
Fixed in ASTInstructionCompiler.visit(InfixExpression). The fix is to only unbox operands for == and != operators when at least one operand is primitive (otherwise, just compare the objects).
Comment 6 Darin Wright CLA 2009-07-28 17:04:00 EDT
Fixed.
Comment 7 Michael Rennie CLA 2009-07-30 09:50:33 EDT
looks good