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: verifier -vs- boolean arrays


I'm checking this in.

The verifier didn't handle boolean arrays correctly.
To the VM these are the same as byte arrays, and both baload and
bastore must have special handling.
This patch fixes the problem.

Also this adds another error handling improvement.

Tom

Index: ChangeLog
from  Tom Tromey  <tromey@redhat.com>
	* verify.cc (_Jv_BytecodeVerifier::require_array_type): Special
	case for boolean arrays.

	* verify.cc (_Jv_BytecodeVerifier::compute_jump): Put PC into
	error message.

Index: verify.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/verify.cc,v
retrieving revision 1.14
diff -u -r1.14 verify.cc
--- verify.cc 2001/11/19 18:28:28 1.14
+++ verify.cc 2001/11/20 00:36:45
@@ -28,7 +28,6 @@
 
 // TO DO
 // * read more about when classes must be loaded
-// * there are bugs with boolean arrays?
 // * class loader madness
 // * Lots and lots of debugging and testing
 // * type representation is still ugly.  look for the big switches
@@ -951,7 +950,18 @@
 
     type t = array.element_type ();
     if (! element.compatible (t))
-      verify_fail ("incompatible array element type");
+      {
+	// Special case for byte arrays, which must also be boolean
+	// arrays.
+	bool ok = true;
+	if (element.key == byte_type)
+	  {
+	    type e2 (boolean_type);
+	    ok = e2.compatible (t);
+	  }
+	if (! ok)
+	  verify_fail ("incompatible array element type");
+      }
 
     // Return T and not ELEMENT, because T might be specialized.
     return t;
@@ -992,7 +1002,7 @@
   {
     int npc = start_PC + offset;
     if (npc < 0 || npc >= current_method->code_length)
-      verify_fail ("branch out of range");
+      verify_fail ("branch out of range", start_PC);
     return npc;
   }
 


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