Some sort of retro-lambdas is certainly possible in theory, re-writing invokedynamic (or whatever other new bytecodes are used) as anonymous classes implementing some SAM type. This is the approach taken by many of the other languages already supporting lambdas/closures on the Java platform.
The devil is in the details though; any such retro-enabling transform would have to pay a great deal of attention to correctness. If you also consider the performance profile to be part of any correctness guarantee then this becomes extra-specially tricky. Optimising for performance on the JVM can be challenging at the best of times! If interested, it's worth reading Charles Nutter's blog/articles on optimising JRuby and Mirah for the platform. There's some very interesting and enlightening revelations in there. On 6 March 2012 21:20, Martijn Verburg <[email protected]> wrote: > Hi Sam, > > I Am Not A Lambdas Expert (IANALE) but assuming they go with an > invokedynamic implementation (which at this stage is likely for > performance reasons) then there won't be the possibility of having 1.5 > compatibility, unless of course they have a separate anonymous inner > class implementation for older versions of Java. > > Either way, best place to ask this Q is on the lambda-dev OpenJDK mailing > list. > > Cheers, > Martijn > > On 6 March 2012 04:22, Sam Reid <[email protected]> wrote: > > I compiled my first lambda expression (function literal) using javac from > > OpenJDK 8, and it was very nice. However, we have many (more than a > > thousand) clients who are still living with JRE 5, and I don't want to > drop > > support for them or force them to upgrade. I tried specifying -target > 1.5, > > but it said targeting 1.5 was not supported if lambda expressions were in > > the code. Do you know of any ways I will be able to use lambda > expressions > > in Java and still being able to accommodate my 1.5 clients? I recall > > something from years ago called RetroWeaver that let you use 1.5 features > > (generics, boxing) and back-compile to run on 1.4 runtime. Are there any > > equivalent tools that will let me use Java 1.7 on 1.5 runtime? Or do you > > know any other ways around this? > > > > Thanks! > > Sam > > > -- You received this message because you are subscribed to the Google Groups "The Java Posse" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/javaposse?hl=en.
