Community
Participate
Working Groups
What steps will reproduce the problem? 1. create a Java 7 project 2. compile the attached class 3. an error dialog pops up -- Error Details -- Date: Wed Oct 19 19:25:52 CEST 2011 Message: Error in JDT Core during AST creation Severity: Error Product: Eclipse SDK 3.7.1.v201109091335 (org.eclipse.sdk.ide) Plugin: org.eclipse.jdt.ui Session Data: eclipse.buildId=M20110909-1335 java.version=1.6.0_26 java.vendor=Apple Inc. BootLoader constants: OS=macosx, ARCH=x86_64, WS=cocoa, NL=en_US Framework arguments: -keyring /Users/marschall/.eclipse_keyring -showlocation Command-line arguments: -os macosx -ws cocoa -arch x86_64 -keyring /Users/marschall/.eclipse_keyring -showlocation Exception Stack Trace: java.lang.ClassCastException: org.eclipse.jdt.internal.compiler.lookup.MethodBinding cannot be cast to org.eclipse.jdt.internal.compiler.lookup.ParameterizedGenericMethodBinding at org.eclipse.jdt.internal.compiler.problem.ProblemReporter.invalidMethod(ProblemReporter.java:3677) at org.eclipse.jdt.internal.compiler.ast.MessageSend.resolveType(MessageSend.java:435) at org.eclipse.jdt.internal.compiler.ast.Expression.resolve(Expression.java:947) at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolveStatements(AbstractMethodDeclaration.java:463) at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.resolveStatements(MethodDeclaration.java:252) at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:422) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1148) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1258) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.resolve(CompilationUnitDeclaration.java:539) at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:1191) at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:681) at org.eclipse.jdt.core.dom.ASTParser.internalCreateAST(ASTParser.java:1181) at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:807) at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider$1.run(ASTProvider.java:544) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.createAST(ASTProvider.java:537) at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.getAST(ASTProvider.java:480) at org.eclipse.jdt.ui.SharedASTProvider.getAST(SharedASTProvider.java:128) at org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$PartListenerGroup.calculateASTandInform(SelectionListenerWithASTManager.java:170) at org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$PartListenerGroup$3.run(SelectionListenerWithASTManager.java:155) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Created attachment 205551 [details] A simple class that reproduces the bug
Happens because of incorrect problem reason found during org.eclipse.jdt.internal.compiler.lookup.Scope.computeCompatibleMethod(MethodBinding, TypeBinding[], InvocationSite). We just assume that since invocation site is generified with type parameters and we couldn't find a matching method, the type parameters are to be blamed. But as shown in this case, this is not so. We should report an error here saying that there's no matching method corresponding to the given arguments URI and Collection<object,object>. javac 7 gives: error: no suitable method found for newFileSystem(URI,Map<Object,Object>) FileSystems.<String, Object>newFileSystem(uri, Collections.emptyMap()); ^ method FileSystems.newFileSystem(Path,ClassLoader) is not applicable (actual argument URI cannot be converted to Path by method invocation conv ersion) method FileSystems.newFileSystem(URI,Map<String,?>,ClassLoader) is not appli cable (actual and formal argument lists differ in length) method FileSystems.newFileSystem(URI,Map<String,?>) is not applicable (actual argument Map<Object,Object> cannot be converted to Map<String,?> b y method invocation conversion) 1 error
Basically javac7 allows us to specify type arguments for even a non-generic method, so the second last line of computeCompatibleMethod(MethodBinding, TypeBinding[], InvocationSite) method should be removed, because type arguments in invocation site when the actual method is non generic is not the real problem.
I'll follow up.
Created attachment 205585 [details] proposed fix Passes compiler tests. Haven't run the full suite yet. But looks reasonable that we should only report a problem as having been caused by a parameterized method, not when type args have been specified at invocation site, but when this is done for an actually generic method.
Created attachment 205587 [details] proposed fix Git messed the above patch.
Created attachment 206718 [details] proposed fix v1.0 + regression tests Added a test in the above patch.
Released in HEAD via commit 23a0c6bd4ce9391b9f82ed7b1662678a44429de5
Srikanth, this is a regression over 3.6.2. Do we want to backport to 3.7.2?
(In reply to comment #9) > Srikanth, this is a regression over 3.6.2. Do we want to backport to 3.7.2? Agree with analysis and fix. Yes, let us backport this to 3.7.2 and 3.6.2+java7 after a bit more testing.
Dani, this is being considered for backport to 3.7.2 and 3.6.2+java7 after a bit more testing. Fix is small and safe and this is a regression since 3.6.2 - FYI.
(In reply to comment #11) > Dani, this is being considered for backport to 3.7.2 and 3.6.2+java7 > after a bit more testing. > > Fix is small and safe and this is a regression since 3.6.2 - FYI. +1.
I just wanted to let you guys know that you rock. Whenever I report a bug against JDT it gets fixed and back ported quickly. Thank you.
(In reply to comment #13) > I just wanted to let you guys know that you rock. Whenever I report a bug > against JDT it gets fixed and back ported quickly. Thank you. Thank you ! For the record the fix hasn't been backported yet, we like the fix to get some exposure on HEAD before backporting, but it us surely in plan for 3.7.2.
Released in R3_7_maintenance via commit 27bdb27668bb0d28026a2d0298321059115dd9db
Jay confirmed release of this patch in 362+java7 branch via commit d36704d1542f1e9fe5510cf4bbc33793ec815d34
Verified for 3.8M4 with build I20111202-0800.
Verified for 3.7.2RC2 using build M20120118-0800.