Bug 9861 and Java 5 Generics

Andrew Haley aph@redhat.com
Wed Aug 17 17:40:00 GMT 2005


Terry Laurenzo writes:
 > Hi all,
 >  
 >  I have spent the last few days working on a solution to this bug
 > which is keeping us from using classes created by a generics compiler
 > with GCJ.  As noted in the comments, the fix does require an ABI
 > change because return types must be included in mangled Java names. 
 > This is likely to cause a number of problems, not the least of which
 > is breaking binary compatibility (such as it is).

I can live with that.  It might be possible to preserve some measure
of binary compatibility by providing aliases that don't encode the
return type.

 > Even so, some of us need this support in a bad way and would
 > probably be willing to use a hacked up version of GCJ that is not
 > wholly compatible with its siblings in order to get it.
 >  
 >  I wanted to ping this off of the list for feedback and/or
 > suggestions.  To my knowledge, no one has produced a patch that
 > purports to fix this problem yet.  I have outlined my work on my
 > web log:
 > http://tjlaurenzo.blogspot.com/2005/08/adventures-with-java-5-and-gcj.html
 >  
 >  In brief, here is what I did:
 >     - Modified gcc/cp/mangle.c to emit the method return type if the
 > function declaration is part of a Java type.
 >     - Modified gcc/java/mangle.c to emit the method return type for
 > non-constructors
 >     - Modified gcc/java/builtins.c to comply with the modified
 > mangling technique
 >  The patch on my weblog has these changes plus a couple others which
 > were needed to make the May 15th source drop compile for mingw.

Please post your patch to this list.

 >  This has been my first time working on the gcc source code, so don't
 > shoot me if I commited a mortal sin or messed up on the coding
 > conventions.  If there is to be an official patch, I'll fix that stuff
 > before the time comes.

OK.

 >  From my naive experience at this level with GCC, I anticipate a few
 > possible problem spots with this change:
 >     - As mentioned before, binary compatibility suffers

We can add a switch to control this.

 >     - GDB may have issues and diagnostic messages that demangle the
 > name are incorrect.  This may not be a problem as long as you're aware
 > of it, because the return type is mangled just prior to the first
 > argument.  As a result, demangled names show the return type as the
 > first argument.

Again, we may be able to fix this by careful use of aliases.  We can
also patch gdb.

 >     - Shared libraries get bigger (I don't have any numbers on that yet)
 >  
 >  So, does anyone have any thoughts?

Sounds good to me.  We know we have to do this, or something like
this.  Once we have a patch, we can talk about it.

However, we won't be able to accept your patch without copyright
assignment.

Andrew.



More information about the Java mailing list