Community
Participate
Working Groups
Build ID: I20090202-1535 Steps To Reproduce: The error "Cannot reference a field before it is defined" appears in the Java compiler of Eclipse 3.5M5 (I20090202-1535). This same code compiles correctly in Eclipse 3.4.1 (M20080911-1700) and javac 1.6.0_11. In the code below, it appears on lines 3 & 4 where Days.OFFSET is used during construction of the enum values. Moving the final OFFSET definition above the enum causes token errors. More information: public enum Days { Monday("Mon", Days.OFFSET + 0), // error here Tuesday("Tue", Days.OFFSET + 1); // and here public static final int OFFSET = 0; // cannot move this above, else more errors Days(String abbr, int index) { } }
Added disabled regression test: org.eclipse.jdt.core.tests.compiler.regression.EnumTest#_test170
Only single name forward references to OFFSET should be complained against. Qualified ones should be tolerated (resulting in using default value).
likely a consequence of fix for bug 255452
Created attachment 124952 [details] Proposed patch
The check for forward references inside Enum introduced with bug 255452 was slightly wrong. It should only complain for enum constants, as opposed to all fields declared inside enums... Since fix for bug 255452 was also backported for 3.4.2, we should fix this one there as well. Unfortunately, 3.4.2 is done already.
Created attachment 124954 [details] Better patch includes a change for EnumTest#test169 which is improved by the change
Created attachment 124955 [details] Proposed patch for 3.4
Released for 3.5M6 Fixed
Released in 3.4.x stream (post 3.4.2)
*** Bug 266466 has been marked as a duplicate of this bug. ***
*** Bug 266500 has been marked as a duplicate of this bug. ***
Verified for 3.5M6 using I20090310-0100
*** Bug 268308 has been marked as a duplicate of this bug. ***
*** Bug 269388 has been marked as a duplicate of this bug. ***
I got it with update to M20090211-1700 and I want to get it off by same way. Could you please set the target milestone to the next coming update.
What do you mean ? It is already marked with proper milestone.
(In reply to comment #16) > What do you mean ? It is already marked with proper milestone. I wouldn't call this a proper schedule for a real defect without any workarounds other than changing our code (which is not an option for an bug in the IDE). And as long as "revert configuration" seems broken for almost all installations in this company, downgrading to 3.4.1 was a real pain ** *** ***.
I'd like to echo the sentiment of previous comment (#17). The IDE is fundamentally broken and there are no plans to put out a 3.4.3? We have to wait until June '09 for 3.5 before the compiler will actually work?
I additionally agree with this sentiment. We have several engineers reporting this problem, and a point release would be great.
I did deliver the fix to 3.4 stream, so we could construct a patch for it. It should be posted at http://www.eclipse.org/jdt/core/r3.4/index.php#UPDATES but I do not see it presently. We will publish one asap.
*** Bug 275736 has been marked as a duplicate of this bug. ***
any ETA about when the fix backport to 3.4.x will be released? I'm using also Flex Builder so upgrading to 3.5 won't be an option for the time needed to Adobe to upgrade that plugin thanks for any info
Install the zip file: http://www.eclipse.org/jdt/core/patches/patch.zip into your dropins folder and restart. This will install a version of JDT/Core that contains the fix.
(In reply to comment #23) > Install the zip file: > http://www.eclipse.org/jdt/core/patches/patch.zip > into your dropins folder and restart. > > This will install a version of JDT/Core that contains the fix. > Thanks Olivier! Now everything works fine!