Signed-off-by: Tomek Grabiec <tgrab...@gmail.com>
---
 .gitignore                     |    2 +
 Makefile                       |    8 +++++-
 regression/jni/Makefile        |   17 +++++++++++++
 regression/jni/jvm_JNITest.cpp |   14 ++++++++++
 regression/jvm/JNITest.java    |   53 ++++++++++++++++++++++++++++++++++++++++
 regression/run-suite.sh        |    3 ++
 6 files changed, 96 insertions(+), 1 deletions(-)
 create mode 100644 regression/jni/Makefile
 create mode 100644 regression/jni/jvm_JNITest.cpp
 create mode 100644 regression/jvm/JNITest.java

diff --git a/.gitignore b/.gitignore
index 71ca5b0..96439a9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,6 +10,7 @@
 # Generated include files
 #
 include/vm/arch.h
+regression/jni/jvm_JNITest.h
 
 #
 # Generated source files
@@ -31,6 +32,7 @@ test/arch-x86/x86-test-runner
 test/jit/jit-test-runner
 test/vm/vm-test-runner
 tools/classpath-config
+regression/jni/libjnitest.so
 
 #
 # ctags generated files
diff --git a/Makefile b/Makefile
index 1cdc587..361f327 100644
--- a/Makefile
+++ b/Makefile
@@ -244,6 +244,7 @@ REGRESSION_TEST_SUITE_CLASSES = \
        regression/jvm/InterfaceInheritanceTest.java \
        regression/jvm/InvokeinterfaceTest.java \
        regression/jvm/InvokestaticPatchingTest.java \
+       regression/jvm/JNITest.java \
        regression/jvm/LoadConstantsTest.java \
        regression/jvm/LongArithmeticExceptionsTest.java \
        regression/jvm/LongArithmeticTest.java \
@@ -273,6 +274,10 @@ JASMIN_REGRESSION_TEST_SUITE_CLASSES = \
        regression/jvm/SubroutineTest.j \
        regression/jvm/WideTest.j
 
+
+jni-regression: java-regression
+       make -C regression/jni
+
 java-regression: FORCE
        $(E) "  JAVAC"
        $(Q) $(JAVAC) -cp $(GLIBJ):regression $(JAVAC_OPTS) -d regression 
$(REGRESSION_TEST_SUITE_CLASSES)
@@ -291,7 +296,7 @@ lib: $(CLASSPATH_CONFIG)
        make -C lib/ JAVAC=$(JAVAC) GLIBJ=$(GLIBJ)
 .PHONY: lib
 
-regression: monoburg $(CLASSPATH_CONFIG) $(PROGRAM) java-regression 
jasmin-regression
+regression: monoburg $(CLASSPATH_CONFIG) $(PROGRAM) java-regression 
jasmin-regression jni-regression
        $(E) "  REGRESSION"
        $(Q) cd regression && /bin/bash run-suite.sh $(JAVA_OPTS)
 .PHONY: regression
@@ -318,6 +323,7 @@ clean:
        $(Q) - make -C test/vm/ clean
        $(Q) - make -C test/jit/ clean
        $(Q) - make -C test/arch-$(ARCH)/ clean
+       $(Q) - make -C regression/jni/ clean
 .PHONY: clean
 
 INSTALL_PREFIX ?= $(HOME)
diff --git a/regression/jni/Makefile b/regression/jni/Makefile
new file mode 100644
index 0000000..339d93d
--- /dev/null
+++ b/regression/jni/Makefile
@@ -0,0 +1,17 @@
+all: libjnitest.so
+
+CXX    := g++
+JAVAH  := javah
+
+jvm_JNITest.h:
+       $(E) "  JAVAH   " $@
+       $(Q) $(JAVAH) -jni -classpath .. jvm.JNITest
+
+libjnitest.so: jvm_JNITest.cpp jvm_JNITest.h
+       $(E) "  CXX     " $@
+       $(Q) $(CXX) -I`../../tools/classpath-config`/include -g 
-fomit-frame-pointer -o $@ -shared jvm_JNITest.cpp
+
+clean:
+       rm -f libjnitest.so
+       rm -f jvm_JNITest.h
+.PHONY: clean
diff --git a/regression/jni/jvm_JNITest.cpp b/regression/jni/jvm_JNITest.cpp
new file mode 100644
index 0000000..f1dd5dd
--- /dev/null
+++ b/regression/jni/jvm_JNITest.cpp
@@ -0,0 +1,14 @@
+#include "jvm_JNITest.h"
+
+/*
+ * Class:     jvm_JNITest
+ * Method:    nativeTestThrow
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_jvm_JNITest_nativeTestThrow
+  (JNIEnv *env, jclass clazz)
+{
+       jclass e_clazz = env->FindClass("java/lang/Exception");
+       env->ThrowNew(e_clazz, "test");
+       env->ThrowNew(e_clazz, "test2");
+}
diff --git a/regression/jvm/JNITest.java b/regression/jvm/JNITest.java
new file mode 100644
index 0000000..fa11ae1
--- /dev/null
+++ b/regression/jvm/JNITest.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2009 Tomasz Grabiec
+ *
+ * This file is released under the GPL version 2 with the following
+ * clarification and special exception:
+ *
+ *     Linking this library statically or dynamically with other modules is
+ *     making a combined work based on this library. Thus, the terms and
+ *     conditions of the GNU General Public License cover the whole
+ *     combination.
+ *
+ *     As a special exception, the copyright holders of this library give you
+ *     permission to link this library with independent modules to produce an
+ *     executable, regardless of the license terms of these independent
+ *     modules, and to copy and distribute the resulting executable under terms
+ *     of your choice, provided that you also meet, for each linked independent
+ *     module, the terms and conditions of the license of that module. An
+ *     independent module is a module which is not derived from or based on
+ *     this library. If you modify this library, you may extend this exception
+ *     to your version of the library, but you are not obligated to do so. If
+ *     you do not wish to do so, delete this exception statement from your
+ *     version.
+ *
+ * Please refer to the file LICENSE for details.
+ */
+package jvm;
+
+class JNITest extends TestCase {
+       public static native void nativeTestThrow();
+
+       public static void testThrow() {
+               boolean caught = false;
+
+               try {
+                       nativeTestThrow();
+               } catch (Exception e) {
+                       assertObjectEquals("test2", e.getMessage());
+                       caught = true;
+               }
+
+               assertTrue(caught);
+       }
+
+       public static void main(String []args) {
+               try {
+                       System.loadLibrary("jnitest");
+               } catch (Exception e) {
+                       fail();
+               }
+
+               testThrow();
+       }
+}
diff --git a/regression/run-suite.sh b/regression/run-suite.sh
index c3f6f7e..5ae8b52 100755
--- a/regression/run-suite.sh
+++ b/regression/run-suite.sh
@@ -23,6 +23,8 @@ if test x"$GNU_CLASSPATH_ROOT" = x -o ! -d 
"$GNU_CLASSPATH_ROOT"; then
   exit
 fi
 
+LD_LIBRARY_PATH=$LD_LIBRARY_PATH:`pwd`/jni/
+
 while [ "$#" -ge 1 ]; do
     case "$1" in 
        -t)
@@ -66,6 +68,7 @@ if [ -z "$CLASS_LIST" ]; then
     run_java jvm.InterfaceInheritanceTest 0
     run_java jvm.InvokeinterfaceTest 0
     run_java jvm.InvokestaticPatchingTest 0
+    run_java jvm.JNITest 0
     run_java jvm.LoadConstantsTest 0
     run_java jvm.LongArithmeticExceptionsTest 0
     run_java jvm.LongArithmeticTest 0
-- 
1.6.0.6


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Jatovm-devel mailing list
Jatovm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jatovm-devel

Reply via email to