Re: local class philosophy



> These final but not-known-at-compile-time values are passed to the local
> class's constructor(s), as you can check for yourself using javap.

Interesting, I always thought that was synthetic methods, but it seems
you're right.

<code>
class One
{
void method()
{
final long time=System.currentTimeMillis();

class Local
{
public Local(int test)
{
}

public void method2()
{
System.out.println(time);
}
}

new Local(5).method2();
}
}
</code>

The above gets compiled to look like this:

<code>
class One
{
void method()
{
final long time=System.currentTimeMillis();
new One$1Local(this,5,time).method2();
}
}

class One$1Local
{
public One$1Local(One oneThis,int number,long time)
{
this$0=oneThis;
this.val$time=time;
}

public void method2()
{
System.out.println(val$time);
}
}

So the order is enclosing instance first, then explicit parameters from
the original source, then extra variables as required.

Interesting.

.