You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Alex Herbert (Jira)" <ji...@apache.org> on 2022/10/27 11:32:00 UTC

[jira] [Updated] (BCEL-113) AnnotationDefault needs a dump method

     [ https://issues.apache.org/jira/browse/BCEL-113?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alex Herbert updated BCEL-113:
------------------------------
    Priority: Minor

> AnnotationDefault needs a dump method
> -------------------------------------
>
>                 Key: BCEL-113
>                 URL: https://issues.apache.org/jira/browse/BCEL-113
>             Project: Commons BCEL
>          Issue Type: Bug
>          Components: Main
>    Affects Versions: 5.3
>         Environment: Operating System: All
> Platform: All
>            Reporter: cfeldmann
>            Assignee: Apache Commons Developers
>            Priority: Minor
>
> While using bcel to read in and then write out an annotation that has a default
> value without making any changes to it, I discovered that the resulting class
> did not contain the annotation default.  The annotation looks something like this:
> @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME)
> public @interface Foo
> {
>    String name() default "";
> }
> The missing bytes caused a (very misleading) NoClassDefFoundError when I tried
> to load the new class.  
> When I tried to decompile the new class, I got this error:
> ItemCollectionInvalidIndex: constants: requested 1280, limit 27
> After comparing the original class with the new class in a hex editor, I
> determined that the bytes for the AnnotationDefault were missing.  The problem
> is that the AnnotationDefault class does not have a dump method.  I added a dump
> method and this fixed the problem.  Here's a diff of the new method:
> $ svn diff
> Index: src/main/java/org/apache/bcel/classfile/AnnotationDefault.java
> ===================================================================
> --- src/main/java/org/apache/bcel/classfile/AnnotationDefault.java     
> (revision 573325)
> +++ src/main/java/org/apache/bcel/classfile/AnnotationDefault.java      (working
> copy)
> @@ -18,6 +18,7 @@
>  import java.io.DataInputStream;
>  import java.io.IOException;
> +import java.io.DataOutputStream;
>  import org.apache.bcel.Constants;
>  /**
> @@ -105,4 +106,10 @@
>         {
>                 throw new RuntimeException("Not implemented yet!");
>         }
> +
> +    public final void dump(DataOutputStream dos) throws IOException
> +    {
> +      super.dump(dos);
> +      default_value.dump(dos);
> +    }
>  }



--
This message was sent by Atlassian Jira
(v8.20.10#820010)