Impossible to extract FMU on Mac with Java 11

Issue #107 resolved
Chanon Sillapasunthon created an issue

Dear Sir/Madam

We have found an issue when running an FMU file with Java 11 on Mac OS. Please see below for the stacktrace:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.javafmi.kernel.Unzipper (file:/Users/csn16/.ivy2/cache/org.siani.javafmi/fmu-wrapper/jars/fmu-wrapper-2.26.1.jar) to method java.util.prefs.FileSystemPreferences.chmod(java.lang.String,int)
WARNING: Please consider reporting this to the maintainers of org.javafmi.kernel.Unzipper
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Exception in thread "main" java.lang.RuntimeException: Impossible to extract bouncingBall.dylib
at org.javafmi.kernel.Unzipper.extractEntryToFile(Unzipper.java:106)
at org.javafmi.kernel.Unzipper.unzipAll(Unzipper.java:89)
at org.javafmi.proxy.FmuFile.<init>(FmuFile.java:66)
at org.javafmi.proxy.FmuFile.<init>(FmuFile.java:61)
at org.javafmi.wrapper.Simulation.fmuFile(Simulation.java:81)
at org.javafmi.wrapper.Simulation.<init>(Simulation.java:68)
at org.javafmi.wrapper.Simulation.<init>(Simulation.java:60)
at com.nomagic.magicdraw.simulation.TestFMU.main(TestFMU.java:13)
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.javafmi.kernel.Unzipper.setExecutionPermission(Unzipper.java:115)
at org.javafmi.kernel.Unzipper.extractEntryToFile(Unzipper.java:103)
... 7 more
Caused by: java.lang.UnsatisfiedLinkError: 'int java.util.prefs.FileSystemPreferences.chmod(java.lang.String, int)'
at java.prefs/java.util.prefs.FileSystemPreferences.chmod(Native Method)
... 13 more

From the stacktrace, it seems the error occurs when it’s trying to invoke the native chmod method of class java.util.prefs.FileSystemPreferences.

We have tried with fmu-wrapper-2.20.2, fmu-wrapper-2.25.3 and the latest one (fmu-wrapper-2.26.1) with AdoptOpenJDK-11 on Mac OS Catalina (10.15.5). All of them gave the same results.

The fmu file is attached and we used the sample code of Simulation class which is given in https://bitbucket.org/siani/javafmi/wiki/FmuWrapper

Best Regards

Chanon S.

Comments (9)

  1. Jose Evora

    Dear Chanon,

    Thank you very much for contacting us. We have tried to use your FMU and it seems to work properly on our machines. FMUs are fully extracted in the temporary folder of your OS. Each extracted file is given permisson to be executable in order to be able to load the dynamic library once all files are extracted. This is what the chmod that you mention makes. It seems to me that the user that opens the simulation (the one tha executes the java code) has no permissions to make files executable. Could you check this?

    Let us know if this worked.

    Best regards,

  2. Chanon Sillapasunthon reporter

    Dear Jose

    Did you try to use our FMU with the same environments as mine? (Mac OSX Catalina 10.15.5 and AdoptOpenJDK-11)

    Please see the information in the image below for what I have tried.

    Best Regards

    Chanon S.

  3. Jose Evora

    Dear Chanon,

    We will do some tests. It will take sometime as we need to prepare the machine for this configuration you mention.

    As a plan B while the machine is prepared, I have been searching on google and I have found this:
    https://github.com/thrau/jarchivelib/issues/70
    It looks to me that it could be related to the problem you are experiencing. I could prepare an ad-hoc version of java fmi implementing the proposal of the link so that you can test it. Would it be possible?

    Best regards,

  4. Chanon Sillapasunthon reporter

    Dear Jose

    That’s would be my pleasure. I did some research and also found the same link in your comment. It seems that the developer of jarchivelib fixed it by using java.nio.file.Files#setPosixFilePermissions, instead of invoking the chmod.

    Please keep me posted.

    Best Regards

    Chanon S.

  5. Jose Evora

    Please find attached the ad-hoc version to validate with you. Let us know your feedback on it. Note this is a “fat jar” including all dependencies.

    Best regards,

  6. Chanon Sillapasunthon reporter

    Dear Jose

    Thank you for your updated jar file. I would like to confirm that the UnsatisfiedLinkError is fixed in your ad-hoc version. I have tested with another fmu file where fmi version is 2.0 and it worked perfectly.

    However, there is another issue, found when running fmu (fmi 1.0) on Mac (regardless of java versions), which is reported as #108.

    Best Regards

    Chanon S.

  7. Log in to comment