Valid java 5 code refuses to compile with lambda-8-b81-linux-x64-12_mar_2013

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Tue Mar 19 10:21:58 PDT 2013


I've fixed this in the latest tip.

Maurizio

On 16/03/13 23:17, Grégoire Neuville wrote:
> Hello,
>
> First of all, let me thank and congratulate you for the hard work you're
> putting into adding a functional tone to java : this is a great move that
> will undoubtedly prove itself immensely beneficial.
>
> That being said, I'm having a hard time compiling some basic java 5 code
> with the binary pre-release of both the bare jdk 1.8 and the
> lambda-enriched one. Indeed, trying to compile the below code :
>
> <code>
>
>   public class TestJ8 {
>
>      interface Func<A, B> {
>          B f(A a);
>      }
>
>      class List<A> {
>
>          <B> List<B> map(Func<A, B> f) {
>              return null;
>          }
>
>          <B> List<B> bind(Func<A, List<B>> f) {
>              return null;
>          }
>
>          <B> List<B> apply(final List<Func<A, B>> lf) {
>              return lf.bind(this::map);
>          }
>
>          <B, C> List<C> bind(final List<B> lb, final Func<A, Func<B, C>> f) {
>              return lb.apply(map(f)); // fails to compile
>          }
>
>      }
>
> }
>
> </code>
>
> fails with the given message :  error: method apply in class TestJ8.List<A>
> cannot be applied to given types
>
> Is it expected behaviour or am I missing something (installation steps or
> whatever...) ?
>
> Note : The compiler is invoked through maven with the following
> configuration :
>
> <plugin>
>              <groupId>org.apache.maven.plugins</groupId>
>              <artifactId>maven-compiler-plugin</artifactId>
>              <version>3.0</version>
>              <configuration>
>                  <verbose>true</verbose>
>                  <fork>true</fork>
>                  <executable>/usr/lib/jvm/java8/bin/javac</executable>
>                  <compilerArgument>-g</compilerArgument>
>                  <compilerVersion>1.8</compilerVersion>
>                  <source>1.8</source>
>                  <target>1.8</target>
>              </configuration>
> </plugin>
>
> Thanks !
>



More information about the lambda-dev mailing list