Community
Participate
Working Groups
package acme.xxxx; program Bug f1_int int; function main() for (f1_int from 1 to 100) end end end intermittently, I get a class cast exception on for statement for the isIncrement method call Caused by: org.eclipse.edt.mof.serialization.MofObjectNotFoundException: MofObject not found: egl:egl.lang.eglboolean at org.eclipse.edt.mof.serialization.AbstractEnvironment.find(AbstractEnvironment.java:120) at org.eclipse.edt.mof.serialization.AbstractEnvironment.find(AbstractEnvironment.java:96) at org.eclipse.edt.mof.egl.utils.IRUtils.getType(IRUtils.java:259)
Hi Paul, I debugged this one and it looks like a problem when deserializing ForStatement from the compiler's mofar. In XMLDeserializer.valueFromString() it falls into the last "else" branch. The EDataType for the "initialValue" attribute on the "isIncrement" field is org.eclipse.edt.mof.JavaObject instead of EBoolean, so it doesn't convert "true" to a Boolean object (stores the value as a String). Also, I was not getting the error Jeff pasted below. He mentions a ClassCastException, which is what I get, but he pasted a MofObjectNotFoundException. To reproduce the CCE, run a clean on the project, and make sure you have the Java generator enabled for the project (build deserializes the IR with the wrong type for isIncrement, and generation invokes ForStatement.isIncrement() which causes the CCE).
I did some more digging on Jeff's stack trace, and I think the problem is with IsNotExpressionImpl.getType(). It's looking for "egl.lang.EGLBoolean", and I found no other references or declarations of this type anywhere in the code/mofars/eglars. If you look at IsAExpressionImpl.getType(), it returns TypeUtils.Type_BOOLEAN, which is probably what IsNotExpressionImpl.getType() should be returning. To reproduce: record myrec s string; end program prog1 function main() m myrec; if (m.s is blanks) end end end
I'm also seeing a classcastexception (java.lang.String cannot be cast to java.lang.Boolean) on the XMLAttribute and XMLElement annotation fields that are type boolean (nillable/required) using the record below. The classcast only happens when I clean the project, if I edit the file to force a build the annotation default value is a Boolean like it should be. I tested Jeff's scenario and it also behaves this way. record Record1{@XMLRootElement{name="root_name", namespace="root_namepsace", nillable=true}} f1 string; f2 string{@XMLElement}; f3 string{@XMLAttribute}; f4 string{@XMLElement{name="f4_name", namespace="f4_namepsace", nillable=true}}; f5 string{@XMLAttribute{name="f5_name", namespace="f5_namepsace", required=true}}; end
Created attachment 199762 [details] Patch for the CCE and MofObjectNotFoundException Paul - I've attached a patch that resolves both Jeff and Joe's issues. Please review it and let me know if it looks correct. As for the code I put into EFieldImpl.getInitialValue(), I don't know if any other types should be checked. I went by what was in EDataTypeImpl.getDefaultValue(), except I omitted the case for java.util.List. I added an array field to one of the types, gave it an initial value, recompiled the .mofxml file and the initial value was not included in the IR. I do not know if this is a bug or if we don't support initial values for array fields.
Patch has been applied and released
closing this defect, which was fixed several months ago