Compilation error with JDK8 (original) (raw)
Maurizio Cimadamore maurizio.cimadamore at oracle.com
Wed Apr 3 02:58:45 PDT 2013
- Previous message: Compilation error with JDK8
- Next message: Compilation error with JDK8
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi, this falls into the bucket of 'glitches around capture conversion in nested generic method calls'. We are aware of the issue and will work to improve the situation. For now, the simplest workaround is to pass an explicit type-parameter to the outermost call, as in:
Service.getParent(findByPk(vo.getClass(), vo.getId()));
Maurizio
On 02/04/13 14:50, Olivier Bourgain wrote:
I'm still trying to compile my project with java 8 (b83), I and get another error.
Here is the simplest test case I've found which reproduce this error : ===== Vo.java public interface Vo { public Integer getId(); }
===== Service.java public class Service { public static H getParentById(H vo) { return (H) getParent(findByPk(vo.getClass(), vo.getId())); } public static H getParent(H vo) { return null; } public static H findByPk(Class voClass, Integer id) { return null; } } The error message is : ยป javac src/*.java src/Service.java:4: error: method getParent in class Service cannot be applied to given types; return (H) getParent(findByPk(vo.getClass(), vo.getId())); ^ required: H#1 found: CAP#1 reason: cannot infer type-variable(s) H#1,H#2 (argument mismatch; Vo cannot be converted to CAP#2) where H#1,H#2 are type-variables: H#1 extends Vo declared in method <H#1>getParent(H#1) H#2 extends Vo declared in method <H#2>findByPk(Class<H#2>,Integer) where CAP#1,CAP#2 are fresh type-variables: CAP#1 extends Vo from capture of ? extends Vo CAP#2 extends Vo from capture of ? extends Vo 1 error The java version : openjdk version "1.8.0-ea" OpenJDK Runtime Environment (build 1.8.0-ea-lambda-nightly-h3797-20130325-b83-b00) OpenJDK Server VM (build 25.0-b21, mixed mode) Olivier Bourgain
- Previous message: Compilation error with JDK8
- Next message: Compilation error with JDK8
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]