src/share/classes/java/lang/Runtime.java
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
@@ -747,14 +747,27 @@
* <code>false</code> to disable this feature.
*/
public native void traceMethodCalls(boolean on);
/**
- * Loads the specified filename as a dynamic library. The filename
- * argument must be a complete path name,
+ * Loads the native library specified by the filename argument. The filename
+ * argument must be an absolute path name.
* (for example
* <code>Runtime.getRuntime().load("/home/avh/lib/libX11.so");</code>).
+ *
+ * If the filename argument, when stripped of any platform-specific library
+ * prefix, path, and file extension, indicates a library whose name is,
+ * for example, L, and a native library called L is statically linked
+ * with the native application or the VM (which itself may be statically
+ * linked into the native application), then the JNI_OnLoad_L
+ * function exported by the library is invoked rather than attempting
+ * to load a dynamic library.
+ * A filename matching the argument does not have to exist in the file
+ * system. See the JNI Specification for more details.
+ *
+ * Otherwise, the filename argument is mapped to a native library image in
+ * an implementation-dependent manner.
* <p>
* First, if there is a security manager, its <code>checkLink</code>
* method is called with the <code>filename</code> as its argument.
* This may result in a security exception.
* <p>
@@ -767,11 +780,14 @@
*
* @param filename the file to load.
* @exception SecurityException if a security manager exists and its
* <code>checkLink</code> method doesn't allow
* loading of the specified dynamic library
- * @exception UnsatisfiedLinkError if the file does not exist.
+ * @exception UnsatisfiedLinkError if either the filename is not an
+ * absolute path name, the native library is not statically
+ * linked with the VM, or the library cannot be mapped to
+ * a native library image by the host system.
* @exception NullPointerException if <code>filename</code> is
* <code>null</code>
* @see java.lang.Runtime#getRuntime()
* @see java.lang.SecurityException
* @see java.lang.SecurityManager#checkLink(java.lang.String)
@@ -791,16 +807,20 @@
}
ClassLoader.loadLibrary(fromClass, filename, true);
}
/**
- * Loads the dynamic library with the specified library name.
- * A file containing native code is loaded from the local file system
- * from a place where library files are conventionally obtained. The
- * details of this process are implementation-dependent. The
- * mapping from a library name to a specific filename is done in a
- * system-specific manner.
+ * Loads the native library specified by the <code>libname</code>
+ * argument. The <code>libname</code> argument must not contain any platform
+ * specific prefix, file extension or path. If a native library
+ * called <code>libname</code> is statically linked with the VM, then the
+ * JNI_OnLoad_<code>libname</code> function exported by the library is invoked.
+ * See the JNI Specification for more details.
+ *
+ * Otherwise, the libname argument is loaded from a system library
+ * location and mapped to a native library image in an implementation-
+ * dependent manner.
* <p>
* First, if there is a security manager, its <code>checkLink</code>
* method is called with the <code>libname</code> as its argument.
* This may result in a security exception.
* <p>
@@ -821,11 +841,14 @@
*
* @param libname the name of the library.
* @exception SecurityException if a security manager exists and its
* <code>checkLink</code> method doesn't allow
* loading of the specified dynamic library
- * @exception UnsatisfiedLinkError if the library does not exist.
+ * @exception UnsatisfiedLinkError if either the libname argument
+ * contains a file path, the native library is not statically
+ * linked with the VM, or the library cannot be mapped to a
+ * native library image by the host system.
* @exception NullPointerException if <code>libname</code> is
* <code>null</code>
* @see java.lang.SecurityException
* @see java.lang.SecurityManager#checkLink(java.lang.String)
*/