From 3ffa3729c00a1d9ddd52a89813ccd31b28b552f5 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Fri, 8 Jul 2005 19:13:30 +0000 Subject: verify.cc (class _Jv_BytecodeVerifier): Don't check for abstract classes or interfaces here... 2005-07-06 Colin Walters * verify.cc (class _Jv_BytecodeVerifier) : 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 | 8 ++++++++ libjava/interpret.cc | 5 +++++ libjava/verify.cc | 4 ++-- 3 files changed, 15 insertions(+), 2 deletions(-) (limited to 'libjava') diff --git a/libjava/ChangeLog b/libjava/ChangeLog index cf84f1a..8183d0c 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,11 @@ +2005-07-06 Colin Walters + + * verify.cc (class _Jv_BytecodeVerifier) : 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 * posix-threads.cc (_Jv_ThreadSetPriority): Use SCHED_OTHER diff --git a/libjava/interpret.cc b/libjava/interpret.cc index 8b46dc6..dcda95e 100644 --- a/libjava/interpret.cc +++ b/libjava/interpret.cc @@ -30,6 +30,7 @@ details. */ #include #include #include +#include #include #include #include @@ -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); diff --git a/libjava/verify.cc b/libjava/verify.cc index 167d74c..3869bff 100644 --- a/libjava/verify.cc +++ b/libjava/verify.cc @@ -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); } -- cgit v1.1