Bug 151368 - [1.5][compiler] enum referencing error
Summary: [1.5][compiler] enum referencing error
Status: RESOLVED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: needinfo
Depends on:
Blocks:
 
Reported: 2006-07-21 01:34 EDT by Sandeep Tamhankar CLA
Modified: 2009-08-30 02:05 EDT (History)
0 users

See Also:


Attachments
Enum class that compiles, but when referenced doesn't always work. (4.19 KB, text/plain)
2006-07-24 20:09 EDT, Sandeep Tamhankar CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sandeep Tamhankar CLA 2006-07-21 01:34:23 EDT
I've seen this problem with several 3.2 pre-releases as well as 3.2 proper:

I have an enum containing about 30-40 members and a static final int.  The enum class itself compiles fine.  However, *some* other classes that refer to the enum elements don't compile, complaining about entries that can't be resolved.  Other values from the same enum class are referenced just fine in the referring class.

The enum elements that fail to get referenced properly are either proper enum members or the public static final int member.  I've tried clean builds, but to no avail.

If I build outside of eclipse via jdk 1.5.0_06, everything builds fine.  Thus, this is either a JDT bug, or I've got something misconfigured.  I know for sure that Eclipse is in 'jdk 1.5' mode.  If it wasn't all the template stuff I'm doing wouldn't work either.

Thanks much.
Comment 1 Philipe Mulet CLA 2006-07-21 04:45:10 EDT
Can you pls provide exact steps to reproduce ? We did address a couple enum issues lately, which will make it into 3.2.1, see early preview at: http://www.eclipse.org/jdt/core/r3.2/index.php#UPDATES

Comment 2 Sandeep Tamhankar CLA 2006-07-21 09:10:37 EDT
I've tried to reproduce it in isolation, but to no avail.  It only fails in the context of our overall system.

Is there any kind of debug logging I can turn on in Eclipse?  For example, I could  do a 'clean', then turn on some debugging, and then build my project.  I could then send you that debug output, which hopefully won't include every line of code in the project! :)

In the past I may have sometimes managed to get past the bug by modifying the enum class to have members in a different order...but I'm not sure.

Sorry I can't give you a test case, but I am very willing to try anything you suggest and to give you any debug info that may help you.
Comment 3 Philipe Mulet CLA 2006-07-21 09:45:27 EDT
There is no specific trace which would help you here I am afraid.

Can't you attach a project ? Also does problem occur in both clean build and incremental build mode ?
Pls check bug 145746, bug 145732 or bug 141810 to see if you recognize something familiar.

Last, did you try the 3.2.1 preview I mentionned earlier, it contains fixes for these issues (and many others), maybe this would address your issues as well.
Comment 4 Sandeep Tamhankar CLA 2006-07-21 18:47:53 EDT
I just downloaded org.eclipse.jdt.core_3.2.1.jar.  I put it in my c:\eclipse\plugins directory and started up Eclipse, but it didn't seem to do anything.  I then tried updating c:\eclipse\features\org.eclipse.jdt_3.2.0.v20060609m-F7snq1fxia-Z4XP\feature.xml to declare that it's got version 3.2.1 of the jdt core plugin rather than 3.2.0.v_671.  That didn't seem to help either.

I can't give you a project because I can't give you our code...it's proprietary.

Please tell me what I have to do to be sure I'm running with the new jdt.  Thanks!
Comment 5 Sandeep Tamhankar CLA 2006-07-24 20:09:19 EDT
Created attachment 46739 [details]
Enum class that compiles, but when referenced doesn't always work.

Some classes that reference this enum's elements fail to compile because they claim that they can't find the enum value.
Comment 6 Sandeep Tamhankar CLA 2006-07-24 20:10:10 EDT
One of my colleagues and I were talking about this a little while ago, and one thing that struck us is that the bug showed up for only one enum class.  All of our other enum classes seem to be referenced fine.

He did some experiments and figured out the critical difference between the "bad" enum class and the other good ones:

the bad one has a non-static method near the end.  If he commented out that method definition and re-built, all of the enum reference problems went away (and naturally, those classes trying to call the commented out method now had compile failures).

I tried reproducing this in isolation, but to no avail.  I'm hoping that this gives you a direction to look in, however.  I just attached our "bad" enum class.  Hopefully, you'll be able to do something useful with it.
Comment 7 Sandeep Tamhankar CLA 2006-07-26 16:28:23 EDT
My colleague did some more experiments and discovered that it's not so much about methods being in the enum class.  He said even after removing methods from the enum, at some point in time some consumer classes stopped being able to reference the enum elements.  He believes that the act of modifying/saving the enum class made problems go away for a little while, regardless of what change occurred.

We both also have wondered, "What's different about this enum than other enums we use?"  This is a bigger enum class than any other that we use in our project, and it's name is BeanName.  Is there anything significant about the name of the enum class? Maybe there's an underlying name resolution bug and we're picking up a different BeanName class in the referents.
Comment 8 Sandeep Tamhankar CLA 2006-08-21 16:14:35 EDT
The enum class that's giving me trouble is BeanName (attached to this bug a few weeks ago).  Classes that have trouble referencing enums in BeanName compile fine if BeanName is already compiled (e.g. an incremental build launched when I make a dummy modification of a class the refers to BeanName).
Comment 9 Philipe Mulet CLA 2006-08-29 12:52:17 EDT
Thanks for the testcase, will look into it.
(delay is due to vacation time)
Comment 10 Philipe Mulet CLA 2006-08-30 06:58:39 EDT
Cannot reproduce on your testcase.
Could you attach an example of some referencing file which doesn't work ?
Comment 11 Philipe Mulet CLA 2006-08-30 07:07:04 EDT
Added EnumTest#test136 (with simple ref to offending BeanName enum).
Comment 12 Philipe Mulet CLA 2006-08-30 07:07:30 EDT
Removing 3.2.1 tag until further reproduced/assessed.
Comment 13 Sandeep Tamhankar CLA 2006-08-31 19:36:58 EDT
It seems I can no longer reproduce the issue.  I've tried several clean builds, but it never fails as it did before.  I suspect that as our code evolved, whatever triggered this bug seems to have stopped.

I suspect there is a race condition between BeanName being built and its consumers.  Thus, a dummy modification of one of the consumers and doing an incremental build would make the problem go away because BeanName is already compiled at the time of the incremental build.

Sorry I can't give you more (well, half-sorry.  I'm half-relieved that I'm not experiencing the issue any more... but of course some other random change in our code might tickle this again).

Also, I did reproduce the issue on 3.3M1, but there's no way to know if I reproduced it on 3.2.1 since I couldn't find the instructions for how to install the 3.2.1 jdt into my 3.2.0 setup (am I supposed to look at "Getting the sources"? "build notes"?)
Comment 14 Philipe Mulet CLA 2006-09-05 04:19:19 EDT
Will close it as REMIND, i.e. if you see it again and have better luck finding steps, then pls reopen it.
Comment 15 Denis Roy CLA 2009-08-30 02:05:57 EDT
As of now 'LATER' and 'REMIND' resolutions are no longer supported.
Please reopen this bug if it is still valid for you.