* Merged with f9adc5b4d7f0.
authorChristian Thalinger <twisti@complang.tuwien.ac.at>
Sat, 26 Apr 2008 14:42:44 +0000 (16:42 +0200)
committerChristian Thalinger <twisti@complang.tuwien.ac.at>
Sat, 26 Apr 2008 14:42:44 +0000 (16:42 +0200)
.hgignore
configure.ac
src/native/vm/gnu/java_lang_reflect_VMMethod.c
src/vm/vm.c
tests/regression/Makefile.am
tests/regression/bugzilla/Makefile.am
tests/regression/clinitexception.2output [deleted file]
tests/regression/clinitexception.java [deleted file]
tests/regression/junit/All.java [new file with mode: 0644]
tests/regression/junit/Makefile.am [new file with mode: 0644]
tests/regression/junit/TestExceptionInStaticClassInitializer.java [new file with mode: 0644]

index 751e5c858c8e804c4327135d019a2d30bb09425f..4f4ca6e213bf6b7d315deac3a6c56c207591b9cb 100644 (file)
--- a/.hgignore
+++ b/.hgignore
@@ -46,6 +46,7 @@ tests/regression/assertion/packagetest/*.class
 tests/regression/bugzilla/*.class
 tests/regression/codepatching/*.class
 tests/regression/jasmin/*.class
+tests/regression/junit/*.class
 tests/regression/native/*.class
 tests/regression/native/*.h
 tests/regression/native/*.so
index 670e163d6a76cb28b87ad0d34c1f97243ff28358..ffc382ec84dd059d0b8556917f8fae019fe7ef45 100644 (file)
@@ -922,6 +922,7 @@ AC_CONFIG_FILES([Makefile]
                [tests/regression/codepatching/Makefile]
                [tests/regression/assertion/Makefile]
                [tests/regression/jasmin/Makefile]
+               [tests/regression/junit/Makefile]
                [tests/regression/native/Makefile]
                [tests/regression/resolving/Makefile]
                [tests/regression/resolving/classes1/Makefile]
index e86c28046aa5493b8fa6ae6a25f4f971cc7cbd4a..8b1853f06237cfa4e10a9f4909ceb914593647a9 100644 (file)
@@ -244,6 +244,8 @@ JNIEXPORT struct java_lang_Object* JNICALL Java_java_lang_reflect_VMMethod_getDe
        java_lang_Class          *constantPoolOop = NULL;            /* methods declaring class                           */
        classinfo                *referer         = NULL;            /* class, which calles the annotation parser         */
                                                                     /* (for the parameter 'referer' of vm_call_method()) */
+       java_lang_reflect_Method* rm;
+       java_handle_t*            h;
 
        if (this == NULL) {
                exceptions_throw_nullpointerexception();
@@ -289,11 +291,12 @@ JNIEXPORT struct java_lang_Object* JNICALL Java_java_lang_reflect_VMMethod_getDe
                }
        }
 
+       LLNI_field_get_ref(this, m,                 rm);
        LLNI_field_get_ref(this, annotationDefault, annotationDefault);
 
-       return (java_lang_Object*)vm_call_method(
-               m_parseAnnotationDefault, NULL,
-               this, annotationDefault, constantPool);
+       h = vm_call_method(m_parseAnnotationDefault, NULL, rm, annotationDefault, constantPool);
+
+       return (java_lang_Object*) h;
 }
 
 
index 4888eb3a3d1666035a8e54067bd8026941368ae1..b2a0a7eaa25a743178c9704e4f36af906ba1852c 100644 (file)
@@ -2240,7 +2240,8 @@ static char *vm_get_mainclass_from_jar(char *mainstring)
        o = vm_call_method(m, o, s);
 
        if (o == NULL) {
-               exceptions_print_stacktrace();
+               fprintf(stderr, "Failed to load Main-Class manifest attribute from\n");
+               fprintf(stderr, "%s\n", mainstring);
                return NULL;
        }
 
index c62ecbd2caf597081401058e2d750ea17237796c..6bd7697ebdd35f09eaf5b69956ada4eca3931cd0 100644 (file)
@@ -26,6 +26,7 @@ SUBDIRS = \
        bugzilla \
        codepatching \
        jasmin \
+       junit \
        native \
        resolving
 
@@ -39,7 +40,6 @@ SOURCE_FILES = \
        $(srcdir)/fptest.java \
        $(srcdir)/fp.java \
        $(srcdir)/extest.java \
-       $(srcdir)/clinitexception.java \
        $(srcdir)/LoadDisplacementOverflow.java \
        $(srcdir)/FieldDisplacementOverflow.java \
        $(srcdir)/StackDisplacementOverflow.java \
@@ -54,7 +54,6 @@ EXTRA_DIST = \
        fptest.output \
        fp.output\
        extest.2output \
-       clinitexception.2output \
        LoadDisplacementOverflow.output \
        FieldDisplacementOverflow.output \
        StackDisplacementOverflow.output \
@@ -74,7 +73,6 @@ OUTPUT_JAVA_TESTS = \
        fp \
        extest \
        \
-       clinitexception \
        LoadDisplacementOverflow \
        FieldDisplacementOverflow \
        StackDisplacementOverflow \
@@ -84,7 +82,7 @@ OUTPUT_JAVA_TESTS = \
 check: build $(SIMPLE_JAVA_TESTS) $(OUTPUT_JAVA_TESTS)
 
 build:
-       @$(JAVACCMD) -d . $(SOURCE_FILES)
+       $(JAVACCMD) -d . $(SOURCE_FILES)
 
 $(SIMPLE_JAVA_TESTS):
        @echo "$@: "
index dc3d2b624693ef71cf22b4a0e3ba1ff236d432c2..7d38821cdc442367ed9c4933a31880ee6403087e 100644 (file)
@@ -32,10 +32,10 @@ CLEANFILES = \
        *.class
 
 build:
-       $(JAVACCMD) -cp /usr/share/java/junit4.jar -d . $(srcdir)/*.java
+       $(JAVACCMD) -classpath /usr/share/java/junit4.jar -d . $(srcdir)/*.java
 
 check: build
-       $(JAVACMD) -cp /usr/share/java/junit4.jar:. org.junit.runner.JUnitCore All
+       $(JAVACMD) -classpath /usr/share/java/junit4.jar:. org.junit.runner.JUnitCore All
 
 
 ## Local variables:
diff --git a/tests/regression/clinitexception.2output b/tests/regression/clinitexception.2output
deleted file mode 100644 (file)
index 9f6a360..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-Exception in thread "main" java.lang.ExceptionInInitializerError
-   <<No stacktrace available>>
-Caused by: java.lang.RuntimeException
-   at clinitexception.<clinit>(clinitexception.java:4)
diff --git a/tests/regression/clinitexception.java b/tests/regression/clinitexception.java
deleted file mode 100644 (file)
index aa75bc4..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-public class clinitexception {
-    static {
-        if (true)
-            throw new RuntimeException();
-    }
-
-    public static void main(String[] argv) {
-    }
-}
diff --git a/tests/regression/junit/All.java b/tests/regression/junit/All.java
new file mode 100644 (file)
index 0000000..0135353
--- /dev/null
@@ -0,0 +1,51 @@
+/* tests/regression/junit/All.java - runs all CACAO regression unit tests
+
+   Copyright (C) 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+
+   This file is part of CACAO.
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2, or (at
+   your option) any later version.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+*/
+
+
+import junit.framework.*;
+import junit.textui.*;
+
+public class All extends TestCase {
+    /**
+     * Runs all CACAO regression unit tests using
+     * junit.textui.TestRunner
+     */
+    public static void main(String[] args) {
+        Test s = suite();
+        TestRunner.run(s);
+    }
+
+    /**
+     * Collects all CACAO regression unit tests as one suite.
+     */
+    public static Test suite() {
+        TestSuite suite = new TestSuite("CACAO Regression Unit Tests");
+
+        // Add your test here.
+
+        suite.addTest(new TestSuite(TestExceptionInStaticClassInitializer.class));
+
+        return suite;
+    }
+}
diff --git a/tests/regression/junit/Makefile.am b/tests/regression/junit/Makefile.am
new file mode 100644 (file)
index 0000000..31b78a2
--- /dev/null
@@ -0,0 +1,47 @@
+## tests/regression/junit/Makefile.am
+##
+## Copyright (C) 2008
+## CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+##
+## This file is part of CACAO.
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License as
+## published by the Free Software Foundation; either version 2, or (at
+## your option) any later version.
+##
+## This program is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+## General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+## 02110-1301, USA.
+
+
+JAVA     = LD_LIBRARY_PATH=$(top_builddir)/src/cacao/.libs $(top_builddir)/src/cacao/cacao
+JAVACMD  = $(JAVA) -Xbootclasspath:$(BOOTCLASSPATH)
+JAVACCMD = $(JAVAC) -bootclasspath $(BOOTCLASSPATH)
+
+EXTRA_DIST = \
+       *.java
+
+CLEANFILES = \
+       *.class
+
+build:
+       $(JAVACCMD) -classpath /usr/share/java/junit4.jar -d . $(srcdir)/*.java
+
+check: build
+       $(JAVACMD) -classpath /usr/share/java/junit4.jar:. org.junit.runner.JUnitCore All
+
+
+## Local variables:
+## mode: Makefile
+## indent-tabs-mode: t
+## c-basic-offset: 4
+## tab-width: 8
+## compile-command: "automake --add-missing"
+## End:
diff --git a/tests/regression/junit/TestExceptionInStaticClassInitializer.java b/tests/regression/junit/TestExceptionInStaticClassInitializer.java
new file mode 100644 (file)
index 0000000..e6cc93e
--- /dev/null
@@ -0,0 +1,66 @@
+/* tests/regression/bugzilla/TestExceptionInStaticClassInitializer.java
+
+   Copyright (C) 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+
+   This file is part of CACAO.
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2, or (at
+   your option) any later version.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+*/
+
+
+import junit.framework.*;
+import junit.textui.*;
+
+public class TestExceptionInStaticClassInitializer extends TestCase {
+    public static void main(String[] args) {
+        TestRunner.run(suite());
+    }
+
+    public static Test suite() {
+        return new TestSuite(TestExceptionInStaticClassInitializer.class);
+    }
+
+    public void test() {
+        try {
+            TestExceptionInStaticClassInitializer_x.i = 1;
+            fail("Should throw ExceptionInInitializerError");
+        }
+        catch (ExceptionInInitializerError success) {
+            Throwable cause = success.getCause();
+
+            assertTrue("Cause should be RuntimeException but is " + cause.getClass(), cause.getClass() == RuntimeException.class);
+
+            StackTraceElement[] ste = cause.getStackTrace();
+
+            assertTrue("Linenumber should be " + LINE + " but is " + ste[0].getLineNumber(), ste[0].getLineNumber() == LINE);
+        }
+    }
+
+    // This linenumber must be the one from...
+    final static int LINE = 64;
+}
+
+class TestExceptionInStaticClassInitializer_x {
+    static int i;
+
+    static {
+        if (true)
+            // ...the following line.
+            throw new RuntimeException();
+    }
+}