And some generic methods with wildcards, used with an array as a generic parameter:
public interface Test {
<T> void use(T t, B<? super T> b);
<T> B<A<? super T>> create();
default void test() {
use(new A<Object[]>(), create());
}
}
The compiler throws the following exception:
java.lang.ClassCastException: class org.eclipse.jdt.internal.compiler.lookup.ArrayBinding cannot be cast to class org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding (org.eclipse.jdt.internal.compiler.lookup.ArrayBinding and org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding are in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @59fc684e)
at org.eclipse.jdt.internal.compiler.lookup.CaptureBinding.downwardsProjection(CaptureBinding.java:544)
at org.eclipse.jdt.internal.compiler.lookup.CaptureBinding.downwardsProjection(CaptureBinding.java:1)
at org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding.upwardsProjection(ParameterizedTypeBinding.java:530)
at org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding.upwardsProjection(ParameterizedTypeBinding.java:1)
at org.eclipse.jdt.internal.compiler.lookup.TypeBinding.upwardsProjection(TypeBinding.java:326)
at org.eclipse.jdt.internal.compiler.lookup.BoundSet.deriveTypeArgumentConstraints(BoundSet.java:974)
at org.eclipse.jdt.internal.compiler.lookup.BoundSet.incorporate(BoundSet.java:630)
at org.eclipse.jdt.internal.compiler.lookup.BoundSet.incorporate(BoundSet.java:511)
at org.eclipse.jdt.internal.compiler.lookup.InferenceContext18.resolve(InferenceContext18.java:1218)
at org.eclipse.jdt.internal.compiler.lookup.InferenceContext18.solve(InferenceContext18.java:1055)
at org.eclipse.jdt.internal.compiler.lookup.InferenceContext18.solve(InferenceContext18.java:1038)
at org.eclipse.jdt.internal.compiler.lookup.ParameterizedGenericMethodBinding.computeCompatibleMethod18(ParameterizedGenericMethodBinding.java:256)
at org.eclipse.jdt.internal.compiler.lookup.ParameterizedGenericMethodBinding.computeCompatibleMethod(ParameterizedGenericMethodBinding.java:92)
at org.eclipse.jdt.internal.compiler.lookup.Scope.computeCompatibleMethod(Scope.java:843)
at org.eclipse.jdt.internal.compiler.lookup.Scope.computeCompatibleMethod(Scope.java:800)
at org.eclipse.jdt.internal.compiler.lookup.Scope.findMethod0(Scope.java:1757)
at org.eclipse.jdt.internal.compiler.lookup.Scope.findMethod(Scope.java:1659)
at org.eclipse.jdt.internal.compiler.lookup.Scope.getImplicitMethod(Scope.java:2645)
at org.eclipse.jdt.internal.compiler.ast.MessageSend.findMethodBinding(MessageSend.java:1172)
at org.eclipse.jdt.internal.compiler.ast.MessageSend.resolveType(MessageSend.java:904)
at org.eclipse.jdt.internal.compiler.ast.Expression.resolve(Expression.java:1126)
at org.eclipse.jdt.internal.compiler.ast.Statement.resolveWithBindings(Statement.java:498)
at org.eclipse.jdt.internal.compiler.ast.ASTNode.resolveStatements(ASTNode.java:725)
at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolveStatements(AbstractMethodDeclaration.java:713)
at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.resolveStatements(MethodDeclaration.java:409)
at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:611)
at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1514)
at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1643)
at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.resolve(CompilationUnitDeclaration.java:666)
at org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:924)
at org.eclipse.jdt.core.tests.compiler.regression.AbstractRegressionTest$5.process(AbstractRegressionTest.java:3500)
at org.eclipse.jdt.internal.compiler.Compiler.processCompiledUnits(Compiler.java:574)
at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:474)
at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:425)
at org.eclipse.jdt.core.tests.compiler.regression.AbstractRegressionTest.runTest(AbstractRegressionTest.java:3512)
at org.eclipse.jdt.core.tests.compiler.regression.AbstractRegressionTest.runTest(AbstractRegressionTest.java:3233)
at org.eclipse.jdt.core.tests.compiler.regression.AbstractRegressionTest.runConformTest(AbstractRegressionTest.java:1898)
at org.eclipse.jdt.core.tests.compiler.regression.GenericsRegressionTest.testX(GenericsRegressionTest.java:352)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at junit.framework.TestCase.runTest(TestCase.java:177)
at org.eclipse.jdt.core.tests.junit.extension.TestCase.runTest(TestCase.java:972)
at junit.framework.TestCase.runBare(TestCase.java:142)
at junit.framework.TestResult$1.protect(TestResult.java:122)
at junit.framework.TestResult.runProtected(TestResult.java:142)
at junit.framework.TestResult.run(TestResult.java:125)
at junit.framework.TestCase.run(TestCase.java:130)
at junit.framework.TestSuite.runTest(TestSuite.java:241)
at junit.framework.TestSuite.run(TestSuite.java:236)
at org.eclipse.jdt.core.tests.util.CompilerTestSetup.run(CompilerTestSetup.java:59)
at junit.framework.TestSuite.runTest(TestSuite.java:241)
at junit.framework.TestSuite.run(TestSuite.java:236)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:90)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:316)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:240)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:214)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:155)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at org.apache.maven.surefire.api.util.ReflectionUtils.invokeMethodWithArray2(ReflectionUtils.java:137)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:148)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:88)
at org.eclipse.tycho.surefire.osgibooter.OsgiSurefireBooter.run(OsgiSurefireBooter.java:140)
at org.eclipse.tycho.surefire.osgibooter.HeadlessTestApplication.start(HeadlessTestApplication.java:29)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:208)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:143)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:109)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:439)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:271)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:668)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:605)
at org.eclipse.equinox.launcher.Main.run(Main.java:1481)
at org.eclipse.equinox.launcher.Main.main(Main.java:1454)
Given a couple generic types:
And some generic methods with wildcards, used with an array as a generic parameter:
The compiler throws the following exception: