Hi,
I’m trying to inherit from a Java class, which has protected final member variables. In the generated Java code the compiler creates for instance the __hx_setField_f method where setting the final field is attempted, so the Java compilation fails.
Is there any way to prevent this? Is it just a bug?
Ideas are highly appreciated.
Minimal code would be:
(Java)
package test;
public class FinalTest {
protected final int protFinalField = 0;
}
(Haxe)
class FinalTest2 extends FinalTest {}
Then in the generated file for FinalTest2.java, code like the following will be found:
.....
public double __hx_setField_f(java.lang.String field, double value, boolean handleProperties)
{
{
boolean __temp_executeDef1 = true;
switch (field.hashCode())
{
case -612101141:
{
if (field.equals("protFinalField"))
{
__temp_executeDef1 = false;
this.protFinalField = ((int) (value) );
return value;
}
break;
}
}
.....
I hope that helps. Maybe there is even a switch to prevent the creation of that code, if not needed and I just didn’t find it.
Thank you.
Michael