Sign in Join
Wiki copytemporary

FPC JVM/Building: what changed

Revision 2 to 3. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11# Building the JVM compiler
22
33The instructions below are for Unix-like platforms, but by changing the forward slashes to backslashes (and adding *.exe* after the compiler binary name when copying it), most, if not all, commands will work on Windows, too.
44
55Every sequence of commands below starts from the assumption that you are in the top-level FPC source directory.
66
77## Prerequisites
88
99A complete and working installation of FPC 2.6.0 or later (matching the version of the JVM compiler you want to build), the [FPC JVM utilities](ftp://ftp.freepascal.org/pub/fpc/contrib/jvm/fpcjvmutilities.zip), and an installation of the JDK 1.5 or later (with the binaries/jar files of all of them in the path).
1010
1111## Obtaining the FPC sources
1212
1313The FPC JVM backend is now part of the main branch.
1414
15-` `[`https://gitlab.com/freepascal.org/fpc/source/-/tree/main/compiler/jvm`](https://gitlab.com/freepascal.org/fpc/source/-/tree/main/compiler/jvm)
15+```text
16+ https://gitlab.com/freepascal.org/fpc/source/-/tree/main/compiler/jvm
17+```
1618
1719To build the compiler, clone the repository to a local folder "fpc" from
1820
19-`  `[`https://gitlab.com/freepascal.org/fpc/source`](https://gitlab.com/freepascal.org/fpc/source)
21+```text
22+ https://gitlab.com/freepascal.org/fpc/source
23+```
2024
2125If the latest official release of FPC, installed on your system does not match the version in the main branch, don't use it to build the JVM. Instead, check out the relevant tagged release from the repository!
2226
2327## Building the compiler and RTL
2428
2529**Note**: all of the commands below require that the latest native FPC release for your platform is in the PATH.
2630
2731Execute the following command in the top level directory of the checked out sources, i.e. in the *fpc* directory (replace *FullPathToInstallLocation* with the directory where to install the result):
2832
29-`make CROSSOPT="-O2 -g" CPU_TARGET=jvm OS_TARGET=java INSTALL_PREFIX=`*`FullPathToInstallLocation`*` all crossinstall`
33+```text
34+make CROSSOPT="-O2 -g" CPU_TARGET=jvm OS_TARGET=java INSTALL_PREFIX=FullPathToInstallLocation all crossinstall
35+```
3036
3137If you wish to also create a run time library that can be used for Android development, use the following command (replace *FullPathToInstallLocation* with the directory where to install the result):
3238
33-`make CROSSOPT="-O2 -g" CPU_TARGET=jvm OS_TARGET=android INSTALL_PREFIX=`*`FullPathToInstallLocation all crossinstall`*
39+```text
40+make CROSSOPT="-O2 -g" CPU_TARGET=jvm OS_TARGET=android INSTALL_PREFIX=FullPathToInstallLocation all crossinstall
41+```
3442
3543The generated compiler is called *ppcjvm*/*ppcjvm.exe*.
3644
3745In both cases, a *ppcjvm* (or *ppcjvm.exe*) binary will be created and installed. The compiler generated by both build processes is the same, so you only need one. When compiling programs using this compiler, specify the correct *-Fu* parameter to point to the Java/Android units.
3846
3947## Building the fpcjres utility
4048
4149This step is optional and is only required for the raw *{\$r xxx}* support. Run the following command in the top-level directory of the checked-out sources:
4250
43-`make all`
51+```text
52+make all
53+```
4454
4555The compiled *fpcjres* utility will be in *utils/fpcres*.
4656
4757# Additional tools
4858
4959## Building javapp
5060
5161The tool used to generate Pascal import headers from Java classes is called *javapp*. It is written in Java because it is based on the *javap* utility from the JDK (version 6).
5262
5363The source code for javapp can be found under *utils/javapp* in the FPC source tree. To build it, create a new Eclipse project and import the sources. Then, add *jgrapht.jar* from <http://www.cs.sunysb.edu/~algorith/implement/jgrapht/distrib/> to the project (used for topological sorting to determine the dependencies between the classes). The main class file is *Main.java*.
5464
5565### Creating the Java RTL headers
5666
5767To create the *rtl/java/java_sysh.inc* and *rtl/java/java_sys.inc* files, run *javapp* as follows:
5868
59-` java -jar javapp.jar -protected java.lang.System java.lang.Object java.io.Serializable java.io.IOException java.io.IIOException java.lang.Readable java.lang.Float java.lang.Double java.lang.Byte java.lang.Short java.lang.Integer java.lang.Long java.lang.Boolean java.lang.String java.lang.StringBuilder java.lang.StringBuffer java.lang.CharSequence java.lang.AbstractStringBuilder java.lang.Appendable java.lang.Number java.lang.IndexOutOfBoundsException java.lang.RuntimeException java.lang.IllegalArgumentException java.lang.IllegalStateException java.lang.UnsupportedOperationException java.lang.Exception java.lang.Throwable java.lang.NoSuchMethodException java.lang.LinkageError java.lang.Error java.lang.Comparable java.lang.Character java.text.Collator java.lang.Cloneable java.lang.Runtime java.lang.ThreadLocal java.math.BigInteger java.util.Comparator java.lang.reflect.Array java.lang.Class java.lang.reflect.GenericDeclaration java.lang.reflect.Type java.lang.reflect.Method java.lang.reflect.AccessibleObject java.lang.reflect.Member java.lang.reflect.AnnotatedElement java.lang.reflect.InvocationTargetException java.lang.reflect.Field java.util.Arrays java.util.Map java.util.HashMap java.util.Set java.util.Collection java.util.AbstractMap java.util.Calendar java.lang.Iterable java.lang.Enum  java.lang.Math java.util.AbstractCollection java.util.AbstractSet java.util.EnumSet java.util.BitSet java.util.Iterator java.nio.Buffer java.nio.ByteBuffer java.nio.CharBuffer java.nio.charset. -i -o java_sys`
69+``` pascal
70+ java -jar javapp.jar -protected java.lang.System java.lang.Object java.io.Serializable java.io.IOException java.io.IIOException java.lang.Readable java.lang.Float java.lang.Double java.lang.Byte java.lang.Short java.lang.Integer java.lang.Long java.lang.Boolean java.lang.String java.lang.StringBuilder java.lang.StringBuffer java.lang.CharSequence java.lang.AbstractStringBuilder java.lang.Appendable java.lang.Number java.lang.IndexOutOfBoundsException java.lang.RuntimeException java.lang.IllegalArgumentException java.lang.IllegalStateException java.lang.UnsupportedOperationException java.lang.Exception java.lang.Throwable java.lang.NoSuchMethodException java.lang.LinkageError java.lang.Error java.lang.Comparable java.lang.Character java.text.Collator java.lang.Cloneable java.lang.Runtime java.lang.ThreadLocal java.math.BigInteger java.util.Comparator java.lang.reflect.Array java.lang.Class java.lang.reflect.GenericDeclaration java.lang.reflect.Type java.lang.reflect.Method java.lang.reflect.AccessibleObject java.lang.reflect.Member java.lang.reflect.AnnotatedElement java.lang.reflect.InvocationTargetException java.lang.reflect.Field java.util.Arrays java.util.Map java.util.HashMap java.util.Set java.util.Collection java.util.AbstractMap java.util.Calendar java.lang.Iterable java.lang.Enum java.lang.Math java.util.AbstractCollection java.util.AbstractSet java.util.EnumSet java.util.BitSet java.util.Iterator java.nio.Buffer java.nio.ByteBuffer java.nio.CharBuffer java.nio.charset. -i -o java_sys
71+```
6072
6173To create the *rtl/java/jdk15.pas* and *rtl/java/jdk15.inc* files, use
6274
63-` java -jar javapp.jar -x java.lang.System -x java.lang.Object -x java.io.Serializable -x java.io.IOException -x java.io.IIOException -x java.lang.Readable -x java.lang.Float -x java.lang.Double -x java.lang.Float -x java.lang.Double -x java.lang.Byte -x java.lang.Short -x java.lang.Integer -x java.lang.Long -x java.lang.Boolean -x java.lang.String -x java.lang.StringBuilder -x java.lang.StringBuffer -x java.lang.CharSequence -x java.lang.AbstractStringBuilder -x java.lang.Appendable -x java.lang.Number -x java.lang.IndexOutOfBoundsException -x java.lang.RuntimeException -x java.lang.IllegalArgumentException -x java.lang.IllegalStateException -x java.lang.UnsupportedOperationException -x java.lang.Exception -x java.lang.Throwable -x java.lang.LinkageError -x java.lang.Error -x java.lang.Comparable -x java.lang.Character  -x java.text.Collator -x java.lang.Cloneable -x java.lang.Runtime -x java.lang.ThreadLocal -x java.math.BigInteger -x java.util.Comparator -x java.lang.reflect.Array -x java.lang.Class -x java.lang.reflect.GenericDeclaration -x java.lang.reflect.Type -x java.lang.reflect.Method -x java.lang.reflect.AccessibleObject -x java.lang.reflect.Member -x java.lang.reflect.AnnotatedElement -x java.lang.reflect.Field -x java.lang.reflect.InvocationTargetException -x java.util.Arrays -x java.util.Map -x java.util.HashMap -x java.util.Set -x java.util.Collection -x java.util.AbstractMap -x java.util.Calendar -x java.lang.Iterable -x java.lang.Enum -x java.lang.Math -x java.util.AbstractCollection -x java.util.AbstractSet -x java.util.EnumSet -x java.util.BitSet -x java.util.Iterator -x java.nio.Buffer -x java.nio.ByteBuffer -x java.nio.CharBuffer -x java.nio.charset. -a sun. -a com.sun. -a apple. -a java.awt.Dialog -protected java. javax. org. -o jdk15`
75+``` pascal
76+ java -jar javapp.jar -x java.lang.System -x java.lang.Object -x java.io.Serializable -x java.io.IOException -x java.io.IIOException -x java.lang.Readable -x java.lang.Float -x java.lang.Double -x java.lang.Float -x java.lang.Double -x java.lang.Byte -x java.lang.Short -x java.lang.Integer -x java.lang.Long -x java.lang.Boolean -x java.lang.String -x java.lang.StringBuilder -x java.lang.StringBuffer -x java.lang.CharSequence -x java.lang.AbstractStringBuilder -x java.lang.Appendable -x java.lang.Number -x java.lang.IndexOutOfBoundsException -x java.lang.RuntimeException -x java.lang.IllegalArgumentException -x java.lang.IllegalStateException -x java.lang.UnsupportedOperationException -x java.lang.Exception -x java.lang.Throwable -x java.lang.LinkageError -x java.lang.Error -x java.lang.Comparable -x java.lang.Character -x java.text.Collator -x java.lang.Cloneable -x java.lang.Runtime -x java.lang.ThreadLocal -x java.math.BigInteger -x java.util.Comparator -x java.lang.reflect.Array -x java.lang.Class -x java.lang.reflect.GenericDeclaration -x java.lang.reflect.Type -x java.lang.reflect.Method -x java.lang.reflect.AccessibleObject -x java.lang.reflect.Member -x java.lang.reflect.AnnotatedElement -x java.lang.reflect.Field -x java.lang.reflect.InvocationTargetException -x java.util.Arrays -x java.util.Map -x java.util.HashMap -x java.util.Set -x java.util.Collection -x java.util.AbstractMap -x java.util.Calendar -x java.lang.Iterable -x java.lang.Enum -x java.lang.Math -x java.util.AbstractCollection -x java.util.AbstractSet -x java.util.EnumSet -x java.util.BitSet -x java.util.Iterator -x java.nio.Buffer -x java.nio.ByteBuffer -x java.nio.CharBuffer -x java.nio.charset. -a sun. -a com.sun. -a apple. -a java.awt.Dialog -protected java. javax. org. -o jdk15
77+```
6478
6579### Creating the Android RTL headers
6680
6781To create the *rtl/android/jvm/java_sysh_android.inc* and *rtl/android/jvm/java_sys_android.inc* files, use (same command line as for creating the equivalent Java RTL includes, except for the additional *bootclasspath* and *extdirs* parameters)
6882
69-` java -jar javapp.jar -bootclasspath /full/path/to/android-sdk/platforms/android-14/android.jar -extdirs . -protected java.lang.System java.lang.Object java.io.Serializable java.io.IOException java.io.IIOException java.lang.Readable java.lang.Float java.lang.Double java.lang.Byte java.lang.Short java.lang.Integer java.lang.Long java.lang.Boolean java.lang.String java.lang.StringBuilder java.lang.StringBuffer java.lang.CharSequence java.lang.AbstractStringBuilder java.lang.Appendable java.lang.Number java.lang.IndexOutOfBoundsException java.lang.RuntimeException java.lang.IllegalArgumentException java.lang.IllegalStateException java.lang.UnsupportedOperationException java.lang.Exception java.lang.Throwable java.lang.NoSuchMethodException java.lang.LinkageError java.lang.Error java.lang.Comparable java.lang.Character java.text.Collator java.lang.Cloneable java.lang.Runtime java.lang.ThreadLocal java.math.BigInteger java.util.Comparator java.lang.reflect.Array java.lang.Class java.lang.reflect.GenericDeclaration java.lang.reflect.Type java.lang.reflect.Method java.lang.reflect.AccessibleObject java.lang.reflect.Member java.lang.reflect.AnnotatedElement java.lang.reflect.InvocationTargetException java.lang.reflect.Field java.util.Arrays java.util.Map java.util.HashMap java.util.Set java.util.Collection java.util.AbstractMap java.util.Calendar java.lang.Iterable java.lang.Enum  java.lang.Math java.util.AbstractCollection java.util.AbstractSet java.util.EnumSet java.util.BitSet java.util.Iterator java.nio.Buffer java.nio.ByteBuffer java.nio.CharBuffer java.nio.charset. -i -o java_sys`
83+``` pascal
84+ java -jar javapp.jar -bootclasspath /full/path/to/android-sdk/platforms/android-14/android.jar -extdirs . -protected java.lang.System java.lang.Object java.io.Serializable java.io.IOException java.io.IIOException java.lang.Readable java.lang.Float java.lang.Double java.lang.Byte java.lang.Short java.lang.Integer java.lang.Long java.lang.Boolean java.lang.String java.lang.StringBuilder java.lang.StringBuffer java.lang.CharSequence java.lang.AbstractStringBuilder java.lang.Appendable java.lang.Number java.lang.IndexOutOfBoundsException java.lang.RuntimeException java.lang.IllegalArgumentException java.lang.IllegalStateException java.lang.UnsupportedOperationException java.lang.Exception java.lang.Throwable java.lang.NoSuchMethodException java.lang.LinkageError java.lang.Error java.lang.Comparable java.lang.Character java.text.Collator java.lang.Cloneable java.lang.Runtime java.lang.ThreadLocal java.math.BigInteger java.util.Comparator java.lang.reflect.Array java.lang.Class java.lang.reflect.GenericDeclaration java.lang.reflect.Type java.lang.reflect.Method java.lang.reflect.AccessibleObject java.lang.reflect.Member java.lang.reflect.AnnotatedElement java.lang.reflect.InvocationTargetException java.lang.reflect.Field java.util.Arrays java.util.Map java.util.HashMap java.util.Set java.util.Collection java.util.AbstractMap java.util.Calendar java.lang.Iterable java.lang.Enum java.lang.Math java.util.AbstractCollection java.util.AbstractSet java.util.EnumSet java.util.BitSet java.util.Iterator java.nio.Buffer java.nio.ByteBuffer java.nio.CharBuffer java.nio.charset. -i -o java_sys
85+```
7086
7187To create the *rtl/android/jvm/androidr14.pas* and *rtl/android/jvm/androidr14.inc* files, use
7288
73-` java -jar javapp.jar -bootclasspath /full/path/to/android-sdk/platforms/android-14/android.jar -extdirs . -protected -x java.lang.System -x java.lang.Object -x java.io.Serializable -x java.io.IOException -x java.io.IIOException -x java.lang.Readable -x java.lang.Float -x java.lang.Double -x java.lang.Float -x java.lang.Double -x java.lang.Byte -x java.lang.Short -x java.lang.Integer -x java.lang.Long -x java.lang.Boolean -x java.lang.String -x java.lang.StringBuilder -x java.lang.StringBuffer -x java.lang.CharSequence -x java.lang.AbstractStringBuilder -x java.lang.Appendable -x java.lang.Number -x java.lang.IndexOutOfBoundsException -x java.lang.RuntimeException -x java.lang.IllegalArgumentException -x java.lang.IllegalStateException -x java.lang.UnsupportedOperationException -x java.lang.Exception -x java.lang.Throwable -x java.lang.LinkageError -x java.lang.Error -x java.lang.Comparable -x java.lang.Character  -x java.text.Collator -x java.lang.Cloneable -x java.lang.Runtime -x java.lang.ThreadLocal -x java.math.BigInteger -x java.util.Comparator -x java.lang.reflect.Array -x java.lang.Class -x java.lang.reflect.GenericDeclaration -x java.lang.reflect.Type -x java.lang.reflect.Method -x java.lang.reflect.AccessibleObject -x java.lang.reflect.Member -x java.lang.reflect.AnnotatedElement -x java.lang.reflect.Field -x java.lang.reflect.InvocationTargetException -x java.util.Arrays -x java.util.Map -x java.util.HashMap -x java.util.Set -x java.util.Collection -x java.util.AbstractMap -x java.util.Calendar -x java.lang.Iterable -x java.lang.Enum -x java.lang.Math -x java.util.AbstractCollection -x java.util.AbstractSet -x java.util.EnumSet -x java.util.BitSet -x java.util.Iterator -x java.nio.Buffer -x java.nio.ByteBuffer -x java.nio.CharBuffer -x java.nio.charset. -a sun. -a com.sun. -a apple. -a java.awt. java. javax. org. android. junit. -o androidr14`
89+``` pascal
90+ java -jar javapp.jar -bootclasspath /full/path/to/android-sdk/platforms/android-14/android.jar -extdirs . -protected -x java.lang.System -x java.lang.Object -x java.io.Serializable -x java.io.IOException -x java.io.IIOException -x java.lang.Readable -x java.lang.Float -x java.lang.Double -x java.lang.Float -x java.lang.Double -x java.lang.Byte -x java.lang.Short -x java.lang.Integer -x java.lang.Long -x java.lang.Boolean -x java.lang.String -x java.lang.StringBuilder -x java.lang.StringBuffer -x java.lang.CharSequence -x java.lang.AbstractStringBuilder -x java.lang.Appendable -x java.lang.Number -x java.lang.IndexOutOfBoundsException -x java.lang.RuntimeException -x java.lang.IllegalArgumentException -x java.lang.IllegalStateException -x java.lang.UnsupportedOperationException -x java.lang.Exception -x java.lang.Throwable -x java.lang.LinkageError -x java.lang.Error -x java.lang.Comparable -x java.lang.Character -x java.text.Collator -x java.lang.Cloneable -x java.lang.Runtime -x java.lang.ThreadLocal -x java.math.BigInteger -x java.util.Comparator -x java.lang.reflect.Array -x java.lang.Class -x java.lang.reflect.GenericDeclaration -x java.lang.reflect.Type -x java.lang.reflect.Method -x java.lang.reflect.AccessibleObject -x java.lang.reflect.Member -x java.lang.reflect.AnnotatedElement -x java.lang.reflect.Field -x java.lang.reflect.InvocationTargetException -x java.util.Arrays -x java.util.Map -x java.util.HashMap -x java.util.Set -x java.util.Collection -x java.util.AbstractMap -x java.util.Calendar -x java.lang.Iterable -x java.lang.Enum -x java.lang.Math -x java.util.AbstractCollection -x java.util.AbstractSet -x java.util.EnumSet -x java.util.BitSet -x java.util.Iterator -x java.nio.Buffer -x java.nio.ByteBuffer -x java.nio.CharBuffer -x java.nio.charset. -a sun. -a com.sun. -a apple. -a java.awt. java. javax. org. android. junit. -o androidr14
91+```
7492
7593You will have to make several manual changes to the result before it compiles, though:
7694
7795- There is a circular dependency involving the *AVViewGroup.LayoutParams* nested class, which results in javapp being unable to order all classes. You will have to manually extract that class and redeclare it as *AVViewGroup_LayoutParams = class external 'android.view' name 'ViewGroup\$LayoutParams' (JLObject)*, and then replace all references to the original class to this new class
7896- There is a class with a constant field called *CREATE*, which results in javapp generating wrong names for its constructors (*\<init\>_*). Rename the constant to *CREATE_* and the constructors to *Create*
7997- The declaration for *AAActionBar.InnerTab* is missing. Add it as *InnerTab = class abstract external 'android.app' name 'Tab' end;* inside *AAActionBar*
8098
8199### Creating interfaces for other Java classes
82100
83101Example of creating a unit called *bcel* containing all classes under *org.apache.bcel* that can be found in bcel-6.0-SNAPSHOT.jar:
84102
85-` java -jar full/path/to/javapp.jar -classpath full/path/to/bcel-6.0-SNAPSHOT.jar -protected -o bcel org.apache.bcel.`
103+```text
104+ java -jar full/path/to/javapp.jar -classpath full/path/to/bcel-6.0-SNAPSHOT.jar -protected -o bcel org.apache.bcel.
105+```
86106
87107The long parameter lists above are due to the split of the classes between the system unit and the jdk15 unit. The extra *-classpath* parameter is required when dumping classes that are not part of the standard JDK and has to point to the jar file(s) and/or directory/ies containing the class hierarchy you want to dump. If they are in the current directory, do not forget to pass explicitly"*-classpath .*"
88108
89109Important:
90110
91111- If an identifier argument to javapp ends in a ".", it is interpreted as a package name, otherwise as a class name (not the '.' at the end of *org.apache.bcel.* in the example above).
92112- In case circular dependencies of inner classes are involved, you must sacrifice one of the classes involved in the cycle by passing it using the *-a* option (anonymous). In that case, this class will be translated as a [[FPC JVM/Language|formal class]] (like *java.awt.Dialog* above, which is involved in a circular dependency with an inner class of *java.awt.Window*).
93113- The *-i* option causes javapp to generate include files. Otherwise, it generates a standalone unit.
94114- Pascal does not support the concept of Java-style *[inner classes](http://download.oracle.com/javase/tutorial/java/javaOO/nested.html)*, but only that of static nested classes. As a result, Java inner classes are not added to the translated headers.
95115
96116The javapp source code is, unfortunately not very clean. The fact that the javap source code could have been cleaner did not help, but the situation has not exactly improved...
97117
98118### Building javapp from command-line
99119
100120The installation and usage of Eclipse might not be desirable. You can compile javapp using JDK tools only. JDK is a prerequisite. Thus, you should have it installed anyway.
101121
102122To compile, you must call **javac** and compile all .java files in "fpc\utils\javapp\src\fpc\tools\javapp" directory. As mentioned earlier, sources depend on jgrapht-jdk1.5.jar. Thus, the class path must be specified during compilation.
103123
104124Once sources are compiled, all .class files must be gathered into a .jar file. The manifest file must declare the entry point class and the dependency on jgrapht.
105125
106126Below is the Windows batch (.bat) script file that performs the compilation. The script is intended to be run from fpc\utils\javapp folder. Directory referencing JDK and jgrapht location should be adjusted according to your end system configuration.
107127
108-`:: Set environmental variables.`\
109-`:: If you have the JDK bin folder in your "PATH" environmental variables`\
110-`:: you can remove the reference to jdkbindir at all`\
111-`:: but make sure that all slash-separators are also removed`\
112-`set jdkbindir=C:\Program Files\Java\jdk1.8.0_91\bin`\
128+``` pascal
129+:: Set environmental variables.
130+:: If you have the JDK bin folder in your "PATH" environmental variables
131+:: you can remove the reference to jdkbindir at all
132+:: but make sure that all slash-separators are also removed
133+set jdkbindir=C:\Program Files\Java\jdk1.8.0_91\bin
113134
114-`:: This is the directory where jgrapht .jar file is located`\
115-`:: make sure you remove the slash at the end `\
116-`set jgraphtdir=C:\jgrapht-0.7.2`\
135+:: This is the directory where jgrapht .jar file is located
136+:: make sure you remove the slash at the end
137+set jgraphtdir=C:\jgrapht-0.7.2
117138
118-`:: This generates a small manifest file template`\
119-`:: It's needed so, "jar" utility will create a dependency for jgrapht-jdk1.5 library`\
120-`@echo Class-Path: jgrapht-jdk1.5.jar > manifest.txt`\
139+:: This generates a small manifest file template
140+:: It's needed so, "jar" utility will create a dependency for jgrapht-jdk1.5 library
141+@echo Class-Path: jgrapht-jdk1.5.jar > manifest.txt
121142
122-`::: Compiling sources using Javac`\
123-`:: -d .\ forces "javac" to put all the class files hierarchy  into the current directory`\
124-`:: once "javac" finished you should have the following file structure created "./fpc/tools/javapp/"`\
125-`:: The structure is important for .jar file`\
126-`"%jdkbindir%\javac.exe" ^`\
127-`  .\src\fpc\tools\javapp*.java ^`\
128-`  -d .\ ^`\
129-`  -cp %jgraphtdir%\jgrapht-jdk1.5.jar`\
143+::: Compiling sources using Javac
144+:: -d .\ forces "javac" to put all the class files hierarchy into the current directory
145+:: once "javac" finished you should have the following file structure created "./fpc/tools/javapp/"
146+:: The structure is important for .jar file
147+"%jdkbindir%\javac.exe" ^
148+ .\src\fpc\tools\javapp*.java ^
149+ -d .\ ^
150+ -cp %jgraphtdir%\jgrapht-jdk1.5.jar
130151
131-`:: Creating a .jar file for the application`\
132-`::  Including manifest file (manifest.txt)`\
133-`::  Specifying entry point  (fpc.tools.javapp.Main)`\
134-`::  "fpc" is the folder where .class files are located`\
135-`"%jdkbindir%\jar" cfme javapp.jar manifest.txt fpc.tools.javapp.Main fpc`\
152+:: Creating a .jar file for the application
153+:: Including manifest file (manifest.txt)
154+:: Specifying entry point (fpc.tools.javapp.Main)
155+:: "fpc" is the folder where .class files are located
156+"%jdkbindir%\jar" cfme javapp.jar manifest.txt fpc.tools.javapp.Main fpc
136157
137-`copy /Y "%jgraphtdir%\jgrapht-jdk1.5.jar" jgrapht-jdk1.5.jar`\
158+copy /Y "%jgraphtdir%\jgrapht-jdk1.5.jar" jgrapht-jdk1.5.jar
138159
139-`:: Clean up time!`\
140-`:: We don't need this file anymore`\
141-`:: /Q is quite mode`\
142-`@del /Q manifest.txt`\
143-`:: Remove the directory structure containing .classes. We don't need them since they should now be part`\
144-`:: of the .jar file. Removing it, quietly `\
145-`@rmdir /S /Q fpc`
160+:: Clean up time!
161+:: We don't need this file anymore
162+:: /Q is quite mode
163+@del /Q manifest.txt
164+:: Remove the directory structure containing .classes. We don't need them since they should now be part
165+:: of the .jar file. Removing it, quietly
166+@rmdir /S /Q fpc
167+```
146168
147169As the result, you'll have two files javapp.jar and jgrapht-jdk1.5.jar. If you need to move javapp.jar to another directory, copy jgrapht-jdk1.5.jar as well.
148170
149171# External tools
150172
151173## Building Jasmin
152174
153175Jasmin is the compiler's Java byte code assembler to translate the generated assembler files (*.j) into Java class files (*.class).
154176
155177- Download the Jasmin 2.4 source code from <https://sourceforge.net/projects/jasmin/files/> and unzip it
156178- Download the patch from <ftp://ftp.freepascal.org/pub/fpc/contrib/jvm/jasmin24b.patch> and apply it to the Jasmin 2.4 source. That patch does the following things:
157179 - Change the Windows-style newlines of the *build.sh* script into Unix-style newlines
158180 - Apply a fix for <https://sourceforge.net/p/jasmin/bugs/3/>
159181 - Apply a fix for <https://sourceforge.net/p/jasmin/bugs/5/>
160182 - Apply a fix for <https://gitlab.com/freepascal.org/fpc/source/-/issues/22807>
161183 - Add support for floating point constants encoded in hexadecimal format
162184 - Fix the type encoding of 64-bit constants declared with an initialization value that fits in 32-bit
163185- For Unix platforms: build Jasmin by making the *build.sh* script executable (*chmod +x build.sh*) and executing *./build.sh all*. This will generate a new *jasmin.jar* in the current directory. There's also a *build.bat* file that will presumably do the same on Windows.
164186
165187## Building BCEL
166188
167189BCEL is a Java byte code verification framework that can be used to look for errors in Java class files. See [[FPC JVM/Debugging]] for usage information.
168190
169191- Check out the svn sources using the following command
170192
171-` svn checkout `[`http://svn.apache.org/repos/asf/commons/sandbox/classscan/trunk/bcel`](http://svn.apache.org/repos/asf/commons/sandbox/classscan/trunk/bcel)` bcel`
193+```text
194+ svn checkout http://svn.apache.org/repos/asf/commons/sandbox/classscan/trunk/bcel bcel
195+```
172196
173197- Before building, apply the patch at <ftp://ftp.freepascal.org/pub/fpc/contrib/jvm/bcel-r1157681-returntype.patch> to prevent incorrect verification errors about return type mismatches.
174198- To build BCEL, you first have to install [Apache Maven](http://maven.apache.org/)
175199- Once Maven is installed and its *mvn* binary is in your PATH, run *mvn package* in the bcel source directory. The first time you do so, Maven will download and configure many plugins, which takes quite some time. After building, the new version of BCEL will be available as *target/bcel-6.0-SNAPSHOT.jar*
176200
177201---
178202*From the Free Pascal wiki, page "FPC JVM/Building", as it stood on 2023-08-31 after a change by Peter.Dell, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
179203Category: JVM

Back to history