Difference between revisions of "FPC JVM"

From Free Pascal wiki
Jump to navigationJump to search
(→‎Snapshots: snapshot 2)
(* new snapshot with Android support)
Line 2: Line 2:
 
=Overview=
 
=Overview=
  
The FPC backend for the Java Virtual Machine (JVM) generates Java byte code that conforms to the specifications of the JDK 1.5 (and later). While not all FPC language features work when targeting the JVM, most do (or will in the future) and we have done our best to introduce as few differences as possible.
+
The FPC backend for the Java Virtual Machine (JVM) generates Java byte code that conforms to the specifications of the <b>JDK 1.5 (and later)</b>, and also to the Dalvik VM from the <b>Android</b> platform. While not all FPC language features work when targeting the JVM, most do (or will in the future) and we have done our best to introduce as few differences as possible.
  
 
This FPC JVM backend is not related to [http://www.remobjects.com/cooper.aspx Project Cooper] by RemObjects, nor does FPC now support the Oxygene language.
 
This FPC JVM backend is not related to [http://www.remobjects.com/cooper.aspx Project Cooper] by RemObjects, nor does FPC now support the Oxygene language.
  
 
=Snapshots=
 
=Snapshots=
You can find compiled snapshots below (svn r19598, 2011/11/07). These are cross-compilers from the mentioned platform to the JVM. The generated code is not specific to the JVM running on that particular platform.
+
You can find compiled snapshots below (svn r1919830, 2011/12/12). These are cross-compilers from the mentioned platform to the JVM. The generated code is not specific to the JVM running on that particular platform.
  
 
Installation instructions:
 
Installation instructions:
Line 17: Line 17:
  
 
Snapshot download links:
 
Snapshot download links:
* [http://sourceforge.net/projects/freepascal/files/JVM/2.7.1-r19598-snapshot2/fpcjvmwin32-snapshot2.zip/download Windows] (i386) ([ftp://ftp.freepascal.org/pub/fpc/contrib/jvm/fpcjvmwin32-snapshot2.zip slower mirror])
+
* [http://sourceforge.net/projects/freepascal/files/JVM/2.7.1-r19830-snapshot3/fpcjvmwin32-snapshot3.zip/download Windows] (i386) ([ftp://ftp.freepascal.org/pub/fpc/contrib/jvm/fpcjvmwin32-snapshot3.zip slower mirror])
* [http://sourceforge.net/projects/freepascal/files/JVM/2.7.1-r19598-snapshot2/fpcjvmmacosx-snapshot2.tbz/download Mac OS X] (universal binary, Mac OS X 10.5 or later) ([ftp://ftp.freepascal.org/pub/fpc/contrib/jvm/fpcjvmmacosx-snapshot2.tbz slower mirror])
+
* [http://sourceforge.net/projects/freepascal/files/JVM/2.7.1-r19830-snapshot3/fpcjvmmacosx-snapshot2.tbz/download Mac OS X] (universal binary, Mac OS X 10.5 or later) ([ftp://ftp.freepascal.org/pub/fpc/contrib/jvm/fpcjvmmacosx-snapshot3.tbz slower mirror])
* [http://sourceforge.net/projects/freepascal/files/JVM/2.7.1-r19598-snapshot2/fpcjvmlinux-snapshot2.tbz/download Linux] (i386) ([ftp://ftp.freepascal.org/pub/fpc/contrib/jvm/fpcjvmlinux-snapshot2.tbz slower mirror])
+
* [http://sourceforge.net/projects/freepascal/files/JVM/2.7.1-r19830-snapshot3/fpcjvmlinux-snapshot2.tbz/download Linux] (i386) ([ftp://ftp.freepascal.org/pub/fpc/contrib/jvm/fpcjvmlinux-snapshot3.tbz slower mirror])
  
 
If your platform is not listed above, or if you are only interested in building the compiler/rtl from source, a separate archive that only contains the compiled Java components (Jasmin, javapp, BCEL) is also available. Building instructions are listed below.
 
If your platform is not listed above, or if you are only interested in building the compiler/rtl from source, a separate archive that only contains the compiled Java components (Jasmin, javapp, BCEL) is also available. Building instructions are listed below.
Line 25: Line 25:
  
 
=Quick start=
 
=Quick start=
 +
 +
==Java or Android==
 +
 +
By default, the compiler will generate code suitable for running on a Java Virtual Machine. If you wish to create Java class files that can be translated using the Android SDK into Dalvik code, add the ''-Tandroid'' compiler command line parameter.
  
 
==Compile a test program==
 
==Compile a test program==
Line 34: Line 38:
 
==Run it on Windows==
 
==Run it on Windows==
  
   java -cp C:\full\path\to\fpcjvm\units\rtl\jvm-java;. trange1
+
''Note: the path to the units has changed since the previous snapshots!''
 +
 
 +
   java -cp C:\full\path\to\fpcjvm\units\jvm-java\rtl;. trange1
  
Replace ''C:\full\path\to\fpcjvm\units\rtl\jvm-java'' with the full path to the ''units\rtl\jvm-java'' directory from the snapshot archive.
+
Replace ''C:\full\path\to\fpcjvm\units\jvm-java\rtl'' with the full path to the ''units\jvm-java\rtl'' directory from the snapshot archive.
  
 
==Run it on Unix-like platforms==
 
==Run it on Unix-like platforms==
  
   java -cp /full/path/to/fpcjvm/units/rtl/jvm-java:. trange1
+
''Note: the path to the units has changed since the previous snapshots!''
 +
 
 +
   java -cp /full/path/to/fpcjvm/units/jvm-java/rtl:. trange1
  
Replace ''/full/path/to/fpcjvm/units/rtl/jvm-java'' with the full path to the ''units/rtl/jvm-java'' directory from the snapshot archive.
+
Replace ''/full/path/to/fpcjvm/units/jvm-java/rtl'' with the full path to the ''units/jvm-java/rtl'' directory from the snapshot archive.
  
 
==Details==
 
==Details==

Revision as of 20:30, 12 December 2011

English (en) русский (ru)

Overview

The FPC backend for the Java Virtual Machine (JVM) generates Java byte code that conforms to the specifications of the JDK 1.5 (and later), and also to the Dalvik VM from the Android platform. While not all FPC language features work when targeting the JVM, most do (or will in the future) and we have done our best to introduce as few differences as possible.

This FPC JVM backend is not related to Project Cooper by RemObjects, nor does FPC now support the Oxygene language.

Snapshots

You can find compiled snapshots below (svn r1919830, 2011/12/12). These are cross-compilers from the mentioned platform to the JVM. The generated code is not specific to the JVM running on that particular platform.

Installation instructions:

  • unpack the archive file
  • adjust the path in the unpacked bin\fpc.cfg (Windows) or etc/fpc.cfg (other platforms) so it points to the directory where you unpacked the file
  • use the included ppcjvm compiler to compile sources

A number of test files used during development of the JVM backend can be found at http://svn.freepascal.org/svn/fpc/branches/jvmbackend/tests/test/jvm

Snapshot download links:

If your platform is not listed above, or if you are only interested in building the compiler/rtl from source, a separate archive that only contains the compiled Java components (Jasmin, javapp, BCEL) is also available. Building instructions are listed below.

  • FPC JVM utilities (you do not need this if you already downloaded one of the files above)

Quick start

Java or Android

By default, the compiler will generate code suitable for running on a Java Virtual Machine. If you wish to create Java class files that can be translated using the Android SDK into Dalvik code, add the -Tandroid compiler command line parameter.

Compile a test program

The used example is http://svn.freepascal.org/svn/fpc/branches/jvmbackend/tests/test/jvm/trange1.pp

 ppcjvm -O2 -g trange1

Run it on Windows

Note: the path to the units has changed since the previous snapshots!

 java -cp C:\full\path\to\fpcjvm\units\jvm-java\rtl;. trange1

Replace C:\full\path\to\fpcjvm\units\jvm-java\rtl with the full path to the units\jvm-java\rtl directory from the snapshot archive.

Run it on Unix-like platforms

Note: the path to the units has changed since the previous snapshots!

 java -cp /full/path/to/fpcjvm/units/jvm-java/rtl:. trange1

Replace /full/path/to/fpcjvm/units/jvm-java/rtl with the full path to the units/jvm-java/rtl directory from the snapshot archive.

Details

See the usage information page for more details.

More information