"Why are you doing this what is wrong with you?" notwithstanding, is there any way to accomplish this without changing the final method parameter name?
private Foo createAnonymousFoo(final Bar bar) {
return new Foo() {
private Bar bar = SomeUnknownScopeQualifier.bar;
public Bar getBar() {
return bar;
}
public void doSomethingThatReassignsBar() {
bar = bar.createSomeDerivedInstanceOfBar();
}
};
}
Obviously without the doSomethingThatReassignsBar call, you wouldn't need the member Bar and so on. In this case, the simple fix is to change final Bar bar
to something like final Bar startBar
and then the assignment is fine. But out of curiosity, is it possible to specifically refer to the final Bar
(Similar to the way you would say Super.this
)?