summaryrefslogtreecommitdiff
path: root/libjava/testsuite
diff options
context:
space:
mode:
authortromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2007-01-22 23:04:16 +0000
committertromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2007-01-22 23:04:16 +0000
commit1e30399304705675a8255728ea937f6a3e37af69 (patch)
tree5a65b021fa1dfa6c969e6de00c7e6ecfad3b93d9 /libjava/testsuite
parent874f8dfb8568a5f5e2a080a3a7ebc14d71817eea (diff)
downloadgcc-1e30399304705675a8255728ea937f6a3e37af69.tar.gz
PR java/29812:
* testsuite/libjava.jni/pr29812.java: New file. * testsuite/libjava.jni/pr29812_injar.java: New file. * testsuite/libjava.jni/pr29812_injar.jar: New file. * testsuite/libjava.jni/pr29812.out: New file. * testsuite/libjava.jni/pr29812_injar.c: New file. * testsuite/libjava.jni/pr29812_injar.h: New file. * testsuite/libjava.jni/pr29812.jar: New file. * testsuite/libjava.jni/pr29812.c: New file. * testsuite/libjava.jni/pr29812.h: New file. * testsuite/libjava.jni/jni.exp (gcj_jni_get_cxxflags_invocation): New proc. (gcj_jni_invocation_test_one): Use it. (gcj_jni_pr29812): New proc. (gcj_jni_run): Use it. * java/lang/natRuntime.cc (_load): Push a new system frame before calling JNI_OnLoad. * include/jvm.h (_Jv_JNI_PopSystemFrame): Declare. (_Jv_GetJNIEnvNewFrameWithLoader): Likewise. * jni.cc (struct _Jv_JNI_LocalFrame) <marker>: Now unsigned char. <allocated_p>: Now bool. <loader>: New field. (_Jv_JNI_EnsureLocalCapacity): Updated. (_Jv_JNI_NewLocalRef): Likewise. (_Jv_JNI_NewLocalRef): Likewise. (_Jv_JNI_PopLocalFrame): Likewise. (_Jv_JNI_FindClass): Likewise. (_Jv_GetJNIEnvNewFrame): Likewise. (_Jv_JNI_AttachCurrentThread): Likewise. (_Jv_GetJNIEnvNewFrameWithLoader): New function. (_Jv_GetJNIEnvNewFrame): Use it. * include/jni_md.h (_CLASSPATH_JNIENV_CONTENTS): Removed 'klass'. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@121064 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/testsuite')
-rw-r--r--libjava/testsuite/libjava.jni/jni.exp89
-rw-r--r--libjava/testsuite/libjava.jni/pr29812.c7
-rw-r--r--libjava/testsuite/libjava.jni/pr29812.h19
-rw-r--r--libjava/testsuite/libjava.jni/pr29812.jarbin0 -> 964 bytes
-rw-r--r--libjava/testsuite/libjava.jni/pr29812.java25
-rw-r--r--libjava/testsuite/libjava.jni/pr29812.out0
-rw-r--r--libjava/testsuite/libjava.jni/pr29812_injar.c26
-rw-r--r--libjava/testsuite/libjava.jni/pr29812_injar.h19
-rw-r--r--libjava/testsuite/libjava.jni/pr29812_injar.jarbin0 -> 1045 bytes
-rw-r--r--libjava/testsuite/libjava.jni/pr29812_injar.java12
10 files changed, 174 insertions, 23 deletions
diff --git a/libjava/testsuite/libjava.jni/jni.exp b/libjava/testsuite/libjava.jni/jni.exp
index 5fa6edefb71..1fff2b2f019 100644
--- a/libjava/testsuite/libjava.jni/jni.exp
+++ b/libjava/testsuite/libjava.jni/jni.exp
@@ -101,7 +101,8 @@ proc gcj_jni_test_one {file} {
# The base name. We use it for several purposes.
set main [file rootname [file tail $file]]
- if {! [runtest_file_p $runtests $main]} {
+ if {! [runtest_file_p $runtests $main]
+ || $main == "pr29812" || $main == "pr29812_injar"} {
# Simply skip it.
return 1
}
@@ -235,6 +236,33 @@ proc gcj_jni_invocation_compile_c_to_binary {file {options {}}} {
return 1
}
+proc gcj_jni_get_cxxflags_invocation {} {
+ # 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*"] } {
+ set cxxflags "-L../.libs -shared-libgcc -ljvm -lgcj -liconv"
+ } else {
+ global LIBJAVA
+ if [info exists LIBJAVA] {
+ set libjava $LIBJAVA;
+ } else {
+ set libjava [libjava_find_lib libjava gcj]
+ }
+ set cxxflags "$libjava -ljvm"
+ }
+
+ if { [istarget "*-*-solaris*"] } {
+ lappend cxxflags "-lsocket"
+ }
+
+ return $cxxflags
+}
+
# Do all the work for a single invocation API test. Return 0 on
# failure.
proc gcj_jni_invocation_test_one {file} {
@@ -259,29 +287,8 @@ proc gcj_jni_invocation_test_one {file} {
# pass "bytecompile $file"
set cfile [file rootname $file].c
- # 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*"] } {
- set cxxflags "-L../.libs -shared-libgcc -ljvm -lgcj -liconv"
- } else {
- global LIBJAVA
- if [info exists LIBJAVA] {
- set libjava $LIBJAVA;
- } else {
- set libjava [libjava_find_lib libjava gcj]
- }
- set cxxflags "$libjava -ljvm"
- }
-
- if { [istarget "*-*-solaris*"] } {
- lappend cxxflags "-lsocket"
- }
+ set cxxflags [gcj_jni_get_cxxflags_invocation]
if {! [gcj_jni_invocation_compile_c_to_binary $cfile $cxxflags]} {
# FIXME
return 0
@@ -309,6 +316,40 @@ proc gcj_jni_invocation_test_one {file} {
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
@@ -328,6 +369,8 @@ proc gcj_jni_run {} {
foreach x $srcfiles {
gcj_jni_invocation_test_one $x
}
+
+ gcj_jni_pr29812
} else {
verbose "JNI tests not run in cross-compilation environment"
}
diff --git a/libjava/testsuite/libjava.jni/pr29812.c b/libjava/testsuite/libjava.jni/pr29812.c
new file mode 100644
index 00000000000..809d5ed2e80
--- /dev/null
+++ b/libjava/testsuite/libjava.jni/pr29812.c
@@ -0,0 +1,7 @@
+#include <pr29812.h>
+
+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 00000000000..70d19993831
--- /dev/null
+++ b/libjava/testsuite/libjava.jni/pr29812.h
@@ -0,0 +1,19 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#include <jni.h>
+
+#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 00000000000..c3cf6aba0b5
--- /dev/null
+++ b/libjava/testsuite/libjava.jni/pr29812.jar
Binary files differ
diff --git a/libjava/testsuite/libjava.jni/pr29812.java b/libjava/testsuite/libjava.jni/pr29812.java
new file mode 100644
index 00000000000..4dde744bee3
--- /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 00000000000..e69de29bb2d
--- /dev/null
+++ b/libjava/testsuite/libjava.jni/pr29812.out
diff --git a/libjava/testsuite/libjava.jni/pr29812_injar.c b/libjava/testsuite/libjava.jni/pr29812_injar.c
new file mode 100644
index 00000000000..5b045ce72a8
--- /dev/null
+++ b/libjava/testsuite/libjava.jni/pr29812_injar.c
@@ -0,0 +1,26 @@
+
+#include <stdlib.h>
+#include <assert.h>
+#include <pr29812_injar.h>
+
+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 00000000000..40f74ff393f
--- /dev/null
+++ b/libjava/testsuite/libjava.jni/pr29812_injar.h
@@ -0,0 +1,19 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#include <jni.h>
+
+#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 00000000000..438dc0063b5
--- /dev/null
+++ b/libjava/testsuite/libjava.jni/pr29812_injar.jar
Binary files differ
diff --git a/libjava/testsuite/libjava.jni/pr29812_injar.java b/libjava/testsuite/libjava.jni/pr29812_injar.java
new file mode 100644
index 00000000000..9dc32a3cdcd
--- /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();
+}