6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test
26 * @enablePreview
27 * @requires jdk.foreign.linker != "UNSUPPORTED"
28 * @compile lookup/Lookup.java
29 * @compile invoker/Invoker.java
30 * @run main/othervm --enable-native-access=ALL-UNNAMED TestLoaderLookup
31 */
32
33 import java.lang.foreign.*;
34 import java.lang.reflect.*;
35 import java.net.MalformedURLException;
36 import java.net.URL;
37 import java.net.URLClassLoader;
38 import java.nio.file.Paths;
39
40 public class TestLoaderLookup {
41 public static void main(String[] args) throws ReflectiveOperationException {
42 ClassLoader loader1 = newClassLoader("lookup");
43 Class<?> lookup = loader1.loadClass("lookup.Lookup");
44 Method fooSymbol = lookup.getDeclaredMethod("fooSymbol");
45 MemorySegment foo = (MemorySegment) fooSymbol.invoke(null);
46
47 ClassLoader loader2 = newClassLoader("invoker");
|
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test
26 * @compile lookup/Lookup.java
27 * @compile invoker/Invoker.java
28 * @run main/othervm --enable-native-access=ALL-UNNAMED TestLoaderLookup
29 */
30
31 import java.lang.foreign.*;
32 import java.lang.reflect.*;
33 import java.net.MalformedURLException;
34 import java.net.URL;
35 import java.net.URLClassLoader;
36 import java.nio.file.Paths;
37
38 public class TestLoaderLookup {
39 public static void main(String[] args) throws ReflectiveOperationException {
40 ClassLoader loader1 = newClassLoader("lookup");
41 Class<?> lookup = loader1.loadClass("lookup.Lookup");
42 Method fooSymbol = lookup.getDeclaredMethod("fooSymbol");
43 MemorySegment foo = (MemorySegment) fooSymbol.invoke(null);
44
45 ClassLoader loader2 = newClassLoader("invoker");
|