jakarta-bcel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 43511] New: - AnnotationDefault needs a dump method
Date Fri, 28 Sep 2007 22:23:05 GMT
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=43511>.
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=43511

           Summary: AnnotationDefault needs a dump method
           Product: BCEL
           Version: 5.3
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Main
        AssignedTo: bcel-dev@jakarta.apache.org
        ReportedBy: christine.feldmann@quest.com


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);
+    }
 }

-- 
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.

---------------------------------------------------------------------
To unsubscribe, e-mail: bcel-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bcel-dev-help@jakarta.apache.org


Mime
View raw message