[fpc-pascal] pas2jni issues

Yuriy Sydorov jura at cp-lab.com
Fri Nov 2 16:33:26 CET 2018


On 10/31/2018 3:23 PM, ksterg at gmail.com wrote:
> I would like to make a suggestion regarding the generated code of the
> pas2jni utility, and report an issue.
> 
> This utility generates a java file called system.java. First thing is that
> there is a reference to TClass which is a non-existent Java class:
>    static TClass GetTClass(int index) { TClass c = new TClass(null);
> c._pasobj=GetClassRef(index); return c; }
> 
> In order to compile the generated system.java I had to comment out this
> line. I didn't look too deep to see how/where it is used, yet for my needs
> this did the work. I assume something simple is missing there.

This issue happens when no classes are used in your code. If you add usage of TObject, the Java code will work.
I've fixed this in trunk in r40179.

> Second thing is the way this file has hard-coded the loading of the .dll
> file: There is a static IniJni() method that is called with a static class
> initializer:
>    static { com.imagetrust.launch.winutils.system.InitJni(); }
> This is a technique that excludes any other way of dynamically loading the
> .dll file. This is a show-stopper for cases where dll files are packaged in
> a jar file and are loaded dynamically with System.load. As the code is
> written, the assumption is that the jni dll file always exists in
> java.library.path.

In r40179 I've added the "-N" switch to pas2jni which prevents auto-loading of the shared library.

Just get the latest trunk sources of pas2jni and compile it to get the fixed version.

Yuriy.



More information about the fpc-pascal mailing list