Bug 180109 - [compiler] JDT Throws ClassCastException on incremental build
Summary: [compiler] JDT Throws ClassCastException on incremental build
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3   Edit
Hardware: All All
: P3 major (vote)
Target Milestone: 3.3 M7   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-03-29 21:53 EDT by Greg Gibeling CLA
Modified: 2007-04-27 09:55 EDT (History)
0 users

See Also:


Attachments
The file in which the exception is reported by JDT. (5.89 KB, text/java)
2007-03-29 21:55 EDT, Greg Gibeling CLA
no flags Details
Proposed patch (40.92 KB, patch)
2007-04-10 15:01 EDT, Kent Johnson CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Greg Gibeling CLA 2007-03-29 21:53:33 EDT
Build ID: I20070323-1616

Possibly related to Bug 180030, similar situation but with a different exception.

Steps To Reproduce:
I changed an internal implementation detail of the QueueCost.java file.  This resulted in the following exception being thrown in line 0 of SortedSetQueue.java (attached).  As with most incremental build related errors this exception is not reproducible after a clean.

More information:
java.lang.ClassCastException: org.eclipse.jdt.internal.compiler.lookup.UnresolvedReferenceBinding cannot be cast to org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding
	at org.eclipse.jdt.internal.compiler.lookup.ClassScope.detectHierarchyCycle(ClassScope.java:1098)
	at org.eclipse.jdt.internal.compiler.lookup.ClassScope.detectHierarchyCycle(ClassScope.java:1056)
	at org.eclipse.jdt.internal.compiler.lookup.ClassScope.detectHierarchyCycle(ClassScope.java:1007)
	at org.eclipse.jdt.internal.compiler.ast.ParameterizedSingleTypeReference.internalResolveType(ParameterizedSingleTypeReference.java:157)
	at org.eclipse.jdt.internal.compiler.ast.ParameterizedSingleTypeReference.resolveType(ParameterizedSingleTypeReference.java:220)
	at org.eclipse.jdt.internal.compiler.ast.TypeReference.resolveSuperType(TypeReference.java:114)
	at org.eclipse.jdt.internal.compiler.lookup.ClassScope.findSupertype(ClassScope.java:1112)
	at org.eclipse.jdt.internal.compiler.lookup.ClassScope.connectSuperclass(ClassScope.java:825)
	at org.eclipse.jdt.internal.compiler.lookup.ClassScope.connectTypeHierarchy(ClassScope.java:950)
	at org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.connectTypeHierarchy(CompilationUnitScope.java:290)
	at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.completeTypeBindings(LookupEnvironment.java:218)
	at org.eclipse.jdt.internal.compiler.Compiler.internalBeginToCompile(Compiler.java:598)
	at org.eclipse.jdt.internal.compiler.Compiler.beginToCompile(Compiler.java:356)
	at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:370)
	at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:356)
	at org.eclipse.jdt.internal.core.builder.IncrementalImageBuilder.compile(IncrementalImageBuilder.java:302)
	at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:293)
	at org.eclipse.jdt.internal.core.builder.IncrementalImageBuilder.build(IncrementalImageBuilder.java:130)
	at org.eclipse.jdt.internal.core.builder.JavaBuilder.buildDeltas(JavaBuilder.java:265)
	at org.eclipse.jdt.internal.core.builder.JavaBuilder.build(JavaBuilder.java:192)
	at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:629)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:163)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:199)
	at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:248)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:251)
	at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:307)
	at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:339)
	at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:137)
	at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:235)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)
Comment 1 Greg Gibeling CLA 2007-03-29 21:55:37 EDT
Created attachment 62452 [details]
The file in which the exception is reported by JDT.

This file may not contain any useful information about the exception.  I will be happy to provide any other files or help that I can.
Comment 2 Philipe Mulet CLA 2007-03-30 04:51:03 EDT
Kent - looks like there is a path missing to trigger resolution of lazy references from binaries.
Comment 3 Philipe Mulet CLA 2007-03-30 05:33:26 EDT
It looks to me that problem comes from:
ClasScope#line 1055
   parentType = ((ParameterizedTypeBinding) parentType).type;

The slot #type may not have been resolved until now.
We construct ParameterizedTypeBinding containing unresolved types possibly.
Feels to me there are more than this one place where we could be affected... (could be wrong).
What if we asked such a type (Param containing Unresolved) for its fields, methods or even erasure ? None of these would trigger resolution. Are we sure that it cannot occur on a yet unresolved param type ?
Comment 4 Kent Johnson CLA 2007-03-30 13:59:57 EDT
Could you please also attach the type declarations for these 3 classes:

extends SkipListSortedSet<T> implements SortedSet<T>, Queue<T>

and all of their superclasses/superinterfaces.

We don't need the fields/methods, just the type declaration portion.
Comment 5 Greg Gibeling CLA 2007-03-30 14:48:00 EDT
I apologize for the size of this and the time it took me to assemble, but it's a pretty complex inheritance hierarchy (as you can see).

Incidentally, I have had larger problems with this hierarchy in past releases of Eclipse.  The class Skiplist seems to be the root of the trouble, files which reference Skiplist or it's descendants are the ones where the JDT compiler exceptions (or just spurious error messages) crop up.

If you would prefer a complete source zip or tarball I can provide one privately, though it's about 25MB at last count.  There are some incorrect license headers in it right now, and not all the code is mine, so it can't really be posted.  Or just let me know if you need any more type signatures....



public class SkipListSortedSet<T> extends Skiplist<T, Skiplist<T, ?, ?, ?, ?>.SkiplistIterator, SkipListSortedSet.SubSkipListSortedSetIterator<T>, SkipListSortedSet.SubSkipListSortedSet<T>, SkipListSortedSet<T>> implements SortedSet<T> {}
public abstract class Skiplist<T, I extends Skiplist<T, ?, ?, ?, ?>.SkiplistIterator, SI extends AbstractSorted.SubSortedIterator<T, I, SI, SS, S>, SS extends AbstractSorted.SubSorted<T, I, SI, SS, S>, S extends Skiplist<T, I, SI, SS, S>> extends AbstractSorted<T, I, SI, SS, S> {}

protected static class SubSkipListSortedSetIterator<T> extends AbstractSortedSet.SubSortedSetIterator<T, Skiplist<T, ?, ?, ?, ?>.SkiplistIterator, SubSkipListSortedSetIterator<T>, SubSkipListSortedSet<T>, SkipListSortedSet<T>> {}
protected static class SubSkipListSortedSet<T> extends AbstractSortedSet.SubSortedSet<T, Skiplist<T, ?, ?, ?, ?>.SkiplistIterator, SubSkipListSortedSetIterator<T>, SubSkipListSortedSet<T>, SkipListSortedSet<T>> {}
public abstract class AbstractSorted<T, I extends SortedBiIterator<T>, SI extends AbstractSorted.SubSortedIterator<T, I, SI, SS, S>, SS extends AbstractSorted.SubSorted<T, I, SI, SS, S>, S extends AbstractSorted<T, I, SI, SS, S>> extends AbstractCollection<T, I, SI, SS, S> implements Sorted<T> {}
public static class SubSortedIterator<T, I extends SortedBiIterator<T>, SI extends AbstractSorted.SubSortedIterator<T, I, SI, SS, S>, SS extends AbstractSorted.SubSorted<T, I, SI, SS, S>, S extends AbstractSorted<T, I, SI, SS, S>> extends AbstractSubCollectionIterator<T, I, SI, SS, S> implements SortedBiIterator<T> {}

public abstract static class SubSorted<T, I extends SortedBiIterator<T>, SI extends AbstractSorted.SubSortedIterator<T, I, SI, SS, S>, SS extends AbstractSorted.SubSorted<T, I, SI, SS, S>, S extends AbstractSorted<T, I, SI, SS, S>> extends AbstractSubCollection<T, I, SI, SS, S> implements Sorted<T> {}
public abstract static class AbstractSubCollection<T, I extends FixedUniIterator<T>, SI extends AbstractSubCollectionIterator<T, I, SI, SC, C>, SC extends AbstractSubCollection<T, I, SI, SC, C>, C extends AbstractCollection<T, I, SI, SC, C>> extends AbstractImmutableSubCollection<T, I, SI, SC, C> implements Collection<T> {}
protected abstract static class AbstractSubCollectionIterator<T, I extends FixedUniIterator<T>, SI extends AbstractSubCollectionIterator<T, I, SI, SC, C>, SC extends AbstractSubCollection<T, I, SI, SC, C>, C extends AbstractCollection<T, I, SI, SC, C>> extends AbstractImmutableSubCollectionIterator<T, I, SI, SC, C> implements FixedUniIterator<T> {}
public abstract class AbstractCollection<T, I extends FixedUniIterator<T>, SI extends AbstractCollection.AbstractSubCollectionIterator<T, I, SI, SC, C>, SC extends AbstractCollection.AbstractSubCollection<T, I, SI, SC, C>, C extends AbstractCollection<T, I, SI, SC, C>> extends AbstractImmutableCollection<T, I, SI, SC, C> implements Collection<T> {}
public abstract static class AbstractImmutableSubCollectionIterator<T, I extends ImmutableFixedUniIterator<T>, SI extends AbstractImmutableSubCollectionIterator<T, I, SI, SC, C>, SC extends AbstractImmutableSubCollection<T, I, SI, SC, C>, C extends AbstractImmutableCollection<T, I, SI, SC, C>> implements ImmutableFixedUniIterator<T> {}
public abstract class AbstractImmutableCollection<T, I extends ImmutableFixedUniIterator<T>, SI extends AbstractImmutableCollection.AbstractImmutableSubCollectionIterator<T, ?, SI, SC, C>, SC extends AbstractImmutableCollection.AbstractImmutableSubCollection<T, ?, SI, SC, C>, C extends AbstractImmutableCollection<T, I, SI, SC, C>> extends AbstractFilter<T> implements ImmutableCollection<T> {}
public abstract class AbstractFilter<T> implements Filter<T> {}

public class SkiplistIterator implements SortedBiIterator<T> {}
public interface SortedBiIterator<T> extends FixedBiIterator<T>, ImmutableSortedBiIterator<T> {}
public interface FixedBiIterator<T> extends ImmutableBiIterator<T>, FixedUniIterator<T>, FixedBiPosition<T> {}
public interface ImmutableBiIterator<T> extends ImmutableFixedUniIterator<T>, ImmutableBiPosition<T> {}
public interface ImmutableFixedUniIterator<T> extends ImmutableIterator<T>, ImmutableFixedUniPosition<T> {}
public interface ImmutableIterator<T> extends ImmutablePosition<T>, Copyable {}
public interface ImmutablePosition<T> extends ImmutableSingletonInterface<T> {}
public interface ImmutableSingletonInterface<A> {}
public interface ImmutableFixedUniPosition<T> extends ImmutablePosition<T>, ImmutableSingletonInterface<T> {}
public interface ImmutableBiPosition<T> extends ImmutableFixedUniPosition<T> {}
public interface FixedUniIterator<T> extends Iterator<T>, ImmutableFixedUniIterator<T>, FixedUniPosition<T> {}
public interface Iterator<T> extends ImmutableIterator<T>, Position<T> {}
public interface Position<T> extends ImmutablePosition<T>, SingletonInterface<T> {}
public interface SingletonInterface<A> extends ImmutableSingletonInterface<A> {}
public interface FixedBiPosition<T> extends ImmutableBiPosition<T>, FixedUniPosition<T> {}
public interface FixedUniPosition<T> extends Position<T>, ImmutableFixedUniPosition<T> {}
public interface ImmutableSortedBiIterator<T> extends ImmutableBiIterator<T> {}

public interface SortedSet<T> extends ImmutableSortedSet<T>, Set<T>, Sorted<T> {}
public interface ImmutableSortedSet<T> extends ImmutableSet<T>, ImmutableSorted<T> {}
public interface Set<T> extends Collection<T>, ImmutableSet<T> {}
public interface Sorted<T> extends SortedBiIterable<T>, Collection<T>, ImmutableSorted<T> {}
public interface ImmutableSet<T> extends ImmutableCollection<T> {}
public interface ImmutableSorted<T> extends ImmutableList<T>, ImmutableSortedBiIterable<T>, Comparing<T> {}
public interface Collection<T> extends ImmutableCollection<T>, ModCount, FixedUniIterable<T>, DynamicFilter<T, CollectionTransaction<T>> {}
public interface ImmutableCollection<T> extends ImmutableFixedUniIterable<T>, Filter<T>, Accessing<T>, Copyable, Immutable {}
public interface ImmutableList<T> extends ImmutableCollection<T>, ImmutableBiIterable<T> {}

public interface DynamicFilter<T, E extends FilterTransaction<T>> extends Filter<T>, Transactional<E>, Copyable, Immutable {}
public interface CollectionTransaction<T> extends FilterTransaction<T> {}

public interface Transactional<X extends Transaction> extends EventSource {}
public interface FilterTransaction<T> extends Transaction, IdentityChangeEvent<Filter<T>> {}
public interface IdentityChangeEvent<T> extends Event {}
public interface Transaction extends Event, Task, ThreadLocking {}
public interface Event {}
public interface Task extends EventSource, GUIAccessible {}
public interface EventSource {}
public interface GUIAccessible {}

public interface Filter<T> {}
public interface Copyable {}
public interface Immutable {}
public interface Comparing<T> extends Accessing<T> {}
public interface Accessing<T> {}
public interface ModCount {}

public interface SortedBiIterable<T> extends FixedBiIterable<T>, ImmutableSortedBiIterable<T> {}
public interface FixedBiIterable<T> extends ImmutableBiIterable<T>, FixedUniIterable<T> {}
public interface ImmutableBiIterable<T> extends ImmutableFixedUniIterable<T> {}
public interface ImmutableFixedUniIterable<T> extends ImmutableIterable<T> {}
public interface ImmutableIterable<T> extends ThreadLocking {}
public interface ThreadLocking {}
public interface FixedUniIterable<T> extends Iterable<T>, ImmutableFixedUniIterable<T> {}
public interface Iterable<T> extends ImmutableIterable<T> {}
public interface ImmutableSortedBiIterable<T> extends ImmutableBiIterable<T> {}
public interface ImmutableBiIterable<T> extends ImmutableFixedUniIterable<T> {}

public interface Queue<T> extends ReadQueue<T>, WriteQueue<T> {}
public interface ReadQueue<T> extends EventSource {}
public interface WriteQueue<T> extends EventSource {}
public interface EventSource {}
Comment 6 Kent Johnson CLA 2007-04-03 15:52:42 EDT
Do you have errors on any of these type declarations or do they all compile without any errors (ignoring method bodies) ?
Comment 7 Greg Gibeling CLA 2007-04-03 17:22:13 EDT
There are no errors associated with any of those types in my files.  I can't imagine how removing method bodies could introduce errors.

However in my code those types are distributed across MANY packages, and some are inner types of others.  I realize now that I did not include the packages the various types came from, or correctly include the inner types within their appropriate outer types.  Thus if you attempt to put that mess of declarations straight into JDT or Javac, there should be errors.

However, in my original code there are NO ERRORS IN ANY OF THESE CLASSES.  The errors only occur on incremental (not post-clean) builds and a transient (i.e. they go away after a single clean and full build).

I think I answered your question, but if not let me know.  I'd be happy to help any way possible, up to and including debugging JDT myself if someone wants to or can help me get a suitable debugging environment set up.
Comment 8 Kent Johnson CLA 2007-04-04 12:17:19 EDT
I've reduced the testcase to these 2 files:

--- in X.java ---
class X<T> extends A<T> {}

--- in Others.java ---
class A<T> extends B<B<T>.M> {}

class B<T> extends Missing<T> {
	class M{}
}

class Missing<T> {}

A full build results in no errors/walkbacks, but an incremental build of X.java causes the walkback from comment #0.

An additional walkback also occurs when the type Missing is commented out & X.java is incrementally built. In this case the walkback is :

java.lang.NullPointerException
  at o.e.jdt.i.comp.util.SimpleLookupTable.get(68)
  at o.e.jdt.i.comp.lookup.LookupEnvironment.createParameterizedType(715)
  at o.e.jdt.i.comp.lookup.LookupEnvironment.getTypeFromTypeSignature(1118)
  at o.e.jdt.i.c.lookup.LookupEnvironment.getTypeFromVariantTypeSignature(1149)
  at o.e.jdt.i.comp.lookup.LookupEnvironment.getTypeArgumentsFromSignature(961)
  at o.e.jdt.i.comp.lookup.LookupEnvironment.getTypeFromTypeSignature(1100)
  at o.e.jdt.i.comp.lookup.BinaryTypeBinding.cachePartsFrom(296)
  at o.e.jdt.i.comp.lookup.LookupEnvironment.createBinaryTypeFrom(599)
  at o.e.jdt.i.comp.lookup.LookupEnvironment.createBinaryTypeFrom(578)
  at o.e.jdt.i.comp.Compiler.accept(275)
  at o.e.jdt.i.comp.lookup.LookupEnvironment.askForType(128)
  at o.e.jdt.i.comp.lookup.PackageBinding.getTypeOrPackage(178)
  at o.e.jdt.i.comp.lookup.Scope.getTypeOrPackage(2381)
  at o.e.jdt.i.comp.lookup.Scope.getType(2121)
  at o.e.jdt.i.c.ast.ParameterizedSingleTypeReference.internalResolveType(99)
  at o.e.jdt.i.comp.ast.ParameterizedSingleTypeReference.resolveType(220)
  at o.e.jdt.i.comp.ast.TypeReference.resolveSuperType(114)
  at o.e.jdt.i.comp.lookup.ClassScope.findSupertype(1112)
  at o.e.jdt.i.comp.lookup.ClassScope.connectSuperclass(825)
  at o.e.jdt.i.comp.lookup.ClassScope.connectTypeHierarchy(950)
  at o.e.jdt.i.comp.lookup.CompilationUnitScope.connectTypeHierarchy(290)
  at o.e.jdt.i.comp.lookup.LookupEnvironment.completeTypeBindings(218)
  at o.e.jdt.i.comp.Compiler.internalBeginToCompile(598)
  at o.e.jdt.i.comp.Compiler.beginToCompile(356)
  at o.e.jdt.i.comp.Compiler.compile(370)
  at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(356)
Comment 9 Kent Johnson CLA 2007-04-10 15:01:23 EDT
Created attachment 63416 [details]
Proposed patch
Comment 10 Kent Johnson CLA 2007-04-10 15:03:15 EDT
Added Java50Tests.testParameterizedMemberType()

Released into HEAD for 3.3M7

Greg - please try your full testcase with a nightly build from later this week.

thanks
Comment 11 Greg Gibeling CLA 2007-04-10 15:16:48 EDT
I will download whatever the most recent build is on Friday morning and see what I can break.

Thanks for the fast response, it's been really helpful!
Comment 12 Greg Gibeling CLA 2007-04-13 13:05:00 EDT
Given the fact that these are incremental build bugs, there's generally no way to duplicate the exact exception that I originally submitted.

However a related, but far less annoying (and non-exception causing) set of incremental build problems has disappeared.  The exact indicator I am able to test is also related to the SortedSetQueue class.

In any case I can no longer find a way to cause incremental build problems.  Thank you very much for the fix!
Comment 13 Olivier Thomann CLA 2007-04-27 09:55:41 EDT
Verified for 3.3M7 using I20070427-0010