This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: New Miscompilation Into Bytecode Error
- From: Ranjit Mathew <rmathew at gmail dot com>
- To: java at gcc dot gnu dot org
- Date: Thu, 01 Jul 2004 14:30:46 +0530
- Subject: Re: New Miscompilation Into Bytecode Error
- References: <cc0flj$s7b$1@sea.gmane.org>
Ranjit Mathew wrote:
> This is the 8.1.2-runtime-1 testcase from Jacks ("Stress
> test of accessing a final local variable through two
> layers of nested local/anonymous classes"):
> ---------------------------- 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< ----------------------------
One question:
For this testcase, the JDK creates the following class files:
Hello.class
Hello$1.class
Hello$1Local.class
while GCJ creates:
Hello.class
Hello$1$Local.class
Hello$Local$2.class
Is this divergence intentional and/or OK?
As an aside, the JDK produces the following code for the
offending method:
---------------------------- 8< ----------------------------
Hello$1Local(Hello,int,int);
Code:
0: aload_0
1: aload_1
2: iload_3
3: invokespecial #4; //Method "<init>":(LHello;I)V
6: return
---------------------------- 8< ----------------------------
in contrast to the following code produced by GCJ:
---------------------------- 8< ----------------------------
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
---------------------------- 8< ----------------------------
Thanks,
Ranjit.
--
Ranjit Mathew Email: rmathew AT gmail DOT com
Bangalore, INDIA. Web: http://ranjitmathew.tripod.com/