Bug 133738 - [compiler] Eclipse compiler compiles program but javac does not (2 of 2)
Summary: [compiler] Eclipse compiler compiles program but javac does not (2 of 2)
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.2 M6   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-03-28 17:25 EST by e2e4e7e5f2f4@yahoo.de CLA
Modified: 2006-03-30 09:53 EST (History)
0 users

See Also:


Attachments
Proposed fix (1.84 KB, patch)
2006-03-29 11:50 EST, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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