This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH to only emit ConstantValue attribute when allowed
- To: gcc-patches at gcc dot gnu dot org, java-patches dot gcc dot gnu dot org at eureka dot bothner dot com
- Subject: PATCH to only emit ConstantValue attribute when allowed
- From: Per Bothner <per at bothner dot com>
- Date: 30 Aug 2001 21:32:44 -0700
My earlier patches today made a latent bug cause boot-strapping to fail.
I didn't catch it in my own boostrap due to configuring with the
wrong source tree (caused by overly-hasty use of bash history). So
I was surprised to receive mail from the regression-tester. That is
why I've checked this fix in before it has been bootstrapped!
Basically, the earlier patch added a call to convert which ended
up adding a conversion node around a string constant, which made
the code that generated the ConstantValue attribute fail. Before
that we would instead generate a bad class file, initializing an
Object field with an String, which according to the JVM spec is
not allowed (and is not done by the JDK).
2001-08-30 Per Bothner <per@bothner.com>
* jcf-write.c (generate_classfile): Check that field is primitive
or string before emitting ConstantValue attribute.
Index: jcf-write.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/jcf-write.c,v
retrieving revision 1.86
diff -u -r1.86 jcf-write.c
--- jcf-write.c 2001/08/30 21:08:32 1.86
+++ jcf-write.c 2001/08/31 04:13:41
@@ -2885,7 +2885,9 @@
PUT2(i);
have_value = DECL_INITIAL (part) != NULL_TREE
&& FIELD_STATIC (part) && CONSTANT_VALUE_P (DECL_INITIAL (part))
- && FIELD_FINAL (part);
+ && FIELD_FINAL (part)
+ && (JPRIMITIVE_TYPE_P (TREE_TYPE (part))
+ || TREE_TYPE (part) == string_ptr_type_node);
if (have_value)
attr_count++;
--
--Per Bothner
per@bothner.com http://www.bothner.com/per/