Class file generated by "gcj -C" throws ClassFormatError

Per Bothner per@bothner.com
Mon Jun 25 15:43:00 GMT 2001


Tom Tromey <tromey@redhat.com> writes:
> I've also noticed that `gcj --syntax-only foo.class' does not give an
> error here. I think it ought to. I often run `gcj --syntax-only' on
> a .class file to do checking; for instance it is an easy way to check
> that the output of `gcj -C' is sensible.

Here is a patch to fix this. Since this causes bootstrapping to fail
(AWTEvent.class contaisn the error), I don't think I'll check it in
quite yet ...
Index: class.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/class.c,v
retrieving revision 1.99
diff -u -p -r1.99 class.c
--- class.c	2001年06月21日 03:20:04	1.99
+++ class.c	2001年06月25日 22:36:16
@@ -751,6 +751,12 @@ set_constant_value (field, constant)
 else
 {
 DECL_INITIAL (field) = constant;
+ if (TREE_TYPE (constant) != TREE_TYPE (field)
+	 && ! (TREE_TYPE (constant) == int_type_node
+		&& INTEGRAL_TYPE_P (TREE_TYPE (field))
+		&& TYPE_PRECISION (TREE_TYPE (field)) <= 32))
+	error ("ConstantValue attribute of field '%s' has wrong type",
+	 IDENTIFIER_POINTER (DECL_NAME (field)));
 if (FIELD_FINAL (field))
 	DECL_FIELD_FINAL_IUD (field) = 1;
 }
-- 
	--Per Bothner
per@bothner.com http://www.bothner.com/per/


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /