Bug 133738

Summary: [compiler] Eclipse compiler compiles program but javac does not (2 of 2)
Product: [Eclipse Project] JDT Reporter: e2e4e7e5f2f4 <e2e4e7e5f2f4>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 3.1.2   
Target Milestone: 3.2 M6   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Proposed fix none

Description e2e4e7e5f2f4@yahoo.de CLA 2006-03-28 17:25:13 EST
// Puzzle 86 from "Java Puzzlers" by Joshua Bloch and Neal Gafter

public class PoisonParen {

  static int i1 = -2147483648;

  static int i2 = -(2147483648);

  public static void main(String[] args) {
    System.out.println("i1=" + i1);
    System.out.println("i2=" + i2);
  }
}


This program does compile within Eclipse 3.1.2 using JRE 1.5.0_02
and the output is as follows:

i1=-2147483648
i2=-2147483648

However, it does not compile using the JDK 1.5.0_02 directly.
The output of the JDK is:

javac PoisonParen.java
PoisonParen.java:12: integer number too large: 2147483648
  static int i2 = -(2147483648);
                    ^
1 error

The OS used in both cases is Windows XP.
Comment 1 Olivier Thomann CLA 2006-03-29 11:50:02 EST
Created attachment 37216 [details]
Proposed fix
Comment 2 Olivier Thomann CLA 2006-03-29 13:42:00 EST
Regression test in org.eclipse.jdt.core.tests.compiler.regression.NumericTest.test003.
Fixed and released in HEAD.
Comment 3 Olivier Thomann CLA 2006-03-29 14:11:36 EST
Also added regression test org.eclipse.jdt.core.tests.compiler.regression.NumericTest.test004 for the long case.
Comment 4 Olivier Thomann CLA 2006-03-30 09:53:49 EST
Verified for 3.2M6 using I20060330-0010