public inbox for java-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug java/16327] New: Invalid Bytecode Generated for Jacks Test 8.1.2-runtime-1
@ 2004-07-02  5:39 rmathew at gcc dot gnu dot org
  2004-07-09  2:37 ` [Bug java/16327] " mckinlay at redhat dot com
  0 siblings, 1 reply; 2+ messages in thread
From: rmathew at gcc dot gnu dot org @ 2004-07-02  5:39 UTC (permalink / raw)
  To: java-prs

The current mainline produces invalid bytecode for the Jacks
testsuite testcase 8.1.2-runtime-1. The testcase is:
---------------------------- 8< ----------------------------
class Hello
{
    public static void main(String[] args) {
        new Hello().foo(1);
    }
    void foo(final int i) {
        class Local {
            Local() {}
            Local(int i) { this(); }
            int foo() {
                return new Local(0) {
                    int j = i;
                }.j;
            }
        }
        System.out.println(new Local().foo());
    }
}
---------------------------- 8< ----------------------------

This should produce "1" as the output when compiled correctly.

However, GCJ miscompiles it (for both native as well as 
bytecode output) and the gij verifier gives a verification 
error on the generated bytecode.

The generated bytecode for "Hello$1$Local" looks like:
---------------------------- 8< ----------------------------
~/src/test/tmp > javap -c Hello\$1\$Local
Compiled from "Hello.java"
class Hello$1$Local extends java.lang.Object{
static Hello access$0(Hello$1$Local);
  Code:
   0:   aload_0
   1:   getfield        #14; //Field this$0:LHello;
   4:   areturn

Hello$1$Local(Hello,int);
  Code:
   0:   aload_0
   1:   aload_1
   2:   putfield        #14; //Field this$0:LHello;
   5:   aload_0
   6:   invokespecial   #24; //Method java/lang/Object."<init>":()V
   9:   aload_0
   10:  iload_2
   11:  invokespecial   #26; //Method finit$:(I)V
   14:  return

Hello$1$Local(Hello,int,int);
  Code:
   0:   aload_0
   1:   aload_1
   2:   putfield        #14; //Field this$0:LHello;
   5:   aload_0
   6:   aload_1
   7:   invokespecial   #29; //Method "<init>":(LHello;I)V
   10:  return

int foo();
  Code:
   0:   new     #33; //class Hello$Local$2
   3:   dup
   4:   aload_0
   5:   iconst_0
   6:   invokespecial   #36; //Method Hello$Local$2."<init>":(LHello$1$Local;I)V
   9:   getfield        #39; //Field Hello$Local$2.j:I
   12:  ireturn

}
---------------------------- 8< ----------------------------

Note that for the method "Hello$1$Local(Hello,int,int);", 
the method called at PC=7 doesn't get the expected
integer argument.

Originally reported at:

  http://gcc.gnu.org/ml/java/2004-07/msg00002.html

-- 
           Summary: Invalid Bytecode Generated for Jacks Test 8.1.2-runtime-
                    1
           Product: gcc
           Version: 3.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: java
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rmathew at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org,java-prs at gcc dot gnu
                    dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16327


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug java/16327] Invalid Bytecode Generated for Jacks Test 8.1.2-runtime-1
  2004-07-02  5:39 [Bug java/16327] New: Invalid Bytecode Generated for Jacks Test 8.1.2-runtime-1 rmathew at gcc dot gnu dot org
@ 2004-07-09  2:37 ` mckinlay at redhat dot com
  0 siblings, 0 replies; 2+ messages in thread
From: mckinlay at redhat dot com @ 2004-07-09  2:37 UTC (permalink / raw)
  To: java-prs


------- Additional Comments From mckinlay at redhat dot com  2004-07-09 02:37 -------
Confirmed. I don't think this is a new failure - this test case is broken going
back to at least GCC 3.3. I don't know why it recently started failing in Jacks.

build_alias_initializer_parameter_list could be the source of the problem. In
the case where a local class is instantiated within the same function that it is
defined, the hidden constructor argument is found from the parameter list in the
local function. But where the constructor call is made from a more deeply nested
context, the argument must be loaded from the synthetic var$ field.

It looks like the second case always fails, not just for anonymous instantiations.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2004-07-09 02:37:56
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16327


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-07-09  2:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-07-02  5:39 [Bug java/16327] New: Invalid Bytecode Generated for Jacks Test 8.1.2-runtime-1 rmathew at gcc dot gnu dot org
2004-07-09  2:37 ` [Bug java/16327] " mckinlay at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).