Andreas Sewe
2014-10-01 13:30:22 UTC
Hi all,
originally, I wanted to open a bug report for this, but then I realized
that this is not a simple bug but a set of related issues.
What I want to do is the following: Annotate a `BugInstance` with a
percentage value which is *insignificant*. Should be simple enough,
right? Unfortunately, no. :-(
Right now I am using an IntAnnotation with a description of
INT_SYNC_PERCENT. This does result in an insignificant annotation (due
to the way `IntAnnotation.isSignificant` works), but has two serious issues:
- The UI (e.g., the Eclipse "Bug Info" view) shows my percentage value
as "synchronized 42% of the time", even though the value has nothing to
do with synchronization.
- IntAnnotation's description/role attribute doesn't survive
serialization/deserialization. IntAnnotation.writeXML produces an
attribute, but SAXBugCollectionHandler.parseBugInstanceContents fails to
take it into account.
Now, the latter is clearly a bug (serialization/deserialization
round-trips should be possible) but what to do about the former?
Subclassing IntAnnotation with, say, PercentageAnnotation and then
customizing isSignificant() and toString() to flag the percentage as
insignificant and change the text to the more generic "42% of the time"
unfortunately won't work as
SAXBugCollectionHandler.parseBugInstanceContents cannot know about my
IntAnnotation subclass and hence deserializes it as a plain
IntAnnotation again.
Personally, I would derive the following conclusions:
- An IntAnnotation's role should be set upon deserialization. That it is
not, is a bug in SAXBugCollectionHandler.
- If round-trips safety is desired (I would say it is) then all
implementations of BugAnnotation should be final, as
SAXBugCollectionHandler can only recognize a fixed set of them. Allowing
users to subclass IntAnnotation (like I tried) invariably leads to
broken deserialization. Making the "official" set of BugAnnotations
final would prevent users from falling into this trap.
- It should be possible to override whether or not a BugAnnotation is
considered significant; hard-coding that only roles of INT_SYNC_PERCENT
and INT_OCCURRENCES (in the case of IntAnnotation) are insignificant is
too limiting.
- If an annotation's role can no longer be relied on to tell FindBugs
whether or not a BugAnnotation is considered significant then this flag
needs to serialized (and deserialized) as well.
- Finally, additional FindBugs plugins need to be able to contribute
their own FindBugsAnnotationDescriptions.properties bundles. For the
above reasons, subclassing IntAnnotation and friends is not feasible,
thus one cannot simply override toString().
Thoughts?
Andreas
--
Codetrails GmbH
The knowledge transfer company
Robert-Bosch-Str. 7, 64293 Darmstadt
Phone: +49-6151-276-7092
Mobile: +49-170-811-3791
http://www.codetrails.com/
Managing Director: Dr. Marcel Bruch
Handelsregister: Darmstadt HRB 91940
originally, I wanted to open a bug report for this, but then I realized
that this is not a simple bug but a set of related issues.
What I want to do is the following: Annotate a `BugInstance` with a
percentage value which is *insignificant*. Should be simple enough,
right? Unfortunately, no. :-(
Right now I am using an IntAnnotation with a description of
INT_SYNC_PERCENT. This does result in an insignificant annotation (due
to the way `IntAnnotation.isSignificant` works), but has two serious issues:
- The UI (e.g., the Eclipse "Bug Info" view) shows my percentage value
as "synchronized 42% of the time", even though the value has nothing to
do with synchronization.
- IntAnnotation's description/role attribute doesn't survive
serialization/deserialization. IntAnnotation.writeXML produces an
attribute, but SAXBugCollectionHandler.parseBugInstanceContents fails to
take it into account.
Now, the latter is clearly a bug (serialization/deserialization
round-trips should be possible) but what to do about the former?
Subclassing IntAnnotation with, say, PercentageAnnotation and then
customizing isSignificant() and toString() to flag the percentage as
insignificant and change the text to the more generic "42% of the time"
unfortunately won't work as
SAXBugCollectionHandler.parseBugInstanceContents cannot know about my
IntAnnotation subclass and hence deserializes it as a plain
IntAnnotation again.
Personally, I would derive the following conclusions:
- An IntAnnotation's role should be set upon deserialization. That it is
not, is a bug in SAXBugCollectionHandler.
- If round-trips safety is desired (I would say it is) then all
implementations of BugAnnotation should be final, as
SAXBugCollectionHandler can only recognize a fixed set of them. Allowing
users to subclass IntAnnotation (like I tried) invariably leads to
broken deserialization. Making the "official" set of BugAnnotations
final would prevent users from falling into this trap.
- It should be possible to override whether or not a BugAnnotation is
considered significant; hard-coding that only roles of INT_SYNC_PERCENT
and INT_OCCURRENCES (in the case of IntAnnotation) are insignificant is
too limiting.
- If an annotation's role can no longer be relied on to tell FindBugs
whether or not a BugAnnotation is considered significant then this flag
needs to serialized (and deserialized) as well.
- Finally, additional FindBugs plugins need to be able to contribute
their own FindBugsAnnotationDescriptions.properties bundles. For the
above reasons, subclassing IntAnnotation and friends is not feasible,
thus one cannot simply override toString().
Thoughts?
Andreas
--
Codetrails GmbH
The knowledge transfer company
Robert-Bosch-Str. 7, 64293 Darmstadt
Phone: +49-6151-276-7092
Mobile: +49-170-811-3791
http://www.codetrails.com/
Managing Director: Dr. Marcel Bruch
Handelsregister: Darmstadt HRB 91940