public AnnotationEntryGen createCombinedAnnotation(final ConstantPoolGen cp) { // Create an annotation instance final AnnotationEntryGen a = createSimpleVisibleAnnotation(cp); final ArrayElementValueGen array = new ArrayElementValueGen(cp); array.addElement(new AnnotationElementValueGen(a, cp)); final ElementValuePairGen nvp = new ElementValuePairGen("value", array, cp); final List<ElementValuePairGen> elements = new ArrayList<>(); elements.add(nvp); return new AnnotationEntryGen(new ObjectType("CombinedAnnotation"), elements, true, cp); }
/** * Return immutable variant of this ArrayElementValueGen */ @Override public ElementValue getElementValue() { final ElementValue[] immutableData = new ElementValue[evalues.size()]; int i = 0; for (final ElementValueGen element : evalues) { immutableData[i++] = element.getElementValue(); } return new ArrayElementValue(super.getElementValueType(), immutableData, getConstantPool().getConstantPool()); }
.getConstantPool()); return new ArrayElementValueGen(ARRAY, evalues, cpGen); default: throw new RuntimeException("Unexpected element value kind in annotation: " + type);
final ArrayElementValueGen arrayValue = (ArrayElementValueGen) value; assertTrue("Array value should be size one but is " + arrayValue.getElementValuesSize(), arrayValue .getElementValuesSize() == 1); final ElementValueGen innerValue = arrayValue.getElementValues().get(0); assertTrue( "Value in the array should be AnnotationElementValueGen but is "
(AnnotationElementValue) value, cpool, copyPoolEntries); case '[': // Array return new ArrayElementValueGen((ArrayElementValue) value, cpool, copyPoolEntries); case 'c': // Class