Community
Participate
Working Groups
:= doesn't work but appendElement does. this is critical because the test frameowrk uses it when I run my java generated code I get a TypeCastException program driver type BasicProgram {} function main() root2 ResultSummaryRoot; persistResult2(root2); root ResultSummaryRoot; persistResult(root); end function persistResult( resultRootSum ResultSummaryRoot) resultSum ResultSummary; resultSum.name = "one"; resultRootSum.trSum ::= resultSum; resultSum2 ResultSummary; resultSum2.name = "two"; resultRootSum.trSum ::= resultSum2; end function persistResult2( resultRootSum ResultSummaryRoot) resultSum ResultSummary; resultSum.name = "one2"; resultRootSum.trSum.appendElement(resultSum); resultSum2 ResultSummary; resultSum2.name = "two2"; resultRootSum.trSum.appendElement(resultSum2); end end Record ResultSummary pkgName String {@XMLAttribute{}}; name String{@XMLAttribute{}}; end Record ResultSummaryRoot {@xmlrootelement {}} expCnt int{@XMLAttribute{}}; trSum ResultSummary[]{}; end
We're generating the ::= as appendAll, but it should be appendElement.
The problem was in IRUtils.makeCompatible(Assignment). It didn't understand that ::= is sometimes array.appendElement(), so it was creating IRs that told the generator to turn the record into an array. When that conversion failed at run time, the TypeCastException was thrown.
using install build 201109152102 I get Multiple markers at this line - IWN.JavaGen.9998.e 18/369 Exception occurred: java.lang.NullPointerException - IWN.JavaGen.9999.e 18/369 Stack Trace: java.lang.NullPointerException on EGL line resultRootSum.trSum ::= resultSum;
That statement has been fixed, although if you code it as: array = array :: record then you will get the same problem. It's because there is no classifier for a record and that causes the NPE in makeCompat. Will look into it
Changing the target milestone since we're in I-15 now.
fixed
works in 201109192102
Closing this defect.