Temurin-build: Native Libraries cannot be loaded with 11.0.4 on Mojave

Created on 9 Aug 2019  ·  19Comments  ·  Source: adoptium/temurin-build

Platform:

OSX Mojave

Darwin Kernel Version 18.7.0: Thu Jun 20 18:42:21 PDT 2019; root:xnu-4903.270.47~4/RELEASE_X86_64

Architecture:

x86_64

Issue description

When attempting to load native libraries on the above platform with any of the 11.0.4 builds, I get an exception:

/private/var/folders/f6/c8gfypz56c5d9b66l6_1n30m0000gn/T/native-platform4313193693498570932dir/libnative-platform.dylib: code signature in (/private/var/folders/f6/c8gfypz56c5d9b66l6_1n30m0000gn/T/native-platform4313193693498570932dir/libnative-platform.dylib) not valid for use in process using Library Validation: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.

When running with 11.0.3, everything works as expected.

Reproducible test

There is a java app over here: https://bintray.com/beta/#/adammurdoch/maven/net.rubygrapefruit:native-platform-test/0.18?tab=files which tests various native calls.

If you download the zip, and unpack it, I get the following results:

11.0.3 (Good)

$ bin/native-platform-test

Select test to run:
  1) Show terminal details
  2) Show machine details
  3) Show file systems
  4) Test input handling
  5) Example prompts
> 6) Exit
Use the arrow keys to select an option and press enter

11.0.4 (Bad)

$ bin/native-platform-test
Exception in thread "main" net.rubygrapefruit.platform.NativeIntegrationLinkageException: Native library 'libnative-platform.dylib' could not be loaded for Mac OS X x86_64.
    at net.rubygrapefruit.platform.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:61)
    at net.rubygrapefruit.platform.Native.init(Native.java:55)
    at net.rubygrapefruit.platform.Native.get(Native.java:80)
    at net.rubygrapefruit.platform.test.Main.terminals(Main.java:286)
    at net.rubygrapefruit.platform.test.Main.main(Main.java:109)
Caused by: java.lang.UnsatisfiedLinkError: /private/var/folders/f6/c8gfypz56c5d9b66l6_1n30m0000gn/T/native-platform4313193693498570932dir/libnative-platform.dylib: dlopen(/private/var/folders/f6/c8gfypz56c5d9b66l6_1n30m0000gn/T/native-platform4313193693498570932dir/libnative-platform.dylib, 1): no suitable image found.  Did find:
    /private/var/folders/f6/c8gfypz56c5d9b66l6_1n30m0000gn/T/native-platform4313193693498570932dir/libnative-platform.dylib: code signature in (/private/var/folders/f6/c8gfypz56c5d9b66l6_1n30m0000gn/T/native-platform4313193693498570932dir/libnative-platform.dylib) not valid for use in process using Library Validation: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.
    at java.base/java.lang.ClassLoader$NativeLibrary.load0(Native Method)
    at java.base/java.lang.ClassLoader$NativeLibrary.load(ClassLoader.java:2430)
    at java.base/java.lang.ClassLoader$NativeLibrary.loadLibrary(ClassLoader.java:2487)
    at java.base/java.lang.ClassLoader.loadLibrary0(ClassLoader.java:2684)
    at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2617)
    at java.base/java.lang.Runtime.load0(Runtime.java:767)
    at java.base/java.lang.System.load(System.java:1831)
    at net.rubygrapefruit.platform.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:51)
    ... 4 more

I suspect this is an OS X only thing, but I'm testing it on ubuntu to make sure

bug macos

Most helpful comment

@taubeklavs we have a fix in place for this and are in the process of creating a jdk-11.0.4+11.3 release. Apologies for the inconvenience

All 19 comments

Tested on Ubuntu, and both version work as expected...

This seems to be just an OS X issue

I am also experiencing the same issue on macos with jdk-11.0.4+11.2, reverting to jdk-11.0.3+7 works.

@gdams likely related to the other issues you're working on...

@taubeklavs we have a fix in place for this and are in the process of creating a jdk-11.0.4+11.3 release. Apologies for the inconvenience

Awesome thanks! 😎👍

Not sure how I missed https://github.com/AdoptOpenJDK/openjdk-build/issues/1206 Sorry about that 😞

Doesn't look like that build is out yet and issue was blocking something I'm working on -- for anyone else in the same boat, you should be able to:

brew cask reinstall https://raw.githubusercontent.com/AdoptOpenJDK/homebrew-openjdk/c017a832eec4f940e11c139b6e7852eeb3b2aad8/Casks/adoptopenjdk11.rb

to get the adoptopenjdk11 cask to read out like so:

$ brew cask info adoptopenjdk11
adoptopenjdk11: 11,0.3:7
https://adoptopenjdk.net/
/usr/local/Caskroom/adoptopenjdk11/11,0.3:7 (181.4MB)
From: https://github.com/adoptopenjdk/homebrew-openjdk/blob/master/Casks/adoptopenjdk11.rb
==> Name
AdoptOpenJDK 11
==> Artifacts
OpenJDK11U-jdk_x64_mac_hotspot_11.0.3_7.pkg (Pkg)

Once the new build is published, simple brew cask upgrade should pick it up. :)

Save erroneous behavior occurs with

openjdk version "12.0.2" 2019-07-16
OpenJDK Runtime Environment AdoptOpenJDK (build 12.0.2+10)

I just downloaded jdk-12.0.2+10.2 and ran the native-platform-test. I got the "Bad" trace reported by OP.

Any hope to get a fixed build?

Hi, can confirm this also on the version 12.

Just checked the latest 11.0.5

openjdk version "11.0.5" 2019-10-15

And this all works on OS X 😎 🎉

Closing this

Thanks all!

I have this problem with 14.0.1 and 11.0.7 on Catalina

@MRigal How did you install the binary - was it a PKG file via homebrew?

Both versions installed via homebrew. I also added the recommended symlinks
after the installation.
brew install java and brew install java11

I'm still having this issue with adoptopenjdk12 and osx catalina

os: mac osx catalina 10.15.4
jdk: installed via

▶ brew tap adoptopenjdk/openjdk
▶ brew cask install adoptopenjdk --no-quarantine

brew installed the jdk under /Library/Java/JavaVirtualMachines/

▶ java --version
openjdk 12.0.2 2019-07-16
OpenJDK Runtime Environment AdoptOpenJDK (build 12.0.2+10)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 12.0.2+10, mixed mode)

sbt installed via:

▶ brew install sbt
▶ sbt sbtVersion
[info]  1.3.10



md5-81688d6fdae4a4fb6cbfecc5b8fbee61



▶ sudo spctl --master-disable
▶ spctl --status
assessments disabled

# starting sbt will produce the same output (code signature in [...] not valid for use in process using Library Validation: mapped file has no cdhash)

▶ sudo spctl --master-enable
▶ spctl --status
assessments enabled



md5-046c5f6222d4ced024068ca879544f9b



▶ codesign -dv --verbose=4 ~/Library/Caches/JNA/temp/jna123.tmp
~/Library/Caches/JNA/temp/jna123.tmp: code object is not signed at all



md5-99fc43abd604e2213e80c0369e20444a



    <key>CFBundleSignature</key>
    <string>????</string>

This is apparently the default on initialisation of new xcode projects and has not been changed?!

@peter-gerhard There's no hardened runtime and notarization support on OpenJDK 12 and there won't be because it has reached its EOL.

Furthermore, I'm closing this issue because 11.0.7's PKG is fully notarized.

@aahlenst I found out the /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Info.plist does not have the bundle signature.

<key>CFBundleShortVersionString</key> <string>1.0</string> <key>CFBundleSignature</key> <string>????</string> <key>CFBundleVersion</key> <string>11.0.7</string>

Which version is currently code signed as I tried 11 and 12 version already

8u252.1, 11.0.7 and 14 are notarized. You need the PKG, however.

@aahlenst FYI this was not fixed in 11.0.7 nor in 11.0.8, but it is indeed fixed in 11.0.9

If anyone got to this thread due while trying to compile a KMM project, I was able to fix it by upgrading gradle version to 7.0.0-alpha09.

Was this page helpful?
0 / 5 - 0 ratings