jaxb-codemodel icon indicating copy to clipboard operation
jaxb-codemodel copied to clipboard

reference for outer class when used only nested

Open glassfishrobot opened this issue 14 years ago • 2 comments

outer class not added to references collection, when used only nested class. As result used full qualified class name.

code to reproduce problem:

JCodeModel cm = new JCodeModel();
JDefinedClass outer = cm._class("somepackage.OuterClass");
JDefinedClass nested = outer._class(JMod.STATIC | JMod.PUBLIC, "NestedClass");

JDefinedClass other = cm._class("somepackage.OtherClass");
other.method(JMod.PUBLIC, nested, "method");

cm.build(new SingleStreamCodeWriter(System.out));

result:

---------- cut ----------

    public somepackage.OuterClass.NestedClass method() {
    }

---------- cut ----------

expected result:

---------- cut ----------

    public OuterClass.NestedClass method() {
    }

---------- cut ----------

problem disappear if in method JFormatter.t(JClass) at COLLECTING stage add if (type.outer()!=null) t(type.outer());

Affected Versions

[2.4, 2.5]

glassfishrobot avatar Sep 26 '11 19:09 glassfishrobot

Reported by irioth

glassfishrobot avatar Sep 26 '11 19:09 glassfishrobot

This issue was imported from java.net JIRA CODEMODEL-7

glassfishrobot avatar Apr 24 '17 07:04 glassfishrobot