Community
Participate
Working Groups
Build 3.5M4 According to JLS 15.12.2.6 (2nd bullet), a method's return type should be erased after any unchecked conversion was necessary during type inference. e.g. class Foo<T> {} public class X { public void test() { Integer i = m(new Foo<Foo<Integer>>(), new Foo()); } public <T> T m(Foo<T> x, T t) { return t; } } should surface an error where the return type got erased: Type mismatch: cannot convert from Foo to Integer instead of: Type mismatch: cannot convert from Foo<Integer> to Integer Hence, an unchecked method invocation warning should be surfaced as well, which is missing today.
Added GenericTypeTest#test1429-1431
also see bug 231094
Created attachment 121819 [details] In progress patch still failing some AmbiguousMethodTest: test011a(org.eclipse.jdt.core.tests.compiler.regression.AmbiguousMethodTest) test011b(org.eclipse.jdt.core.tests.compiler.regression.AmbiguousMethodTest) RunAllJDTCoreTests org.eclipse.jdt.core.tests.RunAllJDTCoreTests org.eclipse.jdt.core.tests.RunAllCompilerTests org.eclipse.jdt.core.tests.RunCompilerTests org.eclipse.jdt.core.tests.compiler.regression.TestAll 1.5 org.eclipse.jdt.core.tests.compiler.regression.AmbiguousMethodTest test011a(org.eclipse.jdt.core.tests.compiler.regression.AmbiguousMethodTest) junit.framework.ComparisonFailure: Unexpected failure. ----------- Expected ------------ ------------ but was ------------ ----------\n 1. ERROR in Combined.java (at line 4)\r\n void pickOne(Combined<Integer,Integer> c) throws ExOne { c.pickOne("test"); }\r\n ^^^^^^^\n The method pickOne(String) is ambiguous for the type Combined<Integer,Integer>\n ----------\n --------- Difference is ---------- expected:<[]> but was:<[----------\n 1. ERROR in Combined.java (at line 4)\r\n void pickOne(Combined<Integer,Integer> c) throws ExOne { c.pickOne("test"); }\r\n ^^^^^^^\n The method pickOne(String) is ambiguous for the type Combined<Integer,Integer>\n ----------\n ]> at org.eclipse.jdt.core.tests.junit.extension.TestCase.assertStringEquals(TestCase.java:230) at org.eclipse.jdt.core.tests.junit.extension.TestCase.assertEquals(TestCase.java:206) at org.eclipse.jdt.core.tests.compiler.regression.AbstractRegressionTest.runTest(AbstractRegressionTest.java:2152) at org.eclipse.jdt.core.tests.compiler.regression.AbstractRegressionTest.runConformTest(AbstractRegressionTest.java:1145) at org.eclipse.jdt.core.tests.compiler.regression.AmbiguousMethodTest.test011a(AmbiguousMethodTest.java:476) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:623) at junit.framework.TestCase.runTest(TestCase.java:164) at junit.framework.TestCase.runBare(TestCase.java:130) 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:120) at junit.framework.TestSuite.runTest(TestSuite.java:230) at junit.framework.TestSuite.run(TestSuite.java:225) at junit.framework.TestSuite.runTest(TestSuite.java:230) at junit.framework.TestSuite.run(TestSuite.java:225) at org.eclipse.jdt.core.tests.util.CompilerTestSetup.run(CompilerTestSetup.java:55) at junit.framework.TestSuite.runTest(TestSuite.java:230) at junit.framework.TestSuite.run(TestSuite.java:225) at junit.framework.TestSuite.runTest(TestSuite.java:230) at junit.framework.TestSuite.run(TestSuite.java:225) at junit.framework.TestSuite.runTest(TestSuite.java:230) at junit.framework.TestSuite.run(TestSuite.java:225) at junit.framework.TestSuite.runTest(TestSuite.java:230) at junit.framework.TestSuite.run(TestSuite.java:225) at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunner.main(RemotePluginTestRunner.java:62) at org.eclipse.pde.internal.junit.runtime.CoreTestApplication.run(CoreTestApplication.java:23) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:623) at org.eclipse.equinox.internal.app.EclipseAppContainer.callMethodWithException(EclipseAppContainer.java:574) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:195) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:366) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:177) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:623) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:550) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:505) at org.eclipse.equinox.launcher.Main.run(Main.java:1237) at org.eclipse.equinox.launcher.Main.main(Main.java:1213) test011b(org.eclipse.jdt.core.tests.compiler.regression.AmbiguousMethodTest) junit.framework.ComparisonFailure: Invalid problem log . ----------- Expected ------------ ----------\n 1. WARNING in Test1.java (at line 4)\n void pickOne2(Test1<Integer,Integer> c) throws ExOne { c.pickOne((Comparable) "test"); }\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n Type safety: Unchecked invocation pickOne(Comparable) of the generic method pickOne(T) of type Test1<Integer,Integer>\n ----------\n 2. WARNING in Test1.java (at line 4)\n void pickOne2(Test1<Integer,Integer> c) throws ExOne { c.pickOne((Comparable) "test"); }\n ^^^^^^^^^^\n Comparable is a raw type. References to generic type Comparable<T> should be parameterized\n ----------\n ------------ but was ------------ ----------\n 1. ERROR in Test1.java (at line 4)\n void pickOne2(Test1<Integer,Integer> c) throws ExOne { c.pickOne((Comparable) "test"); }\n ^^^^^^^\n The method pickOne(Comparable) is ambiguous for the type Test1<Integer,Integer>\n ----------\n 2. WARNING in Test1.java (at line 4)\n void pickOne2(Test1<Integer,Integer> c) throws ExOne { c.pickOne((Comparable) "test"); }\n ^^^^^^^^^^\n Comparable is a raw type. References to generic type Comparable<T> should be parameterized\n ----------\n --------- Difference is ---------- expected:<----------\n 1. [WARNING in Test1.java (at line 4)\n void pickOne2(Test1<Integer,Integer> c) throws ExOne { c.pickOne((Comparable) "test"); }\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n Type safety: Unchecked invocation pickOne(Comparable) of the generic method pickOne(T) of] type Test1<Integer,...> but was:<----------\n 1. [ERROR in Test1.java (at line 4)\n void pickOne2(Test1<Integer,Integer> c) throws ExOne { c.pickOne((Comparable) "test"); }\n ^^^^^^^\n The method pickOne(Comparable) is ambiguous for the] type Test1<Integer,...> at org.eclipse.jdt.core.tests.junit.extension.TestCase.assertStringEquals(TestCase.java:230) at org.eclipse.jdt.core.tests.junit.extension.TestCase.assertEquals(TestCase.java:206) at org.eclipse.jdt.core.tests.compiler.regression.AbstractRegressionTest.checkCompilerLog(AbstractRegressionTest.java:869) at org.eclipse.jdt.core.tests.compiler.regression.AbstractRegressionTest.runTest(AbstractRegressionTest.java:2138) at org.eclipse.jdt.core.tests.compiler.regression.AbstractRegressionTest.runNegativeTest(AbstractRegressionTest.java:1756) at org.eclipse.jdt.core.tests.compiler.regression.AmbiguousMethodTest.test011b(AmbiguousMethodTest.java:495) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:623) at junit.framework.TestCase.runTest(TestCase.java:164) at junit.framework.TestCase.runBare(TestCase.java:130) 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:120) at junit.framework.TestSuite.runTest(TestSuite.java:230) at junit.framework.TestSuite.run(TestSuite.java:225) at junit.framework.TestSuite.runTest(TestSuite.java:230) at junit.framework.TestSuite.run(TestSuite.java:225) at org.eclipse.jdt.core.tests.util.CompilerTestSetup.run(CompilerTestSetup.java:55) at junit.framework.TestSuite.runTest(TestSuite.java:230) at junit.framework.TestSuite.run(TestSuite.java:225) at junit.framework.TestSuite.runTest(TestSuite.java:230) at junit.framework.TestSuite.run(TestSuite.java:225) at junit.framework.TestSuite.runTest(TestSuite.java:230) at junit.framework.TestSuite.run(TestSuite.java:225) at junit.framework.TestSuite.runTest(TestSuite.java:230) at junit.framework.TestSuite.run(TestSuite.java:225) at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunner.main(RemotePluginTestRunner.java:62) at org.eclipse.pde.internal.junit.runtime.CoreTestApplication.run(CoreTestApplication.java:23) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:623) at org.eclipse.equinox.internal.app.EclipseAppContainer.callMethodWithException(EclipseAppContainer.java:574) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:195) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:366) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:177) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:623) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:550) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:505) at org.eclipse.equinox.launcher.Main.run(Main.java:1237) at org.eclipse.equinox.launcher.Main.main(Main.java:1213)
Created attachment 121827 [details] Improved patch Passes a Javadoc test (which failed with previous patch)
cc'ing Frederic for Javadoc failure (Frederic pls file a separate bug for situations which did not work and will be fixed along with changes made for this bug) e.g.: - Should warn missing tag (ko) import java.util.*; public class X<T> { X(ArrayList<T> alt) {} } class Y<U> extends X<U> { /** @see X#X(ArrayList) */ Y(List<U> lu) { super(null); } }
Created attachment 121927 [details] Better patch
Added GenericTypeTest#test1429-1430, test1432-1439
Created attachment 121929 [details] Better patch 2 Still having issues with method ambiguities. Now also erase thrown exception when unchecked invocation (as mandated by 15.12.2.6)
Created attachment 121969 [details] Better patch 2 previous patch was corrupted
*** Bug 231094 has been marked as a duplicate of this bug. ***
*** Bug 118273 has been marked as a duplicate of this bug. ***
*** Bug 117119 has been marked as a duplicate of this bug. ***
Created attachment 122013 [details] Final patch
Released for 3.5M5. Fixed
Added JavadocBugsTest.testBug258798_*
Verified for 3.5M5 using build I20090127-0100.