commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1696411 - in /commons/proper/bcel/trunk/src: main/java/org/apache/commons/bcel6/generic/ test/java/org/apache/commons/bcel6/ test/java/org/apache/commons/bcel6/generic/
Date Tue, 18 Aug 2015 12:32:33 GMT
Author: sebb
Date: Tue Aug 18 12:32:32 2015
New Revision: 1696411

URL: http://svn.apache.org/r1696411
Log:
Reduce visibility of field added in 6.0

Added:
    commons/proper/bcel/trunk/src/test/java/org/apache/commons/bcel6/generic/FieldAnnotationsTestCase.java
      - copied, changed from r1696324, commons/proper/bcel/trunk/src/test/java/org/apache/commons/bcel6/FieldAnnotationsTestCase.java
Removed:
    commons/proper/bcel/trunk/src/test/java/org/apache/commons/bcel6/FieldAnnotationsTestCase.java
Modified:
    commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/AnnotationEntryGen.java
    commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/ClassGen.java
    commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/FieldGen.java
    commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/FieldGenOrMethodGen.java
    commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/MethodGen.java
    commons/proper/bcel/trunk/src/test/java/org/apache/commons/bcel6/generic/AnnotationGenTestCase.java

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/AnnotationEntryGen.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/AnnotationEntryGen.java?rev=1696411&r1=1696410&r2=1696411&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/AnnotationEntryGen.java
(original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/AnnotationEntryGen.java
Tue Aug 18 12:32:32 2015
@@ -194,10 +194,10 @@ public class AnnotationEntryGen {
      * that can be attached to the class file.
      *
      * @param cp  The constant pool gen where we can create the necessary name refs
-     * @param vec A list of AnnotationGen objects
+     * @param annotationEntryGens An array of AnnotationGen objects
      */
-    static Attribute[] getAnnotationAttributes(ConstantPoolGen cp, List<AnnotationEntryGen>
vec) {
-        if (vec.isEmpty()) {
+    static Attribute[] getAnnotationAttributes(ConstantPoolGen cp, AnnotationEntryGen[] annotationEntryGens)
{
+        if (annotationEntryGens.length == 0) {
             return new Attribute[0];
         }
 
@@ -206,7 +206,7 @@ public class AnnotationEntryGen {
             int countInvisible = 0;
 
             //  put the annotations in the right output stream
-            for (AnnotationEntryGen a : vec) {
+            for (AnnotationEntryGen a : annotationEntryGens) {
                 if (a.isRuntimeVisible()) {
                     countVisible++;
                 } else {
@@ -223,7 +223,7 @@ public class AnnotationEntryGen {
             riaDos.writeShort(countInvisible);
 
             // put the annotations in the right output stream
-            for (AnnotationEntryGen a : vec) {
+            for (AnnotationEntryGen a : annotationEntryGens) {
                 if (a.isRuntimeVisible()) {
                     a.dump(rvaDos);
                 } else {

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/ClassGen.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/ClassGen.java?rev=1696411&r1=1696410&r2=1696411&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/ClassGen.java
(original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/ClassGen.java
Tue Aug 18 12:32:32 2015
@@ -204,7 +204,7 @@ public class ClassGen extends AccessFlag
             attributes = getAttributes();
         } else {
             // TODO: Sometime later, trash any attributes called 'RuntimeVisibleAnnotations'
or 'RuntimeInvisibleAnnotations'
-            Attribute[] annAttributes  = AnnotationEntryGen.getAnnotationAttributes(cp,annotation_vec);
+            Attribute[] annAttributes  = AnnotationEntryGen.getAnnotationAttributes(cp, getAnnotationEntries());
             attributes = new Attribute[attribute_vec.size()+annAttributes.length];
             attribute_vec.toArray(attributes);
             System.arraycopy(annAttributes,0,attributes,attribute_vec.size(),annAttributes.length);
      

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/FieldGen.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/FieldGen.java?rev=1696411&r1=1696410&r2=1696411&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/FieldGen.java
(original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/FieldGen.java
Tue Aug 18 12:32:32 2015
@@ -228,7 +228,7 @@ public class FieldGen extends FieldGenOr
     }
 
     private void addAnnotationsAsAttribute(ConstantPoolGen cp) {
-          Attribute[] attrs = AnnotationEntryGen.getAnnotationAttributes(cp,annotation_vec);
+          Attribute[] attrs = AnnotationEntryGen.getAnnotationAttributes(cp, super.getAnnotationEntries());
         for (Attribute attr : attrs) {
             addAttribute(attr);
         }

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/FieldGenOrMethodGen.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/FieldGenOrMethodGen.java?rev=1696411&r1=1696410&r2=1696411&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/FieldGenOrMethodGen.java
(original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/FieldGenOrMethodGen.java
Tue Aug 18 12:32:32 2015
@@ -37,14 +37,18 @@ public abstract class FieldGenOrMethodGe
     protected Type type;
     protected ConstantPoolGen cp;
     private final List<Attribute> attribute_vec = new ArrayList<>();
-    protected List<AnnotationEntryGen>       annotation_vec= new ArrayList<>();
+    // @since 6.0
+    private List<AnnotationEntryGen>       annotation_vec= new ArrayList<>();
 
 
     protected FieldGenOrMethodGen() {
     }
 
 
-    public FieldGenOrMethodGen(int access_flags) {
+    /**
+     * @since 6.0
+     */
+    protected FieldGenOrMethodGen(int access_flags) { // TODO could this be package protected?
         super(access_flags);
     }
 
@@ -99,7 +103,10 @@ public abstract class FieldGenOrMethodGe
         attribute_vec.add(a);
     }
 
-    public void addAnnotationEntry(AnnotationEntryGen ag)
+    /**
+     * @since 6.0
+     */
+    protected void addAnnotationEntry(AnnotationEntryGen ag) // TODO could this be package
protected?
     {
         annotation_vec.add(ag);
     }
@@ -112,7 +119,10 @@ public abstract class FieldGenOrMethodGe
         attribute_vec.remove(a);
     }
 
-    public void removeAnnotationEntry(AnnotationEntryGen ag)
+    /**
+     * @since 6.0
+     */
+    protected void removeAnnotationEntry(AnnotationEntryGen ag) // TODO could this be package
protected?
     {
         annotation_vec.remove(ag);
     }
@@ -125,7 +135,10 @@ public abstract class FieldGenOrMethodGe
         attribute_vec.clear();
     }
 
-    public void removeAnnotationEntries()
+    /**
+     * @since 6.0
+     */
+    protected void removeAnnotationEntries() // TODO could this be package protected?
     {
         annotation_vec.clear();
     }

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/MethodGen.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/MethodGen.java?rev=1696411&r1=1696410&r2=1696411&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/MethodGen.java
(original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/MethodGen.java
Tue Aug 18 12:32:32 2015
@@ -591,13 +591,19 @@ public class MethodGen extends FieldGenO
         return attributes;
     }
 
+    /**
+     * @since 6.0
+     */
     public void addAnnotationsAsAttribute(ConstantPoolGen cp) {
-          Attribute[] attrs = AnnotationEntryGen.getAnnotationAttributes(cp,annotation_vec);
+          Attribute[] attrs = AnnotationEntryGen.getAnnotationAttributes(cp, super.getAnnotationEntries());
         for (Attribute attr : attrs) {
             addAttribute(attr);
         }
       }
 
+    /**
+     * @since 6.0
+     */
       public void addParameterAnnotationsAsAttribute(ConstantPoolGen cp) {
           if (!hasParameterAnnotations) {
             return;
@@ -1070,6 +1076,7 @@ public class MethodGen extends FieldGenO
     // is more likely to suggest to the caller it is readonly (which a List does not). 
     /**
      * Return a list of AnnotationGen objects representing parameter annotations
+     * @since 6.0
      */
     public List<AnnotationEntryGen> getAnnotationsOnParameter(int i) {
         ensureExistingParameterAnnotationsUnpacked();

Modified: commons/proper/bcel/trunk/src/test/java/org/apache/commons/bcel6/generic/AnnotationGenTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/test/java/org/apache/commons/bcel6/generic/AnnotationGenTestCase.java?rev=1696411&r1=1696410&r2=1696411&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/test/java/org/apache/commons/bcel6/generic/AnnotationGenTestCase.java
(original)
+++ commons/proper/bcel/trunk/src/test/java/org/apache/commons/bcel6/generic/AnnotationGenTestCase.java
Tue Aug 18 12:32:32 2015
@@ -98,7 +98,7 @@ public class AnnotationGenTestCase exten
         AnnotationEntryGen a = new AnnotationEntryGen(t, elements, true, cp);
         List<AnnotationEntryGen> v = new ArrayList<>();
         v.add(a);
-        Attribute[] attributes = AnnotationEntryGen.getAnnotationAttributes(cp, v);
+        Attribute[] attributes = AnnotationEntryGen.getAnnotationAttributes(cp, v.toArray(new
AnnotationEntryGen[0]));
         boolean foundRV = false;
         for (Attribute attribute : attributes) {
             if (attribute instanceof RuntimeVisibleAnnotations)
@@ -113,7 +113,7 @@ public class AnnotationGenTestCase exten
         AnnotationEntryGen a2 = new AnnotationEntryGen(t, elements, false, cp);
         List<AnnotationEntryGen> v2 = new ArrayList<>();
         v2.add(a2);
-        Attribute[] attributes2 = AnnotationEntryGen.getAnnotationAttributes(cp, v2);
+        Attribute[] attributes2 = AnnotationEntryGen.getAnnotationAttributes(cp, v2.toArray(new
AnnotationEntryGen[0]));
         boolean foundRIV = false;
         for (Attribute attribute : attributes2) {
             if (attribute instanceof RuntimeInvisibleAnnotations)

Copied: commons/proper/bcel/trunk/src/test/java/org/apache/commons/bcel6/generic/FieldAnnotationsTestCase.java
(from r1696324, commons/proper/bcel/trunk/src/test/java/org/apache/commons/bcel6/FieldAnnotationsTestCase.java)
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/test/java/org/apache/commons/bcel6/generic/FieldAnnotationsTestCase.java?p2=commons/proper/bcel/trunk/src/test/java/org/apache/commons/bcel6/generic/FieldAnnotationsTestCase.java&p1=commons/proper/bcel/trunk/src/test/java/org/apache/commons/bcel6/FieldAnnotationsTestCase.java&r1=1696324&r2=1696411&rev=1696411&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/test/java/org/apache/commons/bcel6/FieldAnnotationsTestCase.java
(original)
+++ commons/proper/bcel/trunk/src/test/java/org/apache/commons/bcel6/generic/FieldAnnotationsTestCase.java
Tue Aug 18 12:32:32 2015
@@ -16,18 +16,16 @@
  * 
  */
 
-package org.apache.commons.bcel6;
+package org.apache.commons.bcel6.generic;
 
 import java.io.File;
 import java.io.IOException;
 
+import org.apache.commons.bcel6.AbstractTestCase;
 import org.apache.commons.bcel6.classfile.AnnotationEntry;
 import org.apache.commons.bcel6.classfile.ElementValuePair;
 import org.apache.commons.bcel6.classfile.Field;
 import org.apache.commons.bcel6.classfile.JavaClass;
-import org.apache.commons.bcel6.generic.AnnotationEntryGen;
-import org.apache.commons.bcel6.generic.ClassGen;
-import org.apache.commons.bcel6.generic.FieldGen;
 import org.apache.commons.bcel6.util.SyntheticRepository;
 
 public class FieldAnnotationsTestCase extends AbstractTestCase



Mime
View raw message