From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository. --- libjava/testsuite/libjava.jni/PR15133.c | 9 + libjava/testsuite/libjava.jni/PR15133.h | 19 + libjava/testsuite/libjava.jni/PR15133.jar | Bin 0 -> 674 bytes libjava/testsuite/libjava.jni/PR15133.java | 14 + libjava/testsuite/libjava.jni/PR15133.out | 1 + libjava/testsuite/libjava.jni/PR18116.c | 35 ++ libjava/testsuite/libjava.jni/PR18116.h | 19 + libjava/testsuite/libjava.jni/PR18116.jar | Bin 0 -> 740 bytes libjava/testsuite/libjava.jni/PR18116.java | 16 + libjava/testsuite/libjava.jni/PR18116.out | 1 + libjava/testsuite/libjava.jni/PR28178.c | 10 + libjava/testsuite/libjava.jni/PR28178.h | 19 + libjava/testsuite/libjava.jni/PR28178.jar | Bin 0 -> 662 bytes libjava/testsuite/libjava.jni/PR28178.java | 15 + libjava/testsuite/libjava.jni/PR28178.out | 0 libjava/testsuite/libjava.jni/bytebuffer.c | 62 ++++ libjava/testsuite/libjava.jni/bytebuffer.h | 25 ++ libjava/testsuite/libjava.jni/bytebuffer.jar | Bin 0 -> 1150 bytes libjava/testsuite/libjava.jni/bytebuffer.java | 38 ++ libjava/testsuite/libjava.jni/bytebuffer.out | 26 ++ libjava/testsuite/libjava.jni/calls.c | 75 ++++ libjava/testsuite/libjava.jni/calls.h | 19 + libjava/testsuite/libjava.jni/calls.jar | Bin 0 -> 1283 bytes libjava/testsuite/libjava.jni/calls.java | 72 ++++ libjava/testsuite/libjava.jni/calls.out | 1 + libjava/testsuite/libjava.jni/cxxtest.cc | 24 ++ libjava/testsuite/libjava.jni/cxxtest.h | 19 + libjava/testsuite/libjava.jni/cxxtest.jar | Bin 0 -> 818 bytes libjava/testsuite/libjava.jni/cxxtest.java | 25 ++ libjava/testsuite/libjava.jni/cxxtest.out | 1 + libjava/testsuite/libjava.jni/directbuffer.c | 75 ++++ libjava/testsuite/libjava.jni/directbuffer.h | 26 ++ libjava/testsuite/libjava.jni/directbuffer.jar | Bin 0 -> 1067 bytes libjava/testsuite/libjava.jni/directbuffer.java | 40 ++ libjava/testsuite/libjava.jni/directbuffer.out | 14 + libjava/testsuite/libjava.jni/field.c | 24 ++ libjava/testsuite/libjava.jni/field.h | 19 + libjava/testsuite/libjava.jni/field.jar | Bin 0 -> 810 bytes libjava/testsuite/libjava.jni/field.java | 25 ++ libjava/testsuite/libjava.jni/field.out | 1 + libjava/testsuite/libjava.jni/final_method.c | 7 + libjava/testsuite/libjava.jni/final_method.h | 19 + libjava/testsuite/libjava.jni/final_method.jar | Bin 0 -> 751 bytes libjava/testsuite/libjava.jni/final_method.java | 17 + libjava/testsuite/libjava.jni/final_method.out | 1 + libjava/testsuite/libjava.jni/findclass.c | 12 + libjava/testsuite/libjava.jni/findclass.h | 19 + libjava/testsuite/libjava.jni/findclass.jar | Bin 0 -> 809 bytes libjava/testsuite/libjava.jni/findclass.java | 16 + libjava/testsuite/libjava.jni/findclass.out | 1 + libjava/testsuite/libjava.jni/findclass2.c | 9 + libjava/testsuite/libjava.jni/findclass2.h | 19 + libjava/testsuite/libjava.jni/findclass2.jar | Bin 0 -> 1073 bytes libjava/testsuite/libjava.jni/findclass2.java | 24 ++ libjava/testsuite/libjava.jni/findclass2.out | 1 + libjava/testsuite/libjava.jni/iface.c | 40 ++ libjava/testsuite/libjava.jni/iface.h | 19 + libjava/testsuite/libjava.jni/iface.jar | Bin 0 -> 991 bytes libjava/testsuite/libjava.jni/iface.java | 27 ++ libjava/testsuite/libjava.jni/iface.out | 2 + libjava/testsuite/libjava.jni/init$NativeClass.h | 19 + libjava/testsuite/libjava.jni/init.c | 8 + libjava/testsuite/libjava.jni/init.h | 18 + libjava/testsuite/libjava.jni/init.jar | Bin 0 -> 1294 bytes libjava/testsuite/libjava.jni/init.java | 26 ++ libjava/testsuite/libjava.jni/init.out | 3 + libjava/testsuite/libjava.jni/invocation/PR16923.c | 43 +++ .../testsuite/libjava.jni/invocation/PR16923.jar | Bin 0 -> 673 bytes .../testsuite/libjava.jni/invocation/PR16923.java | 7 + .../testsuite/libjava.jni/invocation/PR16923.out | 1 + libjava/testsuite/libjava.jni/invoke.c | 7 + libjava/testsuite/libjava.jni/invoke.h | 19 + libjava/testsuite/libjava.jni/invoke.jar | Bin 0 -> 762 bytes libjava/testsuite/libjava.jni/invoke.java | 18 + libjava/testsuite/libjava.jni/invoke.out | 3 + libjava/testsuite/libjava.jni/jni.exp | 404 +++++++++++++++++++++ libjava/testsuite/libjava.jni/jniutf.c | 10 + libjava/testsuite/libjava.jni/jniutf.h | 19 + libjava/testsuite/libjava.jni/jniutf.jar | Bin 0 -> 788 bytes libjava/testsuite/libjava.jni/jniutf.java | 16 + libjava/testsuite/libjava.jni/jniutf.out | 0 libjava/testsuite/libjava.jni/martin.c | 43 +++ libjava/testsuite/libjava.jni/martin.h | 19 + libjava/testsuite/libjava.jni/martin.jar | Bin 0 -> 934 bytes libjava/testsuite/libjava.jni/martin.java | 21 ++ libjava/testsuite/libjava.jni/martin.out | 4 + libjava/testsuite/libjava.jni/noclass.c | 9 + libjava/testsuite/libjava.jni/noclass.h | 19 + libjava/testsuite/libjava.jni/noclass.jar | Bin 0 -> 755 bytes libjava/testsuite/libjava.jni/noclass.java | 25 ++ libjava/testsuite/libjava.jni/noclass.out | 1 + libjava/testsuite/libjava.jni/overload.c | 16 + libjava/testsuite/libjava.jni/overload.h | 20 + libjava/testsuite/libjava.jni/overload.jar | Bin 0 -> 749 bytes libjava/testsuite/libjava.jni/overload.java | 18 + libjava/testsuite/libjava.jni/overload.out | 2 + libjava/testsuite/libjava.jni/pr11951.c | 16 + libjava/testsuite/libjava.jni/pr11951.h | 19 + libjava/testsuite/libjava.jni/pr11951.jar | Bin 0 -> 715 bytes libjava/testsuite/libjava.jni/pr11951.java | 18 + libjava/testsuite/libjava.jni/pr11951.out | 1 + libjava/testsuite/libjava.jni/pr18278.c | 10 + libjava/testsuite/libjava.jni/pr18278.h | 19 + libjava/testsuite/libjava.jni/pr18278.jar | Bin 0 -> 763 bytes libjava/testsuite/libjava.jni/pr18278.java | 13 + libjava/testsuite/libjava.jni/pr18278.out | 2 + libjava/testsuite/libjava.jni/pr23739.c | 12 + libjava/testsuite/libjava.jni/pr23739.h | 19 + libjava/testsuite/libjava.jni/pr23739.jar | Bin 0 -> 1319 bytes libjava/testsuite/libjava.jni/pr23739.java | 22 ++ libjava/testsuite/libjava.jni/pr23739.out | 3 + libjava/testsuite/libjava.jni/pr29812.c | 7 + libjava/testsuite/libjava.jni/pr29812.h | 19 + libjava/testsuite/libjava.jni/pr29812.jar | Bin 0 -> 964 bytes libjava/testsuite/libjava.jni/pr29812.java | 25 ++ libjava/testsuite/libjava.jni/pr29812.out | 0 libjava/testsuite/libjava.jni/pr29812_injar.c | 26 ++ libjava/testsuite/libjava.jni/pr29812_injar.h | 19 + libjava/testsuite/libjava.jni/pr29812_injar.jar | Bin 0 -> 1045 bytes libjava/testsuite/libjava.jni/pr29812_injar.java | 12 + libjava/testsuite/libjava.jni/register.c | 32 ++ libjava/testsuite/libjava.jni/register.h | 19 + libjava/testsuite/libjava.jni/register.jar | Bin 0 -> 724 bytes libjava/testsuite/libjava.jni/register.java | 16 + libjava/testsuite/libjava.jni/register.out | 1 + libjava/testsuite/libjava.jni/register2.c | 48 +++ libjava/testsuite/libjava.jni/register2.jar | Bin 0 -> 1445 bytes libjava/testsuite/libjava.jni/register2.java | 27 ++ libjava/testsuite/libjava.jni/register2.out | 2 + libjava/testsuite/libjava.jni/simple_int.c | 7 + libjava/testsuite/libjava.jni/simple_int.h | 19 + libjava/testsuite/libjava.jni/simple_int.jar | Bin 0 -> 730 bytes libjava/testsuite/libjava.jni/simple_int.java | 16 + libjava/testsuite/libjava.jni/simple_int.out | 1 + libjava/testsuite/libjava.jni/throwit.c | 25 ++ libjava/testsuite/libjava.jni/throwit.h | 19 + libjava/testsuite/libjava.jni/throwit.jar | Bin 0 -> 864 bytes libjava/testsuite/libjava.jni/throwit.java | 33 ++ libjava/testsuite/libjava.jni/throwit.out | 4 + libjava/testsuite/libjava.jni/virtual.c | 7 + libjava/testsuite/libjava.jni/virtual.h | 19 + libjava/testsuite/libjava.jni/virtual.jar | Bin 0 -> 747 bytes libjava/testsuite/libjava.jni/virtual.java | 17 + libjava/testsuite/libjava.jni/virtual.out | 1 + 144 files changed, 2395 insertions(+) create mode 100644 libjava/testsuite/libjava.jni/PR15133.c create mode 100644 libjava/testsuite/libjava.jni/PR15133.h create mode 100644 libjava/testsuite/libjava.jni/PR15133.jar create mode 100644 libjava/testsuite/libjava.jni/PR15133.java create mode 100644 libjava/testsuite/libjava.jni/PR15133.out create mode 100644 libjava/testsuite/libjava.jni/PR18116.c create mode 100644 libjava/testsuite/libjava.jni/PR18116.h create mode 100644 libjava/testsuite/libjava.jni/PR18116.jar create mode 100644 libjava/testsuite/libjava.jni/PR18116.java create mode 100644 libjava/testsuite/libjava.jni/PR18116.out create mode 100644 libjava/testsuite/libjava.jni/PR28178.c create mode 100644 libjava/testsuite/libjava.jni/PR28178.h create mode 100644 libjava/testsuite/libjava.jni/PR28178.jar create mode 100644 libjava/testsuite/libjava.jni/PR28178.java create mode 100644 libjava/testsuite/libjava.jni/PR28178.out create mode 100644 libjava/testsuite/libjava.jni/bytebuffer.c create mode 100644 libjava/testsuite/libjava.jni/bytebuffer.h create mode 100644 libjava/testsuite/libjava.jni/bytebuffer.jar create mode 100644 libjava/testsuite/libjava.jni/bytebuffer.java create mode 100644 libjava/testsuite/libjava.jni/bytebuffer.out create mode 100644 libjava/testsuite/libjava.jni/calls.c create mode 100644 libjava/testsuite/libjava.jni/calls.h create mode 100644 libjava/testsuite/libjava.jni/calls.jar create mode 100644 libjava/testsuite/libjava.jni/calls.java create mode 100644 libjava/testsuite/libjava.jni/calls.out create mode 100644 libjava/testsuite/libjava.jni/cxxtest.cc create mode 100644 libjava/testsuite/libjava.jni/cxxtest.h create mode 100644 libjava/testsuite/libjava.jni/cxxtest.jar create mode 100644 libjava/testsuite/libjava.jni/cxxtest.java create mode 100644 libjava/testsuite/libjava.jni/cxxtest.out create mode 100644 libjava/testsuite/libjava.jni/directbuffer.c create mode 100644 libjava/testsuite/libjava.jni/directbuffer.h create mode 100644 libjava/testsuite/libjava.jni/directbuffer.jar create mode 100644 libjava/testsuite/libjava.jni/directbuffer.java create mode 100644 libjava/testsuite/libjava.jni/directbuffer.out create mode 100644 libjava/testsuite/libjava.jni/field.c create mode 100644 libjava/testsuite/libjava.jni/field.h create mode 100644 libjava/testsuite/libjava.jni/field.jar create mode 100644 libjava/testsuite/libjava.jni/field.java create mode 100644 libjava/testsuite/libjava.jni/field.out create mode 100644 libjava/testsuite/libjava.jni/final_method.c create mode 100644 libjava/testsuite/libjava.jni/final_method.h create mode 100644 libjava/testsuite/libjava.jni/final_method.jar create mode 100644 libjava/testsuite/libjava.jni/final_method.java create mode 100644 libjava/testsuite/libjava.jni/final_method.out create mode 100644 libjava/testsuite/libjava.jni/findclass.c create mode 100644 libjava/testsuite/libjava.jni/findclass.h create mode 100644 libjava/testsuite/libjava.jni/findclass.jar create mode 100644 libjava/testsuite/libjava.jni/findclass.java create mode 100644 libjava/testsuite/libjava.jni/findclass.out create mode 100644 libjava/testsuite/libjava.jni/findclass2.c create mode 100644 libjava/testsuite/libjava.jni/findclass2.h create mode 100644 libjava/testsuite/libjava.jni/findclass2.jar create mode 100644 libjava/testsuite/libjava.jni/findclass2.java create mode 100644 libjava/testsuite/libjava.jni/findclass2.out create mode 100644 libjava/testsuite/libjava.jni/iface.c create mode 100644 libjava/testsuite/libjava.jni/iface.h create mode 100644 libjava/testsuite/libjava.jni/iface.jar create mode 100644 libjava/testsuite/libjava.jni/iface.java create mode 100644 libjava/testsuite/libjava.jni/iface.out create mode 100644 libjava/testsuite/libjava.jni/init$NativeClass.h create mode 100644 libjava/testsuite/libjava.jni/init.c create mode 100644 libjava/testsuite/libjava.jni/init.h create mode 100644 libjava/testsuite/libjava.jni/init.jar create mode 100644 libjava/testsuite/libjava.jni/init.java create mode 100644 libjava/testsuite/libjava.jni/init.out create mode 100644 libjava/testsuite/libjava.jni/invocation/PR16923.c create mode 100644 libjava/testsuite/libjava.jni/invocation/PR16923.jar create mode 100644 libjava/testsuite/libjava.jni/invocation/PR16923.java create mode 100644 libjava/testsuite/libjava.jni/invocation/PR16923.out create mode 100644 libjava/testsuite/libjava.jni/invoke.c create mode 100644 libjava/testsuite/libjava.jni/invoke.h create mode 100644 libjava/testsuite/libjava.jni/invoke.jar create mode 100644 libjava/testsuite/libjava.jni/invoke.java create mode 100644 libjava/testsuite/libjava.jni/invoke.out create mode 100644 libjava/testsuite/libjava.jni/jni.exp create mode 100644 libjava/testsuite/libjava.jni/jniutf.c create mode 100644 libjava/testsuite/libjava.jni/jniutf.h create mode 100644 libjava/testsuite/libjava.jni/jniutf.jar create mode 100644 libjava/testsuite/libjava.jni/jniutf.java create mode 100644 libjava/testsuite/libjava.jni/jniutf.out create mode 100644 libjava/testsuite/libjava.jni/martin.c create mode 100644 libjava/testsuite/libjava.jni/martin.h create mode 100644 libjava/testsuite/libjava.jni/martin.jar create mode 100644 libjava/testsuite/libjava.jni/martin.java create mode 100644 libjava/testsuite/libjava.jni/martin.out create mode 100644 libjava/testsuite/libjava.jni/noclass.c create mode 100644 libjava/testsuite/libjava.jni/noclass.h create mode 100644 libjava/testsuite/libjava.jni/noclass.jar create mode 100644 libjava/testsuite/libjava.jni/noclass.java create mode 100644 libjava/testsuite/libjava.jni/noclass.out create mode 100644 libjava/testsuite/libjava.jni/overload.c create mode 100644 libjava/testsuite/libjava.jni/overload.h create mode 100644 libjava/testsuite/libjava.jni/overload.jar create mode 100644 libjava/testsuite/libjava.jni/overload.java create mode 100644 libjava/testsuite/libjava.jni/overload.out create mode 100644 libjava/testsuite/libjava.jni/pr11951.c create mode 100644 libjava/testsuite/libjava.jni/pr11951.h create mode 100644 libjava/testsuite/libjava.jni/pr11951.jar create mode 100644 libjava/testsuite/libjava.jni/pr11951.java create mode 100644 libjava/testsuite/libjava.jni/pr11951.out create mode 100644 libjava/testsuite/libjava.jni/pr18278.c create mode 100644 libjava/testsuite/libjava.jni/pr18278.h create mode 100644 libjava/testsuite/libjava.jni/pr18278.jar create mode 100644 libjava/testsuite/libjava.jni/pr18278.java create mode 100644 libjava/testsuite/libjava.jni/pr18278.out create mode 100644 libjava/testsuite/libjava.jni/pr23739.c create mode 100644 libjava/testsuite/libjava.jni/pr23739.h create mode 100644 libjava/testsuite/libjava.jni/pr23739.jar create mode 100644 libjava/testsuite/libjava.jni/pr23739.java create mode 100644 libjava/testsuite/libjava.jni/pr23739.out create mode 100644 libjava/testsuite/libjava.jni/pr29812.c create mode 100644 libjava/testsuite/libjava.jni/pr29812.h create mode 100644 libjava/testsuite/libjava.jni/pr29812.jar create mode 100644 libjava/testsuite/libjava.jni/pr29812.java create mode 100644 libjava/testsuite/libjava.jni/pr29812.out create mode 100644 libjava/testsuite/libjava.jni/pr29812_injar.c create mode 100644 libjava/testsuite/libjava.jni/pr29812_injar.h create mode 100644 libjava/testsuite/libjava.jni/pr29812_injar.jar create mode 100644 libjava/testsuite/libjava.jni/pr29812_injar.java create mode 100644 libjava/testsuite/libjava.jni/register.c create mode 100644 libjava/testsuite/libjava.jni/register.h create mode 100644 libjava/testsuite/libjava.jni/register.jar create mode 100644 libjava/testsuite/libjava.jni/register.java create mode 100644 libjava/testsuite/libjava.jni/register.out create mode 100644 libjava/testsuite/libjava.jni/register2.c create mode 100644 libjava/testsuite/libjava.jni/register2.jar create mode 100644 libjava/testsuite/libjava.jni/register2.java create mode 100644 libjava/testsuite/libjava.jni/register2.out create mode 100644 libjava/testsuite/libjava.jni/simple_int.c create mode 100644 libjava/testsuite/libjava.jni/simple_int.h create mode 100644 libjava/testsuite/libjava.jni/simple_int.jar create mode 100644 libjava/testsuite/libjava.jni/simple_int.java create mode 100644 libjava/testsuite/libjava.jni/simple_int.out create mode 100644 libjava/testsuite/libjava.jni/throwit.c create mode 100644 libjava/testsuite/libjava.jni/throwit.h create mode 100644 libjava/testsuite/libjava.jni/throwit.jar create mode 100644 libjava/testsuite/libjava.jni/throwit.java create mode 100644 libjava/testsuite/libjava.jni/throwit.out create mode 100644 libjava/testsuite/libjava.jni/virtual.c create mode 100644 libjava/testsuite/libjava.jni/virtual.h create mode 100644 libjava/testsuite/libjava.jni/virtual.jar create mode 100644 libjava/testsuite/libjava.jni/virtual.java create mode 100644 libjava/testsuite/libjava.jni/virtual.out (limited to 'libjava/testsuite/libjava.jni') diff --git a/libjava/testsuite/libjava.jni/PR15133.c b/libjava/testsuite/libjava.jni/PR15133.c new file mode 100644 index 000000000..be5a48efa --- /dev/null +++ b/libjava/testsuite/libjava.jni/PR15133.c @@ -0,0 +1,9 @@ +#include +#include +#include "PR15133.h" + +JNIEXPORT void JNICALL +Java_PR15133_printIt (JNIEnv *env, jobject x, jint y) +{ + printf ("%d\n", y); +} diff --git a/libjava/testsuite/libjava.jni/PR15133.h b/libjava/testsuite/libjava.jni/PR15133.h new file mode 100644 index 000000000..af9f8f8a3 --- /dev/null +++ b/libjava/testsuite/libjava.jni/PR15133.h @@ -0,0 +1,19 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ + +#include + +#ifndef __PR15133__ +#define __PR15133__ + +#ifdef __cplusplus +extern "C" +{ +#endif + +JNIEXPORT void JNICALL Java_PR15133_printIt (JNIEnv *env, jobject, jint); + +#ifdef __cplusplus +} +#endif + +#endif /* __PR15133__ */ diff --git a/libjava/testsuite/libjava.jni/PR15133.jar b/libjava/testsuite/libjava.jni/PR15133.jar new file mode 100644 index 000000000..ad76705df Binary files /dev/null and b/libjava/testsuite/libjava.jni/PR15133.jar differ diff --git a/libjava/testsuite/libjava.jni/PR15133.java b/libjava/testsuite/libjava.jni/PR15133.java new file mode 100644 index 000000000..90435765b --- /dev/null +++ b/libjava/testsuite/libjava.jni/PR15133.java @@ -0,0 +1,14 @@ +/* Test case for PR java/15133 */ +public class PR15133 +{ + public void printIt (String dummy) { } + + public native void printIt (int num); + + public static void main (String[] args) + { + System.loadLibrary ("PR15133"); + + new PR15133( ).printIt( 1729); + } +} diff --git a/libjava/testsuite/libjava.jni/PR15133.out b/libjava/testsuite/libjava.jni/PR15133.out new file mode 100644 index 000000000..32bb421c6 --- /dev/null +++ b/libjava/testsuite/libjava.jni/PR15133.out @@ -0,0 +1 @@ +1729 diff --git a/libjava/testsuite/libjava.jni/PR18116.c b/libjava/testsuite/libjava.jni/PR18116.c new file mode 100644 index 000000000..bcd14331e --- /dev/null +++ b/libjava/testsuite/libjava.jni/PR18116.c @@ -0,0 +1,35 @@ +#include +#include +#include + +// The purpose of this test is to ensure that signatures with non-top +// level class arguments work. + +static jint +some_random_name (JNIEnv *env, jclass k, jobject v) +{ + return 555; +} + +JNIEXPORT jint JNICALL +JNI_OnLoad (JavaVM *vm, void *nothing) +{ + JNIEnv *env; + JNINativeMethod meth; + jclass k; + jint r; + + r = (*vm)->GetEnv (vm, (void **) &env, JNI_VERSION_1_2); + assert (r == JNI_OK); + k = (*env)->FindClass (env, "PR18116"); + assert (k != NULL); + + meth.name = "doit"; + meth.signature = "(Ljava/lang/String;)I"; + meth.fnPtr = some_random_name; + + r = (*env)->RegisterNatives (env, k, &meth, 1); + assert (r == JNI_OK); + + return JNI_VERSION_1_2; +} diff --git a/libjava/testsuite/libjava.jni/PR18116.h b/libjava/testsuite/libjava.jni/PR18116.h new file mode 100644 index 000000000..56fc648be --- /dev/null +++ b/libjava/testsuite/libjava.jni/PR18116.h @@ -0,0 +1,19 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ + +#include + +#ifndef __PR18116__ +#define __PR18116__ + +#ifdef __cplusplus +extern "C" +{ +#endif + +JNIEXPORT jint JNICALL Java_PR18116_doit (JNIEnv *env, jclass, jstring); + +#ifdef __cplusplus +} +#endif + +#endif /* __PR18116__ */ diff --git a/libjava/testsuite/libjava.jni/PR18116.jar b/libjava/testsuite/libjava.jni/PR18116.jar new file mode 100644 index 000000000..b9a0034ba Binary files /dev/null and b/libjava/testsuite/libjava.jni/PR18116.jar differ diff --git a/libjava/testsuite/libjava.jni/PR18116.java b/libjava/testsuite/libjava.jni/PR18116.java new file mode 100644 index 000000000..d582132b6 --- /dev/null +++ b/libjava/testsuite/libjava.jni/PR18116.java @@ -0,0 +1,16 @@ +// PR18116.java - Test RegisterNatives with more complex signatures. + +public class PR18116 +{ + static + { + System.loadLibrary ("PR18116"); + } + + public static native int doit (java.lang.String s); + + public static void main (String[] args) + { + System.out.println (doit ("Hello World!")); + } +} diff --git a/libjava/testsuite/libjava.jni/PR18116.out b/libjava/testsuite/libjava.jni/PR18116.out new file mode 100644 index 000000000..3749383de --- /dev/null +++ b/libjava/testsuite/libjava.jni/PR18116.out @@ -0,0 +1 @@ +555 diff --git a/libjava/testsuite/libjava.jni/PR28178.c b/libjava/testsuite/libjava.jni/PR28178.c new file mode 100644 index 000000000..17e730a1c --- /dev/null +++ b/libjava/testsuite/libjava.jni/PR28178.c @@ -0,0 +1,10 @@ +#include + +void +Java_PR28178_m (JNIEnv *env, jclass ignore) +{ + (*env)->DeleteLocalRef(env, NULL); + (*env)->DeleteGlobalRef(env, NULL); +} + + diff --git a/libjava/testsuite/libjava.jni/PR28178.h b/libjava/testsuite/libjava.jni/PR28178.h new file mode 100644 index 000000000..e686439ec --- /dev/null +++ b/libjava/testsuite/libjava.jni/PR28178.h @@ -0,0 +1,19 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ + +#include + +#ifndef __PR28178__ +#define __PR28178__ + +#ifdef __cplusplus +extern "C" +{ +#endif + +JNIEXPORT void JNICALL Java_PR28178_m (JNIEnv *env, jclass); + +#ifdef __cplusplus +} +#endif + +#endif /* __PR28178__ */ diff --git a/libjava/testsuite/libjava.jni/PR28178.jar b/libjava/testsuite/libjava.jni/PR28178.jar new file mode 100644 index 000000000..0c9082bb9 Binary files /dev/null and b/libjava/testsuite/libjava.jni/PR28178.jar differ diff --git a/libjava/testsuite/libjava.jni/PR28178.java b/libjava/testsuite/libjava.jni/PR28178.java new file mode 100644 index 000000000..f8d7b904c --- /dev/null +++ b/libjava/testsuite/libjava.jni/PR28178.java @@ -0,0 +1,15 @@ +// Regression test for PR 28178. + +public class PR28178 +{ + static { + System.loadLibrary("PR28178"); + } + + public static native void m(); + + public static void main(String[] args) + { + m(); + } +} diff --git a/libjava/testsuite/libjava.jni/PR28178.out b/libjava/testsuite/libjava.jni/PR28178.out new file mode 100644 index 000000000..e69de29bb diff --git a/libjava/testsuite/libjava.jni/bytebuffer.c b/libjava/testsuite/libjava.jni/bytebuffer.c new file mode 100644 index 000000000..146c6a844 --- /dev/null +++ b/libjava/testsuite/libjava.jni/bytebuffer.c @@ -0,0 +1,62 @@ +#include "bytebuffer.h" + +static void +test_buffer (JNIEnv *env, jobject buffer, const char *name) +{ + void *tmp = (*env)->GetDirectBufferAddress (env, buffer); + + if (tmp == NULL) + printf ("PASS: address of %s\n", name); + else + printf ("FAIL: address of %s\n", name); + + int tmplen = (*env)->GetDirectBufferCapacity (env, buffer); + + if (tmplen == -1) + printf ("PASS: length of %s\n", name); + else + printf ("FAIL: length of %s\n", name); +} + +JNIEXPORT void JNICALL +Java_bytebuffer_testByteBuffer (JNIEnv *env, jclass k, jobject buffer) +{ + test_buffer (env, buffer, "java.nio.ByteBuffer"); +} + +JNIEXPORT void JNICALL +Java_bytebuffer_testCharBuffer (JNIEnv *env, jclass k, jobject buffer) +{ + test_buffer (env, buffer, "java.nio.CharBuffer"); +} + +JNIEXPORT void JNICALL +Java_bytebuffer_testDoubleBuffer (JNIEnv *env, jclass k, jobject buffer) +{ + test_buffer (env, buffer, "java.nio.DoubleBuffer"); +} + +JNIEXPORT void JNICALL +Java_bytebuffer_testFloatBuffer (JNIEnv *env, jclass k, jobject buffer) +{ + test_buffer (env, buffer, "java.nio.FloatBuffer"); +} + +JNIEXPORT void JNICALL +Java_bytebuffer_testIntBuffer (JNIEnv *env, jclass k, jobject buffer) +{ + test_buffer (env, buffer, "java.nio.IntBuffer"); +} + +JNIEXPORT void JNICALL +Java_bytebuffer_testLongBuffer (JNIEnv *env, jclass k, jobject buffer) +{ + test_buffer (env, buffer, "java.nio.LongBuffer"); +} + +JNIEXPORT void JNICALL +Java_bytebuffer_testShortBuffer (JNIEnv *env, jclass k, jobject buffer) +{ + test_buffer (env, buffer, "java.nio.ShortBuffer"); +} + diff --git a/libjava/testsuite/libjava.jni/bytebuffer.h b/libjava/testsuite/libjava.jni/bytebuffer.h new file mode 100644 index 000000000..33b5c3aa0 --- /dev/null +++ b/libjava/testsuite/libjava.jni/bytebuffer.h @@ -0,0 +1,25 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ + +#include + +#ifndef __bytebuffer__ +#define __bytebuffer__ + +#ifdef __cplusplus +extern "C" +{ +#endif + +JNIEXPORT void JNICALL Java_bytebuffer_testByteBuffer (JNIEnv *env, jclass, jobject); +JNIEXPORT void JNICALL Java_bytebuffer_testCharBuffer (JNIEnv *env, jclass, jobject); +JNIEXPORT void JNICALL Java_bytebuffer_testDoubleBuffer (JNIEnv *env, jclass, jobject); +JNIEXPORT void JNICALL Java_bytebuffer_testFloatBuffer (JNIEnv *env, jclass, jobject); +JNIEXPORT void JNICALL Java_bytebuffer_testIntBuffer (JNIEnv *env, jclass, jobject); +JNIEXPORT void JNICALL Java_bytebuffer_testLongBuffer (JNIEnv *env, jclass, jobject); +JNIEXPORT void JNICALL Java_bytebuffer_testShortBuffer (JNIEnv *env, jclass, jobject); + +#ifdef __cplusplus +} +#endif + +#endif /* __bytebuffer__ */ diff --git a/libjava/testsuite/libjava.jni/bytebuffer.jar b/libjava/testsuite/libjava.jni/bytebuffer.jar new file mode 100644 index 000000000..d0ca6d7e9 Binary files /dev/null and b/libjava/testsuite/libjava.jni/bytebuffer.jar differ diff --git a/libjava/testsuite/libjava.jni/bytebuffer.java b/libjava/testsuite/libjava.jni/bytebuffer.java new file mode 100644 index 000000000..0e541123f --- /dev/null +++ b/libjava/testsuite/libjava.jni/bytebuffer.java @@ -0,0 +1,38 @@ +// Test to make sure JNI implementation catches exceptions. + +import java.nio.*; + +public class bytebuffer +{ + static + { + System.loadLibrary("bytebuffer"); + } + + public static native void testByteBuffer(ByteBuffer bb); + public static native void testCharBuffer(CharBuffer b); + public static native void testDoubleBuffer(DoubleBuffer b); + public static native void testFloatBuffer(FloatBuffer b); + public static native void testIntBuffer(IntBuffer b); + public static native void testLongBuffer(LongBuffer b); + public static native void testShortBuffer(ShortBuffer b); + + public static void main(String[] args) + { + ByteBuffer bb = ByteBuffer.allocate(1024); + testByteBuffer(bb); + testCharBuffer(bb.asCharBuffer()); + testDoubleBuffer(bb.asDoubleBuffer()); + testFloatBuffer(bb.asFloatBuffer()); + testIntBuffer(bb.asIntBuffer()); + testLongBuffer(bb.asLongBuffer()); + testShortBuffer(bb.asShortBuffer()); + + testCharBuffer(CharBuffer.allocate(1024)); + testDoubleBuffer(DoubleBuffer.allocate(1024)); + testFloatBuffer(FloatBuffer.allocate(1024)); + testIntBuffer(IntBuffer.allocate(1024)); + testLongBuffer(LongBuffer.allocate(1024)); + testShortBuffer(ShortBuffer.allocate(1024)); + } +} diff --git a/libjava/testsuite/libjava.jni/bytebuffer.out b/libjava/testsuite/libjava.jni/bytebuffer.out new file mode 100644 index 000000000..5af92e206 --- /dev/null +++ b/libjava/testsuite/libjava.jni/bytebuffer.out @@ -0,0 +1,26 @@ +PASS: address of java.nio.ByteBuffer +PASS: length of java.nio.ByteBuffer +PASS: address of java.nio.CharBuffer +PASS: length of java.nio.CharBuffer +PASS: address of java.nio.DoubleBuffer +PASS: length of java.nio.DoubleBuffer +PASS: address of java.nio.FloatBuffer +PASS: length of java.nio.FloatBuffer +PASS: address of java.nio.IntBuffer +PASS: length of java.nio.IntBuffer +PASS: address of java.nio.LongBuffer +PASS: length of java.nio.LongBuffer +PASS: address of java.nio.ShortBuffer +PASS: length of java.nio.ShortBuffer +PASS: address of java.nio.CharBuffer +PASS: length of java.nio.CharBuffer +PASS: address of java.nio.DoubleBuffer +PASS: length of java.nio.DoubleBuffer +PASS: address of java.nio.FloatBuffer +PASS: length of java.nio.FloatBuffer +PASS: address of java.nio.IntBuffer +PASS: length of java.nio.IntBuffer +PASS: address of java.nio.LongBuffer +PASS: length of java.nio.LongBuffer +PASS: address of java.nio.ShortBuffer +PASS: length of java.nio.ShortBuffer diff --git a/libjava/testsuite/libjava.jni/calls.c b/libjava/testsuite/libjava.jni/calls.c new file mode 100644 index 000000000..709e55d13 --- /dev/null +++ b/libjava/testsuite/libjava.jni/calls.c @@ -0,0 +1,75 @@ +#include +#include + +JNIEXPORT jint JNICALL +Java_calls_docall (JNIEnv *env, jobject _this) +{ + jmethodID method; + jclass klass, super; + + jbyte b; + jshort s; + jchar c; + jint i; + jlong l; + jfloat f; + jdouble d; + + jvalue val; + + jint fails = 0; + + klass = (*env)->GetObjectClass (env, _this); + super = (*env)->GetSuperclass (env, klass); + + method = (*env)->GetMethodID (env, klass, "byte_f", "()B"); + b = (*env)->CallByteMethod (env, _this, method); + if (b != 23) + ++fails; + + method = (*env)->GetMethodID (env, klass, "char_f", "(I)C"); + val.i = 10; + c = (*env)->CallCharMethodA (env, _this, method, &val); + if (c != ('a' + 10)) + ++fails; + + method = (*env)->GetMethodID (env, super, "int_f", "()I"); + i = (*env)->CallNonvirtualIntMethod (env, _this, super, method); + if (i != 27) + ++fails; + + i = (*env)->CallIntMethod (env, _this, method); + if (i != 1023) + ++fails; + + method = (*env)->GetStaticMethodID (env, klass, "long_f", "(J)J"); + l = (*env)->CallStaticLongMethod (env, klass, method, (jlong) 10); + if (l != 2033) + ++fails; + + method = (*env)->GetStaticMethodID (env, klass, "longpb_f", "(BJBJBJ)J"); + l = (*env)->CallStaticLongMethod (env, klass, method, (jbyte) 13, (jlong) 3, + (jbyte) 13, (jlong) 3, (jbyte) 13, (jlong) 4); + if (l != 3033) + ++fails; + + method = (*env)->GetMethodID (env, klass, "void_f", "()V"); + (*env)->CallVoidMethod (env, _this, method); + + method = (*env)->GetStaticMethodID (env, klass, "short_f", "()S"); + s = (*env)->CallStaticShortMethod (env, klass, method); + if (s != 2) + ++fails; + + method = (*env)->GetMethodID (env, klass, "double_f", "()D"); + d = (*env)->CallDoubleMethod (env, _this, method); + if (d != -1.0) + ++fails; + + method = (*env)->GetMethodID (env, klass, "float_f", "()F"); + f = (*env)->CallFloatMethod (env, _this, method); + if (f != 1.0) + ++fails; + + return fails; +} diff --git a/libjava/testsuite/libjava.jni/calls.h b/libjava/testsuite/libjava.jni/calls.h new file mode 100644 index 000000000..64b967095 --- /dev/null +++ b/libjava/testsuite/libjava.jni/calls.h @@ -0,0 +1,19 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ + +#include + +#ifndef __calls__ +#define __calls__ + +#ifdef __cplusplus +extern "C" +{ +#endif + +JNIEXPORT jint JNICALL Java_calls_docall (JNIEnv *env, jobject); + +#ifdef __cplusplus +} +#endif + +#endif /* __calls__ */ diff --git a/libjava/testsuite/libjava.jni/calls.jar b/libjava/testsuite/libjava.jni/calls.jar new file mode 100644 index 000000000..3a188ea49 Binary files /dev/null and b/libjava/testsuite/libjava.jni/calls.jar differ diff --git a/libjava/testsuite/libjava.jni/calls.java b/libjava/testsuite/libjava.jni/calls.java new file mode 100644 index 000000000..19c33be2a --- /dev/null +++ b/libjava/testsuite/libjava.jni/calls.java @@ -0,0 +1,72 @@ +// Test a bunch of different calls. + +class base +{ + public int int_f () + { + return 27; + } +} + +public class calls extends base +{ + static + { + System.loadLibrary ("calls"); + } + + public native int docall (); + + public byte byte_f () + { + return 23; + } + + public char char_f (int z) + { + return (char) ('a' + z); + } + + public int int_f () + { + return 1023; + } + + public static long long_f (long q) + { + return q + 2023; + } + + public static long longpb_f (byte b1, long q1, byte b2, long q2, + byte b3, long q3) + { + return q1 + q2 + q3 + 3023; + } + + public void void_f () + { + System.out.println ("void"); + } + + public static short short_f () + { + return 2; + } + + public double double_f () + { + return -1.0; + } + + public float float_f () + { + return (float) 1.0; + } + + public static void main (String[] args) + { + calls c = new calls (); + if (c.docall () != 0) + System.out.println ("fail"); + } +} diff --git a/libjava/testsuite/libjava.jni/calls.out b/libjava/testsuite/libjava.jni/calls.out new file mode 100644 index 000000000..cbab1f6b6 --- /dev/null +++ b/libjava/testsuite/libjava.jni/calls.out @@ -0,0 +1 @@ +void diff --git a/libjava/testsuite/libjava.jni/cxxtest.cc b/libjava/testsuite/libjava.jni/cxxtest.cc new file mode 100644 index 000000000..577273bb5 --- /dev/null +++ b/libjava/testsuite/libjava.jni/cxxtest.cc @@ -0,0 +1,24 @@ +#include +#include + +jobjectArray +Java_cxxtest_fetch (JNIEnv *env, jobject _this) +{ + jclass cls; + jfieldID fid; + jobjectArray obj; + + cls = env->GetObjectClass (_this); + if (! cls) + return 0; + + fid = env->GetFieldID (cls, "F", "[Ljava/lang/Object;"); + if (! fid) + return 0; + + obj = reinterpret_cast (env->GetObjectField (_this, fid)); + + return obj; +} + + diff --git a/libjava/testsuite/libjava.jni/cxxtest.h b/libjava/testsuite/libjava.jni/cxxtest.h new file mode 100644 index 000000000..d903636f4 --- /dev/null +++ b/libjava/testsuite/libjava.jni/cxxtest.h @@ -0,0 +1,19 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ + +#include + +#ifndef __cxxtest__ +#define __cxxtest__ + +#ifdef __cplusplus +extern "C" +{ +#endif + +JNIEXPORT jobjectArray JNICALL Java_cxxtest_fetch (JNIEnv *env, jobject); + +#ifdef __cplusplus +} +#endif + +#endif /* __cxxtest__ */ diff --git a/libjava/testsuite/libjava.jni/cxxtest.jar b/libjava/testsuite/libjava.jni/cxxtest.jar new file mode 100644 index 000000000..5a9a0d772 Binary files /dev/null and b/libjava/testsuite/libjava.jni/cxxtest.jar differ diff --git a/libjava/testsuite/libjava.jni/cxxtest.java b/libjava/testsuite/libjava.jni/cxxtest.java new file mode 100644 index 000000000..b1c3bb945 --- /dev/null +++ b/libjava/testsuite/libjava.jni/cxxtest.java @@ -0,0 +1,25 @@ +// Test for array field lookup. + +public class cxxtest +{ + // A field for us to look up. + public Object[] F = new Object[7]; + + public native Object[] fetch (); + + public void doit () + { + System.out.println (F == fetch ()); + } + + public static void main (String[] args) + { + cxxtest q = new cxxtest (); + q.doit (); + } + + static + { + System.loadLibrary ("cxxtest"); + } +} diff --git a/libjava/testsuite/libjava.jni/cxxtest.out b/libjava/testsuite/libjava.jni/cxxtest.out new file mode 100644 index 000000000..27ba77dda --- /dev/null +++ b/libjava/testsuite/libjava.jni/cxxtest.out @@ -0,0 +1 @@ +true diff --git a/libjava/testsuite/libjava.jni/directbuffer.c b/libjava/testsuite/libjava.jni/directbuffer.c new file mode 100644 index 000000000..3d32aba01 --- /dev/null +++ b/libjava/testsuite/libjava.jni/directbuffer.c @@ -0,0 +1,75 @@ +#include + +#include "directbuffer.h" + +#define BUFFER_SIZE 1024 + +static void *address; + +JNIEXPORT jobject JNICALL +Java_directbuffer_createDirectByteBuffer (JNIEnv *env, jclass k) +{ + address = malloc (BUFFER_SIZE); + return (*env)->NewDirectByteBuffer (env, address, 1024); +} + +static void +test_buffer (JNIEnv *env, jobject buffer, const char *name, int len) +{ + void *tmp = (*env)->GetDirectBufferAddress (env, buffer); + + if (address == tmp) + printf ("PASS: address of %s\n", name); + else + printf ("FAIL: address of %s\n", name); + + int tmplen = (*env)->GetDirectBufferCapacity (env, buffer); + + if (len == tmplen) + printf ("PASS: length of %s\n", name); + else + printf ("FAIL: length of %s\n", name); +} + +JNIEXPORT void JNICALL +Java_directbuffer_testDirectByteBuffer (JNIEnv *env, jclass k, jobject buffer, jint len) +{ + test_buffer (env, buffer, "direct java.nio.ByteBuffer", len); +} + +JNIEXPORT void JNICALL +Java_directbuffer_testCharBuffer (JNIEnv *env, jclass k, jobject buffer, jint len) +{ + test_buffer (env, buffer, "java.nio.CharBuffer view", len); +} + +JNIEXPORT void JNICALL +Java_directbuffer_testDoubleBuffer (JNIEnv *env, jclass k, jobject buffer, jint len) +{ + test_buffer (env, buffer, "java.nio.DoubleBuffer view", len); +} + +JNIEXPORT void JNICALL +Java_directbuffer_testFloatBuffer (JNIEnv *env, jclass k, jobject buffer, jint len) +{ + test_buffer (env, buffer, "java.nio.FloatBuffer view", len); +} + +JNIEXPORT void JNICALL +Java_directbuffer_testIntBuffer (JNIEnv *env, jclass k, jobject buffer, jint len) +{ + test_buffer (env, buffer, "java.nio.IntBuffer view", len); +} + +JNIEXPORT void JNICALL +Java_directbuffer_testLongBuffer (JNIEnv *env, jclass k, jobject buffer, jint len) +{ + test_buffer (env, buffer, "java.nio.LongBuffer view", len); +} + +JNIEXPORT void JNICALL +Java_directbuffer_testShortBuffer (JNIEnv *env, jclass k, jobject buffer, jint len) +{ + test_buffer (env, buffer, "java.nio.ShortBuffer view", len); +} + diff --git a/libjava/testsuite/libjava.jni/directbuffer.h b/libjava/testsuite/libjava.jni/directbuffer.h new file mode 100644 index 000000000..6d5c65276 --- /dev/null +++ b/libjava/testsuite/libjava.jni/directbuffer.h @@ -0,0 +1,26 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ + +#include + +#ifndef __directbuffer__ +#define __directbuffer__ + +#ifdef __cplusplus +extern "C" +{ +#endif + +JNIEXPORT jobject JNICALL Java_directbuffer_createDirectByteBuffer (JNIEnv *env, jclass); +JNIEXPORT void JNICALL Java_directbuffer_testDirectByteBuffer (JNIEnv *env, jclass, jobject, jint); +JNIEXPORT void JNICALL Java_directbuffer_testCharBuffer (JNIEnv *env, jclass, jobject, jint); +JNIEXPORT void JNICALL Java_directbuffer_testDoubleBuffer (JNIEnv *env, jclass, jobject, jint); +JNIEXPORT void JNICALL Java_directbuffer_testFloatBuffer (JNIEnv *env, jclass, jobject, jint); +JNIEXPORT void JNICALL Java_directbuffer_testIntBuffer (JNIEnv *env, jclass, jobject, jint); +JNIEXPORT void JNICALL Java_directbuffer_testLongBuffer (JNIEnv *env, jclass, jobject, jint); +JNIEXPORT void JNICALL Java_directbuffer_testShortBuffer (JNIEnv *env, jclass, jobject, jint); + +#ifdef __cplusplus +} +#endif + +#endif /* __directbuffer__ */ diff --git a/libjava/testsuite/libjava.jni/directbuffer.jar b/libjava/testsuite/libjava.jni/directbuffer.jar new file mode 100644 index 000000000..f1630dad8 Binary files /dev/null and b/libjava/testsuite/libjava.jni/directbuffer.jar differ diff --git a/libjava/testsuite/libjava.jni/directbuffer.java b/libjava/testsuite/libjava.jni/directbuffer.java new file mode 100644 index 000000000..ee844b901 --- /dev/null +++ b/libjava/testsuite/libjava.jni/directbuffer.java @@ -0,0 +1,40 @@ +// Test to make sure JNI implementation catches exceptions. + +import java.nio.*; + +public class directbuffer +{ + static + { + System.loadLibrary("directbuffer"); + } + + public static native ByteBuffer createDirectByteBuffer(); + + public static native void testDirectByteBuffer(ByteBuffer bb, int len); + public static native void testCharBuffer(CharBuffer b, int len); + public static native void testDoubleBuffer(DoubleBuffer b, int len); + public static native void testFloatBuffer(FloatBuffer b, int len); + public static native void testIntBuffer(IntBuffer b, int len); + public static native void testLongBuffer(LongBuffer b, int len); + public static native void testShortBuffer(ShortBuffer b, int len); + + public static void main(String[] args) + { + ByteBuffer bb = createDirectByteBuffer(); + CharBuffer cb = bb.asCharBuffer(); + DoubleBuffer db = bb.asDoubleBuffer(); + FloatBuffer fb = bb.asFloatBuffer(); + IntBuffer ib = bb.asIntBuffer(); + LongBuffer lb = bb.asLongBuffer(); + ShortBuffer sb = bb.asShortBuffer(); + + testDirectByteBuffer(bb, 1024); + testCharBuffer(cb, 512); + testDoubleBuffer(db, 128); + testFloatBuffer(fb, 256); + testIntBuffer(ib, 256); + testLongBuffer(lb, 128); + testShortBuffer(sb, 512); + } +} diff --git a/libjava/testsuite/libjava.jni/directbuffer.out b/libjava/testsuite/libjava.jni/directbuffer.out new file mode 100644 index 000000000..c1404b9f2 --- /dev/null +++ b/libjava/testsuite/libjava.jni/directbuffer.out @@ -0,0 +1,14 @@ +PASS: address of direct java.nio.ByteBuffer +PASS: length of direct java.nio.ByteBuffer +PASS: address of java.nio.CharBuffer view +PASS: length of java.nio.CharBuffer view +PASS: address of java.nio.DoubleBuffer view +PASS: length of java.nio.DoubleBuffer view +PASS: address of java.nio.FloatBuffer view +PASS: length of java.nio.FloatBuffer view +PASS: address of java.nio.IntBuffer view +PASS: length of java.nio.IntBuffer view +PASS: address of java.nio.LongBuffer view +PASS: length of java.nio.LongBuffer view +PASS: address of java.nio.ShortBuffer view +PASS: length of java.nio.ShortBuffer view diff --git a/libjava/testsuite/libjava.jni/field.c b/libjava/testsuite/libjava.jni/field.c new file mode 100644 index 000000000..bce0cc896 --- /dev/null +++ b/libjava/testsuite/libjava.jni/field.c @@ -0,0 +1,24 @@ +#include +#include + +JNIEXPORT jobjectArray JNICALL +Java_field_fetch (JNIEnv *env, jobject this) +{ + jclass cls; + jfieldID fid; + jobjectArray obj; + + cls = (*env)->GetObjectClass (env, this); + if (! cls) + return 0; + + fid = (*env)->GetFieldID (env, cls, "F", "[Ljava/lang/Object;"); + if (! fid) + return 0; + + obj = (*env)->GetObjectField (env, this, fid); + + return obj; +} + + diff --git a/libjava/testsuite/libjava.jni/field.h b/libjava/testsuite/libjava.jni/field.h new file mode 100644 index 000000000..fd1597aae --- /dev/null +++ b/libjava/testsuite/libjava.jni/field.h @@ -0,0 +1,19 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ + +#include + +#ifndef __field__ +#define __field__ + +#ifdef __cplusplus +extern "C" +{ +#endif + +JNIEXPORT jobjectArray JNICALL Java_field_fetch (JNIEnv *env, jobject); + +#ifdef __cplusplus +} +#endif + +#endif /* __field__ */ diff --git a/libjava/testsuite/libjava.jni/field.jar b/libjava/testsuite/libjava.jni/field.jar new file mode 100644 index 000000000..3f636e842 Binary files /dev/null and b/libjava/testsuite/libjava.jni/field.jar differ diff --git a/libjava/testsuite/libjava.jni/field.java b/libjava/testsuite/libjava.jni/field.java new file mode 100644 index 000000000..bd0f7492e --- /dev/null +++ b/libjava/testsuite/libjava.jni/field.java @@ -0,0 +1,25 @@ +// Test for array field lookup. + +public class field +{ + // A field for us to look up. + public Object[] F = new Object[7]; + + public native Object[] fetch (); + + public void doit () + { + System.out.println (F == fetch ()); + } + + public static void main (String[] args) + { + field q = new field (); + q.doit (); + } + + static + { + System.loadLibrary ("field"); + } +} diff --git a/libjava/testsuite/libjava.jni/field.out b/libjava/testsuite/libjava.jni/field.out new file mode 100644 index 000000000..27ba77dda --- /dev/null +++ b/libjava/testsuite/libjava.jni/field.out @@ -0,0 +1 @@ +true diff --git a/libjava/testsuite/libjava.jni/final_method.c b/libjava/testsuite/libjava.jni/final_method.c new file mode 100644 index 000000000..76d5ae528 --- /dev/null +++ b/libjava/testsuite/libjava.jni/final_method.c @@ -0,0 +1,7 @@ +#include + +JNIEXPORT jstring JNICALL +Java_final_1method_meth (JNIEnv *env, jobject thisv) +{ + return (*env)->NewStringUTF (env, "zardoz has spoken"); +} diff --git a/libjava/testsuite/libjava.jni/final_method.h b/libjava/testsuite/libjava.jni/final_method.h new file mode 100644 index 000000000..dbb823549 --- /dev/null +++ b/libjava/testsuite/libjava.jni/final_method.h @@ -0,0 +1,19 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ + +#include + +#ifndef __final_1method__ +#define __final_1method__ + +#ifdef __cplusplus +extern "C" +{ +#endif + +JNIEXPORT jstring JNICALL Java_final_1method_meth (JNIEnv *env, jobject); + +#ifdef __cplusplus +} +#endif + +#endif /* __final_1method__ */ diff --git a/libjava/testsuite/libjava.jni/final_method.jar b/libjava/testsuite/libjava.jni/final_method.jar new file mode 100644 index 000000000..a5f4b63f3 Binary files /dev/null and b/libjava/testsuite/libjava.jni/final_method.jar differ diff --git a/libjava/testsuite/libjava.jni/final_method.java b/libjava/testsuite/libjava.jni/final_method.java new file mode 100644 index 000000000..dcb684e08 --- /dev/null +++ b/libjava/testsuite/libjava.jni/final_method.java @@ -0,0 +1,17 @@ +// Minimal test a non-static final method. + +public class final_method +{ + static + { + System.loadLibrary ("final_method"); + } + + public final native String meth (); + + public static void main (String[] args) + { + final_method fm = new final_method (); + System.out.println (fm.meth ()); + } +} diff --git a/libjava/testsuite/libjava.jni/final_method.out b/libjava/testsuite/libjava.jni/final_method.out new file mode 100644 index 000000000..d93c9b558 --- /dev/null +++ b/libjava/testsuite/libjava.jni/final_method.out @@ -0,0 +1 @@ +zardoz has spoken diff --git a/libjava/testsuite/libjava.jni/findclass.c b/libjava/testsuite/libjava.jni/findclass.c new file mode 100644 index 000000000..1a58a55fe --- /dev/null +++ b/libjava/testsuite/libjava.jni/findclass.c @@ -0,0 +1,12 @@ +#include + +#include + +JNIEXPORT jclass JNICALL +Java_findclass_doit (JNIEnv *env, jclass klass, jstring name) +{ + const char *buf = (*env)->GetStringUTFChars (env, name, NULL); + jclass k = (*env)->FindClass (env, buf); + (*env)->ReleaseStringUTFChars (env, name, buf); + return k; +} diff --git a/libjava/testsuite/libjava.jni/findclass.h b/libjava/testsuite/libjava.jni/findclass.h new file mode 100644 index 000000000..d0d301e93 --- /dev/null +++ b/libjava/testsuite/libjava.jni/findclass.h @@ -0,0 +1,19 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ + +#include + +#ifndef __findclass__ +#define __findclass__ + +#ifdef __cplusplus +extern "C" +{ +#endif + +JNIEXPORT jclass JNICALL Java_findclass_doit (JNIEnv *env, jclass, jstring); + +#ifdef __cplusplus +} +#endif + +#endif /* __findclass__ */ diff --git a/libjava/testsuite/libjava.jni/findclass.jar b/libjava/testsuite/libjava.jni/findclass.jar new file mode 100644 index 000000000..03fe860f7 Binary files /dev/null and b/libjava/testsuite/libjava.jni/findclass.jar differ diff --git a/libjava/testsuite/libjava.jni/findclass.java b/libjava/testsuite/libjava.jni/findclass.java new file mode 100644 index 000000000..b857538e6 --- /dev/null +++ b/libjava/testsuite/libjava.jni/findclass.java @@ -0,0 +1,16 @@ +// Test FindClass part of JNI. + +public class findclass +{ + static + { + System.loadLibrary ("findclass"); + } + + public static native Class doit (String name); + + public static void main (String[] args) + { + System.out.println ("" + doit ("java/lang/String")); + } +} diff --git a/libjava/testsuite/libjava.jni/findclass.out b/libjava/testsuite/libjava.jni/findclass.out new file mode 100644 index 000000000..124026a2e --- /dev/null +++ b/libjava/testsuite/libjava.jni/findclass.out @@ -0,0 +1 @@ +class java.lang.String diff --git a/libjava/testsuite/libjava.jni/findclass2.c b/libjava/testsuite/libjava.jni/findclass2.c new file mode 100644 index 000000000..634aea710 --- /dev/null +++ b/libjava/testsuite/libjava.jni/findclass2.c @@ -0,0 +1,9 @@ +#include + +#include + +JNIEXPORT void JNICALL +Java_findclass2_searchClass (JNIEnv *env, jclass klass) +{ + (*env)->FindClass (env, "findclass2$inner"); +} diff --git a/libjava/testsuite/libjava.jni/findclass2.h b/libjava/testsuite/libjava.jni/findclass2.h new file mode 100644 index 000000000..65d074644 --- /dev/null +++ b/libjava/testsuite/libjava.jni/findclass2.h @@ -0,0 +1,19 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ + +#include + +#ifndef __findclass2__ +#define __findclass2__ + +#ifdef __cplusplus +extern "C" +{ +#endif + +JNIEXPORT void JNICALL Java_findclass2_searchClass (JNIEnv *env, jclass); + +#ifdef __cplusplus +} +#endif + +#endif /* __findclass2__ */ diff --git a/libjava/testsuite/libjava.jni/findclass2.jar b/libjava/testsuite/libjava.jni/findclass2.jar new file mode 100644 index 000000000..05f867dce Binary files /dev/null and b/libjava/testsuite/libjava.jni/findclass2.jar differ diff --git a/libjava/testsuite/libjava.jni/findclass2.java b/libjava/testsuite/libjava.jni/findclass2.java new file mode 100644 index 000000000..f7c0996e1 --- /dev/null +++ b/libjava/testsuite/libjava.jni/findclass2.java @@ -0,0 +1,24 @@ +// Test that FindClass initializes the class. + +public class findclass2 +{ + public static class inner + { + static + { + System.out.println("hello"); + } + } + + public static native void searchClass(); + + static + { + System.loadLibrary("findclass2"); + } + + public static void main(String[] args) + { + searchClass(); + } +} diff --git a/libjava/testsuite/libjava.jni/findclass2.out b/libjava/testsuite/libjava.jni/findclass2.out new file mode 100644 index 000000000..ce0136250 --- /dev/null +++ b/libjava/testsuite/libjava.jni/findclass2.out @@ -0,0 +1 @@ +hello diff --git a/libjava/testsuite/libjava.jni/iface.c b/libjava/testsuite/libjava.jni/iface.c new file mode 100644 index 000000000..6d33dc01f --- /dev/null +++ b/libjava/testsuite/libjava.jni/iface.c @@ -0,0 +1,40 @@ +#include +#include +#include + +void check (JNIEnv *); + +void check(JNIEnv *env) +{ + if ((*env)->ExceptionCheck(env) != JNI_FALSE) + { + fprintf(stderr, "UNEXPECTED EXCEPTION\n"); + exit(-1); + } +} + +void +Java_iface_doCalls (JNIEnv *env, jobject self, jobject other) +{ + jclass iface_class, comparable_class; + jmethodID iface_meth, comparable_meth; + jvalue args[1]; + + iface_class = (*env)->FindClass(env, "iface"); + check (env); + comparable_class = (*env)->FindClass (env, "mycomp"); + check (env); + + iface_meth = (*env)->GetMethodID (env, iface_class, "compareTo", + "(Ljava/lang/Object;)I"); + check (env); + comparable_meth = (*env)->GetMethodID (env, comparable_class, "compareTo", + "(Ljava/lang/Object;)I"); + check (env); + + args[0].l = other; + (*env)->CallObjectMethodA (env, self, iface_meth, args); + check (env); + (*env)->CallObjectMethodA (env, self, comparable_meth, args); + check (env); +} diff --git a/libjava/testsuite/libjava.jni/iface.h b/libjava/testsuite/libjava.jni/iface.h new file mode 100644 index 000000000..58680dd90 --- /dev/null +++ b/libjava/testsuite/libjava.jni/iface.h @@ -0,0 +1,19 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ + +#include + +#ifndef __iface__ +#define __iface__ + +#ifdef __cplusplus +extern "C" +{ +#endif + +JNIEXPORT void JNICALL Java_iface_doCalls (JNIEnv *env, jobject, jobject); + +#ifdef __cplusplus +} +#endif + +#endif /* __iface__ */ diff --git a/libjava/testsuite/libjava.jni/iface.jar b/libjava/testsuite/libjava.jni/iface.jar new file mode 100644 index 000000000..0a9a1af3c Binary files /dev/null and b/libjava/testsuite/libjava.jni/iface.jar differ diff --git a/libjava/testsuite/libjava.jni/iface.java b/libjava/testsuite/libjava.jni/iface.java new file mode 100644 index 000000000..c878ae362 --- /dev/null +++ b/libjava/testsuite/libjava.jni/iface.java @@ -0,0 +1,27 @@ +// JNI calls via an interface method were broken in a couple releases. + +interface mycomp +{ + int compareTo(Object x); +} + +public class iface implements mycomp +{ + static + { + System.loadLibrary("iface"); + } + + public int compareTo (Object x) + { + System.out.println ("hi maude"); + return 3; + } + + public native void doCalls(Object x); + + public static void main (String[] args) + { + new iface().doCalls(args); + } +} diff --git a/libjava/testsuite/libjava.jni/iface.out b/libjava/testsuite/libjava.jni/iface.out new file mode 100644 index 000000000..4eb3a1b43 --- /dev/null +++ b/libjava/testsuite/libjava.jni/iface.out @@ -0,0 +1,2 @@ +hi maude +hi maude diff --git a/libjava/testsuite/libjava.jni/init$NativeClass.h b/libjava/testsuite/libjava.jni/init$NativeClass.h new file mode 100644 index 000000000..0ae6d4cc4 --- /dev/null +++ b/libjava/testsuite/libjava.jni/init$NativeClass.h @@ -0,0 +1,19 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ + +#include + +#ifndef __init_00024NativeClass__ +#define __init_00024NativeClass__ + +#ifdef __cplusplus +extern "C" +{ +#endif + +JNIEXPORT void JNICALL Java_init_00024NativeClass_printHello (JNIEnv *env, jclass); + +#ifdef __cplusplus +} +#endif + +#endif /* __init_00024NativeClass__ */ diff --git a/libjava/testsuite/libjava.jni/init.c b/libjava/testsuite/libjava.jni/init.c new file mode 100644 index 000000000..458d6d789 --- /dev/null +++ b/libjava/testsuite/libjava.jni/init.c @@ -0,0 +1,8 @@ +#include +#include + +JNIEXPORT void JNICALL +Java_init_00024NativeClass_printHello(JNIEnv *env, jclass cl) +{ + printf("hello\n"); +} diff --git a/libjava/testsuite/libjava.jni/init.h b/libjava/testsuite/libjava.jni/init.h new file mode 100644 index 000000000..4ad329871 --- /dev/null +++ b/libjava/testsuite/libjava.jni/init.h @@ -0,0 +1,18 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ + +#include + +#ifndef __init__ +#define __init__ + +#ifdef __cplusplus +extern "C" +{ +#endif + + +#ifdef __cplusplus +} +#endif + +#endif /* __init__ */ diff --git a/libjava/testsuite/libjava.jni/init.jar b/libjava/testsuite/libjava.jni/init.jar new file mode 100644 index 000000000..1bf20ac98 Binary files /dev/null and b/libjava/testsuite/libjava.jni/init.jar differ diff --git a/libjava/testsuite/libjava.jni/init.java b/libjava/testsuite/libjava.jni/init.java new file mode 100644 index 000000000..3303d319e --- /dev/null +++ b/libjava/testsuite/libjava.jni/init.java @@ -0,0 +1,26 @@ +// Regression test for JNI and static initializers. + +public class init +{ + public static class NativeClass + { + static + { + System.out.println("static initializer 2"); + System.loadLibrary("init"); // if it's here, this app doesn't work + } + + public static native void printHello(); + } + + static + { + System.out.println("static initializer 1"); + } + + public static void main(String[] args) + { + //System.loadLibrary("test"); // if it's here, this app works + NativeClass.printHello(); + } +} diff --git a/libjava/testsuite/libjava.jni/init.out b/libjava/testsuite/libjava.jni/init.out new file mode 100644 index 000000000..4e62d1ffe --- /dev/null +++ b/libjava/testsuite/libjava.jni/init.out @@ -0,0 +1,3 @@ +static initializer 1 +static initializer 2 +hello diff --git a/libjava/testsuite/libjava.jni/invocation/PR16923.c b/libjava/testsuite/libjava.jni/invocation/PR16923.c new file mode 100644 index 000000000..881738b61 --- /dev/null +++ b/libjava/testsuite/libjava.jni/invocation/PR16923.c @@ -0,0 +1,43 @@ +#include +#include + +union env_union +{ + void *void_env; + JNIEnv *jni_env; +}; + +int +main (int argc, const char** argv) +{ + union env_union tmp; + JNIEnv* env; + JavaVM* jvm; + JavaVMInitArgs vm_args; + JavaVMOption options[1]; + jclass class_id; + jmethodID method_id; + jint result; + + options[0].optionString = "-DPR16923=optionReceived"; + + vm_args.version = JNI_VERSION_1_2; + vm_args.ignoreUnrecognized = JNI_TRUE; + vm_args.options = options; + vm_args.nOptions = 1; + + result = JNI_CreateJavaVM (&jvm, &tmp.void_env, &vm_args); + assert (result >= 0); + + env = tmp.jni_env; + + class_id = (*env)->FindClass (env, "PR16923"); + assert (class_id); + + method_id = (*env)->GetStaticMethodID (env, class_id, "printIt", "()V"); + assert (method_id); + + (*env)->CallStaticVoidMethod (env, class_id, method_id, NULL); + + return 0; +} diff --git a/libjava/testsuite/libjava.jni/invocation/PR16923.jar b/libjava/testsuite/libjava.jni/invocation/PR16923.jar new file mode 100644 index 000000000..a1a7b8804 Binary files /dev/null and b/libjava/testsuite/libjava.jni/invocation/PR16923.jar differ diff --git a/libjava/testsuite/libjava.jni/invocation/PR16923.java b/libjava/testsuite/libjava.jni/invocation/PR16923.java new file mode 100644 index 000000000..efda4bd75 --- /dev/null +++ b/libjava/testsuite/libjava.jni/invocation/PR16923.java @@ -0,0 +1,7 @@ +public class PR16923 +{ + public static void printIt () + { + System.out.println (System.getProperty ("PR16923")); + } +} diff --git a/libjava/testsuite/libjava.jni/invocation/PR16923.out b/libjava/testsuite/libjava.jni/invocation/PR16923.out new file mode 100644 index 000000000..58bf3fe19 --- /dev/null +++ b/libjava/testsuite/libjava.jni/invocation/PR16923.out @@ -0,0 +1 @@ +optionReceived diff --git a/libjava/testsuite/libjava.jni/invoke.c b/libjava/testsuite/libjava.jni/invoke.c new file mode 100644 index 000000000..c2b78d239 --- /dev/null +++ b/libjava/testsuite/libjava.jni/invoke.c @@ -0,0 +1,7 @@ +#include + +JNIEXPORT jint JNICALL +Java_invoke_val (JNIEnv *env, jclass klass) +{ + return 23; +} diff --git a/libjava/testsuite/libjava.jni/invoke.h b/libjava/testsuite/libjava.jni/invoke.h new file mode 100644 index 000000000..553c598d7 --- /dev/null +++ b/libjava/testsuite/libjava.jni/invoke.h @@ -0,0 +1,19 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ + +#include + +#ifndef __invoke__ +#define __invoke__ + +#ifdef __cplusplus +extern "C" +{ +#endif + +JNIEXPORT jint JNICALL Java_invoke_val (JNIEnv *env, jclass); + +#ifdef __cplusplus +} +#endif + +#endif /* __invoke__ */ diff --git a/libjava/testsuite/libjava.jni/invoke.jar b/libjava/testsuite/libjava.jni/invoke.jar new file mode 100644 index 000000000..dd0579740 Binary files /dev/null and b/libjava/testsuite/libjava.jni/invoke.jar differ diff --git a/libjava/testsuite/libjava.jni/invoke.java b/libjava/testsuite/libjava.jni/invoke.java new file mode 100644 index 000000000..91c9d3747 --- /dev/null +++ b/libjava/testsuite/libjava.jni/invoke.java @@ -0,0 +1,18 @@ +// Test to make sure the minimal invocation works. + +public class invoke +{ + public static native int val (); + + static + { + System.out.println ("trying..."); + System.loadLibrary ("invoke"); + System.out.println ("loaded"); + } + + public static void main (String[] args) + { + System.out.println (val ()); + } +} diff --git a/libjava/testsuite/libjava.jni/invoke.out b/libjava/testsuite/libjava.jni/invoke.out new file mode 100644 index 000000000..f59a6d2e4 --- /dev/null +++ b/libjava/testsuite/libjava.jni/invoke.out @@ -0,0 +1,3 @@ +trying... +loaded +23 diff --git a/libjava/testsuite/libjava.jni/jni.exp b/libjava/testsuite/libjava.jni/jni.exp new file mode 100644 index 000000000..c84d86f2f --- /dev/null +++ b/libjava/testsuite/libjava.jni/jni.exp @@ -0,0 +1,404 @@ +# Tests for JNI code. + +# Compile a single C file and produce a .so file. OPTIONS is a list +# of options to pass to the compiler. Returns 0 on failure, 1 on +# success. +proc gcj_jni_compile_c_to_so {file {options {}}} { + global srcdir subdir + global host_triplet + verbose "options: $options" + set options_cxx $options + set options "" + +# Apple uses a different extension for shared/dynamic libraries +# so we check against powerpc-apple-darwin and set them to +# dylib. +# HP-UX uses sl, so we check this too, otherwise we take so. + + if { [istarget "*-*-darwin*"] } { + set so_extension "dylib" + set so_flag "-dynamiclib" + } elseif { [istarget "hppa*-hp-hpux*"] } { + set so_extension "sl" + set so_flag "-shared" + } elseif { [istarget "*-*-cygwin*"] || [istarget "*-*-mingw*"] } { + set so_extension "dll" + set so_flag "-shared" + } else { + set so_extension "so" + set so_flag "-shared" + } + set filename [file tail $file] + set name [file rootname $filename] + set soname lib${name}.${so_extension} + + if { [istarget "*arm-*eabi*"] } { + lappend options "additional_flags=-fexceptions" + } + + lappend options "additional_flags=${so_flag} -fPIC" + # Find the generated header. + lappend options "additional_flags=-I. -I.. -I$srcdir/$subdir -fdollars-in-identifiers" + + # Ensure that the generated header has correct prototypes. + set cfile [file rootname $file].c + if { [file exists $cfile]} { + # This option is only valid for C sources. + lappend options "additional_flags=-Wmissing-prototypes" + } + + # Find jni.h and jni_md.h. + lappend options "additional_flags=-I$srcdir/../include -I$srcdir/../classpath/include" + + # Append C++ options + lappend options "additional_flags=$options_cxx" + + set x [libjava_prune_warnings \ + [target_compile $file $soname executable $options]] + if {$x != ""} { + verbose "target_compile failed: $x" 2 + fail "$filename compilation" + return 0 + } + + pass "$filename compilation" + return 1 +} + +# Build a header file from a .class file. Return 0 on failure. +proc gcj_jni_build_header {file} { + global libgcj_jar + + set gcjh [find_gcjh] + set file [file rootname $file] + + set cmd "$gcjh -jni -force -classpath .:$libgcj_jar $file" + verbose $cmd + + set x [string trim [libjava_prune_warnings \ + [lindex [local_exec $cmd "" "" 300] 1]]] + if {$x != ""} { + verbose "local_exec failed: $x" 2 + fail "$file header generation" + return 0 + } + + pass "$file header generation" + return 1 +} + +# Do all the work for a single JNI test. Return 0 on failure. +proc gcj_jni_test_one {file} { + global runtests + global host_triplet + global INTERPRETER + +# Apple uses a different extension for shared/dynamic libraries +# so we check against powerpc-apple-darwin and set them to +# dylib. +# HP-UX uses sl, so we check this too, otherwise we take so. + + if { [istarget "*-*-darwin*"] } { + set so_extension "dylib" + } elseif { [istarget "hppa*-hp-hpux*"] } { + set so_extension "sl" + } elseif { [istarget "*-*-cygwin*"] || [istarget "*-*-mingw*"] } { + set so_extension "dll" + } else { + set so_extension "so" + } + + # The base name. We use it for several purposes. + set main [file rootname [file tail $file]] + if {! [runtest_file_p $runtests $main] + || $main == "pr29812" || $main == "pr29812_injar"} { + # Simply skip it. + return 1 + } + +# if {! [bytecompile_file $file [pwd]]} { +# fail "bytecompile $file" +# # FIXME - should use `untested' on all remaining tests. +# # But that is hard. +# return 0 +# } +# pass "bytecompile $file" + +# set bytefile [file rootname [file tail $file]].class +# if {! [gcj_jni_build_header $bytefile]} { +# # FIXME +# return 0 +# } + + set cfile [file rootname $file].c + set cxxflags "" + set cxxldlibflags {} + # If there is no `.c' file, assume there is a `.cc' file. + if {! [file exists $cfile]} { + set cfile [file rootname $file].cc + + set cxxflaglist {} + foreach arg [split [libjava_find_lib libstdc++-v3/src stdc++] " "] { + switch -glob -- $arg { + "-L*" { + set arg [string range $arg 2 end] + lappend cxxldlibflags $arg + # Strip the `.libs' directory; we link with libtool which + # doesn't need it. + set arg "-L[file dirname $arg]" + } + } + lappend cxxflaglist $arg + # In case the libstdc++ is not installed yet, we pass the build + # directory of it to the cxxflaglist. + lappend cxxflaglist "-L$cxxldlibflags" + } + + # If you're building the compiler with --prefix set to a place + # where it's not yet installed, then the linker won't be able to + # find the libgcc used by libffi.dylib. We could pass the + # -dylib_file option, but that's complicated, and it's much easier + # to just make the linker find libgcc using -L options. + if { [istarget "*-*-darwin*"] } { + lappend cxxflaglist "-shared-libgcc -lstdc++" + } else { + lappend cxxflaglist "-lstdc++" + } + + # ARM C++ emits an ABI warning for varargs. + if { [istarget "arm*"] } { + lappend cxxflaglist "-Wno-abi" + } + + set cxxflags [join $cxxflaglist] + } + + if {! [gcj_jni_compile_c_to_so $cfile $cxxflags]} { + # FIXME + return 0 + } + + set args [list "additional_flags=-fjni"] + if {! [gcj_link $main $main $file $args]} { + # FIXME + return 0 + } + + set resultfile [file rootname $file].out + + if {! [gcj_invoke $main $resultfile $cxxldlibflags]} { + # FIXME + return 0 + } + + # We purposely ignore errors here; we still want to run the other + # appropriate tests. + set errname [file rootname [file tail $file]] + set gij [libjava_find_gij] + # libjava_find_gij will return "" if it couldn't find the + # program; in this case we want to skip the test. + # If the libraries are not installed yet, we have to pass them via + # cxxldlibflags to libjava_invoke. + if {$INTERPRETER == "yes" && $gij != ""} { + libjava_invoke $errname "gij test" opts $gij \ + "" $resultfile $cxxldlibflags \ + -classpath $file $main + } + + # When we succeed we remove all our clutter. + eval gcj_cleanup [glob -nocomplain -- ${main}.*] \ + [list $main lib${main}.${so_extension}] + + return 1 +} + +# Compile a single C file and produce a binary. OPTIONS is a list of +# options to pass to the compiler. Returns 0 on failure, 1 on +# success. +proc gcj_jni_invocation_compile_c_to_binary {file {options {}}} { + global srcdir subdir + global host_triplet + verbose "options: $options" + set options_cxx $options + set options "" + + set filename [file tail $file] + set name [file rootname $filename] + + # Set some darwin specific options + if { [istarget "*-*-darwin*"] } { + lappend options "additional_flags= -bind_at_load -multiply_defined suppress" + } + # Find the generated header. + lappend options "additional_flags=-I. -I.. -I$srcdir/$subdir" + + # Find jni.h and jni_md.h. + lappend options "additional_flags=-I$srcdir/../include -I$srcdir/../classpath/include -fdollars-in-identifiers" + + # Append C++ options + lappend options "additional_flags=$options_cxx" + + set x [libjava_prune_warnings \ + [target_compile $file $name executable $options]] + if {$x != ""} { + verbose "target_compile failed: $x" 2 + fail "$filename compilation" + return 0 + } + + pass "$filename compilation" + return 1 +} + +proc gcj_jni_get_cxxflags_invocation {} { + global libiconv + global LIBJAVA + if {$libiconv == ""} { + set libiconv "-liconv" + } + if [info exists LIBJAVA] { + set libjava $LIBJAVA; + } else { + set libjava [libjava_find_lib libjava gcj] + } + set cxxflags "$libjava -ljvm" + + # Darwin needs -liconv linked, otherwise we get some unresolved. + # If you're building the compiler with --prefix set to a place + # where it's not yet installed, then the linker won't be able to + # find the libgcc used by libffi.dylib. We could pass the + # -dylib_file option, but that's complicated, and it's much easier + # to just make the linker find libgcc using -L options. + # Similar logic applies to libgcj. + if { [istarget "*-*-darwin*"] } { + eval lappend cxxflags "-shared-libgcc -lgcj $libiconv" + } + + # Make sure libgcc unwinder is used on 64-bit Solaris 10+/x86 rather than + # the libc one. + if { [istarget "*-*-solaris*"] } { + lappend cxxflags "-shared-libgcc" + } + + # Tru64 UNIX needs -liconv linked explicitly since gcc does the linking. + if { [istarget "alpha*-dec-osf*"] } { + lappend cxxflags $libiconv + } + + return $cxxflags +} + +# Do all the work for a single invocation API test. Return 0 on +# failure. +proc gcj_jni_invocation_test_one {file} { + global env + global runtests + global host_triplet + global INTERPRETER + + # The base name. We use it for several purposes. + set main [file rootname [file tail $file]] + if {! [runtest_file_p $runtests $main]} { + # Simply skip it. + return 1 + } + +# if {! [bytecompile_file $file [pwd]]} { +# fail "bytecompile $file" +# # FIXME - should use `untested' on all remaining tests. +# # But that is hard. +# return 0 +# } +# pass "bytecompile $file" + + set cfile [file rootname $file].c + + set cxxflags [gcj_jni_get_cxxflags_invocation] + if {! [gcj_jni_invocation_compile_c_to_binary $cfile $cxxflags]} { + # FIXME + return 0 + } + + set resultfile [file rootname $file].out + + set env(CLASSPATH) $file + verbose "CLASSPATH = $env(CLASSPATH)" + if {! [gcj_invoke $main $resultfile ""]} { + unset env(CLASSPATH) + # FIXME + return 0 + } + unset env(CLASSPATH) + + # We purposely ignore errors here; we still want to run the other + # appropriate tests. + set errname [file rootname [file tail $file]] + + # When we succeed we remove all our clutter. + eval gcj_cleanup [glob -nocomplain -- ${main}.*] \ + [list $main] + + return 1 +} + +proc gcj_jni_pr29812 {} { + global srcdir subdir + global INTERPRETER runtests + + # Set up a global we need. + libjava_arguments + + set b ${srcdir}/${subdir} + + if {! [runtest_file_p $runtests pr29812]} { + # Simply skip it. + return 1 + } + + if {! [gcj_jni_compile_c_to_so $b/pr29812.c ""]} { + return 0 + } + if {! [gcj_jni_compile_c_to_so $b/pr29812_injar.c ""]} { + return 0 + } + + set gij [libjava_find_gij] + if {$INTERPRETER == "yes" && $gij != ""} { + if {! [libjava_invoke pr29812 "gij test" opts $gij \ + "" $b/pr29812.out "" \ + -classpath $b/pr29812.jar pr29812 $b/pr29812_injar.jar]} { + return 0 + } + } + + # When we succeed we remove all our clutter. + eval gcj_cleanup [glob -nocomplain -- *pr29812*] +} + +# Run the JNI tests. +proc gcj_jni_run {} { + global srcdir subdir + global build_triplet host_triplet + + # For now we only test JNI on native builds. + if {$build_triplet == $host_triplet} { + catch { lsort [glob -nocomplain ${srcdir}/${subdir}/*.jar] } srcfiles + + foreach x $srcfiles { + gcj_jni_test_one $x + } + + # Run JNI invocation API tests + catch { lsort [glob -nocomplain ${srcdir}/${subdir}/invocation/*.jar] } srcfiles + + foreach x $srcfiles { + gcj_jni_invocation_test_one $x + } + + gcj_jni_pr29812 + } else { + verbose "JNI tests not run in cross-compilation environment" + } +} + +gcj_jni_run diff --git a/libjava/testsuite/libjava.jni/jniutf.c b/libjava/testsuite/libjava.jni/jniutf.c new file mode 100644 index 000000000..1ccc7ea93 --- /dev/null +++ b/libjava/testsuite/libjava.jni/jniutf.c @@ -0,0 +1,10 @@ +#include + +JNIEXPORT void JNICALL +Java_jniutf_printString (JNIEnv *env, jobject obj, jstring str) +{ + const char *cstr; + + cstr = (*env)->GetStringUTFChars (env, str, NULL); + (*env)->ReleaseStringUTFChars (env, str, cstr); +} diff --git a/libjava/testsuite/libjava.jni/jniutf.h b/libjava/testsuite/libjava.jni/jniutf.h new file mode 100644 index 000000000..b58db2e32 --- /dev/null +++ b/libjava/testsuite/libjava.jni/jniutf.h @@ -0,0 +1,19 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ + +#include + +#ifndef __jniutf__ +#define __jniutf__ + +#ifdef __cplusplus +extern "C" +{ +#endif + +JNIEXPORT void JNICALL Java_jniutf_printString (JNIEnv *env, jobject, jstring); + +#ifdef __cplusplus +} +#endif + +#endif /* __jniutf__ */ diff --git a/libjava/testsuite/libjava.jni/jniutf.jar b/libjava/testsuite/libjava.jni/jniutf.jar new file mode 100644 index 000000000..764808c4f Binary files /dev/null and b/libjava/testsuite/libjava.jni/jniutf.jar differ diff --git a/libjava/testsuite/libjava.jni/jniutf.java b/libjava/testsuite/libjava.jni/jniutf.java new file mode 100644 index 000000000..e03e16e29 --- /dev/null +++ b/libjava/testsuite/libjava.jni/jniutf.java @@ -0,0 +1,16 @@ +public class jniutf +{ + native void printString (String str); + + static + { + System.loadLibrary ("jniutf"); + } + + public static void main (String[] args) + { + + String s1 = new String("\u3040\u3041\u3042\u3043\u3044\u3045\u3046\u3047\u3048\u3049\u304A\u304B\u304C\u304D\u304E\u304F\u3050\u3051\u3052\u3053\u3054\u3055\u3056\u3057\u3058\u3059\u305A\u305B"); + new jniutf().printString (s1); + } +} diff --git a/libjava/testsuite/libjava.jni/jniutf.out b/libjava/testsuite/libjava.jni/jniutf.out new file mode 100644 index 000000000..e69de29bb diff --git a/libjava/testsuite/libjava.jni/martin.c b/libjava/testsuite/libjava.jni/martin.c new file mode 100644 index 000000000..0fbb8d0aa --- /dev/null +++ b/libjava/testsuite/libjava.jni/martin.c @@ -0,0 +1,43 @@ +#include +#include "martin.h" +#include + +JNIEXPORT void JNICALL +Java_martin_myNative(JNIEnv* env, jobject this, jstring s) +{ + jclass cls; + jfieldID fid; + jobject obj; + jmethodID mid; + + printf("From C\n"); + fflush(stdout); + + cls = (*env)->FindClass(env, "java/lang/System"); + if (cls == 0) { + printf("java/lang/System lookup failed\n"); + return; + } + fid = (*env)->GetStaticFieldID(env, cls, "out", "Ljava/io/PrintStream;"); + if (fid == 0) { + printf("java/lang/System::out lookup failed\n"); + return; + } + obj = (*env)->GetStaticObjectField(env, cls, fid); + if (obj == 0) { + printf("GetStaticObjectField call failed\n"); + return; + } + cls = (*env)->GetObjectClass(env, obj); + if (cls == 0) { + printf("GetObjectClass(out) failed\n"); + return; + } + mid = (*env)->GetMethodID(env, cls, "println", "(Ljava/lang/String;)V"); + if (mid == 0) { + printf("println method lookup failed\n"); + return; + } + (*env)->CallVoidMethod(env, obj, mid, s); +} + diff --git a/libjava/testsuite/libjava.jni/martin.h b/libjava/testsuite/libjava.jni/martin.h new file mode 100644 index 000000000..73b6a062e --- /dev/null +++ b/libjava/testsuite/libjava.jni/martin.h @@ -0,0 +1,19 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ + +#include + +#ifndef __martin__ +#define __martin__ + +#ifdef __cplusplus +extern "C" +{ +#endif + +JNIEXPORT void JNICALL Java_martin_myNative (JNIEnv *env, jobject, jstring); + +#ifdef __cplusplus +} +#endif + +#endif /* __martin__ */ diff --git a/libjava/testsuite/libjava.jni/martin.jar b/libjava/testsuite/libjava.jni/martin.jar new file mode 100644 index 000000000..a0293a75f Binary files /dev/null and b/libjava/testsuite/libjava.jni/martin.jar differ diff --git a/libjava/testsuite/libjava.jni/martin.java b/libjava/testsuite/libjava.jni/martin.java new file mode 100644 index 000000000..b866a605c --- /dev/null +++ b/libjava/testsuite/libjava.jni/martin.java @@ -0,0 +1,21 @@ +// Test case from Martin Kahlert + +public class martin { + public native void myNative(String s); + + public void myJava(String s) { + s = s + ", Java"; + System.out.println(s); + } + + public static void main(String args[]) { + martin x = new martin(); + x.myJava("Hello"); + x.myNative("Hello, Java (from C)"); + x.myJava("Goodbye"); + } + + static { + System.loadLibrary("martin"); + } +} diff --git a/libjava/testsuite/libjava.jni/martin.out b/libjava/testsuite/libjava.jni/martin.out new file mode 100644 index 000000000..a25bc6c28 --- /dev/null +++ b/libjava/testsuite/libjava.jni/martin.out @@ -0,0 +1,4 @@ +Hello, Java +From C +Hello, Java (from C) +Goodbye, Java diff --git a/libjava/testsuite/libjava.jni/noclass.c b/libjava/testsuite/libjava.jni/noclass.c new file mode 100644 index 000000000..87c649c30 --- /dev/null +++ b/libjava/testsuite/libjava.jni/noclass.c @@ -0,0 +1,9 @@ +#include + +JNIEXPORT void JNICALL +Java_noclass_find_1it (JNIEnv *env, jclass k) +{ + /* We cause an exception by asking for a class we know does not + exist. */ + k = (*env)->FindClass (env, "java/lang/Sarcophagus"); +} diff --git a/libjava/testsuite/libjava.jni/noclass.h b/libjava/testsuite/libjava.jni/noclass.h new file mode 100644 index 000000000..67869a916 --- /dev/null +++ b/libjava/testsuite/libjava.jni/noclass.h @@ -0,0 +1,19 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ + +#include + +#ifndef __noclass__ +#define __noclass__ + +#ifdef __cplusplus +extern "C" +{ +#endif + +JNIEXPORT void JNICALL Java_noclass_find_1it (JNIEnv *env, jclass); + +#ifdef __cplusplus +} +#endif + +#endif /* __noclass__ */ diff --git a/libjava/testsuite/libjava.jni/noclass.jar b/libjava/testsuite/libjava.jni/noclass.jar new file mode 100644 index 000000000..969aa950f Binary files /dev/null and b/libjava/testsuite/libjava.jni/noclass.jar differ diff --git a/libjava/testsuite/libjava.jni/noclass.java b/libjava/testsuite/libjava.jni/noclass.java new file mode 100644 index 000000000..7e0b8c34c --- /dev/null +++ b/libjava/testsuite/libjava.jni/noclass.java @@ -0,0 +1,25 @@ +// Test to make sure JNI implementation catches exceptions. + +public class noclass +{ + static + { + System.loadLibrary ("noclass"); + } + + public static native void find_it (); + + public static void main (String[] args) + { + try + { + find_it (); + } + catch (Throwable _) + { + // If find_it() causes a crash, or doesn't throw an exception, + // we won't be running this next line. + System.out.println ("Ok"); + } + } +} diff --git a/libjava/testsuite/libjava.jni/noclass.out b/libjava/testsuite/libjava.jni/noclass.out new file mode 100644 index 000000000..7326d9603 --- /dev/null +++ b/libjava/testsuite/libjava.jni/noclass.out @@ -0,0 +1 @@ +Ok diff --git a/libjava/testsuite/libjava.jni/overload.c b/libjava/testsuite/libjava.jni/overload.c new file mode 100644 index 000000000..4e7a2d928 --- /dev/null +++ b/libjava/testsuite/libjava.jni/overload.c @@ -0,0 +1,16 @@ +#include + +JNIEXPORT jint JNICALL +Java_overload_over__I (JNIEnv *env, jclass klass, jint val) +{ + return val; +} + + +JNIEXPORT jint JNICALL +Java_overload_over__II (JNIEnv *env, jclass klass, jint one, jint two) +{ + return one + two; +} + + diff --git a/libjava/testsuite/libjava.jni/overload.h b/libjava/testsuite/libjava.jni/overload.h new file mode 100644 index 000000000..7b717cd09 --- /dev/null +++ b/libjava/testsuite/libjava.jni/overload.h @@ -0,0 +1,20 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ + +#include + +#ifndef __overload__ +#define __overload__ + +#ifdef __cplusplus +extern "C" +{ +#endif + +JNIEXPORT jint JNICALL Java_overload_over__I (JNIEnv *env, jclass, jint); +JNIEXPORT jint JNICALL Java_overload_over__II (JNIEnv *env, jclass, jint, jint); + +#ifdef __cplusplus +} +#endif + +#endif /* __overload__ */ diff --git a/libjava/testsuite/libjava.jni/overload.jar b/libjava/testsuite/libjava.jni/overload.jar new file mode 100644 index 000000000..430d3d665 Binary files /dev/null and b/libjava/testsuite/libjava.jni/overload.jar differ diff --git a/libjava/testsuite/libjava.jni/overload.java b/libjava/testsuite/libjava.jni/overload.java new file mode 100644 index 000000000..c2e6037a5 --- /dev/null +++ b/libjava/testsuite/libjava.jni/overload.java @@ -0,0 +1,18 @@ +// Test to make sure overloaded functions with long names work. + +public class overload +{ + static + { + System.loadLibrary ("overload"); + } + + public static native int over (int one); + public static native int over (int one, int two); + + public static void main (String[] args) + { + System.out.println (over (1)); + System.out.println (over (1, 2)); + } +} diff --git a/libjava/testsuite/libjava.jni/overload.out b/libjava/testsuite/libjava.jni/overload.out new file mode 100644 index 000000000..2b2f2e1b9 --- /dev/null +++ b/libjava/testsuite/libjava.jni/overload.out @@ -0,0 +1,2 @@ +1 +3 diff --git a/libjava/testsuite/libjava.jni/pr11951.c b/libjava/testsuite/libjava.jni/pr11951.c new file mode 100644 index 000000000..4c8ab63f1 --- /dev/null +++ b/libjava/testsuite/libjava.jni/pr11951.c @@ -0,0 +1,16 @@ +#include +#include + +JNIEXPORT void JNICALL +Java_pr11951_nmethod (JNIEnv *env, jclass myclass) +{ + jmethodID method; + jobject r; + + method = (*env)->GetStaticMethodID (env, myclass, "dosomething", + "()Ljava/lang/Object;"); + r = (*env)->CallStaticObjectMethod (env, myclass, method); + printf ("%d\n", r == NULL); + + (*env)->ExceptionClear (env); +} diff --git a/libjava/testsuite/libjava.jni/pr11951.h b/libjava/testsuite/libjava.jni/pr11951.h new file mode 100644 index 000000000..caeefdb85 --- /dev/null +++ b/libjava/testsuite/libjava.jni/pr11951.h @@ -0,0 +1,19 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ + +#include + +#ifndef __pr11951__ +#define __pr11951__ + +#ifdef __cplusplus +extern "C" +{ +#endif + +JNIEXPORT void JNICALL Java_pr11951_nmethod (JNIEnv *env, jclass); + +#ifdef __cplusplus +} +#endif + +#endif /* __pr11951__ */ diff --git a/libjava/testsuite/libjava.jni/pr11951.jar b/libjava/testsuite/libjava.jni/pr11951.jar new file mode 100644 index 000000000..adea29fe7 Binary files /dev/null and b/libjava/testsuite/libjava.jni/pr11951.jar differ diff --git a/libjava/testsuite/libjava.jni/pr11951.java b/libjava/testsuite/libjava.jni/pr11951.java new file mode 100644 index 000000000..e481503ab --- /dev/null +++ b/libjava/testsuite/libjava.jni/pr11951.java @@ -0,0 +1,18 @@ +public class pr11951 +{ + public static Object dosomething() + { + throw new Error(); + } + + public static native void nmethod(); + + public static void main(String[] args) + { + nmethod(); + } + + static { + System.loadLibrary("pr11951"); + } +} diff --git a/libjava/testsuite/libjava.jni/pr11951.out b/libjava/testsuite/libjava.jni/pr11951.out new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/libjava/testsuite/libjava.jni/pr11951.out @@ -0,0 +1 @@ +1 diff --git a/libjava/testsuite/libjava.jni/pr18278.c b/libjava/testsuite/libjava.jni/pr18278.c new file mode 100644 index 000000000..7ca73a430 --- /dev/null +++ b/libjava/testsuite/libjava.jni/pr18278.c @@ -0,0 +1,10 @@ +#include +#include + +#include "pr18278.h" + +jobject Java_pr18278_weakRef(JNIEnv *env, jclass cls, jobject data) +{ + jobject r = (* env)->NewWeakGlobalRef(env, data); + return r; +} diff --git a/libjava/testsuite/libjava.jni/pr18278.h b/libjava/testsuite/libjava.jni/pr18278.h new file mode 100644 index 000000000..4003fef37 --- /dev/null +++ b/libjava/testsuite/libjava.jni/pr18278.h @@ -0,0 +1,19 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ + +#include + +#ifndef __pr18278__ +#define __pr18278__ + +#ifdef __cplusplus +extern "C" +{ +#endif + +JNIEXPORT jobject JNICALL Java_pr18278_weakRef (JNIEnv *env, jclass, jobject); + +#ifdef __cplusplus +} +#endif + +#endif /* __pr18278__ */ diff --git a/libjava/testsuite/libjava.jni/pr18278.jar b/libjava/testsuite/libjava.jni/pr18278.jar new file mode 100644 index 000000000..c1bf1489a Binary files /dev/null and b/libjava/testsuite/libjava.jni/pr18278.jar differ diff --git a/libjava/testsuite/libjava.jni/pr18278.java b/libjava/testsuite/libjava.jni/pr18278.java new file mode 100644 index 000000000..8a39ddebf --- /dev/null +++ b/libjava/testsuite/libjava.jni/pr18278.java @@ -0,0 +1,13 @@ +public class pr18278 { + public pr18278() {} + + public static void main(String[] args) { + System.loadLibrary("pr18278"); + String bob = "Bob"; + Object o = weakRef("Bob"); + System.out.println(o); + System.out.println(bob == o); + } + + static native Object weakRef(Object o); +} diff --git a/libjava/testsuite/libjava.jni/pr18278.out b/libjava/testsuite/libjava.jni/pr18278.out new file mode 100644 index 000000000..e01142a4a --- /dev/null +++ b/libjava/testsuite/libjava.jni/pr18278.out @@ -0,0 +1,2 @@ +Bob +true diff --git a/libjava/testsuite/libjava.jni/pr23739.c b/libjava/testsuite/libjava.jni/pr23739.c new file mode 100644 index 000000000..0f6bfbefe --- /dev/null +++ b/libjava/testsuite/libjava.jni/pr23739.c @@ -0,0 +1,12 @@ +#include +#include "pr23739.h" + +JNIEXPORT void JNICALL +Java_pr23739_checkOrder (JNIEnv *env, jclass cls, jclass clazz1, jclass clazz2) +{ + printf ("B extends A\n"); + printf ("isAssignableFrom (A, B): %d\n", + (*env)->IsAssignableFrom (env, clazz1, clazz2)); + printf ("isAssignableFrom (B, A): %d\n", + (*env)->IsAssignableFrom (env, clazz2, clazz1)); +} diff --git a/libjava/testsuite/libjava.jni/pr23739.h b/libjava/testsuite/libjava.jni/pr23739.h new file mode 100644 index 000000000..70f228c8c --- /dev/null +++ b/libjava/testsuite/libjava.jni/pr23739.h @@ -0,0 +1,19 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ + +#include + +#ifndef __pr23739__ +#define __pr23739__ + +#ifdef __cplusplus +extern "C" +{ +#endif + +JNIEXPORT void JNICALL Java_pr23739_checkOrder (JNIEnv *env, jclass, jclass, jclass); + +#ifdef __cplusplus +} +#endif + +#endif /* __pr23739__ */ diff --git a/libjava/testsuite/libjava.jni/pr23739.jar b/libjava/testsuite/libjava.jni/pr23739.jar new file mode 100644 index 000000000..d8370461b Binary files /dev/null and b/libjava/testsuite/libjava.jni/pr23739.jar differ diff --git a/libjava/testsuite/libjava.jni/pr23739.java b/libjava/testsuite/libjava.jni/pr23739.java new file mode 100644 index 000000000..b2e54c548 --- /dev/null +++ b/libjava/testsuite/libjava.jni/pr23739.java @@ -0,0 +1,22 @@ +public class pr23739 +{ + static + { + System.loadLibrary ("pr23739"); + } + + public static class A + { + } + + public static class B extends A + { + } + + static native void checkOrder (Class clazz1, Class clazz2); + + public static void main (String[] args) + { + checkOrder (A.class, B.class); + } +} diff --git a/libjava/testsuite/libjava.jni/pr23739.out b/libjava/testsuite/libjava.jni/pr23739.out new file mode 100644 index 000000000..3e94564c2 --- /dev/null +++ b/libjava/testsuite/libjava.jni/pr23739.out @@ -0,0 +1,3 @@ +B extends A +isAssignableFrom (A, B): 0 +isAssignableFrom (B, A): 1 diff --git a/libjava/testsuite/libjava.jni/pr29812.c b/libjava/testsuite/libjava.jni/pr29812.c new file mode 100644 index 000000000..809d5ed2e --- /dev/null +++ b/libjava/testsuite/libjava.jni/pr29812.c @@ -0,0 +1,7 @@ +#include + +void +Java_pr29812_baseN (JNIEnv *env, jclass barf) +{ + /* nothing */ +} diff --git a/libjava/testsuite/libjava.jni/pr29812.h b/libjava/testsuite/libjava.jni/pr29812.h new file mode 100644 index 000000000..70d199938 --- /dev/null +++ b/libjava/testsuite/libjava.jni/pr29812.h @@ -0,0 +1,19 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ + +#include + +#ifndef __pr29812__ +#define __pr29812__ + +#ifdef __cplusplus +extern "C" +{ +#endif + +JNIEXPORT void JNICALL Java_pr29812_baseN (JNIEnv *env, jclass); + +#ifdef __cplusplus +} +#endif + +#endif /* __pr29812__ */ diff --git a/libjava/testsuite/libjava.jni/pr29812.jar b/libjava/testsuite/libjava.jni/pr29812.jar new file mode 100644 index 000000000..c3cf6aba0 Binary files /dev/null and b/libjava/testsuite/libjava.jni/pr29812.jar differ diff --git a/libjava/testsuite/libjava.jni/pr29812.java b/libjava/testsuite/libjava.jni/pr29812.java new file mode 100644 index 000000000..4dde744be --- /dev/null +++ b/libjava/testsuite/libjava.jni/pr29812.java @@ -0,0 +1,25 @@ +import java.io.File; +import java.net.*; +import java.lang.reflect.Method; + +public class pr29812 +{ + static { + System.loadLibrary("pr29812"); + } + + public static native void baseN(); + + public static void main(String[] args) throws Throwable + { + // Make sure JNI environment is initialized. + baseN(); + + File jar = new File(args[0]); + URL u = jar.toURL(); + URLClassLoader uc = new URLClassLoader(new URL[] { u }); + Class k = uc.loadClass("pr29812_injar"); + Method m = k.getMethod("doit", (Class[]) null); + m.invoke(null, (Object[]) null); + } +} diff --git a/libjava/testsuite/libjava.jni/pr29812.out b/libjava/testsuite/libjava.jni/pr29812.out new file mode 100644 index 000000000..e69de29bb diff --git a/libjava/testsuite/libjava.jni/pr29812_injar.c b/libjava/testsuite/libjava.jni/pr29812_injar.c new file mode 100644 index 000000000..5b045ce72 --- /dev/null +++ b/libjava/testsuite/libjava.jni/pr29812_injar.c @@ -0,0 +1,26 @@ + +#include +#include +#include + +JNIEXPORT jint JNICALL +JNI_OnLoad (JavaVM *vm, void *nothing) +{ + JNIEnv *env; + jint r; + jclass k; + + r = (*vm)->GetEnv (vm, (void **) &env, JNI_VERSION_1_2); + assert (r == JNI_OK); + k = (*env)->FindClass (env, "pr29812_injar$inner"); + assert (k != NULL); + + return JNI_VERSION_1_2; +} + +void +Java_pr29812_1injar_doit (JNIEnv *env, jclass b) +{ + jclass k = (*env)->FindClass(env, "pr29812_injar$inner"); + assert (k != NULL); +} diff --git a/libjava/testsuite/libjava.jni/pr29812_injar.h b/libjava/testsuite/libjava.jni/pr29812_injar.h new file mode 100644 index 000000000..40f74ff39 --- /dev/null +++ b/libjava/testsuite/libjava.jni/pr29812_injar.h @@ -0,0 +1,19 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ + +#include + +#ifndef __pr29812_1injar__ +#define __pr29812_1injar__ + +#ifdef __cplusplus +extern "C" +{ +#endif + +JNIEXPORT void JNICALL Java_pr29812_1injar_doit (JNIEnv *env, jclass); + +#ifdef __cplusplus +} +#endif + +#endif /* __pr29812_1injar__ */ diff --git a/libjava/testsuite/libjava.jni/pr29812_injar.jar b/libjava/testsuite/libjava.jni/pr29812_injar.jar new file mode 100644 index 000000000..438dc0063 Binary files /dev/null and b/libjava/testsuite/libjava.jni/pr29812_injar.jar differ diff --git a/libjava/testsuite/libjava.jni/pr29812_injar.java b/libjava/testsuite/libjava.jni/pr29812_injar.java new file mode 100644 index 000000000..9dc32a3cd --- /dev/null +++ b/libjava/testsuite/libjava.jni/pr29812_injar.java @@ -0,0 +1,12 @@ +public class pr29812_injar +{ + public class inner + { + } + + static { + System.loadLibrary("pr29812_injar"); + } + + public static native void doit(); +} diff --git a/libjava/testsuite/libjava.jni/register.c b/libjava/testsuite/libjava.jni/register.c new file mode 100644 index 000000000..049090242 --- /dev/null +++ b/libjava/testsuite/libjava.jni/register.c @@ -0,0 +1,32 @@ +#include +#include +#include + +static jint +some_random_name (JNIEnv *env, jclass k, jint v) +{ + return v - 1; +} + +JNIEXPORT jint JNICALL +JNI_OnLoad (JavaVM *vm, void *nothing) +{ + JNIEnv *env; + JNINativeMethod meth; + jclass k; + jint r; + + r = (*vm)->GetEnv (vm, (void **) &env, JNI_VERSION_1_2); + assert (r == JNI_OK); + k = (*env)->FindClass (env, "register"); + assert (k != NULL); + + meth.name = "doit"; + meth.signature = "(I)I"; + meth.fnPtr = some_random_name; + + r = (*env)->RegisterNatives (env, k, &meth, 1); + assert (r == JNI_OK); + + return JNI_VERSION_1_2; +} diff --git a/libjava/testsuite/libjava.jni/register.h b/libjava/testsuite/libjava.jni/register.h new file mode 100644 index 000000000..85b606be8 --- /dev/null +++ b/libjava/testsuite/libjava.jni/register.h @@ -0,0 +1,19 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ + +#include + +#ifndef __register__ +#define __register__ + +#ifdef __cplusplus +extern "C" +{ +#endif + +JNIEXPORT jint JNICALL Java_register_doit (JNIEnv *env, jclass, jint); + +#ifdef __cplusplus +} +#endif + +#endif /* __register__ */ diff --git a/libjava/testsuite/libjava.jni/register.jar b/libjava/testsuite/libjava.jni/register.jar new file mode 100644 index 000000000..e8682e1a0 Binary files /dev/null and b/libjava/testsuite/libjava.jni/register.jar differ diff --git a/libjava/testsuite/libjava.jni/register.java b/libjava/testsuite/libjava.jni/register.java new file mode 100644 index 000000000..0c0cbf628 --- /dev/null +++ b/libjava/testsuite/libjava.jni/register.java @@ -0,0 +1,16 @@ +// register.java - Test RegisterNatives. + +public class register +{ + static + { + System.loadLibrary ("register"); + } + + public static native int doit (int z); + + public static void main (String[] args) + { + System.out.println (doit (24)); + } +} diff --git a/libjava/testsuite/libjava.jni/register.out b/libjava/testsuite/libjava.jni/register.out new file mode 100644 index 000000000..409940768 --- /dev/null +++ b/libjava/testsuite/libjava.jni/register.out @@ -0,0 +1 @@ +23 diff --git a/libjava/testsuite/libjava.jni/register2.c b/libjava/testsuite/libjava.jni/register2.c new file mode 100644 index 000000000..318e4d8f4 --- /dev/null +++ b/libjava/testsuite/libjava.jni/register2.c @@ -0,0 +1,48 @@ +#include +#include +#include + +static int +twentythree (JNIEnv *env, jclass k) +{ + return 23; +} + +static int +oneninetyseven (JNIEnv *env, jclass k) +{ + return 197; +} + +JNIEXPORT jint JNICALL +JNI_OnLoad (JavaVM *vm, void *nothing) +{ + JNIEnv *env; + JNINativeMethod meth; + jclass k; + jint r; + + r = (*vm)->GetEnv (vm, (void **) &env, JNI_VERSION_1_2); + assert (r == JNI_OK); + k = (*env)->FindClass (env, "register2$I1"); + assert (k != NULL); + + meth.name = "doit"; + meth.signature = "()I"; + meth.fnPtr = twentythree; + + r = (*env)->RegisterNatives (env, k, &meth, 1); + assert (r == JNI_OK); + + k = (*env)->FindClass (env, "register2$I2"); + assert (k != NULL); + + meth.name = "doit"; + meth.signature = "()I"; + meth.fnPtr = oneninetyseven; + + r = (*env)->RegisterNatives (env, k, &meth, 1); + assert (r == JNI_OK); + + return JNI_VERSION_1_2; +} diff --git a/libjava/testsuite/libjava.jni/register2.jar b/libjava/testsuite/libjava.jni/register2.jar new file mode 100644 index 000000000..807524cdc Binary files /dev/null and b/libjava/testsuite/libjava.jni/register2.jar differ diff --git a/libjava/testsuite/libjava.jni/register2.java b/libjava/testsuite/libjava.jni/register2.java new file mode 100644 index 000000000..2d6c56a3b --- /dev/null +++ b/libjava/testsuite/libjava.jni/register2.java @@ -0,0 +1,27 @@ +// Another test of RegisterNatives. +// We neglected to track the class name in our internal hash table. +// This is a regression test for the fix. + +public class register2 +{ + static + { + System.loadLibrary ("register2"); + } + + static class I1 + { + public static native int doit (); + } + + static class I2 + { + public static native int doit (); + } + + public static void main (String[] args) + { + System.out.println (new I1().doit()); + System.out.println (new I2().doit()); + } +} diff --git a/libjava/testsuite/libjava.jni/register2.out b/libjava/testsuite/libjava.jni/register2.out new file mode 100644 index 000000000..5b90358a2 --- /dev/null +++ b/libjava/testsuite/libjava.jni/register2.out @@ -0,0 +1,2 @@ +23 +197 diff --git a/libjava/testsuite/libjava.jni/simple_int.c b/libjava/testsuite/libjava.jni/simple_int.c new file mode 100644 index 000000000..a7c64b0cd --- /dev/null +++ b/libjava/testsuite/libjava.jni/simple_int.c @@ -0,0 +1,7 @@ +#include + +JNIEXPORT jint JNICALL +Java_simple_1int_nat (JNIEnv *env, jclass klass, jint val) +{ + return 2 * val; +} diff --git a/libjava/testsuite/libjava.jni/simple_int.h b/libjava/testsuite/libjava.jni/simple_int.h new file mode 100644 index 000000000..b0b9b579a --- /dev/null +++ b/libjava/testsuite/libjava.jni/simple_int.h @@ -0,0 +1,19 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ + +#include + +#ifndef __simple_1int__ +#define __simple_1int__ + +#ifdef __cplusplus +extern "C" +{ +#endif + +JNIEXPORT jint JNICALL Java_simple_1int_nat (JNIEnv *env, jclass, jint); + +#ifdef __cplusplus +} +#endif + +#endif /* __simple_1int__ */ diff --git a/libjava/testsuite/libjava.jni/simple_int.jar b/libjava/testsuite/libjava.jni/simple_int.jar new file mode 100644 index 000000000..1f0bdc67c Binary files /dev/null and b/libjava/testsuite/libjava.jni/simple_int.jar differ diff --git a/libjava/testsuite/libjava.jni/simple_int.java b/libjava/testsuite/libjava.jni/simple_int.java new file mode 100644 index 000000000..6306c4e93 --- /dev/null +++ b/libjava/testsuite/libjava.jni/simple_int.java @@ -0,0 +1,16 @@ +// Test a simple static function with an `int' argument. + +public class simple_int +{ + public static native int nat (int z); + + static + { + System.loadLibrary ("simple_int"); + } + + public static void main (String[] args) + { + System.out.println (nat (23)); + } +} diff --git a/libjava/testsuite/libjava.jni/simple_int.out b/libjava/testsuite/libjava.jni/simple_int.out new file mode 100644 index 000000000..9e5feb525 --- /dev/null +++ b/libjava/testsuite/libjava.jni/simple_int.out @@ -0,0 +1 @@ +46 diff --git a/libjava/testsuite/libjava.jni/throwit.c b/libjava/testsuite/libjava.jni/throwit.c new file mode 100644 index 000000000..34a3ca076 --- /dev/null +++ b/libjava/testsuite/libjava.jni/throwit.c @@ -0,0 +1,25 @@ +#include +#include + +JNIEXPORT void JNICALL +Java_throwit_throwit (JNIEnv *env, jclass klass, jstring name, + jboolean is_new) +{ + const char *buf = (*env)->GetStringUTFChars (env, name, NULL); + jclass k = (*env)->FindClass (env, buf); + (*env)->ReleaseStringUTFChars (env, name, buf); + + if (k == NULL || (*env)->ExceptionCheck (env)) + return; + + if (is_new) + (*env)->ThrowNew (env, k, "the word is zardoz"); + else + { + jmethodID id = (*env)->GetMethodID (env, k, "", + "(Ljava.lang.String;)V"); + jstring z = (*env)->NewStringUTF (env, "zardoz is the word"); + jobject obj = (*env)->NewObject (env, k, id, z); + (*env)->Throw (env, obj); + } +} diff --git a/libjava/testsuite/libjava.jni/throwit.h b/libjava/testsuite/libjava.jni/throwit.h new file mode 100644 index 000000000..97c7223f7 --- /dev/null +++ b/libjava/testsuite/libjava.jni/throwit.h @@ -0,0 +1,19 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ + +#include + +#ifndef __throwit__ +#define __throwit__ + +#ifdef __cplusplus +extern "C" +{ +#endif + +JNIEXPORT void JNICALL Java_throwit_throwit (JNIEnv *env, jclass, jstring, jboolean); + +#ifdef __cplusplus +} +#endif + +#endif /* __throwit__ */ diff --git a/libjava/testsuite/libjava.jni/throwit.jar b/libjava/testsuite/libjava.jni/throwit.jar new file mode 100644 index 000000000..9fc43b9d8 Binary files /dev/null and b/libjava/testsuite/libjava.jni/throwit.jar differ diff --git a/libjava/testsuite/libjava.jni/throwit.java b/libjava/testsuite/libjava.jni/throwit.java new file mode 100644 index 000000000..459622d39 --- /dev/null +++ b/libjava/testsuite/libjava.jni/throwit.java @@ -0,0 +1,33 @@ +// Test to see if throw works. + +public class throwit +{ + static + { + System.loadLibrary ("throwit"); + } + + public static native void throwit (String name, boolean is_new); + + public static void main (String[] args) + { + try + { + throwit ("java/lang/UnknownError", false); + } + catch (Throwable x) + { + System.out.println (x.getClass ()); + System.out.println (x.getMessage ()); + } + try + { + throwit ("java/lang/Throwable", true); + } + catch (Throwable x) + { + System.out.println (x.getClass ()); + System.out.println (x.getMessage ()); + } + } +} diff --git a/libjava/testsuite/libjava.jni/throwit.out b/libjava/testsuite/libjava.jni/throwit.out new file mode 100644 index 000000000..c50b7a9ab --- /dev/null +++ b/libjava/testsuite/libjava.jni/throwit.out @@ -0,0 +1,4 @@ +class java.lang.UnknownError +zardoz is the word +class java.lang.Throwable +the word is zardoz diff --git a/libjava/testsuite/libjava.jni/virtual.c b/libjava/testsuite/libjava.jni/virtual.c new file mode 100644 index 000000000..024697083 --- /dev/null +++ b/libjava/testsuite/libjava.jni/virtual.c @@ -0,0 +1,7 @@ +#include + +JNIEXPORT jboolean JNICALL +Java_virtual_equals (JNIEnv *env, jobject thisv, jobject other) +{ + return JNI_FALSE; +} diff --git a/libjava/testsuite/libjava.jni/virtual.h b/libjava/testsuite/libjava.jni/virtual.h new file mode 100644 index 000000000..7d9ef8246 --- /dev/null +++ b/libjava/testsuite/libjava.jni/virtual.h @@ -0,0 +1,19 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ + +#include + +#ifndef __virtual__ +#define __virtual__ + +#ifdef __cplusplus +extern "C" +{ +#endif + +JNIEXPORT jboolean JNICALL Java_virtual_equals (JNIEnv *env, jobject, jobject); + +#ifdef __cplusplus +} +#endif + +#endif /* __virtual__ */ diff --git a/libjava/testsuite/libjava.jni/virtual.jar b/libjava/testsuite/libjava.jni/virtual.jar new file mode 100644 index 000000000..dd4090b9b Binary files /dev/null and b/libjava/testsuite/libjava.jni/virtual.jar differ diff --git a/libjava/testsuite/libjava.jni/virtual.java b/libjava/testsuite/libjava.jni/virtual.java new file mode 100644 index 000000000..496389ce5 --- /dev/null +++ b/libjava/testsuite/libjava.jni/virtual.java @@ -0,0 +1,17 @@ +// Minimal test of a virtual method. + +public class virtual +{ + static + { + System.loadLibrary ("virtual"); + } + + public native boolean equals (Object obj); + + public static void main (String[] args) + { + Object v = new virtual (); + System.out.println (v.equals (v)); + } +} diff --git a/libjava/testsuite/libjava.jni/virtual.out b/libjava/testsuite/libjava.jni/virtual.out new file mode 100644 index 000000000..c508d5366 --- /dev/null +++ b/libjava/testsuite/libjava.jni/virtual.out @@ -0,0 +1 @@ +false -- cgit v1.2.3