Building Lambda and a Closure Question
Rémi Forax
forax at univ-mlv.fr
Sun Nov 20 10:21:20 PST 2011
On 11/20/2011 06:33 PM, David Harrigan wrote:
> Hi,
>
> A new user :-) (well, at least to jdk8).
>
> I've put together a "how-to" for getting JDK8 up and running with
> Lambda[1], but I had to modify a few things and I wanted to check
> before I published my blog posting.
>
> When trying to get the project to compile, I hit a stumbling block on
> reweaving using the jsr335-agent. Some digging around eventually led
> me to clone the
> defender-prototype[2] project. Instructions aren't available for
> including this dependency (I ack-grep'ed the source tree - no
> reference). I wasn't even sure where to put
> the cloned defender-prototype directory but putting it at same level
> as the cloned lambda repo seemed to work. My blog contains
> instructions on getting this project.
>
> However, compiling defender-prototype failed since there is a
> depedency on including some classes from asm. I looked at the
> build.xml file, saw it referenced
> asm-all-4.0.jar and proceeded to download that. Unfortnately, even
> with this jar it failed to compile since in asm-all-4.0 they have
> changed some package names
> and removed some classes. Eventually I found out that asm-all-3.3.1
> included the necessary classes to compile. It seems that by creating a
> symlink from asm-all-3.3.1
> to asm-all-4.0 and attempting to recompile the defender-prototype
> project worked. Then, recompiling the lambda project worked. Great
> news!
>
> My first question is:
>
> Is the reference to asm-all-4.0 in build.xml in defender-prototype
> really a reference to asm-all-3.3.1 but symlinked to asm-all-4.0?
> Since 4.0 doesn't contain the
> necessary classes to compile defender-prototype, this leads either to
> a yes answer, or a hand-rolled asm-all-4.0 jar (unlikely). I would
> like a bit of clarification on this
> please.
Hi, I'm one of the developer of ASM,
the defender prototype is based on ASM4 RC1
that you can find here:
http://forge.ow2.org/project/showfiles.php?group_id=23&release_id=4698
In fact, we have goofed during the development of this release of ASM.
After releasing the RC1, we start some heated discussions about
providing or not binary compatibility with the next releases of ASM.
This process ends by doing a major refactoring of most of classes
to support true binary compatibility (ASM is still 1.2/1.4 compatible).
We should have done that during the beta builds cycle instead of after a RC,
we are sorry about that.
>
> My next (and last question) is:
>
> I wrote a very simple closure with the current Lambda Specification
> 0.4.2 in front of me. I could only get my closure to compile if I
> followed the closure block with a
> semi-colon. The examples in the spec don't include this. I'm assuming
> this semi-colon was left off for readability - can this be confirmed?
>
> public class Closures {
>
> interface C {
> String c();
> }
>
> public static void main(final String[] args) {
>
> final C c = () -> { return "Hello World"; }; //<- had to put
> semi-colon here. In the spec, no semi-colon is shown.
> System.out.println(c.c());
>
> }
> }
A lambda is an expression, here you use it in an assignment
which is an instruction so you need to end the sentence with a ';'.
Because the spec talk about lambda expression, there is no semicolon
in the spec.
>
> Thank you all in advance.
>
> [1] http://hg.openjdk.java.net/lambda/lambda
> [2] http://hg.openjdk.java.net/lambda/defender-prototype
>
Rémi
More information about the lambda-dev
mailing list