Details
-
Bug
-
Status: Closed
-
Blocker
-
Resolution: Fixed
-
6.8.1
-
None
Description
Classes containing runtime visible annotations are invalid when processed by BCEL.
Example use case:
The class to be processed:
@javax.persistence.Entity
public class Item {
}
Here the code snippets we are using to process the class:
ClassGen classGen = new ClassGen(javaClass);
...
// perform changes
...
JavaClass result = classGen.getJavaClass();
The result contains now two attributes "RuntimeVisibleAnnotation" which is invalid.
Fix for the problem:
org.apache.bcel.generic.ClassGen:
On line 145 the list of attributes should not be filled with the annoation
attributes, as they are appended later anyways.
Original code:
for (int i = 0; i < attributes.length; i++) {
addAttribute(attributes[i]);
}
Correct code:
for (int i = 0; i < attributes.length; i++) {
if (!(attributes[i] instanceof Annotations))
}