harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sjanu...@apache.org
Subject svn commit: r727368 - /harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/
Date Wed, 17 Dec 2008 13:06:33 GMT
Author: sjanuary
Date: Wed Dec 17 05:06:32 2008
New Revision: 727368

URL: http://svn.apache.org/viewvc?rev=727368&view=rev
Log:
Unpack200 - fix bug in annotations attributes where annotation contents are not added to the
constant pool.

Modified:
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/AnnotationDefaultAttribute.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/AnnotationsAttribute.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/RuntimeVisibleorInvisibleAnnotationsAttribute.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/RuntimeVisibleorInvisibleParameterAnnotationsAttribute.java

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/AnnotationDefaultAttribute.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/AnnotationDefaultAttribute.java?rev=727368&r1=727367&r2=727368&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/AnnotationDefaultAttribute.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/AnnotationDefaultAttribute.java
Wed Dec 17 05:06:32 2008
@@ -18,6 +18,8 @@
 
 import java.io.DataOutputStream;
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * AnnotationDefault class file attribute
@@ -57,4 +59,15 @@
         return this == obj;
     }
 
+    protected ClassFileEntry[] getNestedClassFileEntries() {
+        List nested = new ArrayList();
+        nested.add(attributeName);
+        nested.addAll(element_value.getClassFileEntries());
+        ClassFileEntry[] nestedEntries = new ClassFileEntry[nested.size()];
+        for (int i = 0; i < nestedEntries.length; i++) {
+            nestedEntries[i] = (ClassFileEntry) nested.get(i);
+        }
+        return nestedEntries;
+    }
+
 }

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/AnnotationsAttribute.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/AnnotationsAttribute.java?rev=727368&r1=727367&r2=727368&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/AnnotationsAttribute.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/AnnotationsAttribute.java
Wed Dec 17 05:06:32 2008
@@ -18,6 +18,8 @@
 
 import java.io.DataOutputStream;
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * Abstract superclass for Annotations attributes
@@ -29,10 +31,10 @@
      */
     public static class Annotation {
 
-        private int num_pairs;
-        private CPUTF8[] element_names;
-        private ElementValue[] element_values;
-        private CPUTF8 type;
+        private final int num_pairs;
+        private final CPUTF8[] element_names;
+        private final ElementValue[] element_values;
+        private final CPUTF8 type;
 
         // Resolved values
         private int type_index;
@@ -75,12 +77,21 @@
             }
         }
 
+        public List getClassFileEntries() {
+            List entries = new ArrayList();
+            for (int i = 0; i < element_names.length; i++) {
+                entries.add(element_names[i]);
+                entries.addAll(element_values[i].getClassFileEntries());
+            }
+            entries.add(type);
+            return entries;
+        }
     }
 
     public static class ElementValue {
 
-        private Object value;
-        private int tag;
+        private final Object value;
+        private final int tag;
 
         // resolved value index if it's a constant
         private int constant_value_index = -1;
@@ -90,6 +101,25 @@
             this.value = value;
         }
 
+        public List getClassFileEntries() {
+            List entries = new ArrayList(1);
+            if(value instanceof CPNameAndType) {
+                // used to represent enum, so don't include the actual CPNameAndType
+                entries.add(((CPNameAndType)value).name);
+                entries.add(((CPNameAndType)value).descriptor);
+            } else if(value instanceof ClassFileEntry) {
+                entries.add(value);
+            } else if (value instanceof ElementValue[]) {
+                ElementValue[] values = (ElementValue[]) value;
+                for (int i = 0; i < values.length; i++) {
+                    entries.addAll(values[i].getClassFileEntries());
+                }
+            } else if (value instanceof Annotation) {
+                entries.addAll(((Annotation)value).getClassFileEntries());
+            }
+            return entries;
+        }
+
         public void resolve(ClassConstantPool pool) {
             if (value instanceof CPConstant) {
                 ((CPConstant) value).resolve(pool);

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/RuntimeVisibleorInvisibleAnnotationsAttribute.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/RuntimeVisibleorInvisibleAnnotationsAttribute.java?rev=727368&r1=727367&r2=727368&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/RuntimeVisibleorInvisibleAnnotationsAttribute.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/RuntimeVisibleorInvisibleAnnotationsAttribute.java
Wed Dec 17 05:06:32 2008
@@ -18,6 +18,8 @@
 
 import java.io.DataOutputStream;
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * Annotations class file attribute, either a RuntimeVisibleAnnotations
@@ -66,4 +68,17 @@
     public boolean equals(Object obj) {
         return this == obj;
     }
+
+    protected ClassFileEntry[] getNestedClassFileEntries() {
+        List nested = new ArrayList();
+        nested.add(attributeName);
+        for (int i = 0; i < annotations.length; i++) {
+            nested.addAll(annotations[i].getClassFileEntries());
+        }
+        ClassFileEntry[] nestedEntries = new ClassFileEntry[nested.size()];
+        for (int i = 0; i < nestedEntries.length; i++) {
+            nestedEntries[i] = (ClassFileEntry) nested.get(i);
+        }
+        return nestedEntries;
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/RuntimeVisibleorInvisibleParameterAnnotationsAttribute.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/RuntimeVisibleorInvisibleParameterAnnotationsAttribute.java?rev=727368&r1=727367&r2=727368&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/RuntimeVisibleorInvisibleParameterAnnotationsAttribute.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/RuntimeVisibleorInvisibleParameterAnnotationsAttribute.java
Wed Dec 17 05:06:32 2008
@@ -18,6 +18,8 @@
 
 import java.io.DataOutputStream;
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * Paramenter annotations class file attribute, either a
@@ -98,10 +100,31 @@
             return length;
         }
 
+        public List getClassFileEntries() {
+            List nested = new ArrayList();
+            for (int i = 0; i < annotations.length; i++) {
+                nested.addAll(annotations[i].getClassFileEntries());
+            }
+            return nested;
+        }
+
     }
 
     public boolean equals(Object obj) {
         return this == obj;
     }
 
+    protected ClassFileEntry[] getNestedClassFileEntries() {
+        List nested = new ArrayList();
+        nested.add(attributeName);
+        for (int i = 0; i < parameter_annotations.length; i++) {
+            nested.addAll(parameter_annotations[i].getClassFileEntries());
+        }
+        ClassFileEntry[] nestedEntries = new ClassFileEntry[nested.size()];
+        for (int i = 0; i < nestedEntries.length; i++) {
+            nestedEntries[i] = (ClassFileEntry) nested.get(i);
+        }
+        return nestedEntries;
+    }
+
 }



Mime
View raw message