[SOLVED] Issue with anonymous inner class in Lemur PropertyPanel


#1

Overriding a method on class initialization causes an issue with Lemur PropertyPanel:

 PropertyPanel albedoMapProperties = container.addChild(new PropertyPanel(null));

 MaterialProperty mp = new MaterialProperty(mat, albedoMapField, normalMapField, alphaMapField) {
                    @Override
                    public void setAlbedoMapSlot(int albedoMapSlot) {
                        super.setAlbedoMapSlot(albedoMapSlot);
                        // Refresh GUI to update metallic/roughness/scale values for this AlbedoMap slot
                        albedoMapProperties.refresh();
                    }
                };

 albedoMapProperties.addIntProperty("AlbedoMap", mp, "albedoMapSlot", 0, 11, 1);
 albedoMapProperties.addFloatProperty("Scale", mp, "scale", 0, 10, 0.1f);
 albedoMapProperties.addFloatProperty("Metallic", mp, "metallic", 0, 1, 0.1f);
 albedoMapProperties.addFloatProperty("Roughness", mp, "roughness", 0, 1, 0.1f);

here is the stack trace:

java.lang.RuntimeException: Error setting value
	at com.simsilica.lemur.props.PropertyPanel.setPropertyValue(PropertyPanel.java:300) ~[lemur-props-1.1.0.jar:?]
	at com.simsilica.lemur.props.PropertyPanel$PropertyAccess.setValue(PropertyPanel.java:379) ~[lemur-props-1.1.0.jar:?]
	at com.simsilica.lemur.props.PropertyPanel$AbstractProperty.setValue(PropertyPanel.java:436) ~[lemur-props-1.1.0.jar:?]
	at com.simsilica.lemur.props.PropertyPanel$IntProperty.update(PropertyPanel.java:631) ~[lemur-props-1.1.0.jar:?]
	at com.simsilica.lemur.props.PropertyPanel.updateLogicalState(PropertyPanel.java:281) ~[lemur-props-1.1.0.jar:?]
	at com.jme3.scene.Node.updateLogicalState(Node.java:243) ~[jme3-core-3.3.0-SNAPSHOT.jar:3.3-6804]
	at com.jme3.app.SimpleApplication.update(SimpleApplication.java:260) ~[jme3-core-3.3.0-SNAPSHOT.jar:3.3-6804]
	at com.jme3.system.lwjgl.LwjglWindow.runLoop(LwjglWindow.java:499) ~[jme3-lwjgl3-3.3.0-SNAPSHOT.jar:3.3-6805]
	at com.jme3.system.lwjgl.LwjglWindow.run(LwjglWindow.java:581) ~[jme3-lwjgl3-3.3.0-SNAPSHOT.jar:3.3-6805]
	at com.jme3.system.lwjgl.LwjglWindow.create(LwjglWindow.java:423) ~[jme3-lwjgl3-3.3.0-SNAPSHOT.jar:3.3-6805]
	at com.jme3.app.LegacyApplication.start(LegacyApplication.java:463) ~[jme3-core-3.3.0-SNAPSHOT.jar:3.3-6804]
	at com.jme3.app.LegacyApplication.start(LegacyApplication.java:424) ~[jme3-core-3.3.0-SNAPSHOT.jar:3.3-6804]
	at com.jme3.app.SimpleApplication.start(SimpleApplication.java:125) ~[jme3-core-3.3.0-SNAPSHOT.jar:3.3-6804]
	at app.Main.main(Main.java:126) ~[main/:?]
Caused by: java.lang.IllegalAccessException: class com.simsilica.lemur.props.PropertyPanel cannot access a member of class otm.moona.environment.view.BlockEditor$1$1 with modifiers "public"
	at java.base/jdk.internal.reflect.Reflection.newIllegalAccessException(Reflection.java:355) ~[?:?]
	at java.base/java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:639) ~[?:?]
	at java.base/java.lang.reflect.Method.invoke(Method.java:559) ~[?:?]
	at com.simsilica.lemur.props.PropertyPanel.setPropertyValue(PropertyPanel.java:297) ~[lemur-props-1.1.0.jar:?]

Offcourse not an important issue as I can work around it without creating an anonymous class. I just wanted to report it and know why Lemur PropertyPanel fails to handle it and see if there is an easy fix for this at Lemur side.

Edit:
Note MaterialProperty is an inner class.


#2

I changed it from protected class MaterialProperty to public and it solved the issue :wink:
Using protected modifier works fine for non-anonymous classes but it seems in case of the anonymous classes it should be public.