117 throw new IllegalArgumentException("No @NativeHeader annotation on class " + c);
118 }
119
120 // Thread local is used to pass additional argument to the header
121 // implementation generator's computeValue method.
122 try {
123 curSymLookup.set(lookup);
124 return (Class<? extends T>)HEADER_IMPLEMENTATIONS.get(c);
125 } finally {
126 curSymLookup.remove();
127 }
128 }
129
130 /**
131 * Load the specified shared library.
132 *
133 * @param lookup Lookup object of the caller.
134 * @param name Name of the shared library to load.
135 */
136 public static Library loadLibrary(Lookup lookup, String name) {
137 return jlAccess.findLibrary(lookup, name);
138 }
139
140 // return the absolute path of the library of given name by searching
141 // in the given array of paths.
142 private static Optional<Path> findLibraryPath(Path[] paths, String libName) {
143 return Arrays.stream(paths).
144 map(p -> p.resolve(System.mapLibraryName(libName))).
145 filter(Files::isRegularFile).map(Path::toAbsolutePath).findFirst();
146 }
147
148 /**
149 * Load the specified shared libraries from the specified paths.
150 *
151 * @param lookup Lookup object of the caller.
152 * @param pathStrs array of paths to load the shared libraries from.
153 * @param names array of shared library names.
154 */
155 // used by jextract tool to load libraries for symbol checks.
156 public static Library[] loadLibraries(Lookup lookup, String[] pathStrs, String[] names) {
157 if (pathStrs == null || pathStrs.length == 0) {
|
117 throw new IllegalArgumentException("No @NativeHeader annotation on class " + c);
118 }
119
120 // Thread local is used to pass additional argument to the header
121 // implementation generator's computeValue method.
122 try {
123 curSymLookup.set(lookup);
124 return (Class<? extends T>)HEADER_IMPLEMENTATIONS.get(c);
125 } finally {
126 curSymLookup.remove();
127 }
128 }
129
130 /**
131 * Load the specified shared library.
132 *
133 * @param lookup Lookup object of the caller.
134 * @param name Name of the shared library to load.
135 */
136 public static Library loadLibrary(Lookup lookup, String name) {
137 return jlAccess.loadLibrary(lookup, name);
138 }
139
140 /**
141 * Load the specified shared library.
142 *
143 * @param lookup Lookup object of the caller.
144 * @param path Path of the shared library to load.
145 */
146 public static Library load(Lookup lookup, String path) {
147 return jlAccess.load(lookup, path);
148 }
149
150 // return the absolute path of the library of given name by searching
151 // in the given array of paths.
152 private static Optional<Path> findLibraryPath(Path[] paths, String libName) {
153 return Arrays.stream(paths).
154 map(p -> p.resolve(System.mapLibraryName(libName))).
155 filter(Files::isRegularFile).map(Path::toAbsolutePath).findFirst();
156 }
157
158 /**
159 * Load the specified shared libraries from the specified paths.
160 *
161 * @param lookup Lookup object of the caller.
162 * @param pathStrs array of paths to load the shared libraries from.
163 * @param names array of shared library names.
164 */
165 // used by jextract tool to load libraries for symbol checks.
166 public static Library[] loadLibraries(Lookup lookup, String[] pathStrs, String[] names) {
167 if (pathStrs == null || pathStrs.length == 0) {
|