You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 5, 2019. It is now read-only.
I was trying to add the generateMixedExtensions="true" feature to a working project and started getting an NPE:
Caused by: java.lang.NullPointerException
at com.sun.codemodel.JInvocation.generate(JInvocation.java:176)
at com.sun.codemodel.JFormatter.g(JFormatter.java:350)
at com.sun.codemodel.JFormatter.g(JFormatter.java:363)
at com.sun.codemodel.JInvocation.generate(JInvocation.java:185)
at com.sun.codemodel.JFormatter.g(JFormatter.java:350)
at com.sun.codemodel.JAssignment.generate(JAssignment.java:65)
at com.sun.codemodel.JFormatter.g(JFormatter.java:350)
at com.sun.codemodel.JAssignment.state(JAssignment.java:69)
at com.sun.codemodel.JFormatter.s(JFormatter.java:386)
at com.sun.codemodel.JBlock.generateBody(JBlock.java:448)
at com.sun.codemodel.JBlock.generate(JBlock.java:436)
at com.sun.codemodel.JFormatter.g(JFormatter.java:350)
at com.sun.codemodel.JBlock.state(JBlock.java:464)
at com.sun.codemodel.JFormatter.s(JFormatter.java:386)
at com.sun.codemodel.JBlock.generateBody(JBlock.java:448)
at com.sun.codemodel.JBlock.generate(JBlock.java:436)
at com.sun.codemodel.JFormatter.g(JFormatter.java:350)
at com.sun.codemodel.JBlock.state(JBlock.java:464)
at com.sun.codemodel.JFormatter.s(JFormatter.java:386)
at com.sun.codemodel.JMethod.declare(JMethod.java:464)
at com.sun.codemodel.JFormatter.d(JFormatter.java:376)
at com.sun.codemodel.JDefinedClass.declareBody(JDefinedClass.java:832)
at com.sun.codemodel.JDefinedClass.declare(JDefinedClass.java:803)
at com.sun.codemodel.JFormatter.d(JFormatter.java:376)
at com.sun.codemodel.JFormatter.write(JFormatter.java:406)
at com.sun.codemodel.JPackage.build(JPackage.java:442)
at com.sun.codemodel.JCodeModel.build(JCodeModel.java:311)
at com.sun.codemodel.JCodeModel.build(JCodeModel.java:301)
at org.jvnet.mjiip.v_2_2.XJC22Mojo.writeCode(XJC22Mojo.java:98)
at org.jvnet.mjiip.v_2_2.XJC22Mojo.doExecute(XJC22Mojo.java:42)
at org.jvnet.mjiip.v_2_2.XJC22Mojo.doExecute(XJC22Mojo.java:28)
After some debugging I've found out that the NPE was thrown because the passed JMethod was null.
And that was because of the DummyListField.$get - a getter for the dummy list field. $get is a private field which is never initialized in the code, but used in the field accessor, for instance:
This leads to $target.invoke(...) with null and consequently to the NPE during code generation.
I think it was forgotten to initialize the $get field. Other list fields have something like:
$get = writer.declareMethod(listT,"get"+prop.getName(true));
writer.javadoc().append(prop.javadoc);
JBlock block = $get.body();
fixNullRef(block); // avoid using an internal getter
block._return(acc.ref(true));
I think this appeared here because the generateMixedExtensions="true" feature probably creates a dummy field. Should it be dummy, actually? Anyway, somehow with that feature a DummyListField is created and it has a bug.
The text was updated successfully, but these errors were encountered:
Today I've spent a few hours hunting an NPE bug.
I was trying to add the generateMixedExtensions="true" feature to a working project and started getting an NPE:
After some debugging I've found out that the NPE was thrown because the passed JMethod was null.
And that was because of the DummyListField.$get - a getter for the dummy list field. $get is a private field which is never initialized in the code, but used in the field accessor, for instance:
This leads to $target.invoke(...) with null and consequently to the NPE during code generation.
I think it was forgotten to initialize the $get field. Other list fields have something like:
I think this appeared here because the generateMixedExtensions="true" feature probably creates a dummy field. Should it be dummy, actually? Anyway, somehow with that feature a DummyListField is created and it has a bug.
The text was updated successfully, but these errors were encountered: