New Miscompilation Into Bytecode Error

Ranjit Mathew rmathew@gmail.com
Thu Jul 1 09:03:00 GMT 2004


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
 Hello1ドル.class
 Hello1ドルLocal.class
while GCJ creates:
 Hello.class
 Hello1ドル$Local.class
 Hello$Local2ドル.class
Is this divergence intentional and/or OK?
As an aside, the JDK produces the following code for the
offending method:
---------------------------- 8< ----------------------------
Hello1ドルLocal(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< ----------------------------
Hello1ドル$Local(Hello,int,int);
 Code:
 0: aload_0
 1: aload_1
 2: putfield #14; //Field this0ドル: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/


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /