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]

[gcjx] Patch: FYI: verifier fixes


I'm checking this in on the gcjx branch.

This fixes a couple of minor bugs relating to bytecode verification in
gcjx.

Tom

2005-03-27  Tom Tromey  <tromey@redhat.com>

	* verify.h (vfy_find_class): Handle both forms of signature.
	(vfy_has_method): Ensure class members resolved.

Index: verify.h
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/Attic/verify.h,v
retrieving revision 1.1.2.4
diff -u -r1.1.2.4 verify.h
--- verify.h 3 Apr 2005 23:39:54 -0000 1.1.2.4
+++ verify.h 3 Apr 2005 23:53:11 -0000
@@ -180,9 +180,31 @@
 inline vfy_jclass vfy_find_class (vfy_method *method, vfy_jclass,
 				  vfy_string name)
 {
-  return method->unit->find_class_from_descriptor (method->scope,
-						   method->method,
-						   name);
+  int array_count = 0;
+  int offset = 0;
+  int len = strlen (name);
+
+  for (; offset < len && name[offset] == '['; ++offset)
+    ++array_count;
+
+  // FIXME: throw error...
+  if (offset == len)
+    return NULL;
+
+  int nlen = len - offset;
+  if (name[offset] == 'L' && name[len - 1] == ';')
+    {
+      ++offset;
+      nlen -= 2;
+    }
+  std::string name_str (name, offset, nlen);
+  vfy_jclass result = method->unit->find_class_from_descriptor (method->scope,
+								method->method,
+								name_str);
+  while (array_count-- > 0)
+    result = result->array ();
+
+  return result;
 }
 
 /**
@@ -195,6 +217,7 @@
                             vfy_string method_descriptor)
 {
   model_class *klass = assert_cast<model_class *> (k);
+  klass->resolve_members ();
   return klass->has_method_with_descriptor_p (method_name, method_descriptor);
 }
 
Index: bytecode/verify.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/bytecode/Attic/verify.cc,v
retrieving revision 1.1.2.4
diff -u -r1.1.2.4 verify.cc
--- bytecode/verify.cc 3 Apr 2005 23:39:55 -0000 1.1.2.4
+++ bytecode/verify.cc 3 Apr 2005 23:53:15 -0000
@@ -2960,7 +2960,8 @@
 	    {
 	      type t = check_class_constant (get_ushort ());
 	      if (t.isarray () || t.isinterface (this) || t.isabstract (this))
-		verify_fail ("type for 'new' is array, interface, or abstract");
+		verify_fail ("type for 'new' is array, interface, "
+			     "or abstract");
 	      t.set_uninitialized (start_PC, this);
 	      push_type (t);
 	    }


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