Bug 28089 - jc1 miscompilation with fields inherited from interfaces
Summary: jc1 miscompilation with fields inherited from interfaces
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: java (show other bugs)
Version: 4.2.0
: P3 normal
Target Milestone: 4.2.0
Assignee: Tom Tromey
URL:
Keywords:
Depends on:
Blocks: 28067
  Show dependency treegraph
 
Reported: 2006-06-19 22:42 UTC by Tom Tromey
Modified: 2006-09-12 19:41 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-06-20 18:11:55


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Tromey 2006-06-19 22:42:24 UTC
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.
Comment 1 Tom Tromey 2006-06-21 18:01:46 UTC
Subject: Bug 28089

Author: tromey
Date: Wed Jun 21 18:01:37 2006
New Revision: 114856

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=114856
Log:
	PR java/28089:
	* expr.c (expand_java_field_op): Initialize field's declaring
	class.

Modified:
    branches/gcj-eclipse/gcc/java/ChangeLog
    branches/gcj-eclipse/gcc/java/expr.c

Comment 2 Tom Tromey 2006-06-21 18:14:41 UTC
Fix checked in on gcj-eclipse branch.

Comment 3 Tom Tromey 2006-09-12 19:41:04 UTC
Also fixed on trunk; updating target milestone.