This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Patch: FYI: Another verifier fix


I'm checking this in.

We were handling anewarray like multianewarray.  That is wrong; the
latter takes the name of the array class as its argument whereas the
former uses the name of the array element class.  An odd asymmetry.

Tom

Index: ChangeLog
from  Tom Tromey  <tromey@redhat.com>
	* verify.cc (type::to_array): New method.
	(_Jv_BytecodeVerifier::verify_instructions_0) [op_anewarray]:
	Construct new array type.

Index: verify.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/verify.cc,v
retrieving revision 1.12
diff -u -r1.12 verify.cc
--- verify.cc 2001/11/19 02:13:08 1.12
+++ verify.cc 2001/11/19 07:05:04
@@ -491,6 +491,23 @@
       return type (k);
     }
 
+    // Return the array type corresponding to an initialized
+    // reference.  We could expand this to work for other kinds of
+    // types, but currently we don't need to.
+    type to_array ()
+    {
+      // Resolving isn't ideal, because it might force us to load
+      // another class, but it's easy.  FIXME?
+      if (key == unresolved_reference_type)
+	resolve ();
+
+      if (key == reference_type)
+	return type (_Jv_GetArrayClass (data.klass,
+					data.klass->getClassLoader ()));
+      else
+	verify_fail ("internal error in type::to_array()");
+    }
+
     bool isreference () const
     {
       return key >= reference_type;
@@ -2426,7 +2443,7 @@
 	    break;
 	  case op_anewarray:
 	    pop_type (int_type);
-	    push_type (check_class_constant (get_ushort ()));
+	    push_type (check_class_constant (get_ushort ()).to_array ());
 	    break;
 	  case op_arraylength:
 	    {


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]