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
As of v4.0.4, the ConstField class generates empty Javadoc comment blocks when no <javadoc>text</javadoc> is explicitly provided in the XML schema.
Example: Empty Javadoc for a Constant Field
/**
*
*
*/
@XmlAttribute(name = "fa_long")
public static final boolean FA_LONG = 7L;
A fix is to conditionally append the prop.javadoc only when it has content:
--- a/jaxb-ri/xjc/src/main/java/com/sun/tools/xjc/generator/bean/field/ConstField.java
+++ b/jaxb-ri/xjc/src/main/java/com/sun/tools/xjc/generator/bean/field/ConstField.java
@@ -54,8 +54,11 @@ final class ConstField extends AbstractField {
$ref = outline.ref.field(JMod.PUBLIC|JMod.STATIC|JMod.FINAL,
ptype!=null?ptype:implType, prop.getName(true), defaultValue );
- $ref.javadoc().append(prop.javadoc);
+ // Do not append empty javadoc.
+ if ( (prop.javadoc != null) && (prop.javadoc.length() > 0) )
+ $ref.javadoc().append(prop.javadoc);
+
annotate($ref);
}
Rationale
Currently, when $ref.javadoc() is invoked by ConstField, the jdoc field of JFieldVar is initialized to a non-null value. Later, the declare method is invoked and the JFormatter.g(jdoc) method is triggered whenever jdoc is not null. This leads to a call to JDocComment.generate(JFormatter) which includes blank lines when @param, @return, @throws, etc. are not applicable.
The proposed fix is to prevent an unnecessary initialization of the jdoc field of JFieldVar; thus, avoiding a call to JDocComment.generate(JFormatter). I will submit a pull request with the fix and a unit test.
As of v4.0.4, the ConstField class generates empty Javadoc comment blocks when no
<javadoc>text</javadoc>
is explicitly provided in the XML schema.Example: Empty Javadoc for a Constant Field
A fix is to conditionally append the
prop.javadoc
only when it has content:Rationale
Currently, when
$ref.javadoc()
is invoked byConstField
, thejdoc
field ofJFieldVar
is initialized to a non-null value. Later, thedeclare
method is invoked and theJFormatter.g(jdoc)
method is triggered wheneverjdoc
is not null. This leads to a call toJDocComment.generate(JFormatter)
which includes blank lines when@param
,@return
,@throws
, etc. are not applicable.The proposed fix is to prevent an unnecessary initialization of the
jdoc
field ofJFieldVar
; thus, avoiding a call toJDocComment.generate(JFormatter)
. I will submit a pull request with the fix and a unit test.ConstField: Call Sequence
The text was updated successfully, but these errors were encountered: