Bug 103994 - [1.5][compiler] Internal compiler error while overriding bootstrap class
Summary: [1.5][compiler] Internal compiler error while overriding bootstrap class
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Linux
: P3 major (vote)
Target Milestone: 3.1.1   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 106740 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-07-15 09:23 EDT by baikuo21 CLA
Modified: 2005-09-26 11:26 EDT (History)
2 users (show)

See Also:


Attachments
Proposed fix (3.88 KB, patch)
2005-07-19 07:24 EDT, Philipe Mulet CLA
no flags Details | Diff
Better fix (4.13 KB, patch)
2005-07-19 08:25 EDT, Philipe Mulet CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description baikuo21 CLA 2005-07-15 09:23:03 EDT
Creates a new java 5 project:

package java.nio.channels.spi;

public abstract class AbstractSelectableChannel
	extends java.nio.channels.SelectableChannel
{
}

package test;

class A<C extends java.nio.channels.Channel>
{
	class B
		extends A<java.nio.channels.SocketChannel>
	{
	}
}

Then an internal compiler error was issued:
java.lang.NullPointerException
	at
org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding.implementsInterface(ReferenceBinding.java:682)
	at
org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding.isCompatibleWith(ReferenceBinding.java:768)
	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.ClassScope.connectMemberTypes(ClassScope.java:723)
	at
org.eclipse.jdt.internal.compiler.lookup.ClassScope.connectTypeHierarchy(ClassScope.java:936)
	at
org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.connectTypeHierarchy(CompilationUnitScope.java:254)
	at
org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.completeTypeBindings(LookupEnvironment.java:195)
...

The null reference is SourceTypeBinding.superInterfaces for class
AbstractSelectableChannel.
No error when the type parameter of class A is changed into <C extends
SocketChannel>
Comment 1 baikuo21 CLA 2005-07-15 09:29:57 EDT
To repeat this error, the package name of class A must be after "java" in alphabet
Comment 2 Philipe Mulet CLA 2005-07-18 11:04:56 EDT
Cannot reproduce in latest. Likely dup of bug 101456.

Kent - pls add a regression test
Comment 3 Philipe Mulet CLA 2005-07-19 06:47:53 EDT
Actually, after addressing bug 103528, it reproduces quite easily (stricter
bound check).

Problem arises from the fact that when connecting type hierarchy of A$B, it
needs to check that SocketChannel is within bounds of <C extends Channel>.
However, the binary type SocketChannel has the source type
AbstractSelectableChannel as its superclass, and AbstractSelectableChannel
superinterfaces are still null since haven't been connected yet.

In order to handle type compatibility rules (which bound check needs), it seems
that bound checks should be deferred until entire connecting has occurred (and
not happen during type hierarchy connecting).
Comment 4 Philipe Mulet CLA 2005-07-19 06:54:26 EDT
A needs to be compiled before AbstractSelectableChannel for the problem to show up.
Comment 5 Philipe Mulet CLA 2005-07-19 06:57:18 EDT
Added GenericTypeTest#test788-789.

NPE from test788 is:

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:137)
	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:698)
	at
org.eclipse.jdt.internal.compiler.lookup.ClassScope.connectTypeHierarchy(ClassScope.java:939)
	at
org.eclipse.jdt.internal.compiler.lookup.ClassScope.connectMemberTypes(ClassScope.java:719)
	at
org.eclipse.jdt.internal.compiler.lookup.ClassScope.connectTypeHierarchy(ClassScope.java:940)
	at
org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.connectTypeHierarchy(CompilationUnitScope.java:254)
	at
org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.completeTypeBindings(LookupEnvironment.java:195)
	at org.eclipse.jdt.internal.compiler.Compiler.beginToCompile(Compiler.java:301)
	at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:315)
	at
org.eclipse.jdt.core.tests.compiler.regression.AbstractRegressionTest.runConformTest(AbstractRegressionTest.java:217)
	at
org.eclipse.jdt.core.tests.compiler.regression.AbstractComparableTest.runConformTest(AbstractComparableTest.java:182)
	at
org.eclipse.jdt.core.tests.compiler.regression.AbstractRegressionTest.runConformTest(AbstractRegressionTest.java:174)
	at
org.eclipse.jdt.core.tests.compiler.regression.AbstractRegressionTest.runConformTest(AbstractRegressionTest.java:165)
	at
org.eclipse.jdt.core.tests.compiler.regression.GenericTypeTest.test788(GenericTypeTest.java:22795)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:585)
	at junit.framework.TestCase.runTest(TestCase.java:154)
	at junit.framework.TestCase.runBare(TestCase.java:127)
	at junit.framework.TestResult$1.protect(TestResult.java:106)
	at junit.framework.TestResult.runProtected(TestResult.java:124)
	at junit.framework.TestResult.run(TestResult.java:109)
	at junit.framework.TestCase.run(TestCase.java:118)
	at junit.framework.TestSuite.runTest(TestSuite.java:208)
	at junit.framework.TestSuite.run(TestSuite.java:203)
	at junit.extensions.TestDecorator.basicRun(TestDecorator.java:22)
	at junit.extensions.TestDecorator.run(TestDecorator.java:28)
	at org.eclipse.jdt.core.tests.util.CompilerTestSetup.run(CompilerTestSetup.java:48)
	at junit.framework.TestSuite.runTest(TestSuite.java:208)
	at junit.framework.TestSuite.run(TestSuite.java:203)
	at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
	at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
	at
org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunner.main(RemotePluginTestRunner.java:57)
	at
org.eclipse.pde.internal.junit.runtime.CoreTestApplication.run(CoreTestApplication.java:24)
	at
org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:226)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:376)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:163)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:585)
	at org.eclipse.core.launcher.Main.invokeFramework(Main.java:334)
	at org.eclipse.core.launcher.Main.basicRun(Main.java:278)
	at org.eclipse.core.launcher.Main.run(Main.java:973)
	at org.eclipse.core.launcher.Main.main(Main.java:948)

Comment 6 Philipe Mulet CLA 2005-07-19 06:59:00 EDT
The ordering is what makes the difference (no influence from bug 103528 as said
in comment 3).
Comment 7 Philipe Mulet CLA 2005-07-19 07:24:48 EDT
Created attachment 24969 [details]
Proposed fix

Patch defers bound checks after super type hierarchy got fully interconnected.
Comment 8 Philipe Mulet CLA 2005-07-19 08:25:10 EDT
Created attachment 24970 [details]
Better fix

Had forgotten the case of completeTypeBindings for a single unit.
Comment 9 Philipe Mulet CLA 2005-07-19 08:25:50 EDT
Fixed. Kent - pls verify the patch.
Comment 10 Philipe Mulet CLA 2005-07-19 08:40:24 EDT
Fixed (both in 3.1 maintenance & HEAD)
Comment 11 Kent Johnson CLA 2005-07-26 12:24:26 EDT
looks good.
Comment 12 Maxime Daniel CLA 2005-08-09 12:45:40 EDT
Verified in 3.2 M1 with build I20050808-2000.
Comment 13 Olivier Thomann CLA 2005-08-11 18:13:36 EDT
*** Bug 106740 has been marked as a duplicate of this bug. ***
Comment 14 David Audel CLA 2005-09-26 11:26:31 EDT
Verified using M20050923-1430 for 3.1.1