107 * <code>checkLink</code> method doesn't allow
108 * loading of the specified dynamic library
109 * @exception UnsatisfiedLinkError if either the filename is not an
110 * absolute path name, the native library is not statically
111 * linked with the VM, or the library cannot be mapped to
112 * a native library image by the host system.
113 * @exception NullPointerException if <code>filename</code> is
114 * <code>null</code>
115 * @see java.lang.SecurityManager#checkLink(java.lang.String)
116 */
117 public static Library load(Lookup lookup, String filename) {
118 Objects.requireNonNull(filename);
119 SecurityManager security = System.getSecurityManager();
120 if (security != null) {
121 security.checkLink(filename);
122 }
123 if (!(new File(filename).isAbsolute())) {
124 throw new UnsatisfiedLinkError(
125 "Expecting an absolute path of the library: " + filename);
126 }
127 return LibrariesHelper.loadLibrary(checkLookup(lookup), filename);
128 }
129
130 public static Library getDefaultLibrary() {
131 SecurityManager security = System.getSecurityManager();
132 if (security != null) {
133 security.checkPermission(new RuntimePermission("java.nicl.getDefaultLibrary"));
134 }
135 return LibrariesHelper.getDefaultLibrary();
136 }
137
138 private static Lookup checkLookup(Lookup lookup) {
139 if (!Objects.requireNonNull(lookup).hasPrivateAccess()) {
140 throw new IllegalArgumentException("Attempt to use non-private lookup object");
141 }
142 return lookup;
143 }
144 }
|
107 * <code>checkLink</code> method doesn't allow
108 * loading of the specified dynamic library
109 * @exception UnsatisfiedLinkError if either the filename is not an
110 * absolute path name, the native library is not statically
111 * linked with the VM, or the library cannot be mapped to
112 * a native library image by the host system.
113 * @exception NullPointerException if <code>filename</code> is
114 * <code>null</code>
115 * @see java.lang.SecurityManager#checkLink(java.lang.String)
116 */
117 public static Library load(Lookup lookup, String filename) {
118 Objects.requireNonNull(filename);
119 SecurityManager security = System.getSecurityManager();
120 if (security != null) {
121 security.checkLink(filename);
122 }
123 if (!(new File(filename).isAbsolute())) {
124 throw new UnsatisfiedLinkError(
125 "Expecting an absolute path of the library: " + filename);
126 }
127 return LibrariesHelper.load(checkLookup(lookup), filename);
128 }
129
130 public static Library getDefaultLibrary() {
131 SecurityManager security = System.getSecurityManager();
132 if (security != null) {
133 security.checkPermission(new RuntimePermission("java.nicl.getDefaultLibrary"));
134 }
135 return LibrariesHelper.getDefaultLibrary();
136 }
137
138 private static Lookup checkLookup(Lookup lookup) {
139 if (!Objects.requireNonNull(lookup).hasPrivateAccess()) {
140 throw new IllegalArgumentException("Attempt to use non-private lookup object");
141 }
142 return lookup;
143 }
144 }
|