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

Bug 350095

Summary: The 2000th (0-based) enum constant is null
Product: [Eclipse Project] JDT Reporter: Cliff <zhaotq>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: VERIFIED FIXED QA Contact:
Severity: critical    
Priority: P3 CC: daniel_megert, deepakazad, flood, jarthana, Olivier_Thomann, zhaotq
Version: 3.7Flags: daniel_megert: pmc_approved+
jarthana: review+
Target Milestone: 3.7.1   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
The test case shows the null enum constant.
none
Proposed fix + updated regression test
none
Proposed fix + regression tests none

Description Cliff CLA 2011-06-22 15:27:21 EDT
Build Identifier: 20110615-0604

Any enum class that has more than 2000 constants has this problem.
Enum.getEnumConstants()[2000] is a null value.

The test case is attached. You will see the 2000th value is null.

Sun compiler does not have this problem.



Reproducible: Always

Steps to Reproduce:
1. Compile the attached the TestEnum.java
2. Run the TestEnum
3. will see a null printed.
Comment 1 Cliff CLA 2011-06-22 15:29:11 EDT
Created attachment 198432 [details]
The test case shows the null enum constant.
Comment 2 Olivier Thomann CLA 2011-06-22 19:22:05 EDT
I'll fix it.
Comment 3 Olivier Thomann CLA 2011-06-23 13:23:06 EDT
Created attachment 198483 [details]
Proposed fix + updated regression test

In fact an existing regression test was bogus. It clearly shows null for one of the constants.
Comment 4 Olivier Thomann CLA 2011-07-07 14:04:01 EDT
Released in BETA_JAVA7 branch. Since this branch will be our 3.7.1 contents,
this is fine.
Comment 5 Deepak Azad CLA 2011-07-19 08:33:24 EDT
Verified with v20110714-1300.
Comment 6 Jan Koops CLA 2011-08-29 07:51:46 EDT
Bug is still there for exactly 2001 values, tested with "Eclipse Compiler for Java(TM) 0.B75_R37x, 3.7.1", just shorten the test case TestEnum to end after "E2000".
Comment 7 Olivier Thomann CLA 2011-08-29 07:56:30 EDT
I'll take a look.
Comment 8 Olivier Thomann CLA 2011-08-29 09:25:26 EDT
Created attachment 202315 [details]
Proposed fix + regression tests

When the number of enum constants is exactly the limit + 1, the last constant was not properly initialized.
Good catch.
Comment 9 Olivier Thomann CLA 2011-08-29 09:27:27 EDT
Daniel, I think this needs to be fixed as one constant is not initialized and there is no workaround.
Jay, please review.

Daniel, Srikanth is in vacations this week. So it will be difficult to get his +1.
Comment 10 Dani Megert CLA 2011-08-29 10:49:22 EDT
+1 for 3.7.1 RC3
Comment 11 Jay Arthanareeswaran CLA 2011-08-29 11:03:03 EDT
(In reply to comment #9)
> Daniel, I think this needs to be fixed as one constant is not initialized and
> there is no workaround.
> Jay, please review.

+1 for the patch. One question is, do we even need the statement 'count = 1'?
Comment 12 Olivier Thomann CLA 2011-08-29 11:07:04 EDT
(In reply to comment #11)
> +1 for the patch. One question is, do we even need the statement 'count = 1'?
Yes, this is to make sure we generate the last constant (here only the last one) when we check if count != 0 after the loop.
Comment 13 Olivier Thomann CLA 2011-08-29 12:36:49 EDT
Released for 3.7.1 and 3.8M2.
Comment 14 Jay Arthanareeswaran CLA 2011-09-05 05:40:43 EDT
Verified for 3.7.1 with build M20110831-1030.
Comment 15 Jay Arthanareeswaran CLA 2011-09-14 04:33:29 EDT
Verified for 3.8M2 with build I20110912-2126.