equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved. |
|
3 * Copyright (c) 2019, Azul Systems, Inc. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
5 * |
5 * This code is free software; you can redistribute it and/or modify it |
6 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
8 * published by the Free Software Foundation. Oracle designates this |
2002 scl = builtinLoader; |
2003 scl = builtinLoader; |
2003 } |
2004 } |
2004 return scl; |
2005 return scl; |
2005 } |
2006 } |
2006 |
2007 |
|
2008 /* |
|
2009 * Initialize default paths for native libraries search. |
|
2010 * Must be done early as JDK may load libraries during bootstrap. |
|
2011 * |
|
2012 * @see java.lang.System#initPhase1 |
|
2013 */ |
|
2014 static void initLibraryPaths() { |
|
2015 usr_paths = initializePath("java.library.path"); |
|
2016 sys_paths = initializePath("sun.boot.library.path"); |
|
2017 } |
|
2018 |
2007 // Returns true if the specified class loader can be found in this class |
2019 // Returns true if the specified class loader can be found in this class |
2008 // loader's delegation chain. |
2020 // loader's delegation chain. |
2009 boolean isAncestor(ClassLoader cl) { |
2021 boolean isAncestor(ClassLoader cl) { |
2010 ClassLoader acl = this; |
2022 ClassLoader acl = this; |
2011 do { |
2023 do { |
2471 * When a library is being loaded, JNI_OnLoad function can cause |
2483 * When a library is being loaded, JNI_OnLoad function can cause |
2472 * another loadLibrary invocation that should succeed. |
2484 * another loadLibrary invocation that should succeed. |
2473 * |
2485 * |
2474 * We use a static stack to hold the list of libraries we are |
2486 * We use a static stack to hold the list of libraries we are |
2475 * loading because this can happen only when called by the |
2487 * loading because this can happen only when called by the |
2476 * same thread because Runtime.load and Runtime.loadLibrary |
2488 * same thread because this block is synchronous. |
2477 * are synchronous. |
|
2478 * |
2489 * |
2479 * If there is a pending load operation for the library, we |
2490 * If there is a pending load operation for the library, we |
2480 * immediately return success; otherwise, we raise |
2491 * immediately return success; otherwise, we raise |
2481 * UnsatisfiedLinkError. |
2492 * UnsatisfiedLinkError. |
2482 */ |
2493 */ |
2617 // Invoked in the java.lang.Runtime class to implement load and loadLibrary. |
2628 // Invoked in the java.lang.Runtime class to implement load and loadLibrary. |
2618 static void loadLibrary(Class<?> fromClass, String name, |
2629 static void loadLibrary(Class<?> fromClass, String name, |
2619 boolean isAbsolute) { |
2630 boolean isAbsolute) { |
2620 ClassLoader loader = |
2631 ClassLoader loader = |
2621 (fromClass == null) ? null : fromClass.getClassLoader(); |
2632 (fromClass == null) ? null : fromClass.getClassLoader(); |
2622 if (sys_paths == null) { |
2633 assert sys_paths != null : "should be initialized at this point"; |
2623 usr_paths = initializePath("java.library.path"); |
2634 assert usr_paths != null : "should be initialized at this point"; |
2624 sys_paths = initializePath("sun.boot.library.path"); |
2635 |
2625 } |
|
2626 if (isAbsolute) { |
2636 if (isAbsolute) { |
2627 if (loadLibrary0(fromClass, new File(name))) { |
2637 if (loadLibrary0(fromClass, new File(name))) { |
2628 return; |
2638 return; |
2629 } |
2639 } |
2630 throw new UnsatisfiedLinkError("Can't load library: " + name); |
2640 throw new UnsatisfiedLinkError("Can't load library: " + name); |