Bug 58722 - [1.5] cannot extend interfaces
Summary: [1.5] cannot extend interfaces
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M1   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 62806 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-04-15 15:10 EDT by Kasper Nielsen CLA
Modified: 2005-01-11 11:03 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kasper Nielsen CLA 2004-04-15 15:10:12 EDT
its not possible to extend generic interfaces:


public interface A<T>
{
}

public interface B<T> extends A<T>
{
}

 fails with



Internal compiler error
java.lang.ArrayIndexOutOfBoundsException: 22

	at
org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getTypeFromTypeSignature(LookupEnvironment.java:651)

	at
org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.cachePartsFrom(BinaryTypeBinding.java:192)

	at
org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createBinaryTypeFrom(LookupEnvironment.java:314)

	at
org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createBinaryTypeFrom(LookupEnvironment.java:297)

	at org.eclipse.jdt.internal.compiler.Compiler.accept(Compiler.java:191)

	at
org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType(LookupEnvironment.java:107)

	at
org.eclipse.jdt.internal.compiler.lookup.PackageBinding.getTypeOrPackage(PackageBinding.java:173)

	at org.eclipse.jdt.internal.compiler.lookup.Scope.getTypeOrPackage(Scope.java:1602)

	at org.eclipse.jdt.internal.compiler.lookup.Scope.getType(Scope.java:1395)

	at
org.eclipse.jdt.internal.compiler.ast.ParameterizedSingleTypeReference.internalResolveType(ParameterizedSingleTypeReference.java:62)

	at
org.eclipse.jdt.internal.compiler.ast.ParameterizedSingleTypeReference.resolveType(ParameterizedSingleTypeReference.java:153)

	at
org.eclipse.jdt.internal.compiler.ast.TypeReference.resolveSuperType(TypeReference.java:93)

	at
org.eclipse.jdt.internal.compiler.lookup.ClassScope.findSupertype(ClassScope.java:882)

	at
org.eclipse.jdt.internal.compiler.lookup.ClassScope.connectSuperInterfaces(ClassScope.java:665)

	at
org.eclipse.jdt.internal.compiler.lookup.ClassScope.connectTypeHierarchy(ClassScope.java:719)

	at
org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.connectTypeHierarchy(CompilationUnitScope.java:236)

	at
org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.completeTypeBindings(LookupEnvironment.java:177)

	at org.eclipse.jdt.internal.compiler.Compiler.beginToCompile(Compiler.java:305)

	at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:319)

	at
org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:209)

	at
org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:159)

	at
org.eclipse.jdt.internal.core.builder.IncrementalImageBuilder.build(IncrementalImageBuilder.java:113)

	at
org.eclipse.jdt.internal.core.builder.JavaBuilder.buildDeltas(JavaBuilder.java:223)

	at org.eclipse.jdt.internal.core.builder.JavaBuilder.build(JavaBuilder.java:151)

	at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:512)

	at
org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java:611)

	at org.eclipse.core.runtime.Platform.run(Platform.java:543)

	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:140)

	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:227)

	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:169)

	at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:197)

	at
org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java:611)

	at org.eclipse.core.runtime.Platform.run(Platform.java:543)

	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:200)

	at
org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:245)

	at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:273)

	at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:141)

	at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:177)

	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:62)
Comment 1 Kasper Nielsen CLA 2004-04-15 15:13:15 EDT
If i change A to 

import java.util.Collection;

public interface A<T> extends Collection<T> {
}


I do not get an exception.
Comment 2 Philipe Mulet CLA 2004-04-15 18:57:13 EDT
It works fine now. You were likely using Cheetah01, weren't you ?
Comment 3 Kasper Nielsen CLA 2004-04-16 04:50:19 EDT
No im using latest drop cheetah02.
    id = "org.eclipse.jdt.core"
    version = "3.0.0.cheetah02"


but it is actually only every second time I save a file I get the exception. 
Using the above example:

save B -> no problem
save B again -> ArrayIndexOfBound
save B again-> no problem
save B again -> ArrayIndexOfBound
............(no modfications just adding a space)


another problem with B is that the compiler complains about 
"The type A is not generic; it cannot be parameterized with arguments T"
(while underlining A in B,  interface B<T> extends _A_<T> { ...
this happens no matter if I extend Collection from A or not.
Comment 4 Kasper Nielsen CLA 2004-04-16 14:31:30 EDT
Tried cheetah_03 and its *still* an issue.

Notice that i've only experienced problems with interfaces.

Here are some usecase that work
------
public class A<T> { }
public class B<T> extends A<T>{}
-----
//for some there arent any problem if they are declared in the same file
public class F {	
	public static class B<T>{}
	public interface C<T>{}
	public static class D<T> extends B<T>{}
	public static class E<T> implements C<T>{}
}
-----------

Here are two that only compiles occasionally
-----
public interface C<T> {}
public class E<T> implements C<T> {}
-----
public interface C<T> {}
public interface D<T> extends C<T> {}
------
Comment 5 Kasper Nielsen CLA 2004-04-16 14:45:47 EDT
One more update:)

public interface A {}
public interface B extends A {}

works, but
public interface A<T> {}
public interface B extends A {}

doesn't
Comment 6 Philipe Mulet CLA 2004-04-19 06:04:40 EDT
These problems only show up when reconciling editor changes. These never occur 
when building. Problem comes from the fact that the source element converter 
doesn't recreate type variables (yet).
Comment 7 Philipe Mulet CLA 2004-04-19 06:09:33 EDT
BTW, with Cheetah03, I did not get any exception. Simply unexpected compile 
errors about a type not being generic.
Comment 8 Philipe Mulet CLA 2004-05-21 15:51:59 EDT
*** Bug 62806 has been marked as a duplicate of this bug. ***
Comment 9 Philipe Mulet CLA 2004-05-22 08:24:13 EDT
Added basic support to JavaModel to surface type parameters in type 
declarations; so as to get reconcile operations happy again.

This isn't the final take on this front, need to switch to using signatures 
instead of type names in SourceTypeConverter, plus generalize the solution to 
other ISourceElementRequestor implementations; also need to support 
constructor/method type parameters.
Comment 10 Philipe Mulet CLA 2004-05-22 08:25:04 EDT
Will still close this one defect as the released basic support covers these 
very issues.