Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 410114

Summary: [1.8] CCE when trying to parse method reference expression with inappropriate type arguments
Product: [Eclipse Project] JDT Reporter: Markus Keller <markus.kell.r>
Component: CoreAssignee: Jay Arthanareeswaran <jarthana>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: jarthana, manoj.palat, srikanth_sankaran
Version: 4.3Flags: srikanth_sankaran: review+
Target Milestone: BETA J8   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
Proposed fix + Test none

Description Markus Keller CLA 2013-06-06 13:52:36 EDT
BETA_JAVA8

CCE when trying to parse method reference expression with inappropriate type arguments:

//---------------------
package jsr335;

import java.io.Serializable;
import java.util.concurrent.Callable;

public class MethodReference {
    class Inner<E> {

    }

    void foo() {
        Callable<Inner<String>> fi = MethodReference.Inner::<Serializable> new;
    }
}
//---------------------

Note that the example doesn't make sense, and I didn't try to make it "right". Similar exceptions happen when I remove the <Serializable> or add type arguments after MethodReference.Inner.


java.lang.ClassCastException: org.eclipse.jdt.internal.compiler.lookup.RawTypeBinding cannot be cast to org.eclipse.jdt.internal.compiler.lookup.NestedTypeBinding
	at org.eclipse.jdt.internal.compiler.ast.ReferenceExpression.generateCode(ReferenceExpression.java:119)
	at org.eclipse.jdt.internal.compiler.ast.LocalDeclaration.generateCode(LocalDeclaration.java:143)
	at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.generateCode(AbstractMethodDeclaration.java:304)
	at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.generateCode(AbstractMethodDeclaration.java:249)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.generateCode(TypeDeclaration.java:566)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.generateCode(TypeDeclaration.java:635)
	at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.generateCode(CompilationUnitDeclaration.java:367)
	at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:1213)
	at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:692)
	at org.eclipse.jdt.core.dom.ASTParser.internalCreateAST(ASTParser.java:1186)
	at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:812)
Comment 1 Srikanth Sankaran CLA 2013-06-07 00:51:58 EDT
I'll grab this one as it is my code that is faulty.
Comment 2 Srikanth Sankaran CLA 2013-07-04 02:00:42 EDT
See also https://bugs.eclipse.org/bugs/show_bug.cgi?id=412257
Comment 3 Jay Arthanareeswaran CLA 2013-07-04 03:50:40 EDT
*** Bug 412257 has been marked as a duplicate of this bug. ***
Comment 4 Jay Arthanareeswaran CLA 2013-07-08 02:09:53 EDT
Created attachment 233193 [details]
Proposed fix + Test
Comment 5 Srikanth Sankaran CLA 2013-07-08 02:57:51 EDT
(In reply to comment #4)
> Created attachment 233193 [details]
> Proposed fix + Test

Patch looks good. Two changes requested:

(1) I think we should have a conform test that shows that
emitted code is correct and its behavior matches RI.

(2) Add a test from the duplicate.
Comment 6 Jay Arthanareeswaran CLA 2013-07-08 11:27:09 EDT
(In reply to comment #5)
> (In reply to comment #4)
> > Created attachment 233193 [details]
> > Proposed fix + Test
> 
> Patch looks good. Two changes requested:

Corrected and released the fix here:

http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?h=BETA_JAVA8&id=39cfeabaf2630f8aaf01c3058d94b243711e01e5