From bf36271421a9abf13baa8b6446d447fdd381d60d Mon Sep 17 00:00:00 2001 From: Christian Thalinger Date: Fri, 21 Mar 2008 12:48:00 +0100 Subject: [PATCH] Fixes PR52. * src/vm/array.c (array_objectarray_element_set): Use builtin_canstore. * .hgignore (tests/regression/assertion/*.class) (tests/regression/assertion/packagetest/*.class) (tests/regression/bugzilla/*.class): Added. * configure.ac (AC_CONFIG_FILES): Added tests/regression/bugzilla/Makefile. * tests/regression/Makefile.am (SUBDIRS): Added bugzilla. * tests/regression/bugzilla/All.java: New file. * tests/regression/bugzilla/Makefile.am: Likewise. * tests/regression/bugzilla/PR52.java: Likewise. --- .hgignore | 3 ++ configure.ac | 1 + src/vm/array.c | 23 ++++-------- tests/regression/Makefile.am | 1 + tests/regression/bugzilla/All.java | 51 +++++++++++++++++++++++++++ tests/regression/bugzilla/Makefile.am | 47 ++++++++++++++++++++++++ tests/regression/bugzilla/PR52.java | 44 +++++++++++++++++++++++ 7 files changed, 154 insertions(+), 16 deletions(-) create mode 100644 tests/regression/bugzilla/All.java create mode 100644 tests/regression/bugzilla/Makefile.am create mode 100644 tests/regression/bugzilla/PR52.java diff --git a/.hgignore b/.hgignore index 9db53cfce..751e5c858 100644 --- a/.hgignore +++ b/.hgignore @@ -41,6 +41,9 @@ src/native/include/*.h src/scripts/java tests/*.class tests/regression/*.class +tests/regression/assertion/*.class +tests/regression/assertion/packagetest/*.class +tests/regression/bugzilla/*.class tests/regression/codepatching/*.class tests/regression/jasmin/*.class tests/regression/native/*.class diff --git a/configure.ac b/configure.ac index fcbd64940..0677557d8 100644 --- a/configure.ac +++ b/configure.ac @@ -906,6 +906,7 @@ AC_CONFIG_FILES([Makefile] [src/vmcore/Makefile] [tests/Makefile] [tests/regression/Makefile] + [tests/regression/bugzilla/Makefile] [tests/regression/codepatching/Makefile] [tests/regression/assertion/Makefile] [tests/regression/jasmin/Makefile] diff --git a/src/vm/array.c b/src/vm/array.c index f19177ac1..30f231d3e 100644 --- a/src/vm/array.c +++ b/src/vm/array.c @@ -304,30 +304,21 @@ void array_##name##array_element_set(java_handle_##name##array_t *a, int32_t ind void array_objectarray_element_set(java_handle_objectarray_t *a, int32_t index, java_handle_t *value) { - arraydescriptor *ad; - classinfo *cc; - int32_t size; + int32_t size; if (a == NULL) { exceptions_throw_nullpointerexception(); return; } - /* TODO Write inline functions for that and use LLNI. */ - - LLNI_CRITICAL_START; - - ad = a->header.objheader.vftbl->arraydesc; - cc = ad->componentvftbl->class; + /* Sanity check. */ - LLNI_CRITICAL_END; + assert(a->header.objheader.vftbl->arraydesc->arraytype == ARRAYTYPE_OBJECT); - if (ad->arraytype == ARRAYTYPE_OBJECT) { - if (value != NULL) { - if (builtin_instanceof(value, cc) == false) { - exceptions_throw_illegalargumentexception(); - return; - } + if (value != NULL) { + if (builtin_canstore(a, value) == false) { + exceptions_throw_illegalargumentexception(); + return; } } diff --git a/tests/regression/Makefile.am b/tests/regression/Makefile.am index 6e2d5656b..c62ecbd2c 100644 --- a/tests/regression/Makefile.am +++ b/tests/regression/Makefile.am @@ -23,6 +23,7 @@ SUBDIRS = \ assertion \ + bugzilla \ codepatching \ jasmin \ native \ diff --git a/tests/regression/bugzilla/All.java b/tests/regression/bugzilla/All.java new file mode 100644 index 000000000..6b1efa05f --- /dev/null +++ b/tests/regression/bugzilla/All.java @@ -0,0 +1,51 @@ +/* tests/regression/bugzilla/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(PR52.class)); + + return suite; + } +} diff --git a/tests/regression/bugzilla/Makefile.am b/tests/regression/bugzilla/Makefile.am new file mode 100644 index 000000000..d9ba79ad1 --- /dev/null +++ b/tests/regression/bugzilla/Makefile.am @@ -0,0 +1,47 @@ +## tests/regression/bugzilla/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 = $(top_builddir)/src/cacao/cacao +JAVACMD = $(JAVA) -Xbootclasspath:$(BOOTCLASSPATH) +JAVACCMD = $(JAVAC) -bootclasspath $(BOOTCLASSPATH) + +EXTRA_DIST = \ + *.java + +CLEANFILES = \ + *.class + +build: + $(JAVACCMD) -cp /usr/share/java/junit4.jar -d . *.java + +check: build + LD_LIBRARY_PATH=$(top_builddir)/src/cacao/.libs $(JAVACMD) -cp /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/bugzilla/PR52.java b/tests/regression/bugzilla/PR52.java new file mode 100644 index 000000000..fae85f1ca --- /dev/null +++ b/tests/regression/bugzilla/PR52.java @@ -0,0 +1,44 @@ +/* tests/regression/bugzilla/PR52.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.*; + +import java.security.*; + +public class PR52 extends TestCase { + public static void main(String[] args) { + TestRunner.run(suite()); + } + + public static Test suite() { + return new TestSuite(PR52.class); + } + + public void test() { + // This one only triggers with GNU Classpath. + AccessController.getContext(); + } +} -- 2.25.1