Compilation error with JDK8 and Guava

Remi Forax forax at univ-mlv.fr
Tue Apr 2 05:54:30 PDT 2013


On 04/02/2013 01:20 PM, Sven Reimers wrote:
> Hi Rémi,
>
> do you think of the b83 lambda build? The early access at 
> http://jdk8.java.net/download.html still shows b82..

The current *lambda* build is b83,
http://jdk8.java.net/lambda/

The current jdk8 build is b82.

>
> Thanks
>
> Sven

cheers,
Rémi

>
>
> On Tue, Apr 2, 2013 at 11:45 AM, Remi Forax <forax at univ-mlv.fr 
> <mailto:forax at univ-mlv.fr>> wrote:
>
>     On 04/02/2013 08:50 AM, Olivier Bourgain wrote:
>     > Hi all,
>     >
>     > I tried to compile my project at work with the JDK 8 and I get a
>     > compilation error.
>     >
>     > The simplest example which I was able to extract is the
>     following. It uses
>     > Guava 1.14.0.1.
>
>     Hi Olivier,
>     could you test with b83 because it looks like a bug that was fixed
>     recently.
>
>     cheers,
>     Rémi
>
>     >
>     > import java.util.LinkedHashMap;
>     > import java.util.List;
>     > import java.util.Map;
>     > import com.google.common.collect.Lists;
>     >
>     > public class TestCase {
>     >
>     >     public static <K, V> Map<K, V> reverseMap(List<Map.Entry<K,
>     V>> list) {
>     >        return toMap(Lists.reverse(list));
>     >     }
>     >
>     >     public static <K, V> Map<K, V> toMap(List<Map.Entry<K, V>>
>     list) {
>     >        Map<K, V> result = new LinkedHashMap<>();
>     >        for (Map.Entry<K, V> entry : list)
>     >           result.put(entry.getKey(), entry.getValue());
>     >        return result;
>     >     }
>     > }
>     >
>     > The compilation error is :
>     >
>     > » javac -cp lib/guava-14.0.1.jar src/TestCase.java
>     > src/TestCase.java:9: error: method toMap in class TestCase cannot be
>     > applied to given types;
>     >        return toMap(Lists.reverse(list));
>     >               ^
>     >    required: List<Entry<K#1,V#1>>
>     >    found: List<Entry<K#2,V#2>>
>     >    reason: inferred type does not conform to equality constraint(s)
>     >      inferred: Entry<Object,Object>
>     >      equality constraints(s): Entry<Object,Object>,Entry<K#2,V#2>
>     >    where K#1,V#1,K#2,V#2 are type-variables:
>     >      K#1 extends Object declared in method
>     > <K#1,V#1>toMap(List<Entry<K#1,V#1>>)
>     >      V#1 extends Object declared in method
>     > <K#1,V#1>toMap(List<Entry<K#1,V#1>>)
>     >      K#2 extends Object declared in method
>     > <K#2,V#2>reverseMap(List<Entry<K#2,V#2>>)
>     >      V#2 extends Object declared in method
>     > <K#2,V#2>reverseMap(List<Entry<K#2,V#2>>)
>     > 1 error
>     >
>     >
>     > The java version is :
>     >
>     > java version "1.8.0-ea"
>     > Java(TM) SE Runtime Environment (build 1.8.0-ea-b82)
>     > Java HotSpot(TM) Server VM (build 25.0-b23, mixed mode)
>     >
>     > The same code compiles without error with Java 1.7.
>     >
>     >
>     > Olivier Bourgain
>     >
>
>
>
>
>
> -- 
> Sven Reimers
>
> * Senior Expert Software Architect
> * NetBeans Dream Team Member: http://dreamteam.netbeans.org
> * Community Leader  NetBeans: http://community.java.net/netbeans
>                               Desktop Java: 
> http://community.java.net/javadesktop
> * Duke's Choice Award Winner 2009
> * Blog: http://nbguru.blogspot.com
>
> * XING: https://www.xing.com/profile/Sven_Reimers8
> * LinkedIn: http://www.linkedin.com/in/svenreimers
>
> Join the NetBeans Groups:
> * XING: http://www.xing.com/group-20148.82db20
> * NUGM: http://haug-server.dyndns.org/display/NUGM/Home
> * LinkedIn: http://www.linkedin.com/groups?gid=1860468
> http://www.linkedin.com/groups?gid=107402
> http://www.linkedin.com/groups?gid=1684717
> * Oracle: https://mix.oracle.com/groups/18497



More information about the lambda-dev mailing list