Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8213362

[macOS] Could not find libjava.dylib error when initializing JVM via JNI_CreateJavaVM

    Details

    • Subcomponent:
    • Introduced In Build:
      b13
    • Introduced In Version:
      12
    • Resolved In Build:
      b23
    • CPU:
      x86_64
    • OS:
      os_x
    • Verification:
      Verified

      Description

      ADDITIONAL SYSTEM INFORMATION :
      OS: MacOS Sierra 10.12.6 (16G1618)
      -------------------------
      Java:
      openjdk version "12-ea" 2019-03-19
      OpenJDK Runtime Environment (build 12-ea+17)
      OpenJDK 64-Bit Server VM (build 12-ea+17, mixed mode, sharing)

      A DESCRIPTION OF THE PROBLEM :
      With the https://bugs.openjdk.java.net/browse/JDK-8210931 libjli has moved from "jli" subdirectory into standard lib directory.
      However `GetJREPath` method in `src/java.base/macosx/native/libjli/java_md_macosx.m` still assumes that `libjli.dylib` should be on `lib/jli/libjli.dylib` path.

      The fix is simplly to remove `/jli` from the lastPathComponent like patch below shows:
      --- a/src/java.base/macosx/native/libjli/java_md_macosx.m Fri Nov 02 19:38:54 2018 +0100
      +++ b/src/java.base/macosx/native/libjli/java_md_macosx.m Sun Nov 04 16:36:19 2018 +0100
      @@ -508,7 +508,7 @@
               return JNI_FALSE;
           }
       
      - const char lastPathComponent[] = "/lib/jli/libjli.dylib";
      + const char lastPathComponent[] = "/lib/libjli.dylib";
           size_t sizeOfLastPathComponent = sizeof(lastPathComponent) - 1;
           if (pathLen < sizeOfLastPathComponent) {
               return JNI_FALSE;


      REGRESSION : Last worked in version 11.0.1

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run application which uses `JNI_CreateJavaVM` to create a JVM (like Eclipse 4.9/4.10 does).
      Download Eclipse application, run Eclipse with `-vm` parameter pointing to the openJDK 12 build as shown below:
      $ ~/Workspace/test/Eclipse.app/Contents/MacOS/eclipse -vm ~/Workspace/test/jdk-12.jdk/Contents/Home/bin/java

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Eclipse application starts.

      ACTUAL -
      Eclipse fails to start with "Failed to create the Java Virtual Machine." error dialog. In console "Failed to GetJREPath()" is printed:
      $ ~/Workspace/test/Eclipse.app/Contents/MacOS/eclipse -vm ~/Workspace/test/jdk-12.jdk/Contents/Home/bin/java
      CONSOLE OUT:
      Error: could not find libjava.dylib
      Failed to GetJREPath()


      FREQUENCY : always


        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                henryjen Henry Jen
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: