748 * It has been superseded by JVM-specific tracing mechanisms.
749 * This method is subject to removal in a future version of Java SE.
750 *
751 * @param on ignored
752 */
753 @Deprecated(since="9", forRemoval=true)
754 public void traceMethodCalls(boolean on) { }
755
756 /**
757 * Loads the native library specified by the filename argument. The filename
758 * argument must be an absolute path name.
759 * (for example
760 * {@code Runtime.getRuntime().load("/home/avh/lib/libX11.so");}).
761 *
762 * If the filename argument, when stripped of any platform-specific library
763 * prefix, path, and file extension, indicates a library whose name is,
764 * for example, L, and a native library called L is statically linked
765 * with the VM, then the JNI_OnLoad_L function exported by the library
766 * is invoked rather than attempting to load a dynamic library.
767 * A filename matching the argument does not have to exist in the file
768 * system. See the JNI Specification for more details.
769 *
770 * Otherwise, the filename argument is mapped to a native library image in
771 * an implementation-dependent manner.
772 * <p>
773 * First, if there is a security manager, its {@code checkLink}
774 * method is called with the {@code filename} as its argument.
775 * This may result in a security exception.
776 * <p>
777 * This is similar to the method {@link #loadLibrary(String)}, but it
778 * accepts a general file name as an argument rather than just a library
779 * name, allowing any file of native code to be loaded.
780 * <p>
781 * The method {@link System#load(String)} is the conventional and
782 * convenient means of invoking this method.
783 *
784 * @param filename the file to load.
785 * @exception SecurityException if a security manager exists and its
786 * {@code checkLink} method doesn't allow
787 * loading of the specified dynamic library
788 * @exception UnsatisfiedLinkError if either the filename is not an
801 }
802
803 synchronized void load0(Class<?> fromClass, String filename) {
804 SecurityManager security = System.getSecurityManager();
805 if (security != null) {
806 security.checkLink(filename);
807 }
808 if (!(new File(filename).isAbsolute())) {
809 throw new UnsatisfiedLinkError(
810 "Expecting an absolute path of the library: " + filename);
811 }
812 ClassLoader.loadLibrary(fromClass, filename, true);
813 }
814
815 /**
816 * Loads the native library specified by the {@code libname}
817 * argument. The {@code libname} argument must not contain any platform
818 * specific prefix, file extension or path. If a native library
819 * called {@code libname} is statically linked with the VM, then the
820 * JNI_OnLoad_{@code libname} function exported by the library is invoked.
821 * See the JNI Specification for more details.
822 *
823 * Otherwise, the libname argument is loaded from a system library
824 * location and mapped to a native library image in an implementation-
825 * dependent manner.
826 * <p>
827 * First, if there is a security manager, its {@code checkLink}
828 * method is called with the {@code libname} as its argument.
829 * This may result in a security exception.
830 * <p>
831 * The method {@link System#loadLibrary(String)} is the conventional
832 * and convenient means of invoking this method. If native
833 * methods are to be used in the implementation of a class, a standard
834 * strategy is to put the native code in a library file (call it
835 * {@code LibFile}) and then to put a static initializer:
836 * <blockquote><pre>
837 * static { System.loadLibrary("LibFile"); }
838 * </pre></blockquote>
839 * within the class declaration. When the class is loaded and
840 * initialized, the necessary native code implementation for the native
841 * methods will then be loaded as well.
|
748 * It has been superseded by JVM-specific tracing mechanisms.
749 * This method is subject to removal in a future version of Java SE.
750 *
751 * @param on ignored
752 */
753 @Deprecated(since="9", forRemoval=true)
754 public void traceMethodCalls(boolean on) { }
755
756 /**
757 * Loads the native library specified by the filename argument. The filename
758 * argument must be an absolute path name.
759 * (for example
760 * {@code Runtime.getRuntime().load("/home/avh/lib/libX11.so");}).
761 *
762 * If the filename argument, when stripped of any platform-specific library
763 * prefix, path, and file extension, indicates a library whose name is,
764 * for example, L, and a native library called L is statically linked
765 * with the VM, then the JNI_OnLoad_L function exported by the library
766 * is invoked rather than attempting to load a dynamic library.
767 * A filename matching the argument does not have to exist in the file
768 * system.
769 * See the <a href="{@docRoot}/../specs/jni/index.html"> JNI Specification</a>
770 * for more details.
771 *
772 * Otherwise, the filename argument is mapped to a native library image in
773 * an implementation-dependent manner.
774 * <p>
775 * First, if there is a security manager, its {@code checkLink}
776 * method is called with the {@code filename} as its argument.
777 * This may result in a security exception.
778 * <p>
779 * This is similar to the method {@link #loadLibrary(String)}, but it
780 * accepts a general file name as an argument rather than just a library
781 * name, allowing any file of native code to be loaded.
782 * <p>
783 * The method {@link System#load(String)} is the conventional and
784 * convenient means of invoking this method.
785 *
786 * @param filename the file to load.
787 * @exception SecurityException if a security manager exists and its
788 * {@code checkLink} method doesn't allow
789 * loading of the specified dynamic library
790 * @exception UnsatisfiedLinkError if either the filename is not an
803 }
804
805 synchronized void load0(Class<?> fromClass, String filename) {
806 SecurityManager security = System.getSecurityManager();
807 if (security != null) {
808 security.checkLink(filename);
809 }
810 if (!(new File(filename).isAbsolute())) {
811 throw new UnsatisfiedLinkError(
812 "Expecting an absolute path of the library: " + filename);
813 }
814 ClassLoader.loadLibrary(fromClass, filename, true);
815 }
816
817 /**
818 * Loads the native library specified by the {@code libname}
819 * argument. The {@code libname} argument must not contain any platform
820 * specific prefix, file extension or path. If a native library
821 * called {@code libname} is statically linked with the VM, then the
822 * JNI_OnLoad_{@code libname} function exported by the library is invoked.
823 * See the <a href="{@docRoot}/../specs/jni/index.html"> JNI Specification</a>
824 * for more details.
825 *
826 * Otherwise, the libname argument is loaded from a system library
827 * location and mapped to a native library image in an implementation-
828 * dependent manner.
829 * <p>
830 * First, if there is a security manager, its {@code checkLink}
831 * method is called with the {@code libname} as its argument.
832 * This may result in a security exception.
833 * <p>
834 * The method {@link System#loadLibrary(String)} is the conventional
835 * and convenient means of invoking this method. If native
836 * methods are to be used in the implementation of a class, a standard
837 * strategy is to put the native code in a library file (call it
838 * {@code LibFile}) and then to put a static initializer:
839 * <blockquote><pre>
840 * static { System.loadLibrary("LibFile"); }
841 * </pre></blockquote>
842 * within the class declaration. When the class is loaded and
843 * initialized, the necessary native code implementation for the native
844 * methods will then be loaded as well.
|