[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-compiler-dev
Subject:    Re: inconsistent generic types behaviour when compiling together vs. separate
From:       Vicente-Arturo Romero-Zaldivar <vicente.romero () oracle ! com>
Date:       2014-02-03 12:34:39
Message-ID: 52EF8CDF.8030700 () oracle ! com
[Download RAW message or body]

Hi Peter,

Thanks for the report. I have created: 
https://bugs.openjdk.java.net/browse/JDK-8033437 to track this issue.

Vicente

On 29/01/14 14:59, Peter Levart wrote:
> Here's an example:
>
> Create an empty directory and copy into it the following two sources:
>
> Ref.java:
>
>     public class Ref<T> {
>         final RefQueue<? super T> queue = new RefQueue<>();
>
>         public static void main(String[] args) {
>             Ref<Object> r = new Ref<>();
>             RefQueue<Object> q = r.queue;
>         }
>     }
>
> RefQueue.java:
>
>     public class RefQueue<T> {
>     }
>
> Then execute:
>
>     mkdir out
>     javac -d out Ref.java
>
> This compiles fine and produces two class files in out directory:
>
>     Ref.class
>     RefQueue.class
>
> Now do the following:
>
>     rm RefQueue.java
>     mkdir out2
>     javac -cp out -d out2 Ref.java
>
> Which produces compile-time error:
>
> Ref.java:6: error: incompatible types: RefQueue<CAP#1> cannot be 
> converted to RefQueue<Object>
>         RefQueue<Object> q = r.queue;
>                               ^
>   where CAP#1 is a fresh type-variable:
>     CAP#1 extends Object super: Object from capture of ? super Object
> 1 error
>
>
> It seems that the behaviour is inconsistent. There's also a question 
> whether the compile-time error is a correct behaviour or not. I tried 
> this with JDK 7u51, JDK 8 ea-b121 and recent JDK 9 from dev forest. 
> They all behave the same.
>
>
> Regards, Peter
>

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic