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: boolean field initializers


I'm checking this in on the gcjx branch.

When reading a .class file, we have to special-case boolean field
initializers, by giving them 'boolean' type.  Otherwise they end up
with 'int' type and field resolution fails.  Only boolean fields need
this treatment, because there is a narrowing conversion for the other
cases.

Tom

Index: ChangeLog
from  Tom Tromey  <tromey@redhat.com>

	* bytecode/classreader.cc (parse_constant_value): Special case
	initializers of boolean fields.

Index: bytecode/classreader.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/bytecode/Attic/classreader.cc,v
retrieving revision 1.1.2.9
diff -u -r1.1.2.9 classreader.cc
--- bytecode/classreader.cc 13 Feb 2005 03:46:45 -0000 1.1.2.9
+++ bytecode/classreader.cc 8 Mar 2005 23:11:26 -0000
@@ -318,6 +318,14 @@
 
   ref_expression init;
   parse_constant_value (init);
+
+  // We handle boolean constant expressions specially here.
+  if (current_field->type () == primitive_boolean_type)
+    {
+      jint val = jint (init->value ());
+      init = new model_boolean_literal (where, val);
+    }
+
   current_field->set_initializer (init);
 }
 


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