Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Boxing Compiler Warnings
Boxing Compiler Warnings [message #664588] Mon, 11 April 2011 09:57 Go to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi,

I've been hit by NPEs in code produced by my co-workers and found the
compiler option "Java > Compiler > Error/Warnings >
Potential programming problems > Boxing and unboxing conversions".
Setting this one to a "Warning" adds the warnings whenever you type:

int i = o.getInteger(); // Bla#getInteger(): Integer

but also if you do:

o.setIntger(10); // Bla#setInteger(Integer): void

Is there an option I missed which adds a warning when a conversion from
the object to the primitive type is happening (which is a potential
programming problem) but in the opposite case?

Tom
Re: Boxing Compiler Warnings [message #664654 is a reply to message #664588] Mon, 11 April 2011 13:53 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.us.NOSPAM.ibm.com

Hi,
>
> o.setIntger(10); // Bla#setInteger(Integer): void
>

I'm not sure if I understand correctly. But it is not physically
possible to have an NPE going from from a primitive->Object. There is no
such thing as a null primitive value so you will always get an instance
of Integer (assuming going into an Integer) and never a null.
--
Thanks,
Rich Kulp
Re: Boxing Compiler Warnings [message #664655 is a reply to message #664654] Mon, 11 April 2011 14:02 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Am 11.04.11 15:53, schrieb Rich Kulp:
> Hi,
>>
>> o.setIntger(10); // Bla#setInteger(Integer): void
>>
>
> I'm not sure if I understand correctly. But it is not physically
> possible to have an NPE going from from a primitive->Object. There is no
> such thing as a null primitive value so you will always get an instance
> of Integer (assuming going into an Integer) and never a null.

Exactly and that's why a warning on this line is NOT making sense
whereas on the opposite it does.

So my request is:
a) Get a new prefernce where only Object => Primitive is flagged with a
warning
b) Modify the current warning to only Object => Primitive leads to a
warning

Tom
Previous Topic:How to Modify the Eclipse Java Compiler/Grammar java.g. has any introducts the grammar of .g file?
Next Topic:How to add custom validation?
Goto Forum:
  


Current Time: Fri Apr 26 02:22:55 GMT 2024

Powered by FUDForum. Page generated in 0.02896 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top