DO NOT REPLY [Bug 42791] New: - RuntimeVisible Annotations duplicated

[email protected] Mon, 2 Jul 2007 02:14:08 -0700 (PDT)
Newsgroups gmane.comp.jakarta.bcel.devel
Message-ID <[email protected]/bugzilla/>
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUGĀ·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=42791>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED ANDĀ·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=42791

           Summary: RuntimeVisible Annotations duplicated
           Product: BCEL
           Version: 5.3
          Platform: All
        OS/Version: other
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Main
        AssignedTo: [email protected]
        ReportedBy: [email protected]


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)) {
    addAttribute(attributes[i]);
  }
}

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.