Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 370117

Summary: Java Compiler Errors/Warnings: split boxing and unboxing conversions to separate settings
Product: [Eclipse Project] JDT Reporter: Jonas Berlin <eclipse.bugs>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: RESOLVED DUPLICATE QA Contact:
Severity: enhancement    
Priority: P3 CC: amj87.iitr, deepakazad, jarthana
Version: 3.8   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Jonas Berlin CLA 2012-01-30 07:36:05 EST
Build Identifier: I20111027-1800

The "Java Compiler Errors/Warnings" preferences page should have separate settings for the severity of boxing and unboxing conversions, as unboxing may throw NPE whereas boxing will not.

Wanted operation:

1. Set "Boxing conversions" to Ignore
2. Set "Unboxing conversions" to Warning
3. Enter the following code:

  int a = new Integer(5);
  Integer b = 5;

4. Only the former line should produce a warning with these settings.

Reproducible: Always
Comment 1 Ayushman Jain CLA 2012-01-30 08:20:07 EST
(In reply to comment #0)
> as unboxing may
> throw NPE whereas boxing will not.

The warning is not really related to only NPEs. Autoboxing also has a performance cost which programmers might want to know about.
Comment 2 Deepak Azad CLA 2012-01-30 08:41:12 EST
(In reply to comment #1)
> The warning is not really related to only NPEs. Autoboxing also has a
> performance cost which programmers might want to know about.
Sure, but a developer may not be worried about performance but only NPEs.
'It is ok if the application runs a bit slower, as long as it runs without any exception'
Comment 3 Deepak Azad CLA 2012-01-30 08:45:08 EST

*** This bug has been marked as a duplicate of bug 163065 ***
Comment 4 Ayushman Jain CLA 2012-01-30 08:48:16 EST
(In reply to comment #2)
> (In reply to comment #1)
> > The warning is not really related to only NPEs. Autoboxing also has a
> > performance cost which programmers might want to know about.
> Sure, but a developer may not be worried about performance but only NPEs.
I'm not saying i'm against the RFE. Just pointing out another motivation behind the warning. :)
Comment 5 Deepak Azad CLA 2012-01-30 08:57:06 EST
Setting whiteboard for this bug to 'To be verified for 3.8M6' is lame IMHO... I don't know what needs to be 'verified' here.
Comment 6 Jay Arthanareeswaran CLA 2012-01-30 09:02:12 EST
It's required only when the original bug has a target set or released in the particular milestone.