Hi there,
I'm trying to generate an anonymous inner class, but I get an NPE when I
create a new instance of this class...
java.lang.NullPointerException
at
com.sun.codemodel.JDefinedClass._package(JDefinedClass.java:806)
at
com.sun.codemodel.JFormatter$ReferenceList.collisions(JFormatter.java:49
6)
at com.sun.codemodel.JFormatter.write(JFormatter.java:392)
at com.sun.codemodel.JPackage.build(JPackage.java:436)
at com.sun.codemodel.JCodeModel.build(JCodeModel.java:281)
at com.sun.codemodel.JCodeModel.build(JCodeModel.java:250)
at com.sun.codemodel.JCodeModel.build(JCodeModel.java:229)
at com.sun.codemodel.JCodeModel.build(JCodeModel.java:257)
As far as I can see, this will never work for an anonymous class. Here
is an example of how the above exception is raised:
JBlock body = method.body();
JDefinedClass runnable = model.anonymousClass(Runnable.class);
JMethod runMethod = runnable.method(JMod.PUBLIC, model.VOID,
"run");
runMethod.body().directStatement("System.out.println(\"Running...\"");
body.add(JExpr._new(runnable).invoke("run"));
Am I using it incorrectly? Any help would be appreciated.
Cheers
Walter
--
This message and any attachments are confidential, proprietary, and may be privileged. If this message was misdirected, Barclays Global Investors (BGI) does not waive any confidentiality or privilege. If you are not the intended recipient, please notify us immediately and destroy the message without disclosing its contents to anyone. Any distribution, use or copying of this e-mail or the information it contains by other than an intended recipient is unauthorized. The views and opinions expressed in this e-mail message are the author's own and may not reflect the views and opinions of BGI, unless the author is authorized by BGI to express such views or opinions on its behalf. All email sent to or from this address is subject to electronic storage and review by BGI. Although BGI operates anti-virus programs, it does not accept responsibility for any damage whatsoever caused by viruses being passed.
--
Barclays Global Investors Limited is authorized and regulated by The Financial Services Authority. Registered in England. Registered No:796793. Registered Office: 1 Churchill Place, London E14 5HP.