Skip to content

Frequently Asked Questions

Marimuthu Madasamy edited this page Jun 29, 2013 · 15 revisions

Can Frege be used to ....

If it cannot be done with Java, then it cannot be done with Frege either. Otherwise, the answer is "most likely". Remember, writing Frege code is just a more convenient way to write Java code.

Why would I need Java 7? How can I use frege with Java 6?

JDK7 is the official development platform, it is choosen because it has the fork/join packages which are used for parallelization.

However, apart from that, no Java 7 features are used. Hence, it is possible to compile and run frege programs that do not need paralellism with Java 6.

Here are the steps to follow, based on the "Re-Compiling the Compiler" section of the Getting Started page:

After cloning the frege repository, do the following adaptions:

  1. In the Makefile, we let JAVAC point to a java6 compiler and comment out the lines referring ForkJoin.fr, ForkJoin.class

  2. In the JAVA macro, the property -Dfrege.javac must also point to the java6 compiler.

  3. In frege/runtime/CompilerSupport.java, we need to remove references to the Files class and re-implement the slurp method. The following one-liner could help with the imports import java.util.Scanner and import java.io.File: return new Scanner(new File(filename), encoding).useDelimiter("\\Z").next();

  4. In frege/runtime/Concurrent.java, comment out the fork method and references to ForkJoinPool.

  5. In frege/StandardLibrary.fr, the import Lib.ForkJoin needs to be removed.

  6. In frege/runtime/Runtime.java, replace import java.nio.charset.StandardCharsets with java.nio.charset.Charset and replace the usage of StandardCharsets.UTF_8 with Charset.forName("UTF-8").

  7. java.util.zip.ZipFile implements Closeable only in Java 7 so we cannot call close through Closeable. In frege/java/util/Zip.fr, for ZipFile, add this function native close :: ZipFile -> IO () throws IOException and in frege/frege/tools/Quick.fr, replace j.close in checkArch function with (ZipFile.close j).

  8. Finally due to this bug in Java 6 compiler, you may not be able to compile Frege compiler sources with Java 6 compiler. In this case, you can cross compile to Java 6 using Java 7 compiler with source, target and bootclasspath options in your frege/Makefile like:

JAVAC = javac -encoding UTF-8 -source 1.6 -target 1.6 -bootclasspath /your/path/to/jre-6/lib/rt.jar -extdirs "" -J-Xmx512m

JAVA = java -XX:+TieredCompilation "-Dfrege.javac=javac -encoding UTF-8 -source 1.6 -target 1.6 -bootclasspath /your/path/to/jre-6/lib/rt.jar -extdirs \\"\\" -J-Xmx512m" 

Note that, in order to run the downloaded frege compiler, you still need at least JRE 7.

Clone this wiki locally