Author: ebourg Date: Wed Feb 25 09:24:47 2015 New Revision: 1662190 URL: http://svn.apache.org/r1662190 Log: Move the getAnnotationAttributes and getParameterAnnotationAttributes method from Utility to AnnotationEntryGen and hide them from the public API
Added: commons/proper/bcel/trunk/src/test/java/org/apache/bcel/generic/AnnotationGenTestCase.java - copied, changed from r1654901, commons/proper/bcel/trunk/src/test/java/org/apache/bcel/AnnotationGenTestCase.java Removed: commons/proper/bcel/trunk/src/test/java/org/apache/bcel/AnnotationGenTestCase.java Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/classfile/RuntimeInvisibleAnnotations.java commons/proper/bcel/trunk/src/main/java/org/apache/bcel/classfile/RuntimeInvisibleParameterAnnotations.java commons/proper/bcel/trunk/src/main/java/org/apache/bcel/classfile/RuntimeVisibleAnnotations.java commons/proper/bcel/trunk/src/main/java/org/apache/bcel/classfile/RuntimeVisibleParameterAnnotations.java commons/proper/bcel/trunk/src/main/java/org/apache/bcel/classfile/Utility.java commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/AnnotationEntryGen.java commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/ClassGen.java commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/FieldGen.java commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/MethodGen.java Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/classfile/RuntimeInvisibleAnnotations.java URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/classfile/RuntimeInvisibleAnnotations.java?rev=1662190&r1=1662189&r2=1662190&view=diff ============================================================================== --- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/classfile/RuntimeInvisibleAnnotations.java (original) +++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/classfile/RuntimeInvisibleAnnotations.java Wed Feb 25 09:24:47 2015 @@ -44,7 +44,7 @@ public class RuntimeInvisibleAnnotations * @param constant_pool * Array of constants */ - RuntimeInvisibleAnnotations(int name_index, int length, DataInput input, ConstantPool constant_pool) + public RuntimeInvisibleAnnotations(int name_index, int length, DataInput input, ConstantPool constant_pool) throws IOException { super(Constants.ATTR_RUNTIME_INVISIBLE_ANNOTATIONS, name_index, length, input, constant_pool, false); Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/classfile/RuntimeInvisibleParameterAnnotations.java URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/classfile/RuntimeInvisibleParameterAnnotations.java?rev=1662190&r1=1662189&r2=1662190&view=diff ============================================================================== --- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/classfile/RuntimeInvisibleParameterAnnotations.java (original) +++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/classfile/RuntimeInvisibleParameterAnnotations.java Wed Feb 25 09:24:47 2015 @@ -39,7 +39,7 @@ public class RuntimeInvisibleParameterAn * @param input Input stream * @param constant_pool Array of constants */ - RuntimeInvisibleParameterAnnotations(int name_index, int length, DataInput input, ConstantPool constant_pool) + public RuntimeInvisibleParameterAnnotations(int name_index, int length, DataInput input, ConstantPool constant_pool) throws IOException { super(Constants.ATTR_RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS, name_index, length, input, constant_pool); } Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/classfile/RuntimeVisibleAnnotations.java URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/classfile/RuntimeVisibleAnnotations.java?rev=1662190&r1=1662189&r2=1662190&view=diff ============================================================================== --- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/classfile/RuntimeVisibleAnnotations.java (original) +++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/classfile/RuntimeVisibleAnnotations.java Wed Feb 25 09:24:47 2015 @@ -44,7 +44,7 @@ public class RuntimeVisibleAnnotations e * @param constant_pool * Array of constants */ - RuntimeVisibleAnnotations(int name_index, int length, DataInput input, ConstantPool constant_pool) throws IOException + public RuntimeVisibleAnnotations(int name_index, int length, DataInput input, ConstantPool constant_pool) throws IOException { super(Constants.ATTR_RUNTIME_VISIBLE_ANNOTATIONS, name_index, length, input, constant_pool, true); } Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/classfile/RuntimeVisibleParameterAnnotations.java URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/classfile/RuntimeVisibleParameterAnnotations.java?rev=1662190&r1=1662189&r2=1662190&view=diff ============================================================================== --- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/classfile/RuntimeVisibleParameterAnnotations.java (original) +++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/classfile/RuntimeVisibleParameterAnnotations.java Wed Feb 25 09:24:47 2015 @@ -39,7 +39,7 @@ public class RuntimeVisibleParameterAnno * @param input Input stream * @param constant_pool Array of constants */ - RuntimeVisibleParameterAnnotations(int name_index, int length, DataInput input, ConstantPool constant_pool) + public RuntimeVisibleParameterAnnotations(int name_index, int length, DataInput input, ConstantPool constant_pool) throws IOException { super(Constants.ATTR_RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS, name_index, length, input, constant_pool); } Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/classfile/Utility.java URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/classfile/Utility.java?rev=1662190&r1=1662189&r2=1662190&view=diff ============================================================================== --- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/classfile/Utility.java (original) +++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/classfile/Utility.java Wed Feb 25 09:24:47 2015 @@ -13,16 +13,14 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ + package org.apache.bcel.classfile; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.CharArrayReader; import java.io.CharArrayWriter; -import java.io.DataInputStream; -import java.io.DataOutputStream; import java.io.FilterReader; import java.io.FilterWriter; import java.io.IOException; @@ -37,8 +35,6 @@ import java.util.zip.GZIPInputStream; import java.util.zip.GZIPOutputStream; import org.apache.bcel.Constants; -import org.apache.bcel.generic.AnnotationEntryGen; -import org.apache.bcel.generic.ConstantPoolGen; import org.apache.bcel.util.ByteSequence; /** @@ -1455,172 +1451,4 @@ public abstract class Utility { return buf.toString(); } - - /** - * Converts a list of AnnotationGen objects into a set of attributes - * 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 - */ - public static Attribute[] getAnnotationAttributes(ConstantPoolGen cp,List<AnnotationEntryGen> vec) { - - if (vec.isEmpty()) { - return new Attribute[0]; - } - - try { - int countVisible = 0; - int countInvisible = 0; - - // put the annotations in the right output stream - for (AnnotationEntryGen a : vec) { - if (a.isRuntimeVisible()) { - countVisible++; - } else { - countInvisible++; - } - } - - ByteArrayOutputStream rvaBytes = new ByteArrayOutputStream(); - ByteArrayOutputStream riaBytes = new ByteArrayOutputStream(); - DataOutputStream rvaDos = new DataOutputStream(rvaBytes); - DataOutputStream riaDos = new DataOutputStream(riaBytes); - - rvaDos.writeShort(countVisible); - riaDos.writeShort(countInvisible); - - // put the annotations in the right output stream - for (AnnotationEntryGen a : vec) { - if (a.isRuntimeVisible()) { - a.dump(rvaDos); - } else { - a.dump(riaDos); - } - } - - rvaDos.close(); - riaDos.close(); - - byte[] rvaData = rvaBytes.toByteArray(); - byte[] riaData = riaBytes.toByteArray(); - - int rvaIndex = -1; - int riaIndex = -1; - - if (rvaData.length>2) { - rvaIndex = cp.addUtf8("RuntimeVisibleAnnotations"); - } - if (riaData.length>2) { - riaIndex = cp.addUtf8("RuntimeInvisibleAnnotations"); - } - - List<Attribute> newAttributes = new ArrayList<Attribute>(); - if (rvaData.length>2) { - - newAttributes.add( - new RuntimeVisibleAnnotations(rvaIndex,rvaData.length,new DataInputStream(new ByteArrayInputStream(rvaData)),cp.getConstantPool())); - } - if (riaData.length>2) { - newAttributes.add( - new RuntimeInvisibleAnnotations(riaIndex,riaData.length,new DataInputStream(new ByteArrayInputStream(riaData)),cp.getConstantPool())); - } - - return newAttributes.toArray(new Attribute[newAttributes.size()]); - } catch (IOException e) { - System.err.println("IOException whilst processing annotations"); - e.printStackTrace(); - } - return null; - } - - - /** - * Annotations against a class are stored in one of four attribute kinds: - * - RuntimeVisibleParameterAnnotations - * - RuntimeInvisibleParameterAnnotations - */ - public static Attribute[] getParameterAnnotationAttributes( - ConstantPoolGen cp, - List<AnnotationEntryGen>[] /*Array of lists, array size depends on #params */vec) - { - int visCount[] = new int[vec.length]; - int totalVisCount = 0; - int invisCount[] = new int[vec.length]; - int totalInvisCount = 0; - try { - for (int i = 0; i < vec.length; i++) { - if (vec[i] != null) { - for (AnnotationEntryGen element : vec[i]) { - if (element.isRuntimeVisible()) { - visCount[i]++; - totalVisCount++; - } - else { - invisCount[i]++; - totalInvisCount++; - } - } - } - } - // Lets do the visible ones - ByteArrayOutputStream rvaBytes = new ByteArrayOutputStream(); - DataOutputStream rvaDos = new DataOutputStream(rvaBytes); - rvaDos.writeByte(vec.length); // First goes number of parameters - for (int i = 0; i < vec.length; i++) { - rvaDos.writeShort(visCount[i]); - if (visCount[i] > 0) { - for (AnnotationEntryGen element : vec[i]) { - if (element.isRuntimeVisible()) { - element.dump(rvaDos); - } - } - } - } - rvaDos.close(); - // Lets do the invisible ones - ByteArrayOutputStream riaBytes = new ByteArrayOutputStream(); - DataOutputStream riaDos = new DataOutputStream(riaBytes); - riaDos.writeByte(vec.length); // First goes number of parameters - for (int i = 0; i < vec.length; i++) { - riaDos.writeShort(invisCount[i]); - if (invisCount[i] > 0) { - for (AnnotationEntryGen element : vec[i]) { - if (!element.isRuntimeVisible()) { - element.dump(riaDos); - } - } - } - } - riaDos.close(); - byte[] rvaData = rvaBytes.toByteArray(); - byte[] riaData = riaBytes.toByteArray(); - int rvaIndex = -1; - int riaIndex = -1; - if (totalVisCount > 0) { - rvaIndex = cp.addUtf8("RuntimeVisibleParameterAnnotations"); - } - if (totalInvisCount > 0) { - riaIndex = cp.addUtf8("RuntimeInvisibleParameterAnnotations"); - } - List<Attribute> newAttributes = new ArrayList<Attribute>(); - if (totalVisCount > 0) { - newAttributes - .add(new RuntimeVisibleParameterAnnotations(rvaIndex, - rvaData.length, new DataInputStream(new ByteArrayInputStream(rvaData)), cp.getConstantPool())); - } - if (totalInvisCount > 0) { - newAttributes - .add(new RuntimeInvisibleParameterAnnotations(riaIndex, - riaData.length, new DataInputStream(new ByteArrayInputStream(riaData)), cp.getConstantPool())); - } - return newAttributes.toArray(new Attribute[newAttributes.size()]); - } - catch (IOException e) { - System.err - .println("IOException whilst processing parameter annotations"); - e.printStackTrace(); - } - return null; - } } Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/AnnotationEntryGen.java URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/AnnotationEntryGen.java?rev=1662190&r1=1662189&r2=1662190&view=diff ============================================================================== --- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/AnnotationEntryGen.java (original) +++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/AnnotationEntryGen.java Wed Feb 25 09:24:47 2015 @@ -17,21 +17,28 @@ */ package org.apache.bcel.generic; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; import java.io.DataInput; +import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.List; import org.apache.bcel.classfile.AnnotationEntry; +import org.apache.bcel.classfile.Attribute; import org.apache.bcel.classfile.ConstantUtf8; import org.apache.bcel.classfile.ElementValuePair; +import org.apache.bcel.classfile.RuntimeInvisibleAnnotations; +import org.apache.bcel.classfile.RuntimeInvisibleParameterAnnotations; +import org.apache.bcel.classfile.RuntimeVisibleAnnotations; +import org.apache.bcel.classfile.RuntimeVisibleParameterAnnotations; /** * @since 6.0 */ -public class AnnotationEntryGen -{ +public class AnnotationEntryGen { private int typeIndex; private List<ElementValuePairGen> evs; @@ -49,15 +56,11 @@ public class AnnotationEntryGen * and the visibility. */ public AnnotationEntryGen(AnnotationEntry a, ConstantPoolGen cpool, - boolean copyPoolEntries) - { + boolean copyPoolEntries) { this.cpool = cpool; - if (copyPoolEntries) - { + if (copyPoolEntries) { typeIndex = cpool.addUtf8(a.getAnnotationType()); - } - else - { + } else { typeIndex = a.getAnnotationTypeIndex(); } isRuntimeVisible = a.isRuntimeVisible(); @@ -65,26 +68,22 @@ public class AnnotationEntryGen } private List<ElementValuePairGen> copyValues(ElementValuePair[] in, ConstantPoolGen cpool, - boolean copyPoolEntries) - { + boolean copyPoolEntries) { List<ElementValuePairGen> out = new ArrayList<ElementValuePairGen>(); - for (ElementValuePair nvp : in) - { + for (ElementValuePair nvp : in) { out.add(new ElementValuePairGen(nvp, cpool, copyPoolEntries)); } return out; } - private AnnotationEntryGen(ConstantPoolGen cpool) - { + private AnnotationEntryGen(ConstantPoolGen cpool) { this.cpool = cpool; } /** * Retrieve an immutable version of this AnnotationGen */ - public AnnotationEntry getAnnotation() - { + public AnnotationEntry getAnnotation() { AnnotationEntry a = new AnnotationEntry(typeIndex, cpool.getConstantPool(), isRuntimeVisible); for (ElementValuePairGen element : evs) { @@ -94,9 +93,8 @@ public class AnnotationEntryGen } public AnnotationEntryGen(ObjectType type, - List<ElementValuePairGen> elements, boolean vis, - ConstantPoolGen cpool) - { + List<ElementValuePairGen> elements, boolean vis, + ConstantPoolGen cpool) { this.cpool = cpool; this.typeIndex = cpool.addUtf8(type.getSignature()); evs = elements; @@ -104,13 +102,11 @@ public class AnnotationEntryGen } public static AnnotationEntryGen read(DataInput dis, - ConstantPoolGen cpool, boolean b) throws IOException - { + ConstantPoolGen cpool, boolean b) throws IOException { AnnotationEntryGen a = new AnnotationEntryGen(cpool); a.typeIndex = dis.readUnsignedShort(); int elemValuePairCount = dis.readUnsignedShort(); - for (int i = 0; i < elemValuePairCount; i++) - { + for (int i = 0; i < elemValuePairCount; i++) { int nidx = dis.readUnsignedShort(); a.addElementNameValuePair(new ElementValuePairGen(nidx, ElementValueGen.readElementValue(dis, cpool), cpool)); @@ -119,58 +115,49 @@ public class AnnotationEntryGen return a; } - public void dump(DataOutputStream dos) throws IOException - { + public void dump(DataOutputStream dos) throws IOException { dos.writeShort(typeIndex); // u2 index of type name in cpool dos.writeShort(evs.size()); // u2 element_value pair count - for (ElementValuePairGen envp : evs) - { + for (ElementValuePairGen envp : evs) { envp.dump(dos); } } - public void addElementNameValuePair(ElementValuePairGen evp) - { + public void addElementNameValuePair(ElementValuePairGen evp) { if (evs == null) { evs = new ArrayList<ElementValuePairGen>(); } evs.add(evp); } - public int getTypeIndex() - { + public int getTypeIndex() { return typeIndex; } - public final String getTypeSignature() - { + public final String getTypeSignature() { // ConstantClass c = (ConstantClass)cpool.getConstant(typeIndex); ConstantUtf8 utf8 = (ConstantUtf8) cpool .getConstant(typeIndex/* c.getNameIndex() */); return utf8.getBytes(); } - public final String getTypeName() - { + public final String getTypeName() { return getTypeSignature();// BCELBUG: Should I use this instead? - // Utility.signatureToString(getTypeSignature()); + // Utility.signatureToString(getTypeSignature()); } /** * Returns list of ElementNameValuePair objects */ - public List<ElementValuePairGen> getValues() - { + public List<ElementValuePairGen> getValues() { return evs; } @Override - public String toString() - { + public String toString() { StringBuilder s = new StringBuilder(32); s.append("AnnotationGen:[" + getTypeName() + " #" + evs.size() + " {"); - for (int i = 0; i < evs.size(); i++) - { + for (int i = 0; i < evs.size(); i++) { s.append(evs.get(i)); if (i + 1 < evs.size()) { s.append(","); @@ -180,12 +167,10 @@ public class AnnotationEntryGen return s.toString(); } - public String toShortString() - { + public String toShortString() { StringBuilder s = new StringBuilder(); s.append("@" + getTypeName() + "("); - for (int i = 0; i < evs.size(); i++) - { + for (int i = 0; i < evs.size(); i++) { s.append(evs.get(i)); if (i + 1 < evs.size()) { s.append(","); @@ -195,13 +180,176 @@ public class AnnotationEntryGen return s.toString(); } - private void isRuntimeVisible(boolean b) - { + private void isRuntimeVisible(boolean b) { isRuntimeVisible = b; } - public boolean isRuntimeVisible() - { + public boolean isRuntimeVisible() { return isRuntimeVisible; } + + + /** + * Converts a list of AnnotationGen objects into a set of attributes + * 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 + */ + static Attribute[] getAnnotationAttributes(ConstantPoolGen cp, List<AnnotationEntryGen> vec) { + if (vec.isEmpty()) { + return new Attribute[0]; + } + + try { + int countVisible = 0; + int countInvisible = 0; + + // put the annotations in the right output stream + for (AnnotationEntryGen a : vec) { + if (a.isRuntimeVisible()) { + countVisible++; + } else { + countInvisible++; + } + } + + ByteArrayOutputStream rvaBytes = new ByteArrayOutputStream(); + ByteArrayOutputStream riaBytes = new ByteArrayOutputStream(); + DataOutputStream rvaDos = new DataOutputStream(rvaBytes); + DataOutputStream riaDos = new DataOutputStream(riaBytes); + + rvaDos.writeShort(countVisible); + riaDos.writeShort(countInvisible); + + // put the annotations in the right output stream + for (AnnotationEntryGen a : vec) { + if (a.isRuntimeVisible()) { + a.dump(rvaDos); + } else { + a.dump(riaDos); + } + } + + rvaDos.close(); + riaDos.close(); + + byte[] rvaData = rvaBytes.toByteArray(); + byte[] riaData = riaBytes.toByteArray(); + + int rvaIndex = -1; + int riaIndex = -1; + + if (rvaData.length > 2) { + rvaIndex = cp.addUtf8("RuntimeVisibleAnnotations"); + } + if (riaData.length > 2) { + riaIndex = cp.addUtf8("RuntimeInvisibleAnnotations"); + } + + List<Attribute> newAttributes = new ArrayList<Attribute>(); + if (rvaData.length > 2) { + newAttributes.add( + new RuntimeVisibleAnnotations(rvaIndex, rvaData.length, new DataInputStream(new ByteArrayInputStream(rvaData)), cp.getConstantPool())); + } + if (riaData.length > 2) { + newAttributes.add( + new RuntimeInvisibleAnnotations(riaIndex, riaData.length, new DataInputStream(new ByteArrayInputStream(riaData)), cp.getConstantPool())); + } + + return newAttributes.toArray(new Attribute[newAttributes.size()]); + } catch (IOException e) { + System.err.println("IOException whilst processing annotations"); + e.printStackTrace(); + } + return null; + } + + + /** + * Annotations against a class are stored in one of four attribute kinds: + * - RuntimeVisibleParameterAnnotations + * - RuntimeInvisibleParameterAnnotations + */ + static Attribute[] getParameterAnnotationAttributes( + ConstantPoolGen cp, + List<AnnotationEntryGen>[] /*Array of lists, array size depends on #params */vec) { + int visCount[] = new int[vec.length]; + int totalVisCount = 0; + int invisCount[] = new int[vec.length]; + int totalInvisCount = 0; + try { + for (int i = 0; i < vec.length; i++) { + if (vec[i] != null) { + for (AnnotationEntryGen element : vec[i]) { + if (element.isRuntimeVisible()) { + visCount[i]++; + totalVisCount++; + } else { + invisCount[i]++; + totalInvisCount++; + } + } + } + } + // Lets do the visible ones + ByteArrayOutputStream rvaBytes = new ByteArrayOutputStream(); + DataOutputStream rvaDos = new DataOutputStream(rvaBytes); + rvaDos.writeByte(vec.length); // First goes number of parameters + for (int i = 0; i < vec.length; i++) { + rvaDos.writeShort(visCount[i]); + if (visCount[i] > 0) { + for (AnnotationEntryGen element : vec[i]) { + if (element.isRuntimeVisible()) { + element.dump(rvaDos); + } + } + } + } + rvaDos.close(); + // Lets do the invisible ones + ByteArrayOutputStream riaBytes = new ByteArrayOutputStream(); + DataOutputStream riaDos = new DataOutputStream(riaBytes); + riaDos.writeByte(vec.length); // First goes number of parameters + for (int i = 0; i < vec.length; i++) { + riaDos.writeShort(invisCount[i]); + if (invisCount[i] > 0) { + for (AnnotationEntryGen element : vec[i]) { + if (!element.isRuntimeVisible()) { + element.dump(riaDos); + } + } + } + } + riaDos.close(); + byte[] rvaData = rvaBytes.toByteArray(); + byte[] riaData = riaBytes.toByteArray(); + int rvaIndex = -1; + int riaIndex = -1; + if (totalVisCount > 0) { + rvaIndex = cp.addUtf8("RuntimeVisibleParameterAnnotations"); + } + if (totalInvisCount > 0) { + riaIndex = cp.addUtf8("RuntimeInvisibleParameterAnnotations"); + } + List<Attribute> newAttributes = new ArrayList<Attribute>(); + if (totalVisCount > 0) { + newAttributes + .add(new RuntimeVisibleParameterAnnotations(rvaIndex, + rvaData.length, new DataInputStream(new ByteArrayInputStream(rvaData)), cp.getConstantPool())); + } + if (totalInvisCount > 0) { + newAttributes + .add(new RuntimeInvisibleParameterAnnotations(riaIndex, + riaData.length, new DataInputStream(new ByteArrayInputStream(riaData)), cp.getConstantPool())); + } + return newAttributes.toArray(new Attribute[newAttributes.size()]); + } catch (IOException e) { + System.err + .println("IOException whilst processing parameter annotations"); + e.printStackTrace(); + } + return null; + } + } Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/ClassGen.java URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/ClassGen.java?rev=1662190&r1=1662189&r2=1662190&view=diff ============================================================================== --- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/ClassGen.java (original) +++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/ClassGen.java Wed Feb 25 09:24:47 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 = Utility.getAnnotationAttributes(cp,annotation_vec); + Attribute[] annAttributes = AnnotationEntryGen.getAnnotationAttributes(cp,annotation_vec); 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/bcel/generic/FieldGen.java URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/FieldGen.java?rev=1662190&r1=1662189&r2=1662190&view=diff ============================================================================== --- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/FieldGen.java (original) +++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/FieldGen.java Wed Feb 25 09:24:47 2015 @@ -226,7 +226,7 @@ public class FieldGen extends FieldGenOr } private void addAnnotationsAsAttribute(ConstantPoolGen cp) { - Attribute[] attrs = Utility.getAnnotationAttributes(cp,annotation_vec); + Attribute[] attrs = AnnotationEntryGen.getAnnotationAttributes(cp,annotation_vec); for (Attribute attr : attrs) { addAttribute(attr); } Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/MethodGen.java URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/MethodGen.java?rev=1662190&r1=1662189&r2=1662190&view=diff ============================================================================== --- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/MethodGen.java (original) +++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/MethodGen.java Wed Feb 25 09:24:47 2015 @@ -609,7 +609,7 @@ public class MethodGen extends FieldGenO } public void addAnnotationsAsAttribute(ConstantPoolGen cp) { - Attribute[] attrs = Utility.getAnnotationAttributes(cp,annotation_vec); + Attribute[] attrs = AnnotationEntryGen.getAnnotationAttributes(cp,annotation_vec); for (Attribute attr : attrs) { addAttribute(attr); } @@ -619,7 +619,7 @@ public class MethodGen extends FieldGenO if (!hasParameterAnnotations) { return; } - Attribute[] attrs = Utility.getParameterAnnotationAttributes(cp,param_annotations); + Attribute[] attrs = AnnotationEntryGen.getParameterAnnotationAttributes(cp,param_annotations); if (attrs!=null) { for (Attribute attr : attrs) { addAttribute(attr); Copied: commons/proper/bcel/trunk/src/test/java/org/apache/bcel/generic/AnnotationGenTestCase.java (from r1654901, commons/proper/bcel/trunk/src/test/java/org/apache/bcel/AnnotationGenTestCase.java) URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/test/java/org/apache/bcel/generic/AnnotationGenTestCase.java?p2=commons/proper/bcel/trunk/src/test/java/org/apache/bcel/generic/AnnotationGenTestCase.java&p1=commons/proper/bcel/trunk/src/test/java/org/apache/bcel/AnnotationGenTestCase.java&r1=1654901&r2=1662190&rev=1662190&view=diff ============================================================================== --- commons/proper/bcel/trunk/src/test/java/org/apache/bcel/AnnotationGenTestCase.java (original) +++ commons/proper/bcel/trunk/src/test/java/org/apache/bcel/generic/AnnotationGenTestCase.java Wed Feb 25 09:24:47 2015 @@ -13,10 +13,9 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ -package org.apache.bcel; +package org.apache.bcel.generic; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -26,18 +25,13 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Vector; + +import org.apache.bcel.AbstractTestCase; +import org.apache.bcel.Constants; import org.apache.bcel.classfile.Annotations; import org.apache.bcel.classfile.Attribute; import org.apache.bcel.classfile.RuntimeInvisibleAnnotations; import org.apache.bcel.classfile.RuntimeVisibleAnnotations; -import org.apache.bcel.classfile.Utility; -import org.apache.bcel.generic.AnnotationEntryGen; -import org.apache.bcel.generic.ClassGen; -import org.apache.bcel.generic.ConstantPoolGen; -import org.apache.bcel.generic.ElementValueGen; -import org.apache.bcel.generic.ElementValuePairGen; -import org.apache.bcel.generic.ObjectType; -import org.apache.bcel.generic.SimpleElementValueGen; public class AnnotationGenTestCase extends AbstractTestCase { @@ -98,7 +92,7 @@ public class AnnotationGenTestCase exten AnnotationEntryGen a = new AnnotationEntryGen(t, elements, true, cp); Vector<AnnotationEntryGen> v = new Vector<AnnotationEntryGen>(); v.add(a); - Attribute[] attributes = Utility.getAnnotationAttributes(cp, v); + Attribute[] attributes = AnnotationEntryGen.getAnnotationAttributes(cp, v); boolean foundRV = false; for (Attribute attribute : attributes) { if (attribute instanceof RuntimeVisibleAnnotations) @@ -113,7 +107,7 @@ public class AnnotationGenTestCase exten AnnotationEntryGen a2 = new AnnotationEntryGen(t, elements, false, cp); Vector<AnnotationEntryGen> v2 = new Vector<AnnotationEntryGen>(); v2.add(a2); - Attribute[] attributes2 = Utility.getAnnotationAttributes(cp, v2); + Attribute[] attributes2 = AnnotationEntryGen.getAnnotationAttributes(cp, v2); boolean foundRIV = false; for (Attribute attribute : attributes2) { if (attribute instanceof RuntimeInvisibleAnnotations)