Bug 136508 - Inner Classes in Interfaces No Longer Compiles
Summary: Inner Classes in Interfaces No Longer Compiles
Status: VERIFIED FIXED
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: 3.2 RC2   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-04-12 20:59 EDT by Doug Schaefer CLA
Modified: 2006-04-28 11:01 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Doug Schaefer CLA 2006-04-12 20:59:50 EDT
Thas was introduced with M6. You can argue the sanity of this code, but the org.eclipse.cdt.core plugin has an interface ICSearchConstants that has two inner classes defined like this:

	public class SearchFor{
		private SearchFor( int value )
		{
			this.value = value;
		}
		private final int value;
	}

	public class LimitTo {
		private LimitTo( int value )
		{
			this.value = value;
		}
		private final int value;
	}

I am getting a compile error in a sub-interface ICSearchPattern when LimitTo is used as a parameter:

	boolean	canAccept( LimitTo limit );

Everywhere else seems to be fine with it.

You can check out the org.eclipse.cdt.core plugin from /cvsroot/tools/org.eclipse.cdt-core. This code now only exists on the cdt_3_0 branch.
Comment 1 Olivier Thomann CLA 2006-04-17 10:07:25 EDT
Could you please provide a complete test case?
I tried with N0417 and it worked fine.
Closing as REMIND.
Please reopen when the requested information is available.
Comment 2 Olivier Thomann CLA 2006-04-17 10:12:49 EDT
Reproduced checking out the branch 3_0 of the cdt-core plugin.
Comment 3 Olivier Thomann CLA 2006-04-17 10:23:46 EDT
Kent,

This fails during the first full build, but if you modify the contents of the ICSearchPattern interface and recompiles, the error is gone.
I tried to reduce the test case, but I could not get a test case that reproduces the failure once isolated.
Comment 4 Olivier Thomann CLA 2006-04-17 10:27:05 EDT
If I compile using only the batch compiler (and the ant script), I cannot reproduce.
Comment 5 Olivier Thomann CLA 2006-04-17 10:36:17 EDT
It seems to be related to the position of the ISearchConstants and ICSearchPattern  interfaces in the build process.
If the two interfaces are compiled after all other types, it fails. But if I insert them at the beginning of the compilation process, it succeeds.
Comment 6 Kent Johnson CLA 2006-04-25 15:43:59 EDT
This was a heck of a bug!

We used a tagBit to temporarily mark interfaces while we walked the hierarchy of a type in case it contained multiple references to the same interface, then cleared the bit at the end of the loop.

The problem was we used the same bit in other places for the same purpose and after marking an interface ICSearchPattern, we ended up resolving a method of ICSearchConstants which contained a reference to a member type of ICSearchPattern.

Well findMemberType() also used the bit to walk the hierarchy to find inherited member types.

This bug has been around for a long time but is very order dependent. The affected types needed to be compiled in a very specific order for the bug to happen.

I've thrown away the bit and we're now using SimpleSets to hold onto the interfaces that we've seen.
Comment 7 Doug Schaefer CLA 2006-04-25 15:53:36 EDT
Excellent! I'll give it a try when RC2 comes out. Thanks.
Comment 8 Olivier Thomann CLA 2006-04-25 16:50:29 EDT
Moved org.eclipse.jdt.internal.core.util.SimpleSet into org.eclipse.jdt.internal.compiler.util.SimpleSet.
Otherwise this introduces a dependency on the compiler on the model classes.
Comment 9 Philipe Mulet CLA 2006-04-26 05:00:25 EDT
Kent - where is the regression test ?
Comment 10 Kent Johnson CLA 2006-04-26 11:56:43 EDT
Had no luck reducing this case to a smaller testcase.

To test, compile the org.eclipse.cdt.core plugin from the cdt_3_0 branch in /cvsroot/tools/org.eclipse.cdt-core
Comment 11 Philipe Mulet CLA 2006-04-27 10:02:08 EDT
I reverted Scope to what it was before the change (keeping MethodVerifier change), and wasn't able to reproduce the issue in CDT.
Comment 12 Doug Schaefer CLA 2006-04-28 11:01:40 EDT
Excellent. CDT 3.0.x now compiles. Thanks!