verify.cc (class _Jv_BytecodeVerifier): Don't check for abstract classes or interface...
authorColin Walters <walters@verbum.org>
Fri, 8 Jul 2005 19:13:30 +0000 (19:13 +0000)
committerTom Tromey <tromey@gcc.gnu.org>
Fri, 8 Jul 2005 19:13:30 +0000 (19:13 +0000)
2005-07-06  Colin Walters  <walters@verbum.org>

* verify.cc (class _Jv_BytecodeVerifier) <op_new>: Don't
check for abstract classes or interfaces here; JVM spec
says it should throw an exception, so we'll do so later.
* interpret.cc (run): Throw an InstantiationException for
abstract classes and interfaces.

From-SVN: r101788

libjava/ChangeLog
libjava/interpret.cc
libjava/verify.cc

index cf84f1a9d00f1b2c7facfaab4a6b5b3834feee27..8183d0c9fd127ef234a7a824c5ffe77ef4c046e2 100644 (file)
@@ -1,3 +1,11 @@
+2005-07-06  Colin Walters  <walters@verbum.org>
+
+       * verify.cc (class _Jv_BytecodeVerifier) <op_new>: Don't
+       check for abstract classes or interfaces here; JVM spec
+       says it should throw an exception, so we'll do so later.
+       * interpret.cc (run): Throw an InstantiationException for
+       abstract classes and interfaces.
+
 2005-07-08  Andrew Haley  <aph@redhat.com>
 
         * posix-threads.cc (_Jv_ThreadSetPriority): Use SCHED_OTHER
index 8b46dc6fa4a2112eb226f75123026a06d415d598..dcda95e64de71a9c3921e22d11f5ded63830dc4b 100644 (file)
@@ -30,6 +30,7 @@ details.  */
 #include <java/lang/NullPointerException.h>
 #include <java/lang/ArithmeticException.h>
 #include <java/lang/IncompatibleClassChangeError.h>
+#include <java/lang/InstantiationException.h>
 #include <java/lang/Thread.h>
 #include <java-insns.h>
 #include <java-signal.h>
@@ -2942,6 +2943,10 @@ _Jv_InterpMethod::run (void *retp, ffi_raw *args, _Jv_InterpMethod *meth)
        int index = GET2U ();
        jclass klass = (_Jv_Linker::resolve_pool_entry (meth->defining_class,
                                                          index)).clazz;
+       /* VM spec, section 3.11.5 */
+       if ((klass->getModifiers() & Modifier::ABSTRACT)
+           || klass->isInterface())
+         throw new java::lang::InstantiationException;
        jobject res = _Jv_AllocObject (klass);
        PUSHA (res);
 
index 167d74cf8f6390ccfd1db36b8b8d98364727e350..3869bffd50201e8af103cad658a868ac1229761d 100644 (file)
@@ -2926,8 +2926,8 @@ private:
          case op_new:
            {
              type t = check_class_constant (get_ushort ());
-             if (t.isarray () || t.isinterface (this) || t.isabstract (this))
-               verify_fail ("type is array, interface, or abstract");
+             if (t.isarray ())
+               verify_fail ("type is array");
              t.set_uninitialized (start_PC, this);
              push_type (t);
            }