Bug 13493 - extra '<clinit>' generated in object file.
extra '<clinit>' generated in object file.
Status: RESOLVED FIXED
Product: gcc
Classification: Unclassified
Component: java
3.4.0
: P2 normal
: 4.3.0
Assigned To: Not yet assigned to anyone
: missed-optimization, wrong-code
Depends on: 28067
Blocks: 1259
  Show dependency treegraph
 
Reported: 2003-12-26 13:43 UTC by Guilhem Lavaux
Modified: 2007-01-09 20:46 UTC (History)
2 users (show)

See Also:
Host:
Target: any
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-03-01 02:40:08


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Guilhem Lavaux 2003-12-26 13:43:46 UTC
a '<clinit>' is generated in the output file of gcc whereas it isn't present in
the class file. In that case it should not be enumerated as a declared method:
this can cause major troubles in the serialization logic of libjava which then
fails to produce a valid serialVersionUID. This seems to happen only in the
typical case of the following example:

public class C
{
        static class D extends C
        {
          private static final String s = "hello";
        }
}

If you try to compile this example, it will generate a static '<clinit>' method
in the inner class D, which should not happen as the class file doesn't have it.
Comment 1 Andrew Pinski 2003-12-26 16:31:42 UTC
Confirmed.  The problem is that GCJ when generating native from source does create C.D.s really 
statically, it has to do a store which causes this.  When GCC generates from class files to native or 
to class files, it produces no <clinit> at all, just like Sun's javac.
Comment 2 Tom Tromey 2003-12-29 00:31:03 UTC
It isn't clear this is actually a bug.
Here's a nice discussion of some of the problems:

http://gcc.gnu.org/ml/java-patches/2002-q4/msg00036.html
Comment 3 Andrew Pinski 2004-01-01 22:40:08 UTC
Okay this is not an ABI bug but it still is a pressimize code generation, there is no need 
for <clinit>.
Comment 4 Andrew Pinski 2004-01-07 20:21:13 UTC
More than just that it can cause wrong-code, see PR 1259.
Comment 5 Tom Tromey 2007-01-09 20:46:01 UTC
All gcj front end bugs have been fixed by the gcj-eclipse branch merge.
I'm mass-closing the affected PRs.
If you believe one of these was closed in error, please reopen it
with a note explaining why.
Thanks.