Bug 101456

Summary: Proposals and Open Declaration fail with NPE
Product: [Eclipse Project] JDT Reporter: Daniel Mueller <daniel.mueller>
Component: CoreAssignee: Kent Johnson <kent_johnson>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: eric-inman, ewasserman, fterrier, garret, jcleary
Version: 3.1   
Target Milestone: 3.1.1   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
A demonstration of the bug as simple eclipse project none

Description Daniel Mueller CLA 2005-06-23 10:42:25 EDT
In a certain type of class it's not possible to get proposals and navigate to
type (Ctrl + Space & F3 [Standard Shortcuts]), or do refactorings or other
interesting stuff. Appended the log and a demo implementation which shows the
bug. eclipse build is 3.1RC3.

[ Log ]

eclipse.buildId=I20050617-1618
java.version=1.5.0_03
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=de_CH
Command-line arguments:  -os win32 -ws win32 -arch x86

[...snip...]

!ENTRY org.eclipse.ui.workbench 4 2 2005-06-23 15:18:30.443
!MESSAGE Problems occurred when invoking code from plug-in:
"org.eclipse.ui.workbench".
!STACK 0
java.lang.NullPointerException
	at
org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding.implementsInterface(ReferenceBinding.java:681)
	at
org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding.isCompatibleWith(ReferenceBinding.java:766)
	at
org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding.boundCheck(TypeVariableBinding.java:135)
	at
org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding.boundCheck(ParameterizedTypeBinding.java:58)
	at
org.eclipse.jdt.internal.compiler.ast.ParameterizedSingleTypeReference.checkBounds(ParameterizedSingleTypeReference.java:40)
	at
org.eclipse.jdt.internal.compiler.lookup.ClassScope.checkParameterizedTypeBounds(ClassScope.java:702)
	at
org.eclipse.jdt.internal.compiler.lookup.ClassScope.connectTypeHierarchy(ClassScope.java:935)
	at
org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.connectTypeHierarchy(CompilationUnitScope.java:254)
	at
org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.completeTypeBindings(LookupEnvironment.java:249)
	at
org.eclipse.jdt.internal.core.hierarchy.HierarchyResolver.accept(HierarchyResolver.java:153)
	at
org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType(LookupEnvironment.java:131)
	at
org.eclipse.jdt.internal.compiler.lookup.PackageBinding.getTypeOrPackage(PackageBinding.java:178)
	at org.eclipse.jdt.internal.compiler.lookup.Scope.getTypeOrPackage(Scope.java:2392)
	at org.eclipse.jdt.internal.compiler.lookup.Scope.getType(Scope.java:2137)
	at
org.eclipse.jdt.internal.compiler.ast.SingleTypeReference.getTypeBinding(SingleTypeReference.java:39)
	at
org.eclipse.jdt.internal.compiler.ast.TypeReference.resolveType(TypeReference.java:141)
	at
org.eclipse.jdt.internal.compiler.ast.TypeReference.resolveTypeArgument(TypeReference.java:158)
	at
org.eclipse.jdt.internal.compiler.ast.ParameterizedSingleTypeReference.internalResolveType(ParameterizedSingleTypeReference.java:132)
	at
org.eclipse.jdt.internal.compiler.ast.ParameterizedSingleTypeReference.resolveType(ParameterizedSingleTypeReference.java:217)
	at
org.eclipse.jdt.internal.compiler.ast.TypeReference.resolveSuperType(TypeReference.java:104)
	at
org.eclipse.jdt.internal.compiler.lookup.ClassScope.findSupertype(ClassScope.java:1088)
	at
org.eclipse.jdt.internal.compiler.lookup.ClassScope.connectSuperclass(ClassScope.java:755)
	at
org.eclipse.jdt.internal.compiler.lookup.ClassScope.connectTypeHierarchy(ClassScope.java:927)
	at
org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.connectTypeHierarchy(CompilationUnitScope.java:254)
	at
org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.completeTypeBindings(LookupEnvironment.java:249)
	at
org.eclipse.jdt.internal.core.hierarchy.HierarchyResolver.resolve(HierarchyResolver.java:653)
	at
org.eclipse.jdt.internal.core.hierarchy.HierarchyResolver.resolve(HierarchyResolver.java:486)
	at
org.eclipse.jdt.internal.core.hierarchy.HierarchyBuilder.buildSupertypes(HierarchyBuilder.java:119)
	at
org.eclipse.jdt.internal.core.hierarchy.IndexBasedHierarchyBuilder.build(IndexBasedHierarchyBuilder.java:136)
	at
org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy.compute(TypeHierarchy.java:320)
	at
org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy.refresh(TypeHierarchy.java:1255)
	at
org.eclipse.jdt.internal.core.CreateTypeHierarchyOperation.executeOperation(CreateTypeHierarchyOperation.java:90)
	at
org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:718)
	at
org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:777)
	at
org.eclipse.jdt.internal.core.SourceType.newSupertypeHierarchy(SourceType.java:671)
	at
org.eclipse.jdt.internal.core.SourceType.newSupertypeHierarchy(SourceType.java:623)
	at
org.eclipse.jdt.internal.corext.util.SuperTypeHierarchyCache.getTypeHierarchy(SuperTypeHierarchyCache.java:88)
	at
org.eclipse.jdt.internal.corext.util.SuperTypeHierarchyCache.getTypeHierarchy(SuperTypeHierarchyCache.java:78)
	at
org.eclipse.jdt.ui.OverrideIndicatorLabelDecorator.getOverrideIndicators(OverrideIndicatorLabelDecorator.java:160)
	at
org.eclipse.jdt.ui.OverrideIndicatorLabelDecorator.computeAdornmentFlags(OverrideIndicatorLabelDecorator.java:128)
	at
org.eclipse.jdt.ui.OverrideIndicatorLabelDecorator.decorate(OverrideIndicatorLabelDecorator.java:251)
	at
org.eclipse.ui.internal.decorators.LightweightDecoratorDefinition.decorate(LightweightDecoratorDefinition.java:220)
	at
org.eclipse.ui.internal.decorators.LightweightDecoratorManager$LightweightRunnable.run(LightweightDecoratorManager.java:67)
	at
org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java:1044)
	at org.eclipse.core.runtime.Platform.run(Platform.java:783)
	at
org.eclipse.ui.internal.decorators.LightweightDecoratorManager.decorate(LightweightDecoratorManager.java:289)
	at
org.eclipse.ui.internal.decorators.LightweightDecoratorManager.getDecorations(LightweightDecoratorManager.java:275)
	at
org.eclipse.ui.internal.decorators.DecorationScheduler$1.run(DecorationScheduler.java:318)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:76)

!ENTRY org.eclipse.ui 4 4 2005-06-23 15:18:30.584
!MESSAGE Exception in Decorator

[...snip...]

Demo Implementaion:

package bug;

import java.util.Date;


public abstract class AbstractSnapshot<S extends Snapshot, P extends SnapshotPro
vider<S>>
    implements Snapshot<S>
{
    private final Date date;
    private final P provider;

    public AbstractSnapshot(P provider, Date date)
    {
        this.provider = provider;
        this.date = date;
    }

    public S at(Date d)
    {
        return provider.getSnapshot(d);
    }

    public S shift(int days)
    {
        return at(getWhen() /* .shift(days) */);
    }

    public Date getWhen()
    {
        return date;
    }

    public P getProvider()
    {
        return provider;
    }
}
package bug;

import java.util.Date;


class ProviderImpl
    implements SnapshotProvider<SnapshotImpl>
{
    public SnapshotImpl getSnapshot(Date arg0)
    {
        return null;
    }
}
package bug;

import java.util.Date;


public interface Snapshot<S extends Snapshot>
{
    Date getWhen();

    public S at(Date when);

    /**
     * Snapshot, der um <i>days </i> Tage geschoben ist.
     *
     * @param days
     * @return nie <code>null</code>
     */
    public S shift(int days);
}
package bug;

import java.util.Date;


// FIXME autocompletion and other navigation methods fail.
// refactoring (e.g. SnapshotProvider fails also)
class SnapshotImpl
    extends AbstractSnapshot<SnapshotImpl, ProviderImpl>
{

    public SnapshotImpl(ProviderImpl provider, Date date)
    {
        super(provider, date);
    }

    public void execute()
    {
        //
    }
}package bug;

import java.util.Date;


interface SnapshotProvider<S extends Snapshot>
{
    S getSnapshot(Date date);
}
Comment 1 Philipe Mulet CLA 2005-06-23 12:52:13 EDT
Looks like another case where we have null superinterfaces.
Comment 2 Kent Johnson CLA 2005-07-04 10:16:57 EDT
*** Bug 102545 has been marked as a duplicate of this bug. ***
Comment 3 Kent Johnson CLA 2005-07-04 10:18:21 EDT
*** Bug 102594 has been marked as a duplicate of this bug. ***
Comment 4 Kent Johnson CLA 2005-07-05 14:45:18 EDT
Reverted back to the previous code which initialized the interfaces at the 
beginning of connectSuperInterfaces(). Was changed to detect cycles, but we 
have another change to handle them now.

Released into the 3.1.1 branch
Comment 5 Olivier Thomann CLA 2005-08-09 11:11:02 EDT
Verified in 3.2M1 (I20050808-2000)
Comment 6 Olivier Thomann CLA 2005-08-30 08:02:16 EDT
All tests passed.
Comment 7 Olivier Thomann CLA 2005-08-30 09:44:08 EDT
*** Bug 108308 has been marked as a duplicate of this bug. ***
Comment 8 Olivier Thomann CLA 2005-08-30 09:44:19 EDT
*** Bug 108335 has been marked as a duplicate of this bug. ***
Comment 9 Olivier Thomann CLA 2005-08-30 13:40:47 EDT
*** Bug 108378 has been marked as a duplicate of this bug. ***
Comment 10 Daniel Mueller CLA 2005-09-21 04:55:49 EDT
Created attachment 27326 [details]
A demonstration of the bug as simple eclipse project
Comment 11 Daniel Mueller CLA 2005-09-21 04:57:06 EDT
none of the current versions has the bug fixed. We verified with:

Latest Release	3.1	Mon, 27 Jun 2005 -- 14:35 (-0400)
3.2 Stream Stable Build	3.2M1	Thu, 11 Aug 2005 -- 15:30 (-0400)
3.2 Stream Integration Build	I20050921-0010	Wed, 21 Sep 2005 -- 00:10 (-0400)
3.2 Stream Nightly Build	N20050918-0010	Sun, 18 Sep 2005 -- 00:10 (-0400)
3.1.1 Stream Maintenance Build	M20050914-1235	Wed, 14 Sep 2005 -- 12:35 (-0400)

I have attached a zip which can be used for testing (the sources are the same as
from my first post and the ones used to verify the builds).
Comment 12 Kent Johnson CLA 2005-09-22 15:15:02 EDT
*** Bug 110136 has been marked as a duplicate of this bug. ***
Comment 13 Kent Johnson CLA 2005-09-22 16:30:19 EDT
Added CompletionTests_1_5 test0245

Released in 3.1.1 stream.

But did not make it into 3.2M2 build in time - will show up in subsequent 
builds.
Comment 14 Olivier Thomann CLA 2005-09-26 11:05:56 EDT
Verified for 3.1.1 using M20050923-1430.
Comment 15 François Terrier CLA 2005-09-26 12:17:42 EDT
(In reply to comment #14)
> Verified for 3.1.1 using M20050923-1430.

My code snippet at https://bugs.eclipse.org/bugs/show_bug.cgi?id=110136 still
causes a NullPointerException in version M20050923-1430. 
Comment 16 Kent Johnson CLA 2005-09-26 15:34:19 EDT
Released into HEAD