György Szarvas created UIMA-4073:
------------------------------------

             Summary: JCasGen generated code causes findbugs to complain
                 Key: UIMA-4073
                 URL: https://issues.apache.org/jira/browse/UIMA-4073
             Project: UIMA
          Issue Type: Bug
          Components: jcasgen-maven-plugin
    Affects Versions: 2.6.0SDK
            Reporter: György Szarvas
            Priority: Trivial


There is an issue with UIMA's JCasGen & FindBugs 2.0.3

Whenever a Type is defined and JCasGen generates the Java bindings for it, 
findbugs will report a high importance issue with the generated code, 
pertaining to the lines: 

/** @generated 
   * @return the generator for this type
   */
  @Override
  protected FSGenerator getFSGenerator() {return fsGenerator;}

The error is the one below.

In short, getFSGenerator() is called in the constructor of the superclass of 
the generated *_Type.java class, and getFSGenerator() is overridden in the 
subclass. This is a findbugs trigger in the above version.
Superclass is Annotation_Type.java, see here: 
http://grepcode.com/file/repo1.maven.org/maven2/org.apache.uima/uimaj-core/2.6.0/org/apache/uima/jcas/cas/AnnotationBase_Type.java#AnnotationBase_Type.getFSGenerator%28%29

Line 76 is the place where the call is made that triggers the findbug.

However, getFSGenerator() in superclass is : 
   protected FSGenerator getFSGenerator() {
     return fsGenerator;
   }

and this is overridden to 
protected FSGenerator getFSGenerator() {return fsGenerator;} in *_Type.java

Since this is the exact same code, I see no problems in removing this (the 
lines commented out in the diff), which fixes findbugs:
http://grepcode.com/file/repo1.maven.org/maven2/org.apache.uima/uimaj-tools/2.6.0/org/apache/uima/tools/jcasgen/JCas_TypeTemplate.java?av=f#68
remove from the String literal this part:
"/** @generated \n   * @return the generator for this type\n   */\n  
@Override\n  protected FSGenerator getFSGenerator() {return fsGenerator;}\n"




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to