[
https://issues.apache.org/jira/browse/UIMA-4073?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Marshall Schor resolved UIMA-4073.
----------------------------------
Resolution: Not a Problem
Although the code is "identical", the effect is not, because in the superclass,
the line
{code:java}
/** @generated */
private final FSGenerator fsGenerator = new FSGenerator() {
...
}
protected FSGenerator getFSGenerator() {return fsGenerator;}
{code:java}
in each of the class and its superclass, reference different instances of
"fsGenerator", which is a shadowed local variable having a different value in
the Class and Superclass. So the two methods return different things, and both
are needed.
I think this is just a Findbugs lack of analysis detail.
> 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
> Labels: patch
> Original Estimate: 5m
> Remaining Estimate: 5m
>
> 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)