Building Lambda and a Closure Question

David Harrigan dharrigan at gmail.com
Sun Nov 20 09:33:39 PST 2011


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.

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());

    }
}

Thank you all in advance.

[1] http://hg.openjdk.java.net/lambda/lambda
[2] http://hg.openjdk.java.net/lambda/defender-prototype

-- 
I prefer encrypted and signed messages. KeyID: B20A22F9
Fingerprint: 110A F423 3647 54E2 880F ADAD 1C52 85BF B20A 22F9

"It is not usually until you've built and used a version of the
program that you understand the issues well enough to get the design
right." - Rob Pike, Brian Kernighan.

No trees were harmed in the sending of this message, however, a number
of electrons were inconvenienced.


More information about the lambda-dev mailing list