You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AnnotationsAttribute.java 23KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702
  1. /*
  2. * Javassist, a Java-bytecode translator toolkit.
  3. * Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.
  4. *
  5. * The contents of this file are subject to the Mozilla Public License Version
  6. * 1.1 (the "License"); you may not use this file except in compliance with
  7. * the License. Alternatively, the contents of this file may be used under
  8. * the terms of the GNU Lesser General Public License Version 2.1 or later,
  9. * or the Apache License Version 2.0.
  10. *
  11. * Software distributed under the License is distributed on an "AS IS" basis,
  12. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  13. * for the specific language governing rights and limitations under the
  14. * License.
  15. */
  16. package javassist.bytecode;
  17. import java.util.Map;
  18. import java.util.HashMap;
  19. import java.io.IOException;
  20. import java.io.DataInputStream;
  21. import java.io.ByteArrayOutputStream;
  22. import javassist.bytecode.annotation.*;
  23. /**
  24. * A class representing
  25. * <code>RuntimeVisibleAnnotations_attribute</code> and
  26. * <code>RuntimeInvisibleAnnotations_attribute</code>.
  27. *
  28. * <p>To obtain an AnnotationAttribute object, invoke
  29. * <code>getAttribute(AnnotationsAttribute.visibleTag)</code>
  30. * in <code>ClassFile</code>, <code>MethodInfo</code>,
  31. * or <code>FieldInfo</code>. The obtained attribute is a
  32. * runtime visible annotations attribute.
  33. * If the parameter is
  34. * <code>AnnotationAttribute.invisibleTag</code>, then the obtained
  35. * attribute is a runtime invisible one.
  36. *
  37. * <p>For example,
  38. *
  39. * <ul><pre>
  40. * import javassist.bytecode.annotation.Annotation;
  41. * :
  42. * CtMethod m = ... ;
  43. * MethodInfo minfo = m.getMethodInfo();
  44. * AnnotationsAttribute attr = (AnnotationsAttribute)
  45. * minfo.getAttribute(AnnotationsAttribute.invisibleTag);
  46. * Annotation an = attr.getAnnotation("Author");
  47. * String s = ((StringMemberValue)an.getMemberValue("name")).getValue();
  48. * System.out.println("@Author(name=" + s + ")");
  49. * </pre></ul>
  50. *
  51. * <p>This code snippet retrieves an annotation of the type <code>Author</code>
  52. * from the <code>MethodInfo</code> object specified by <code>minfo</code>.
  53. * Then, it prints the value of <code>name</code> in <code>Author</code>.
  54. *
  55. * <p>If the annotation type <code>Author</code> is annotated by a meta annotation:
  56. *
  57. * <ul><pre>
  58. * &#64;Retention(RetentionPolicy.RUNTIME)
  59. * </pre></ul>
  60. *
  61. * <p>Then <code>Author</code> is visible at runtime. Therefore, the third
  62. * statement of the code snippet above must be changed into:
  63. *
  64. * <ul><pre>
  65. * AnnotationsAttribute attr = (AnnotationsAttribute)
  66. * minfo.getAttribute(AnnotationsAttribute.visibleTag);
  67. * </pre></ul>
  68. *
  69. * <p>The attribute tag must be <code>visibleTag</code> instead of
  70. * <code>invisibleTag</code>.
  71. *
  72. * <p>If the member value of an annotation is not specified, the default value
  73. * is used as that member value. If so, <code>getMemberValue()</code> in
  74. * <code>Annotation</code> returns <code>null</code>
  75. * since the default value is not included in the
  76. * <code>AnnotationsAttribute</code>. It is included in the
  77. * <code>AnnotationDefaultAttribute</code> of the method declared in the
  78. * annotation type.
  79. *
  80. * <p>If you want to record a new AnnotationAttribute object, execute the
  81. * following snippet:
  82. *
  83. * <ul><pre>
  84. * ClassFile cf = ... ;
  85. * ConstPool cp = cf.getConstPool();
  86. * AnnotationsAttribute attr
  87. * = new AnnotationsAttribute(cp, AnnotationsAttribute.visibleTag);
  88. * Annotation a = new Annotation("Author", cp);
  89. * a.addMemberValue("name", new StringMemberValue("Chiba", cp));
  90. * attr.setAnnotation(a);
  91. * cf.addAttribute(attr);
  92. * cf.setVersionToJava5();
  93. * </pre></ul>
  94. *
  95. * <p>The last statement is necessary if the class file was produced by
  96. * Javassist or JDK 1.4. Otherwise, it is not necessary.
  97. *
  98. * @see AnnotationDefaultAttribute
  99. * @see javassist.bytecode.annotation.Annotation
  100. */
  101. public class AnnotationsAttribute extends AttributeInfo {
  102. /**
  103. * The name of the <code>RuntimeVisibleAnnotations</code> attribute.
  104. */
  105. public static final String visibleTag = "RuntimeVisibleAnnotations";
  106. /**
  107. * The name of the <code>RuntimeInvisibleAnnotations</code> attribute.
  108. */
  109. public static final String invisibleTag = "RuntimeInvisibleAnnotations";
  110. /**
  111. * Constructs a <code>Runtime(In)VisibleAnnotations_attribute</code>.
  112. *
  113. * @param cp constant pool
  114. * @param attrname attribute name (<code>visibleTag</code> or
  115. * <code>invisibleTag</code>).
  116. * @param info the contents of this attribute. It does not
  117. * include <code>attribute_name_index</code> or
  118. * <code>attribute_length</code>.
  119. */
  120. public AnnotationsAttribute(ConstPool cp, String attrname, byte[] info) {
  121. super(cp, attrname, info);
  122. }
  123. /**
  124. * Constructs an empty
  125. * <code>Runtime(In)VisibleAnnotations_attribute</code>.
  126. * A new annotation can be later added to the created attribute
  127. * by <code>setAnnotations()</code>.
  128. *
  129. * @param cp constant pool
  130. * @param attrname attribute name (<code>visibleTag</code> or
  131. * <code>invisibleTag</code>).
  132. * @see #setAnnotations(Annotation[])
  133. */
  134. public AnnotationsAttribute(ConstPool cp, String attrname) {
  135. this(cp, attrname, new byte[] { 0, 0 });
  136. }
  137. /**
  138. * @param n the attribute name.
  139. */
  140. AnnotationsAttribute(ConstPool cp, int n, DataInputStream in)
  141. throws IOException
  142. {
  143. super(cp, n, in);
  144. }
  145. /**
  146. * Returns <code>num_annotations</code>.
  147. */
  148. public int numAnnotations() {
  149. return ByteArray.readU16bit(info, 0);
  150. }
  151. /**
  152. * Copies this attribute and returns a new copy.
  153. */
  154. public AttributeInfo copy(ConstPool newCp, Map classnames) {
  155. Copier copier = new Copier(info, constPool, newCp, classnames);
  156. try {
  157. copier.annotationArray();
  158. return new AnnotationsAttribute(newCp, getName(), copier.close());
  159. }
  160. catch (Exception e) {
  161. throw new RuntimeException(e);
  162. }
  163. }
  164. /**
  165. * Parses the annotations and returns a data structure representing
  166. * the annotation with the specified type. See also
  167. * <code>getAnnotations()</code> as to the returned data structure.
  168. *
  169. * @param type the annotation type.
  170. * @return null if the specified annotation type is not included.
  171. * @see #getAnnotations()
  172. */
  173. public Annotation getAnnotation(String type) {
  174. Annotation[] annotations = getAnnotations();
  175. for (int i = 0; i < annotations.length; i++) {
  176. if (annotations[i].getTypeName().equals(type))
  177. return annotations[i];
  178. }
  179. return null;
  180. }
  181. /**
  182. * Adds an annotation. If there is an annotation with the same type,
  183. * it is removed before the new annotation is added.
  184. *
  185. * @param annotation the added annotation.
  186. */
  187. public void addAnnotation(Annotation annotation) {
  188. String type = annotation.getTypeName();
  189. Annotation[] annotations = getAnnotations();
  190. for (int i = 0; i < annotations.length; i++) {
  191. if (annotations[i].getTypeName().equals(type)) {
  192. annotations[i] = annotation;
  193. setAnnotations(annotations);
  194. return;
  195. }
  196. }
  197. Annotation[] newlist = new Annotation[annotations.length + 1];
  198. System.arraycopy(annotations, 0, newlist, 0, annotations.length);
  199. newlist[annotations.length] = annotation;
  200. setAnnotations(newlist);
  201. }
  202. /**
  203. * Parses the annotations and returns a data structure representing
  204. * that parsed annotations. Note that changes of the node values of the
  205. * returned tree are not reflected on the annotations represented by
  206. * this object unless the tree is copied back to this object by
  207. * <code>setAnnotations()</code>.
  208. *
  209. * @see #setAnnotations(Annotation[])
  210. */
  211. public Annotation[] getAnnotations() {
  212. try {
  213. return new Parser(info, constPool).parseAnnotations();
  214. }
  215. catch (Exception e) {
  216. throw new RuntimeException(e);
  217. }
  218. }
  219. /**
  220. * Changes the annotations represented by this object according to
  221. * the given array of <code>Annotation</code> objects.
  222. *
  223. * @param annotations the data structure representing the
  224. * new annotations.
  225. */
  226. public void setAnnotations(Annotation[] annotations) {
  227. ByteArrayOutputStream output = new ByteArrayOutputStream();
  228. AnnotationsWriter writer = new AnnotationsWriter(output, constPool);
  229. try {
  230. int n = annotations.length;
  231. writer.numAnnotations(n);
  232. for (int i = 0; i < n; ++i)
  233. annotations[i].write(writer);
  234. writer.close();
  235. }
  236. catch (IOException e) {
  237. throw new RuntimeException(e); // should never reach here.
  238. }
  239. set(output.toByteArray());
  240. }
  241. /**
  242. * Changes the annotations. A call to this method is equivalent to:
  243. * <ul><pre>setAnnotations(new Annotation[] { annotation })</pre></ul>
  244. *
  245. * @param annotation the data structure representing
  246. * the new annotation.
  247. */
  248. public void setAnnotation(Annotation annotation) {
  249. setAnnotations(new Annotation[] { annotation });
  250. }
  251. /**
  252. * @param oldname a JVM class name.
  253. * @param newname a JVM class name.
  254. */
  255. void renameClass(String oldname, String newname) {
  256. HashMap map = new HashMap();
  257. map.put(oldname, newname);
  258. renameClass(map);
  259. }
  260. void renameClass(Map classnames) {
  261. Renamer renamer = new Renamer(info, getConstPool(), classnames);
  262. try {
  263. renamer.annotationArray();
  264. } catch (Exception e) {
  265. throw new RuntimeException(e);
  266. }
  267. }
  268. void getRefClasses(Map classnames) { renameClass(classnames); }
  269. /**
  270. * Returns a string representation of this object.
  271. */
  272. public String toString() {
  273. Annotation[] a = getAnnotations();
  274. StringBuilder sbuf = new StringBuilder();
  275. int i = 0;
  276. while (i < a.length) {
  277. sbuf.append(a[i++].toString());
  278. if (i != a.length)
  279. sbuf.append(", ");
  280. }
  281. return sbuf.toString();
  282. }
  283. static class Walker {
  284. byte[] info;
  285. Walker(byte[] attrInfo) {
  286. info = attrInfo;
  287. }
  288. final void parameters() throws Exception {
  289. int numParam = info[0] & 0xff;
  290. parameters(numParam, 1);
  291. }
  292. void parameters(int numParam, int pos) throws Exception {
  293. for (int i = 0; i < numParam; ++i)
  294. pos = annotationArray(pos);
  295. }
  296. final void annotationArray() throws Exception {
  297. annotationArray(0);
  298. }
  299. final int annotationArray(int pos) throws Exception {
  300. int num = ByteArray.readU16bit(info, pos);
  301. return annotationArray(pos + 2, num);
  302. }
  303. int annotationArray(int pos, int num) throws Exception {
  304. for (int i = 0; i < num; ++i)
  305. pos = annotation(pos);
  306. return pos;
  307. }
  308. final int annotation(int pos) throws Exception {
  309. int type = ByteArray.readU16bit(info, pos);
  310. int numPairs = ByteArray.readU16bit(info, pos + 2);
  311. return annotation(pos + 4, type, numPairs);
  312. }
  313. int annotation(int pos, int type, int numPairs) throws Exception {
  314. for (int j = 0; j < numPairs; ++j)
  315. pos = memberValuePair(pos);
  316. return pos;
  317. }
  318. final int memberValuePair(int pos) throws Exception {
  319. int nameIndex = ByteArray.readU16bit(info, pos);
  320. return memberValuePair(pos + 2, nameIndex);
  321. }
  322. int memberValuePair(int pos, int nameIndex) throws Exception {
  323. return memberValue(pos);
  324. }
  325. final int memberValue(int pos) throws Exception {
  326. int tag = info[pos] & 0xff;
  327. if (tag == 'e') {
  328. int typeNameIndex = ByteArray.readU16bit(info, pos + 1);
  329. int constNameIndex = ByteArray.readU16bit(info, pos + 3);
  330. enumMemberValue(pos, typeNameIndex, constNameIndex);
  331. return pos + 5;
  332. }
  333. else if (tag == 'c') {
  334. int index = ByteArray.readU16bit(info, pos + 1);
  335. classMemberValue(pos, index);
  336. return pos + 3;
  337. }
  338. else if (tag == '@')
  339. return annotationMemberValue(pos + 1);
  340. else if (tag == '[') {
  341. int num = ByteArray.readU16bit(info, pos + 1);
  342. return arrayMemberValue(pos + 3, num);
  343. }
  344. else { // primitive types or String.
  345. int index = ByteArray.readU16bit(info, pos + 1);
  346. constValueMember(tag, index);
  347. return pos + 3;
  348. }
  349. }
  350. void constValueMember(int tag, int index) throws Exception {}
  351. void enumMemberValue(int pos, int typeNameIndex, int constNameIndex)
  352. throws Exception {
  353. }
  354. void classMemberValue(int pos, int index) throws Exception {}
  355. int annotationMemberValue(int pos) throws Exception {
  356. return annotation(pos);
  357. }
  358. int arrayMemberValue(int pos, int num) throws Exception {
  359. for (int i = 0; i < num; ++i) {
  360. pos = memberValue(pos);
  361. }
  362. return pos;
  363. }
  364. }
  365. static class Renamer extends Walker {
  366. ConstPool cpool;
  367. Map classnames;
  368. /**
  369. * Constructs a renamer. It renames some class names
  370. * into the new names specified by <code>map</code>.
  371. *
  372. * @param info the annotations attribute.
  373. * @param cp the constant pool.
  374. * @param map pairs of replaced and substituted class names.
  375. * It can be null.
  376. */
  377. Renamer(byte[] info, ConstPool cp, Map map) {
  378. super(info);
  379. cpool = cp;
  380. classnames = map;
  381. }
  382. int annotation(int pos, int type, int numPairs) throws Exception {
  383. renameType(pos - 4, type);
  384. return super.annotation(pos, type, numPairs);
  385. }
  386. void enumMemberValue(int pos, int typeNameIndex, int constNameIndex)
  387. throws Exception
  388. {
  389. renameType(pos + 1, typeNameIndex);
  390. super.enumMemberValue(pos, typeNameIndex, constNameIndex);
  391. }
  392. void classMemberValue(int pos, int index) throws Exception {
  393. renameType(pos + 1, index);
  394. super.classMemberValue(pos, index);
  395. }
  396. private void renameType(int pos, int index) {
  397. String name = cpool.getUtf8Info(index);
  398. String newName = Descriptor.rename(name, classnames);
  399. if (!name.equals(newName)) {
  400. int index2 = cpool.addUtf8Info(newName);
  401. ByteArray.write16bit(index2, info, pos);
  402. }
  403. }
  404. }
  405. static class Copier extends Walker {
  406. ByteArrayOutputStream output;
  407. AnnotationsWriter writer;
  408. ConstPool srcPool, destPool;
  409. Map classnames;
  410. /**
  411. * Constructs a copier. This copier renames some class names
  412. * into the new names specified by <code>map</code> when it copies
  413. * an annotation attribute.
  414. *
  415. * @param info the source attribute.
  416. * @param src the constant pool of the source class.
  417. * @param dest the constant pool of the destination class.
  418. * @param map pairs of replaced and substituted class names.
  419. * It can be null.
  420. */
  421. Copier(byte[] info, ConstPool src, ConstPool dest, Map map) {
  422. super(info);
  423. output = new ByteArrayOutputStream();
  424. writer = new AnnotationsWriter(output, dest);
  425. srcPool = src;
  426. destPool = dest;
  427. classnames = map;
  428. }
  429. byte[] close() throws IOException {
  430. writer.close();
  431. return output.toByteArray();
  432. }
  433. void parameters(int numParam, int pos) throws Exception {
  434. writer.numParameters(numParam);
  435. super.parameters(numParam, pos);
  436. }
  437. int annotationArray(int pos, int num) throws Exception {
  438. writer.numAnnotations(num);
  439. return super.annotationArray(pos, num);
  440. }
  441. int annotation(int pos, int type, int numPairs) throws Exception {
  442. writer.annotation(copyType(type), numPairs);
  443. return super.annotation(pos, type, numPairs);
  444. }
  445. int memberValuePair(int pos, int nameIndex) throws Exception {
  446. writer.memberValuePair(copy(nameIndex));
  447. return super.memberValuePair(pos, nameIndex);
  448. }
  449. void constValueMember(int tag, int index) throws Exception {
  450. writer.constValueIndex(tag, copy(index));
  451. super.constValueMember(tag, index);
  452. }
  453. void enumMemberValue(int pos, int typeNameIndex, int constNameIndex)
  454. throws Exception
  455. {
  456. writer.enumConstValue(copyType(typeNameIndex), copy(constNameIndex));
  457. super.enumMemberValue(pos, typeNameIndex, constNameIndex);
  458. }
  459. void classMemberValue(int pos, int index) throws Exception {
  460. writer.classInfoIndex(copyType(index));
  461. super.classMemberValue(pos, index);
  462. }
  463. int annotationMemberValue(int pos) throws Exception {
  464. writer.annotationValue();
  465. return super.annotationMemberValue(pos);
  466. }
  467. int arrayMemberValue(int pos, int num) throws Exception {
  468. writer.arrayValue(num);
  469. return super.arrayMemberValue(pos, num);
  470. }
  471. /**
  472. * Copies a constant pool entry into the destination constant pool
  473. * and returns the index of the copied entry.
  474. *
  475. * @param srcIndex the index of the copied entry into the source
  476. * constant pool.
  477. * @return the index of the copied item into the destination
  478. * constant pool.
  479. */
  480. int copy(int srcIndex) {
  481. return srcPool.copy(srcIndex, destPool, classnames);
  482. }
  483. /**
  484. * Copies a constant pool entry into the destination constant pool
  485. * and returns the index of the copied entry. That entry must be
  486. * a Utf8Info representing a class name in the L<class name>; form.
  487. *
  488. * @param srcIndex the index of the copied entry into the source
  489. * constant pool.
  490. * @return the index of the copied item into the destination
  491. * constant pool.
  492. */
  493. int copyType(int srcIndex) {
  494. String name = srcPool.getUtf8Info(srcIndex);
  495. String newName = Descriptor.rename(name, classnames);
  496. return destPool.addUtf8Info(newName);
  497. }
  498. }
  499. static class Parser extends Walker {
  500. ConstPool pool;
  501. Annotation[][] allParams; // all parameters
  502. Annotation[] allAnno; // all annotations
  503. Annotation currentAnno; // current annotation
  504. MemberValue currentMember; // current member
  505. /**
  506. * Constructs a parser. This parser constructs a parse tree of
  507. * the annotations.
  508. *
  509. * @param info the attribute.
  510. * @param src the constant pool.
  511. */
  512. Parser(byte[] info, ConstPool cp) {
  513. super(info);
  514. pool = cp;
  515. }
  516. Annotation[][] parseParameters() throws Exception {
  517. parameters();
  518. return allParams;
  519. }
  520. Annotation[] parseAnnotations() throws Exception {
  521. annotationArray();
  522. return allAnno;
  523. }
  524. MemberValue parseMemberValue() throws Exception {
  525. memberValue(0);
  526. return currentMember;
  527. }
  528. void parameters(int numParam, int pos) throws Exception {
  529. Annotation[][] params = new Annotation[numParam][];
  530. for (int i = 0; i < numParam; ++i) {
  531. pos = annotationArray(pos);
  532. params[i] = allAnno;
  533. }
  534. allParams = params;
  535. }
  536. int annotationArray(int pos, int num) throws Exception {
  537. Annotation[] array = new Annotation[num];
  538. for (int i = 0; i < num; ++i) {
  539. pos = annotation(pos);
  540. array[i] = currentAnno;
  541. }
  542. allAnno = array;
  543. return pos;
  544. }
  545. int annotation(int pos, int type, int numPairs) throws Exception {
  546. currentAnno = new Annotation(type, pool);
  547. return super.annotation(pos, type, numPairs);
  548. }
  549. int memberValuePair(int pos, int nameIndex) throws Exception {
  550. pos = super.memberValuePair(pos, nameIndex);
  551. currentAnno.addMemberValue(nameIndex, currentMember);
  552. return pos;
  553. }
  554. void constValueMember(int tag, int index) throws Exception {
  555. MemberValue m;
  556. ConstPool cp = pool;
  557. switch (tag) {
  558. case 'B' :
  559. m = new ByteMemberValue(index, cp);
  560. break;
  561. case 'C' :
  562. m = new CharMemberValue(index, cp);
  563. break;
  564. case 'D' :
  565. m = new DoubleMemberValue(index, cp);
  566. break;
  567. case 'F' :
  568. m = new FloatMemberValue(index, cp);
  569. break;
  570. case 'I' :
  571. m = new IntegerMemberValue(index, cp);
  572. break;
  573. case 'J' :
  574. m = new LongMemberValue(index, cp);
  575. break;
  576. case 'S' :
  577. m = new ShortMemberValue(index, cp);
  578. break;
  579. case 'Z' :
  580. m = new BooleanMemberValue(index, cp);
  581. break;
  582. case 's' :
  583. m = new StringMemberValue(index, cp);
  584. break;
  585. default :
  586. throw new RuntimeException("unknown tag:" + tag);
  587. }
  588. currentMember = m;
  589. super.constValueMember(tag, index);
  590. }
  591. void enumMemberValue(int pos, int typeNameIndex, int constNameIndex)
  592. throws Exception
  593. {
  594. currentMember = new EnumMemberValue(typeNameIndex,
  595. constNameIndex, pool);
  596. super.enumMemberValue(pos, typeNameIndex, constNameIndex);
  597. }
  598. void classMemberValue(int pos, int index) throws Exception {
  599. currentMember = new ClassMemberValue(index, pool);
  600. super.classMemberValue(pos, index);
  601. }
  602. int annotationMemberValue(int pos) throws Exception {
  603. Annotation anno = currentAnno;
  604. pos = super.annotationMemberValue(pos);
  605. currentMember = new AnnotationMemberValue(currentAnno, pool);
  606. currentAnno = anno;
  607. return pos;
  608. }
  609. int arrayMemberValue(int pos, int num) throws Exception {
  610. ArrayMemberValue amv = new ArrayMemberValue(pool);
  611. MemberValue[] elements = new MemberValue[num];
  612. for (int i = 0; i < num; ++i) {
  613. pos = memberValue(pos);
  614. elements[i] = currentMember;
  615. }
  616. amv.setValue(elements);
  617. currentMember = amv;
  618. return pos;
  619. }
  620. }
  621. }