Community
Participate
Working Groups
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>
To repeat this error, the package name of class A must be after "java" in alphabet
Cannot reproduce in latest. Likely dup of bug 101456. Kent - pls add a regression test
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).
A needs to be compiled before AbstractSelectableChannel for the problem to show up.
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)
The ordering is what makes the difference (no influence from bug 103528 as said in comment 3).
Created attachment 24969 [details] Proposed fix Patch defers bound checks after super type hierarchy got fully interconnected.
Created attachment 24970 [details] Better fix Had forgotten the case of completeTypeBindings for a single unit.
Fixed. Kent - pls verify the patch.
Fixed (both in 3.1 maintenance & HEAD)
looks good.
Verified in 3.2 M1 with build I20050808-2000.
*** Bug 106740 has been marked as a duplicate of this bug. ***
Verified using M20050923-1430 for 3.1.1