This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
FYI: Fix PR 17020
- From: Bryce McKinlay <mckinlay at redhat dot com>
- To: java-patches at gcc dot gnu dot org
- Date: Fri, 13 Aug 2004 13:51:33 -0400
- Subject: FYI: Fix PR 17020
According to the VM spec, gij should not throw an error when it sees
method or field flags that it doesn't recognise in a class file. I'm
checking in this patch.
Regards
Bryce.
2004-08-13 Bryce McKinlay <mckinlay@redhat.com>
PR libgcj/17020
Reported by Robin Green.
* defineclass.cc (handleField): Don't throw exception on unrecognised
modifier. Add FIXME comments for spec compliance.
(handleMethod): Likewise.
Index: defineclass.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/defineclass.cc,v
retrieving revision 1.39
diff -u -r1.39 defineclass.cc
--- defineclass.cc 12 Aug 2004 06:53:40 -0000 1.39
+++ defineclass.cc 13 Aug 2004 17:48:10 -0000
@@ -1096,16 +1096,15 @@
throw_class_format_error ("duplicate field name");
}
- if (field->flags & (Modifier::SYNCHRONIZED
- | Modifier::NATIVE
- | Modifier::INTERFACE
- | Modifier::ABSTRACT))
- throw_class_format_error ("erroneous field access flags");
-
+ // At most one of PUBLIC, PRIVATE, or PROTECTED is allowed.
if (1 < ( ((field->flags & Modifier::PUBLIC) ? 1 : 0)
+((field->flags & Modifier::PRIVATE) ? 1 : 0)
+((field->flags & Modifier::PROTECTED) ? 1 : 0)))
throw_class_format_error ("erroneous field access flags");
+
+ // FIXME: JVM spec S4.5: Verify ACC_FINAL and ACC_VOLATILE are not
+ // both set. Verify modifiers for interface fields.
+
}
if (verify)
@@ -1256,15 +1255,15 @@
throw_class_format_error ("duplicate method");
}
- if (method->accflags & (Modifier::VOLATILE
- | Modifier::TRANSIENT
- | Modifier::INTERFACE))
- throw_class_format_error ("erroneous method access flags");
-
+ // At most one of PUBLIC, PRIVATE, or PROTECTED is allowed.
if (1 < ( ((method->accflags & Modifier::PUBLIC) ? 1 : 0)
+((method->accflags & Modifier::PRIVATE) ? 1 : 0)
+((method->accflags & Modifier::PROTECTED) ? 1 : 0)))
throw_class_format_error ("erroneous method access flags");
+
+ // FIXME: JVM spec S4.6: if ABSTRACT modifier is set, verify other
+ // flags are not set. Verify flags for interface methods. Verifiy
+ // modifiers for initializers.
}
}