views:

168

answers:

2

I am trying to use the BGGA closures prototype with an existing JDK 6 (standard on Mac OS X Leopard). The sample code I'm compiling is from a BGGA tutorial:

public static void main(String[] args) {
  // function with no arguments; return value is always 42
  int answer = { => 42 }.invoke();
  System.out.println(answer);
}

I have tried the following, and none work:

  1. Copied closures.jar to /System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home/lib
  2. Ran javac with -Xbootclasspath/a:/path/to/closures.jar
  3. Ran javac with -J-Xbootclasspath/a:/path/to/closures.jar
  4. Tried from eclipse ganymede by defining my own system library and attaching it to my project with code utilizing BGGA.

In all four cases, I get compilation errors, indicating that the compiler did not pick up closures.jar on the bootstrap classpath. I'd really like to get this working from eclipse, or at the very least maven. Thanks!

A: 

Have you tried javac with -J-Xbootclasspath instead? That's used for passing -X arguments to the VM itself, which may be necessary for a change as low-level as this.

I very much doubt this will work with Eclipse, though. System libraries are for APIs, not language changes. You'd need to patch the Eclipse compiler.

skaffman
Thank you for the suggestion - unfortunately, this didn't work (I edited the question to reflect this).
Julie
+1  A: 

The TAR file distribution includes a modified javac.bat with a complete command line, including "-source 7", which is probably what you are missing here.

skaffman
On a mac, the bin/javac bash script worked for compiling, and bin/java worked for executing.
Julie