I have a class that I can't change as follows:

```
public class Foo {
    public final int ID=0;
    public int bar;
    public final Object baz=null;
}

```

I want to have an anonymous inner class that overrides `Foo` such as:

```
public Foo newFoo(final int mID, final int mbar, final Object mbaz) {
    return new Foo(){
        public final int ID = mID;
        public int bar = mbar;
        public final Object baz = mbaz;
    };
}

```

I then have a `javax.script.ScriptEngine` that I want to call something like this in JS: `newFoo(0,0,undefined)["ID"]`

My problem is that I get an exception like this:

```
sun.org.mozilla.javascript.internal.WrappedException: Wrapped java.lang.IllegalAccessException: Class sun.org.mozilla.javascript.internal.JavaMembers can not access a member of class Baz$1 with modifiers "public final" (mod.js#9) in test.js at line number 9

```

I don't understand how I could be getting a problem here: this works just fine if `newFoo` returns a plain 'ol `Foo`, but if I try to override `Foo` with an anonymous inner class, I can't access any overridden members even if they're public.