blob: 4014f7f08e299b2e895fa40b98d57ed2b01b550e [file] [log] [blame]
The Android Open Source Project88b60792009-03-03 19:28:42 -08001/*
2 * Copyright (C) 2008 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17import com.sun.javadoc.*;
18import com.sun.tools.doclets.*;
19import org.clearsilver.HDF;
20import org.clearsilver.CS;
21import java.util.ArrayList;
22import java.util.HashMap;
23import java.util.HashSet;
24
25public class Converter
26{
27 private static RootDoc root;
28
29 public static void makeInfo(RootDoc r)
30 {
31 root = r;
32
33 int N, i;
34
35 // create the objects
36 ClassDoc[] classDocs = r.classes();
37 N = classDocs.length;
38 for (i=0; i<N; i++) {
39 Converter.obtainClass(classDocs[i]);
40 }
41 ArrayList<ClassInfo> classesNeedingInit2 = new ArrayList<ClassInfo>();
42 // fill in the fields that reference other classes
43 while (mClassesNeedingInit.size() > 0) {
44 i = mClassesNeedingInit.size()-1;
45 ClassNeedingInit clni = mClassesNeedingInit.get(i);
46 mClassesNeedingInit.remove(i);
47
48 initClass(clni.c, clni.cl);
49 classesNeedingInit2.add(clni.cl);
50 }
51 mClassesNeedingInit = null;
52 for (ClassInfo cl: classesNeedingInit2) {
53 cl.init2();
54 }
55
56 finishAnnotationValueInit();
57
58 // fill in the "root" stuff
59 mRootClasses = Converter.convertClasses(r.classes());
60 }
61
62 private static ClassInfo[] mRootClasses;
63 public static ClassInfo[] rootClasses()
64 {
65 return mRootClasses;
66 }
67
68 public static ClassInfo[] allClasses() {
69 return (ClassInfo[])mClasses.all();
70 }
71
72 private static void initClass(ClassDoc c, ClassInfo cl)
73 {
74 MethodDoc[] annotationElements;
75 if (c instanceof AnnotationTypeDoc) {
76 annotationElements = ((AnnotationTypeDoc)c).elements();
77 } else {
78 annotationElements = new MethodDoc[0];
79 }
80 cl.init(Converter.obtainType(c),
81 Converter.convertClasses(c.interfaces()),
82 Converter.convertTypes(c.interfaceTypes()),
83 Converter.convertClasses(c.innerClasses()),
84 Converter.convertMethods(c.constructors(false)),
85 Converter.convertMethods(c.methods(false)),
86 Converter.convertMethods(annotationElements),
87 Converter.convertFields(c.fields(false)),
88 Converter.convertFields(c.enumConstants()),
89 Converter.obtainPackage(c.containingPackage()),
90 Converter.obtainClass(c.containingClass()),
91 Converter.obtainClass(c.superclass()),
92 Converter.obtainType(c.superclassType()),
93 Converter.convertAnnotationInstances(c.annotations())
94 );
95 cl.setHiddenMethods(Converter.getHiddenMethods(c.methods(false)));
96 cl.setNonWrittenConstructors(Converter.convertNonWrittenConstructors(c.constructors(false)));
97 cl.init3(Converter.convertTypes(c.typeParameters()), Converter.convertClasses(c.innerClasses(false)));
98 }
99
100 public static ClassInfo obtainClass(String className)
101 {
102 return Converter.obtainClass(root.classNamed(className));
103 }
104
105 public static PackageInfo obtainPackage(String packageName)
106 {
107 return Converter.obtainPackage(root.packageNamed(packageName));
108 }
109
110 private static TagInfo convertTag(Tag tag)
111 {
112 return new TextTagInfo(tag.name(), tag.kind(), tag.text(),
113 Converter.convertSourcePosition(tag.position()));
114 }
115
116 private static ThrowsTagInfo convertThrowsTag(ThrowsTag tag,
117 ContainerInfo base)
118 {
119 return new ThrowsTagInfo(tag.name(), tag.text(), tag.kind(),
120 Converter.obtainClass(tag.exception()),
121 tag.exceptionComment(), base,
122 Converter.convertSourcePosition(tag.position()));
123 }
124
125 private static ParamTagInfo convertParamTag(ParamTag tag,
126 ContainerInfo base)
127 {
128 return new ParamTagInfo(tag.name(), tag.kind(), tag.text(),
129 tag.isTypeParameter(), tag.parameterComment(),
130 tag.parameterName(),
131 base,
132 Converter.convertSourcePosition(tag.position()));
133 }
134
135 private static SeeTagInfo convertSeeTag(SeeTag tag, ContainerInfo base)
136 {
137 return new SeeTagInfo(tag.name(), tag.kind(), tag.text(), base,
138 Converter.convertSourcePosition(tag.position()));
139 }
140
141 private static SourcePositionInfo convertSourcePosition(SourcePosition sp)
142 {
143 if (sp == null) {
144 return null;
145 }
146 return new SourcePositionInfo(sp.file().toString(), sp.line(),
147 sp.column());
148 }
149
150 public static TagInfo[] convertTags(Tag[] tags, ContainerInfo base)
151 {
152 int len = tags.length;
153 TagInfo[] out = new TagInfo[len];
154 for (int i=0; i<len; i++) {
155 Tag t = tags[i];
156 /*
157 System.out.println("Tag name='" + t.name() + "' kind='"
158 + t.kind() + "'");
159 */
160 if (t instanceof SeeTag) {
161 out[i] = Converter.convertSeeTag((SeeTag)t, base);
162 }
163 else if (t instanceof ThrowsTag) {
164 out[i] = Converter.convertThrowsTag((ThrowsTag)t, base);
165 }
166 else if (t instanceof ParamTag) {
167 out[i] = Converter.convertParamTag((ParamTag)t, base);
168 }
169 else {
170 out[i] = Converter.convertTag(t);
171 }
172 }
173 return out;
174 }
175
176 public static ClassInfo[] convertClasses(ClassDoc[] classes)
177 {
178 if (classes == null) return null;
179 int N = classes.length;
180 ClassInfo[] result = new ClassInfo[N];
181 for (int i=0; i<N; i++) {
182 result[i] = Converter.obtainClass(classes[i]);
183 }
184 return result;
185 }
186
187 private static ParameterInfo convertParameter(Parameter p, SourcePosition pos)
188 {
189 if (p == null) return null;
190 ParameterInfo pi = new ParameterInfo(p.name(), p.typeName(),
191 Converter.obtainType(p.type()),
192 Converter.convertSourcePosition(pos));
193 return pi;
194 }
195
196 private static ParameterInfo[] convertParameters(Parameter[] p, MemberDoc m)
197 {
198 SourcePosition pos = m.position();
199 int len = p.length;
200 ParameterInfo[] q = new ParameterInfo[len];
201 for (int i=0; i<len; i++) {
202 q[i] = Converter.convertParameter(p[i], pos);
203 }
204 return q;
205 }
206
207 private static TypeInfo[] convertTypes(Type[] p)
208 {
209 if (p == null) return null;
210 int len = p.length;
211 TypeInfo[] q = new TypeInfo[len];
212 for (int i=0; i<len; i++) {
213 q[i] = Converter.obtainType(p[i]);
214 }
215 return q;
216 }
217
218 private Converter()
219 {
220 }
221
222 private static class ClassNeedingInit
223 {
224 ClassNeedingInit(ClassDoc c, ClassInfo cl)
225 {
226 this.c = c;
227 this.cl = cl;
228 }
229 ClassDoc c;
230 ClassInfo cl;
231 };
232 private static ArrayList<ClassNeedingInit> mClassesNeedingInit
233 = new ArrayList<ClassNeedingInit>();
234
235 static ClassInfo obtainClass(ClassDoc o)
236 {
237 return (ClassInfo)mClasses.obtain(o);
238 }
239 private static Cache mClasses = new Cache()
240 {
241 protected Object make(Object o)
242 {
243 ClassDoc c = (ClassDoc)o;
244 ClassInfo cl = new ClassInfo(
245 c,
246 c.getRawCommentText(),
247 Converter.convertSourcePosition(c.position()),
248 c.isPublic(),
249 c.isProtected(),
250 c.isPackagePrivate(),
251 c.isPrivate(),
252 c.isStatic(),
253 c.isInterface(),
254 c.isAbstract(),
255 c.isOrdinaryClass(),
256 c.isException(),
257 c.isError(),
258 c.isEnum(),
259 (c instanceof AnnotationTypeDoc),
260 c.isFinal(),
261 c.isIncluded(),
262 c.name(),
263 c.qualifiedName(),
264 c.qualifiedTypeName(),
265 c.isPrimitive());
266 if (mClassesNeedingInit != null) {
267 mClassesNeedingInit.add(new ClassNeedingInit(c, cl));
268 }
269 return cl;
270 }
271 protected void made(Object o, Object r)
272 {
273 if (mClassesNeedingInit == null) {
274 initClass((ClassDoc)o, (ClassInfo)r);
275 ((ClassInfo)r).init2();
276 }
277 }
278 ClassInfo[] all()
279 {
280 return (ClassInfo[])mCache.values().toArray(new ClassInfo[mCache.size()]);
281 }
282 };
283
284 private static MethodInfo[] getHiddenMethods(MethodDoc[] methods){
285 if (methods == null) return null;
286 ArrayList<MethodInfo> out = new ArrayList<MethodInfo>();
287 int N = methods.length;
288 for (int i=0; i<N; i++) {
289 MethodInfo m = Converter.obtainMethod(methods[i]);
290 //System.out.println(m.toString() + ": ");
291 //for (TypeInfo ti : m.getTypeParameters()){
292 // if (ti.asClassInfo() != null){
293 //System.out.println(" " +ti.asClassInfo().toString());
294 //} else {
295 //System.out.println(" null");
296 //}
297 //}
298 if (m.isHidden()) {
299 out.add(m);
300 }
301 }
302 return out.toArray(new MethodInfo[out.size()]);
303 }
304
305 /**
306 * Convert MethodDoc[] into MethodInfo[]. Also filters according
307 * to the -private, -public option, because the filtering doesn't seem
308 * to be working in the ClassDoc.constructors(boolean) call.
309 */
310 private static MethodInfo[] convertMethods(MethodDoc[] methods)
311 {
312 if (methods == null) return null;
313 ArrayList<MethodInfo> out = new ArrayList<MethodInfo>();
314 int N = methods.length;
315 for (int i=0; i<N; i++) {
316 MethodInfo m = Converter.obtainMethod(methods[i]);
317 //System.out.println(m.toString() + ": ");
318 //for (TypeInfo ti : m.getTypeParameters()){
319 // if (ti.asClassInfo() != null){
320 //System.out.println(" " +ti.asClassInfo().toString());
321 //} else {
322 //System.out.println(" null");
323 //}
324 //}
325 if (m.checkLevel()) {
326 out.add(m);
327 }
328 }
329 return out.toArray(new MethodInfo[out.size()]);
330 }
331
332 private static MethodInfo[] convertMethods(ConstructorDoc[] methods)
333 {
334 if (methods == null) return null;
335 ArrayList<MethodInfo> out = new ArrayList<MethodInfo>();
336 int N = methods.length;
337 for (int i=0; i<N; i++) {
338 MethodInfo m = Converter.obtainMethod(methods[i]);
339 if (m.checkLevel()) {
340 out.add(m);
341 }
342 }
343 return out.toArray(new MethodInfo[out.size()]);
344 }
345
346 private static MethodInfo[] convertNonWrittenConstructors(ConstructorDoc[] methods)
347 {
348 if (methods == null) return null;
349 ArrayList<MethodInfo> out = new ArrayList<MethodInfo>();
350 int N = methods.length;
351 for (int i=0; i<N; i++) {
352 MethodInfo m = Converter.obtainMethod(methods[i]);
353 if (!m.checkLevel()) {
354 out.add(m);
355 }
356 }
357 return out.toArray(new MethodInfo[out.size()]);
358 }
359
360 private static MethodInfo obtainMethod(MethodDoc o)
361 {
362 return (MethodInfo)mMethods.obtain(o);
363 }
364 private static MethodInfo obtainMethod(ConstructorDoc o)
365 {
366 return (MethodInfo)mMethods.obtain(o);
367 }
368 private static Cache mMethods = new Cache()
369 {
370 protected Object make(Object o)
371 {
372 if (o instanceof AnnotationTypeElementDoc) {
373 AnnotationTypeElementDoc m = (AnnotationTypeElementDoc)o;
374 MethodInfo result = new MethodInfo(
375 m.getRawCommentText(),
376 Converter.convertTypes(m.typeParameters()),
377 m.name(), m.signature(),
378 Converter.obtainClass(m.containingClass()),
379 Converter.obtainClass(m.containingClass()),
380 m.isPublic(), m.isProtected(),
381 m.isPackagePrivate(), m.isPrivate(),
382 m.isFinal(), m.isStatic(), m.isSynthetic(),
383 m.isAbstract(), m.isSynchronized(), m.isNative(), true,
384 "annotationElement",
385 m.flatSignature(),
386 Converter.obtainMethod(m.overriddenMethod()),
387 Converter.obtainType(m.returnType()),
388 Converter.convertParameters(m.parameters(), m),
389 Converter.convertClasses(m.thrownExceptions()),
390 Converter.convertSourcePosition(m.position()),
391 Converter.convertAnnotationInstances(m.annotations())
392 );
393 result.setVarargs(m.isVarArgs());
394 result.init(Converter.obtainAnnotationValue(m.defaultValue(), result));
395 return result;
396 }
397 else if (o instanceof MethodDoc) {
398 MethodDoc m = (MethodDoc)o;
399 MethodInfo result = new MethodInfo(
400 m.getRawCommentText(),
401 Converter.convertTypes(m.typeParameters()),
402 m.name(), m.signature(),
403 Converter.obtainClass(m.containingClass()),
404 Converter.obtainClass(m.containingClass()),
405 m.isPublic(), m.isProtected(),
406 m.isPackagePrivate(), m.isPrivate(),
407 m.isFinal(), m.isStatic(), m.isSynthetic(),
408 m.isAbstract(), m.isSynchronized(), m.isNative(), false,
409 "method",
410 m.flatSignature(),
411 Converter.obtainMethod(m.overriddenMethod()),
412 Converter.obtainType(m.returnType()),
413 Converter.convertParameters(m.parameters(), m),
414 Converter.convertClasses(m.thrownExceptions()),
415 Converter.convertSourcePosition(m.position()),
416 Converter.convertAnnotationInstances(m.annotations())
417 );
418 result.setVarargs(m.isVarArgs());
419 result.init(null);
420 return result;
421 }
422 else {
423 ConstructorDoc m = (ConstructorDoc)o;
424 MethodInfo result = new MethodInfo(
425 m.getRawCommentText(),
426 Converter.convertTypes(m.typeParameters()),
427 m.name(), m.signature(),
428 Converter.obtainClass(m.containingClass()),
429 Converter.obtainClass(m.containingClass()),
430 m.isPublic(), m.isProtected(),
431 m.isPackagePrivate(), m.isPrivate(),
432 m.isFinal(), m.isStatic(), m.isSynthetic(),
433 false, m.isSynchronized(), m.isNative(), false,
434 "constructor",
435 m.flatSignature(),
436 null,
437 null,
438 Converter.convertParameters(m.parameters(), m),
439 Converter.convertClasses(m.thrownExceptions()),
440 Converter.convertSourcePosition(m.position()),
441 Converter.convertAnnotationInstances(m.annotations())
442 );
443 result.setVarargs(m.isVarArgs());
444 result.init(null);
445 return result;
446 }
447 }
448 };
449
450
451 private static FieldInfo[] convertFields(FieldDoc[] fields)
452 {
453 if (fields == null) return null;
454 ArrayList<FieldInfo> out = new ArrayList<FieldInfo>();
455 int N = fields.length;
456 for (int i=0; i<N; i++) {
457 FieldInfo f = Converter.obtainField(fields[i]);
458 if (f.checkLevel()) {
459 out.add(f);
460 }
461 }
462 return out.toArray(new FieldInfo[out.size()]);
463 }
464
465 private static FieldInfo obtainField(FieldDoc o)
466 {
467 return (FieldInfo)mFields.obtain(o);
468 }
469 private static FieldInfo obtainField(ConstructorDoc o)
470 {
471 return (FieldInfo)mFields.obtain(o);
472 }
473 private static Cache mFields = new Cache()
474 {
475 protected Object make(Object o)
476 {
477 FieldDoc f = (FieldDoc)o;
478 return new FieldInfo(f.name(),
479 Converter.obtainClass(f.containingClass()),
480 Converter.obtainClass(f.containingClass()),
481 f.isPublic(), f.isProtected(),
482 f.isPackagePrivate(), f.isPrivate(),
483 f.isFinal(), f.isStatic(), f.isTransient(), f.isVolatile(),
484 f.isSynthetic(),
485 Converter.obtainType(f.type()),
486 f.getRawCommentText(), f.constantValue(),
487 Converter.convertSourcePosition(f.position()),
488 Converter.convertAnnotationInstances(f.annotations())
489 );
490 }
491 };
492
493 private static PackageInfo obtainPackage(PackageDoc o)
494 {
495 return (PackageInfo)mPackagees.obtain(o);
496 }
497 private static Cache mPackagees = new Cache()
498 {
499 protected Object make(Object o)
500 {
501 PackageDoc p = (PackageDoc)o;
502 return new PackageInfo(p, p.name(),
503 Converter.convertSourcePosition(p.position()));
504 }
505 };
506
507 private static TypeInfo obtainType(Type o)
508 {
509 return (TypeInfo)mTypes.obtain(o);
510 }
511 private static Cache mTypes = new Cache()
512 {
513 protected Object make(Object o)
514 {
515 Type t = (Type)o;
516 String simpleTypeName;
517 if (t instanceof ClassDoc) {
518 simpleTypeName = ((ClassDoc)t).name();
519 } else {
520 simpleTypeName = t.simpleTypeName();
521 }
522 TypeInfo ti = new TypeInfo(t.isPrimitive(), t.dimension(),
523 simpleTypeName, t.qualifiedTypeName(),
524 Converter.obtainClass(t.asClassDoc()));
525 return ti;
526 }
527 protected void made(Object o, Object r)
528 {
529 Type t = (Type)o;
530 TypeInfo ti = (TypeInfo)r;
531 if (t.asParameterizedType() != null) {
532 ti.setTypeArguments(Converter.convertTypes(
533 t.asParameterizedType().typeArguments()));
534 }
535 else if (t instanceof ClassDoc) {
536 ti.setTypeArguments(Converter.convertTypes(((ClassDoc)t).typeParameters()));
537 }
538 else if (t.asTypeVariable() != null) {
539 ti.setBounds(null, Converter.convertTypes((t.asTypeVariable().bounds())));
540 ti.setIsTypeVariable(true);
541 }
542 else if (t.asWildcardType() != null) {
543 ti.setIsWildcard(true);
544 ti.setBounds(Converter.convertTypes(t.asWildcardType().superBounds()),
545 Converter.convertTypes(t.asWildcardType().extendsBounds()));
546 }
547 }
548 protected Object keyFor(Object o)
549 {
550 Type t = (Type)o;
551 String keyString = o.getClass().getName() + "/" + o.toString() + "/";
552 if (t.asParameterizedType() != null){
553 keyString += t.asParameterizedType().toString() +"/";
554 if (t.asParameterizedType().typeArguments() != null){
555 for(Type ty : t.asParameterizedType().typeArguments()){
556 keyString += ty.toString() + "/";
557 }
558 }
559 }else{
560 keyString += "NoParameterizedType//";
561 }
562 if (t.asTypeVariable() != null){
563 keyString += t.asTypeVariable().toString() +"/";
564 if (t.asTypeVariable().bounds() != null){
565 for(Type ty : t.asTypeVariable().bounds()){
566 keyString += ty.toString() + "/";
567 }
568 }
569 }else{
570 keyString += "NoTypeVariable//";
571 }
572 if (t.asWildcardType() != null){
573 keyString += t.asWildcardType().toString() +"/";
574 if (t.asWildcardType().superBounds() != null){
575 for(Type ty : t.asWildcardType().superBounds()){
576 keyString += ty.toString() + "/";
577 }
578 }
579 if (t.asWildcardType().extendsBounds() != null){
580 for(Type ty : t.asWildcardType().extendsBounds()){
581 keyString += ty.toString() + "/";
582 }
583 }
584 }else{
585 keyString += "NoWildCardType//";
586 }
587
588
589
590 return keyString;
591 }
592 };
593
594
595
596 private static MemberInfo obtainMember(MemberDoc o)
597 {
598 return (MemberInfo)mMembers.obtain(o);
599 }
600 private static Cache mMembers = new Cache()
601 {
602 protected Object make(Object o)
603 {
604 if (o instanceof MethodDoc) {
605 return Converter.obtainMethod((MethodDoc)o);
606 }
607 else if (o instanceof ConstructorDoc) {
608 return Converter.obtainMethod((ConstructorDoc)o);
609 }
610 else if (o instanceof FieldDoc) {
611 return Converter.obtainField((FieldDoc)o);
612 }
613 else {
614 return null;
615 }
616 }
617 };
618
619 private static AnnotationInstanceInfo[] convertAnnotationInstances(AnnotationDesc[] orig)
620 {
621 int len = orig.length;
622 AnnotationInstanceInfo[] out = new AnnotationInstanceInfo[len];
623 for (int i=0; i<len; i++) {
624 out[i] = Converter.obtainAnnotationInstance(orig[i]);
625 }
626 return out;
627 }
628
629
630 private static AnnotationInstanceInfo obtainAnnotationInstance(AnnotationDesc o)
631 {
632 return (AnnotationInstanceInfo)mAnnotationInstances.obtain(o);
633 }
634 private static Cache mAnnotationInstances = new Cache()
635 {
636 protected Object make(Object o)
637 {
638 AnnotationDesc a = (AnnotationDesc)o;
639 ClassInfo annotationType = Converter.obtainClass(a.annotationType());
640 AnnotationDesc.ElementValuePair[] ev = a.elementValues();
641 AnnotationValueInfo[] elementValues = new AnnotationValueInfo[ev.length];
642 for (int i=0; i<ev.length; i++) {
643 elementValues[i] = obtainAnnotationValue(ev[i].value(),
644 Converter.obtainMethod(ev[i].element()));
645 }
646 return new AnnotationInstanceInfo(annotationType, elementValues);
647 }
648 };
649
650
651 private abstract static class Cache
652 {
653 void put(Object key, Object value)
654 {
655 mCache.put(key, value);
656 }
657 Object obtain(Object o)
658 {
659 if (o == null ) {
660 return null;
661 }
662 Object k = keyFor(o);
663 Object r = mCache.get(k);
664 if (r == null) {
665 r = make(o);
666 mCache.put(k, r);
667 made(o, r);
668 }
669 return r;
670 }
671 protected HashMap<Object,Object> mCache = new HashMap<Object,Object>();
672 protected abstract Object make(Object o);
673 protected void made(Object o, Object r)
674 {
675 }
676 protected Object keyFor(Object o) { return o; }
677 Object[] all() { return null; }
678 }
679
680 // annotation values
681 private static HashMap<AnnotationValue,AnnotationValueInfo> mAnnotationValues = new HashMap();
682 private static HashSet<AnnotationValue> mAnnotationValuesNeedingInit = new HashSet();
683
684 private static AnnotationValueInfo obtainAnnotationValue(AnnotationValue o, MethodInfo element)
685 {
686 if (o == null) {
687 return null;
688 }
689 AnnotationValueInfo v = mAnnotationValues.get(o);
690 if (v != null) return v;
691 v = new AnnotationValueInfo(element);
692 mAnnotationValues.put(o, v);
693 if (mAnnotationValuesNeedingInit != null) {
694 mAnnotationValuesNeedingInit.add(o);
695 } else {
696 initAnnotationValue(o, v);
697 }
698 return v;
699 }
700
701 private static void initAnnotationValue(AnnotationValue o, AnnotationValueInfo v) {
702 Object orig = o.value();
703 Object converted;
704 if (orig instanceof Type) {
705 // class literal
706 converted = Converter.obtainType((Type)orig);
707 }
708 else if (orig instanceof FieldDoc) {
709 // enum constant
710 converted = Converter.obtainField((FieldDoc)orig);
711 }
712 else if (orig instanceof AnnotationDesc) {
713 // annotation instance
714 converted = Converter.obtainAnnotationInstance((AnnotationDesc)orig);
715 }
716 else if (orig instanceof AnnotationValue[]) {
717 AnnotationValue[] old = (AnnotationValue[])orig;
718 AnnotationValueInfo[] array = new AnnotationValueInfo[old.length];
719 for (int i=0; i<array.length; i++) {
720 array[i] = Converter.obtainAnnotationValue(old[i], null);
721 }
722 converted = array;
723 }
724 else {
725 converted = orig;
726 }
727 v.init(converted);
728 }
729
730 private static void finishAnnotationValueInit()
731 {
732 int depth = 0;
733 while (mAnnotationValuesNeedingInit.size() > 0) {
734 HashSet<AnnotationValue> set = mAnnotationValuesNeedingInit;
735 mAnnotationValuesNeedingInit = new HashSet();
736 for (AnnotationValue o: set) {
737 AnnotationValueInfo v = mAnnotationValues.get(o);
738 initAnnotationValue(o, v);
739 }
740 depth++;
741 }
742 mAnnotationValuesNeedingInit = null;
743 }
744}