author | jcbeyler |
Thu, 14 Mar 2019 09:35:45 -0700 | |
changeset 54128 | c0fccca69aff |
parent 53273 | bbc79e0ec9ee |
permissions | -rw-r--r-- |
52788
241b8151b6b6
8213362: [macOS] Could not find libjava.dylib error when initializing JVM via JNI_CreateJavaVM
henryjen
parents:
diff
changeset
|
1 |
/* |
53273
bbc79e0ec9ee
8216265: [testbug] Introduce Platform.sharedLibraryPathVariableName() and adapt all tests.
goetz
parents:
52788
diff
changeset
|
2 |
* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. |
52788
241b8151b6b6
8213362: [macOS] Could not find libjava.dylib error when initializing JVM via JNI_CreateJavaVM
henryjen
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
241b8151b6b6
8213362: [macOS] Could not find libjava.dylib error when initializing JVM via JNI_CreateJavaVM
henryjen
parents:
diff
changeset
|
4 |
* |
241b8151b6b6
8213362: [macOS] Could not find libjava.dylib error when initializing JVM via JNI_CreateJavaVM
henryjen
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
241b8151b6b6
8213362: [macOS] Could not find libjava.dylib error when initializing JVM via JNI_CreateJavaVM
henryjen
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
241b8151b6b6
8213362: [macOS] Could not find libjava.dylib error when initializing JVM via JNI_CreateJavaVM
henryjen
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
241b8151b6b6
8213362: [macOS] Could not find libjava.dylib error when initializing JVM via JNI_CreateJavaVM
henryjen
parents:
diff
changeset
|
8 |
* |
241b8151b6b6
8213362: [macOS] Could not find libjava.dylib error when initializing JVM via JNI_CreateJavaVM
henryjen
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
241b8151b6b6
8213362: [macOS] Could not find libjava.dylib error when initializing JVM via JNI_CreateJavaVM
henryjen
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
241b8151b6b6
8213362: [macOS] Could not find libjava.dylib error when initializing JVM via JNI_CreateJavaVM
henryjen
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
241b8151b6b6
8213362: [macOS] Could not find libjava.dylib error when initializing JVM via JNI_CreateJavaVM
henryjen
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
241b8151b6b6
8213362: [macOS] Could not find libjava.dylib error when initializing JVM via JNI_CreateJavaVM
henryjen
parents:
diff
changeset
|
13 |
* accompanied this code). |
241b8151b6b6
8213362: [macOS] Could not find libjava.dylib error when initializing JVM via JNI_CreateJavaVM
henryjen
parents:
diff
changeset
|
14 |
* |
241b8151b6b6
8213362: [macOS] Could not find libjava.dylib error when initializing JVM via JNI_CreateJavaVM
henryjen
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
241b8151b6b6
8213362: [macOS] Could not find libjava.dylib error when initializing JVM via JNI_CreateJavaVM
henryjen
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
241b8151b6b6
8213362: [macOS] Could not find libjava.dylib error when initializing JVM via JNI_CreateJavaVM
henryjen
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
241b8151b6b6
8213362: [macOS] Could not find libjava.dylib error when initializing JVM via JNI_CreateJavaVM
henryjen
parents:
diff
changeset
|
18 |
* |
241b8151b6b6
8213362: [macOS] Could not find libjava.dylib error when initializing JVM via JNI_CreateJavaVM
henryjen
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
241b8151b6b6
8213362: [macOS] Could not find libjava.dylib error when initializing JVM via JNI_CreateJavaVM
henryjen
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
241b8151b6b6
8213362: [macOS] Could not find libjava.dylib error when initializing JVM via JNI_CreateJavaVM
henryjen
parents:
diff
changeset
|
21 |
* questions. |
241b8151b6b6
8213362: [macOS] Could not find libjava.dylib error when initializing JVM via JNI_CreateJavaVM
henryjen
parents:
diff
changeset
|
22 |
* |
241b8151b6b6
8213362: [macOS] Could not find libjava.dylib error when initializing JVM via JNI_CreateJavaVM
henryjen
parents:
diff
changeset
|
23 |
*/ |
241b8151b6b6
8213362: [macOS] Could not find libjava.dylib error when initializing JVM via JNI_CreateJavaVM
henryjen
parents:
diff
changeset
|
24 |
|
241b8151b6b6
8213362: [macOS] Could not find libjava.dylib error when initializing JVM via JNI_CreateJavaVM
henryjen
parents:
diff
changeset
|
25 |
/** |
241b8151b6b6
8213362: [macOS] Could not find libjava.dylib error when initializing JVM via JNI_CreateJavaVM
henryjen
parents:
diff
changeset
|
26 |
* @test |
241b8151b6b6
8213362: [macOS] Could not find libjava.dylib error when initializing JVM via JNI_CreateJavaVM
henryjen
parents:
diff
changeset
|
27 |
* @bug 8213362 |
241b8151b6b6
8213362: [macOS] Could not find libjava.dylib error when initializing JVM via JNI_CreateJavaVM
henryjen
parents:
diff
changeset
|
28 |
* @comment Test uses custom launcher that starts VM using JNI via libjli, only for MacOS |
241b8151b6b6
8213362: [macOS] Could not find libjava.dylib error when initializing JVM via JNI_CreateJavaVM
henryjen
parents:
diff
changeset
|
29 |
* @requires os.family == "mac" |
241b8151b6b6
8213362: [macOS] Could not find libjava.dylib error when initializing JVM via JNI_CreateJavaVM
henryjen
parents:
diff
changeset
|
30 |
* @library /test/lib |
241b8151b6b6
8213362: [macOS] Could not find libjava.dylib error when initializing JVM via JNI_CreateJavaVM
henryjen
parents:
diff
changeset
|
31 |
* @run main/native JniInvocationTest |
241b8151b6b6
8213362: [macOS] Could not find libjava.dylib error when initializing JVM via JNI_CreateJavaVM
henryjen
parents:
diff
changeset
|
32 |
*/ |
241b8151b6b6
8213362: [macOS] Could not find libjava.dylib error when initializing JVM via JNI_CreateJavaVM
henryjen
parents:
diff
changeset
|
33 |
|
241b8151b6b6
8213362: [macOS] Could not find libjava.dylib error when initializing JVM via JNI_CreateJavaVM
henryjen
parents:
diff
changeset
|
34 |
import java.util.Map; |
53273
bbc79e0ec9ee
8216265: [testbug] Introduce Platform.sharedLibraryPathVariableName() and adapt all tests.
goetz
parents:
52788
diff
changeset
|
35 |
import jdk.test.lib.Platform; |
52788
241b8151b6b6
8213362: [macOS] Could not find libjava.dylib error when initializing JVM via JNI_CreateJavaVM
henryjen
parents:
diff
changeset
|
36 |
import jdk.test.lib.Utils; |
241b8151b6b6
8213362: [macOS] Could not find libjava.dylib error when initializing JVM via JNI_CreateJavaVM
henryjen
parents:
diff
changeset
|
37 |
import jdk.test.lib.process.OutputAnalyzer; |
241b8151b6b6
8213362: [macOS] Could not find libjava.dylib error when initializing JVM via JNI_CreateJavaVM
henryjen
parents:
diff
changeset
|
38 |
|
241b8151b6b6
8213362: [macOS] Could not find libjava.dylib error when initializing JVM via JNI_CreateJavaVM
henryjen
parents:
diff
changeset
|
39 |
import java.io.IOException; |
241b8151b6b6
8213362: [macOS] Could not find libjava.dylib error when initializing JVM via JNI_CreateJavaVM
henryjen
parents:
diff
changeset
|
40 |
import java.nio.file.Files; |
241b8151b6b6
8213362: [macOS] Could not find libjava.dylib error when initializing JVM via JNI_CreateJavaVM
henryjen
parents:
diff
changeset
|
41 |
import java.nio.file.Path; |
241b8151b6b6
8213362: [macOS] Could not find libjava.dylib error when initializing JVM via JNI_CreateJavaVM
henryjen
parents:
diff
changeset
|
42 |
import java.nio.file.Paths; |
241b8151b6b6
8213362: [macOS] Could not find libjava.dylib error when initializing JVM via JNI_CreateJavaVM
henryjen
parents:
diff
changeset
|
43 |
|
241b8151b6b6
8213362: [macOS] Could not find libjava.dylib error when initializing JVM via JNI_CreateJavaVM
henryjen
parents:
diff
changeset
|
44 |
public class JniInvocationTest { |
241b8151b6b6
8213362: [macOS] Could not find libjava.dylib error when initializing JVM via JNI_CreateJavaVM
henryjen
parents:
diff
changeset
|
45 |
public static void main(String[] args) throws IOException { |
241b8151b6b6
8213362: [macOS] Could not find libjava.dylib error when initializing JVM via JNI_CreateJavaVM
henryjen
parents:
diff
changeset
|
46 |
Path launcher = Paths.get(System.getProperty("test.nativepath"), "JniInvocationTest"); |
241b8151b6b6
8213362: [macOS] Could not find libjava.dylib error when initializing JVM via JNI_CreateJavaVM
henryjen
parents:
diff
changeset
|
47 |
System.out.println("Launcher = " + launcher + (Files.exists(launcher) ? " (exists)" : " (not exists)")); |
241b8151b6b6
8213362: [macOS] Could not find libjava.dylib error when initializing JVM via JNI_CreateJavaVM
henryjen
parents:
diff
changeset
|
48 |
ProcessBuilder pb = new ProcessBuilder(launcher.toString()); |
241b8151b6b6
8213362: [macOS] Could not find libjava.dylib error when initializing JVM via JNI_CreateJavaVM
henryjen
parents:
diff
changeset
|
49 |
Map<String, String> env = pb.environment(); |
241b8151b6b6
8213362: [macOS] Could not find libjava.dylib error when initializing JVM via JNI_CreateJavaVM
henryjen
parents:
diff
changeset
|
50 |
String libdir = Paths.get(Utils.TEST_JDK).resolve("lib").toAbsolutePath().toString(); |
53273
bbc79e0ec9ee
8216265: [testbug] Introduce Platform.sharedLibraryPathVariableName() and adapt all tests.
goetz
parents:
52788
diff
changeset
|
51 |
env.compute(Platform.sharedLibraryPathVariableName(), (k, v) -> (k == null) ? libdir : v + ":" + libdir); |
52788
241b8151b6b6
8213362: [macOS] Could not find libjava.dylib error when initializing JVM via JNI_CreateJavaVM
henryjen
parents:
diff
changeset
|
52 |
OutputAnalyzer outputf = new OutputAnalyzer(pb.start()); |
241b8151b6b6
8213362: [macOS] Could not find libjava.dylib error when initializing JVM via JNI_CreateJavaVM
henryjen
parents:
diff
changeset
|
53 |
outputf.shouldHaveExitValue(0); |
241b8151b6b6
8213362: [macOS] Could not find libjava.dylib error when initializing JVM via JNI_CreateJavaVM
henryjen
parents:
diff
changeset
|
54 |
} |
241b8151b6b6
8213362: [macOS] Could not find libjava.dylib error when initializing JVM via JNI_CreateJavaVM
henryjen
parents:
diff
changeset
|
55 |
} |
241b8151b6b6
8213362: [macOS] Could not find libjava.dylib error when initializing JVM via JNI_CreateJavaVM
henryjen
parents:
diff
changeset
|
56 |