This is the mail archive of the java-prs@sourceware.cygnus.com 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]

Re: gcj/74: jc1 dumps core when compiling java/lang/Object.java


The following reply was made to PR gcj/74; it has been noted by GNATS.

From: Pekka Nikander <Pekka.Nikander@hut.fi>
To: Tom Tromey <tromey@cygnus.com>
Cc: java-gnats@sourceware.cygnus.com
Subject: Re: gcj/74: jc1 dumps core when compiling java/lang/Object.java
Date: Fri, 22 Oct 1999 21:21:21 +0300

 Tom Tromey wrote:
 > 
 > java.lang.Object and java.lang.Class are special and belong to the
 > implementation.  You can't make your own versions of them.  Why are
 > you trying to do this?
 
 I am trying to build a minimalistic runtime environment for Hitachi H8,
 i.e., the Lego Robotics RCX controller.   I cannot use libgcj because 
 it is far too big.  It seems to me that I also have to hack the compiler
 in other respects, too, since e.g. java.lang.Class has a huge number
 of internal, compiler generated fields that I won't need.
 
 > I agree the compiler shouldn't crash.  It should print some nice
 > error.  However, I don't think this is very important, either, since
 > people shouldn't do this.
 
 Here is a tentative patch to fix the problem.  I have to say that 
 I don't _really_ (I mean deeply) know why this does fix the problem,
 but it seems to do so.  Especially, I don't understand why you need
 the "DECL_NAME (field) != NULL_TREE), but that is needed, too.  
 With this patch, my compiler does not crash and generates code; 
 however, I haven't had time to look at the code to determine how
 relevant or "right" it is.
 
 The file to patch is gcc/java/class.c.
 
 --Pekka
 
 --- class.c.orig        Fri Jun 25 06:27:08 1999
 +++ class.c     Fri Oct 22 20:21:59 1999
 @@ -1022,7 +1022,7 @@
      field = TREE_CHAIN (field);  /* Skip dummy field for inherited
 data. */
    for ( ;  field != NULL_TREE;  field = TREE_CHAIN (field))
      {
 -      if (! DECL_ARTIFICIAL (field))
 +      if (! DECL_ARTIFICIAL (field) && DECL_NAME (field) != NULL_TREE)
         {
           tree init = make_field_value (field);
           if (FIELD_STATIC (field))
 @@ -1470,6 +1470,37 @@
  {
    tree super_class = CLASSTYPE_SUPER (this_class);
    tree field;
 +
 +  if (this_class == object_type_node || this_class == class_type_node)
 +    {
 +      /* If there are new (user defined) fields, they will
 +        be at the start of the field chain.  Extract the
 +        nonarticial fields, reverse them, and build up
 +        new chain with the nonartificial fields at the end. */
 +
 +      if (!DECL_ARTIFICIAL (TYPE_FIELDS (this_class)))
 +       {
 +         tree field = TYPE_FIELDS (this_class);
 +         tree artificials;
 +
 +         while (!DECL_ARTIFICIAL (TREE_CHAIN(field)))
 +           {
 +             field = TREE_CHAIN (field);
 +             if (!field) abort(); /* Compiler error */
 +           }
 +
 +         /* DECL_ARTIFICIAL (field) == 0
 +            && DECL_ARTIFICIAL (TREE_CHAIN (field)) == 1. */
 +
 +         artificials = TREE_CHAIN (field);
 +         TREE_CHAIN (field) = NULL_TREE;
 +
 +         TYPE_FIELDS (this_class) =
 +             chainon(artificials, nreverse (TYPE_FIELDS (this_class)));
 +
 +         TYPE_SIZE (this_class) = NULL_TREE;
 +       }
 +    }
 
    if (super_class)
      {

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