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

Bug 337802

Summary: [1.7][compiler] Usage of 0x0ffffffff is being reported as out of range.
Product: [Eclipse Project] JDT Reporter: Satyam Kandula <satyam.kandula>
Component: CoreAssignee: Satyam Kandula <satyam.kandula>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: amj87.iitr, Olivier_Thomann, srikanth_sankaran
Version: 3.7   
Target Milestone: 3.7.1   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Patch under consideration
none
Proposed fix + regression tests
none
Proposed fix + regression tests
none
Proposed fix + regression tests
none
Cleanup fix none

Description Satyam Kandula CLA 2011-02-22 05:06:05 EST
int a = 0x0FFFFFFFF;
On using the above line, the compiler built on BETA_JAVA7 reports "
The literal 0x0FFFFFFFF of type int is out of range". 
Note that there are only 8F's and hence it should be a valid integer except they are some leading 0's. 
FYI, JDT/Core source code fails with this error when built with BETA_JAVA7 compiler. There are couple of references of 0x00000000FFFFFFFF.
Comment 1 Satyam Kandula CLA 2011-02-22 05:07:49 EST
I know the fix and will take care of this.
Comment 2 Olivier Thomann CLA 2011-02-22 08:27:09 EST
We need to remove all "0" between "0x" and the first non zero digits.
This value is -1 and we have a special treatment for it.
Comment 3 Satyam Kandula CLA 2011-02-22 09:50:30 EST
Created attachment 189498 [details]
Patch under consideration
Comment 4 Olivier Thomann CLA 2011-02-22 10:25:18 EST
Created attachment 189499 [details]
Proposed fix + regression tests

I wonder if we should not "clean" the literal ahead of time. This is a draft. I would need to clean the iteration on "0" inside the compute constant value code.
Let me know what you think.
Comment 5 Olivier Thomann CLA 2011-02-22 10:46:52 EST
Created attachment 189504 [details]
Proposed fix + regression tests

This would be the cleanup version. It can then take advantage of using predefined constants when computing the value.
Comment 6 Olivier Thomann CLA 2011-02-22 11:18:08 EST
Created attachment 189509 [details]
Proposed fix + regression tests

I forgot to remove one comment in LongLiteral. We could prevent the string buffer creation by doing a second iteration over the literal when the modified flag is true.
Comment 7 Olivier Thomann CLA 2011-02-22 11:33:39 EST
Created attachment 189511 [details]
Cleanup fix

This patch only creates the string buffer if either '0' or '_' has to be removed.
Comment 8 Srikanth Sankaran CLA 2011-02-22 23:23:09 EST
Satyam, for fixes getting released only in a branch,
the plan is to leave the milestone empty for the time
being and to mention in white board contents that
it is "Released in BETA_JAVA7 branch only"
Comment 9 Satyam Kandula CLA 2011-02-23 02:02:55 EST
Olivier, Your patch in comment 7 looks good and hence I have released it in the BETA_JAVA7 branch. Thank you.
Comment 10 Ayushman Jain CLA 2011-06-29 07:03:20 EDT
Verified using Eclipse Java 7 Support(Beta) feature patch v20110623-0900.