Uploaded image for project: 'Commons BCEL'
  1. Commons BCEL
  2. BCEL-108

RuntimeVisible Annotations duplicated

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Blocker
    • Resolution: Fixed
    • 6.8.1
    • 6.0
    • Main
    • 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))

      { addAttribute(attributes[i]); }

      }

      Attachments

        Activity

          People

            issues@commons.apache.org Apache Commons Developers
            reinhard.pilz@dynatrace.com Reinhard Pilz
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: