Look at initfield.java or PR162.java from the test suite.
>From initfield:
interface iface
{
final value x = new value();
}
public class initfield implements iface
{
public static void main(String[] args)
{
System.out.println(x.field);
...
When compiled with a correct java compiler (not gcj)
to bytecode, this line is compiled as:
0: getstatic #18=<Field java.lang.System.out java.io.PrintStream>
3: getstatic #24=<Field initfield.x value>
6: getfield #28=<Field value.field java.lang.Object>
9: invokevirtual #34=<Method java.io.PrintStream.println
(java.lang.Object)void>
Note at PC=3 how the qualifying class is 'initfield', not 'iface'.
If this class is the run through gcj (using the c++ abi) the resulting
program will crash.
I think the fix is for gcj to notice this situation and emit an
explicit class initialization call for the declaring class of the field.
This conforms to the overall c++ abi idea; for BC we already properly
handle this at runtime.
This is a blocker for ecj integration.
--
Summary: jc1 miscompilation with fields inherited from interfaces
Product: gcc
Version: 4.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: java
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: tromey at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28089