001    /* This file was generated with JastAdd2 (http://jastadd.org) version 2.1.13-12-g880e696 */
002    package org.extendj.ast;
003    
004    import java.util.HashSet;
005    import java.io.File;
006    import java.util.Set;
007    import java.util.Collections;
008    import java.util.Collection;
009    import java.util.ArrayList;
010    import beaver.*;
011    import java.util.*;
012    import java.io.ByteArrayOutputStream;
013    import java.io.PrintStream;
014    import java.lang.reflect.InvocationTargetException;
015    import java.lang.reflect.Method;
016    import org.jastadd.util.*;
017    import java.util.zip.*;
018    import java.io.*;
019    import org.jastadd.util.PrettyPrintable;
020    import org.jastadd.util.PrettyPrinter;
021    import java.io.FileNotFoundException;
022    import java.io.BufferedInputStream;
023    import java.io.DataInputStream;
024    /**
025     * @ast node
026     * @declaredat /home/jesper/git/extendj/java4/grammar/Java.ast:64
027     * @production InterfaceDecl : {@link ReferenceType} ::= <span class="component">{@link Modifiers}</span> <span class="component">&lt;ID:String&gt;</span> <span class="component">SuperInterface:{@link Access}*</span> <span class="component">{@link BodyDecl}*</span>;
028    
029     */
030    public class InterfaceDecl extends ReferenceType implements Cloneable {
031      /**
032       * @aspect AccessControl
033       * @declaredat /home/jesper/git/extendj/java4/frontend/AccessControl.jrag:197
034       */
035      public void accessControl() {
036        super.accessControl();
037    
038        if (!isCircular()) {
039          // 9.1.2
040          HashSet set = new HashSet();
041          for (int i = 0; i < getNumSuperInterface(); i++) {
042            TypeDecl decl = getSuperInterface(i).type();
043    
044            if (!decl.isInterfaceDecl() && !decl.isUnknown()) {
045              errorf("interface %s can not extend non interface type %s", fullName(), decl.fullName());
046            }
047            if (!decl.isCircular() && !decl.accessibleFrom(this)) {
048              errorf("interface %s can not extend non accessible type %s", fullName(), decl.fullName());
049            }
050            if (set.contains(decl)) {
051              errorf("extended interface %s is mentionened multiple times in extends clause",
052                  decl.fullName());
053            }
054            set.add(decl);
055          }
056        }
057      }
058      /**
059       * @aspect Modifiers
060       * @declaredat /home/jesper/git/extendj/java4/frontend/Modifiers.jrag:132
061       */
062      public void checkModifiers() {
063        super.checkModifiers();
064      }
065      /**
066       * @aspect Java4PrettyPrint
067       * @declaredat /home/jesper/git/extendj/java4/frontend/PrettyPrint.jadd:325
068       */
069      public void prettyPrint(PrettyPrinter out) {
070        if (hasDocComment()) {
071          out.print(docComment());
072        }
073        if (!out.isNewLine()) {
074          out.println();
075        }
076        out.print(getModifiers());
077        out.print("interface ");
078        out.print(getID());
079        if (hasSuperInterface()) {
080          out.print(" extends ");
081          out.join(getSuperInterfaceList(), new PrettyPrinter.Joiner() {
082            @Override
083            public void printSeparator(PrettyPrinter out) {
084              out.print(", ");
085            }
086          });
087        }
088        out.print(" {");
089        out.println();
090        out.indent(1);
091        out.join(getBodyDecls(), new PrettyPrinter.Joiner() {
092          @Override
093          public void printSeparator(PrettyPrinter out) {
094            out.println();
095            out.println();
096          }
097        });
098        if (!out.isNewLine()) {
099          out.println();
100        }
101        out.print("}");
102      }
103      /**
104       * @aspect SuperClasses
105       * @declaredat /home/jesper/git/extendj/java4/frontend/TypeAnalysis.jrag:718
106       */
107      public Iterator<TypeDecl> interfacesIterator() {
108        return new Iterator<TypeDecl>() {
109          public boolean hasNext() {
110            computeNextCurrent();
111            return current != null;
112          }
113          public TypeDecl next() {
114            return current;
115          }
116          public void remove() {
117            throw new UnsupportedOperationException();
118          }
119          private int index = 0;
120          private TypeDecl current = null;
121          private void computeNextCurrent() {
122            current = null;
123            if (isCircular()) {
124              return;
125            }
126            while (index < getNumSuperInterface()) {
127              TypeDecl typeDecl = getSuperInterface(index++).type();
128              if (!typeDecl.isCircular() && typeDecl.isInterfaceDecl()) {
129                current = typeDecl;
130                return;
131              }
132            }
133          }
134        };
135      }
136      /**
137       * @aspect GenerateClassfile
138       * @declaredat /home/jesper/git/extendj/java4/backend/GenerateClassfile.jrag:171
139       */
140      public void generateClassfile() {
141        super.generateClassfile();
142        String fileName = destinationPath();
143        if (program().options().verbose()) {
144          System.out.println("Writing class file to " + fileName);
145        }
146        try {
147          ConstantPool cp = constantPool();
148          // force building of constant pool
149          cp.addClass(constantPoolName());
150          cp.addClass("java/lang/Object");
151          for (int i = 0; i < getNumSuperInterface(); i++) {
152            cp.addClass(getSuperInterface(i).type().constantPoolName());
153          }
154          for (Iterator iter = bcFields().iterator(); iter.hasNext(); ) {
155            FieldDeclaration field = (FieldDeclaration) iter.next();
156            cp.addUtf8(field.name());
157            cp.addUtf8(field.type().typeDescriptor());
158            field.attributes();
159          }
160          for (Iterator iter = bcMethods().iterator(); iter.hasNext(); ) {
161            Object obj = iter.next();
162            if (obj instanceof MethodDecl) {
163              MethodDecl m = (MethodDecl) obj;
164              cp.addUtf8(m.name());
165              cp.addUtf8(m.descName());
166              m.attributes();
167            }
168          }
169          attributes();
170    
171          if (hasClinit()) {
172            cp.addUtf8("<clinit>");
173            cp.addUtf8("()V");
174            clinit_attributes();
175          }
176    
177          // actual classfile generation
178          File dest = new File(fileName);
179          File parentFile = dest.getParentFile();
180          if (parentFile != null) {
181            parentFile.mkdirs();
182          }
183    
184          FileOutputStream f = new FileOutputStream(fileName);
185          DataOutputStream out = new DataOutputStream(new BufferedOutputStream(f));
186          out.writeInt(magicHeader());
187          out.writeChar(minorVersion());
188          out.writeChar(majorVersion());
189          cp.emit(out);
190          int flags = flags();
191          if (isNestedType()) {
192            flags = mangledFlags(flags);
193          }
194          if (isInterfaceDecl()) {
195            flags |= Modifiers.ACC_INTERFACE;
196          }
197          out.writeChar(flags);
198          out.writeChar(cp.addClass(constantPoolName()));
199          out.writeChar(cp.addClass("java/lang/Object"));
200          if (getNumSuperInterface() == 1 && getSuperInterface(0).type().isObject()) {
201            out.writeChar(0);
202          } else {
203            out.writeChar(getNumSuperInterface());
204          }
205          for (int i = 0; i < getNumSuperInterface(); i++) {
206            TypeDecl typeDecl = getSuperInterface(i).type();
207            if (typeDecl.isInterfaceDecl()) {
208              out.writeChar(cp.addClass(typeDecl.constantPoolName()));
209            }
210          }
211          Collection fields = bcFields();
212          out.writeChar(fields.size());
213          for (Iterator iter = fields.iterator(); iter.hasNext(); ) {
214            FieldDeclaration field = (FieldDeclaration) iter.next();
215            out.writeChar(field.flags());
216            out.writeChar(cp.addUtf8(field.name()));
217            out.writeChar(cp.addUtf8(field.type().typeDescriptor()));
218            out.writeChar(field.attributes().size());
219            for (Iterator itera = field.attributes().iterator(); itera.hasNext();) {
220              ((Attribute) itera.next()).emit(out);
221            }
222          }
223          Collection methods = bcMethods();
224          out.writeChar(methods.size() + (hasClinit() ? 1 : 0));
225          for (Iterator iter = methods.iterator(); iter.hasNext(); ) {
226            BodyDecl b = (BodyDecl) iter.next();
227            b.generateMethod(out, cp);
228          }
229          if (hasClinit()) {
230            out.writeChar(Modifiers.ACC_STATIC);
231            out.writeChar(cp.addUtf8("<clinit>"));
232            out.writeChar(cp.addUtf8("()V"));
233            out.writeChar(clinit_attributes().size());
234            for (Iterator itera = clinit_attributes().iterator(); itera.hasNext();) {
235              ((Attribute) itera.next()).emit(out);
236            }
237          }
238          out.writeChar(attributes().size());
239          for (Iterator itera = attributes().iterator(); itera.hasNext();) {
240            ((Attribute) itera.next()).emit(out);
241          }
242    
243          out.close();
244        } catch (IOException e) {
245          e.printStackTrace();
246        }
247      }
248      /**
249       * @aspect Java2Rewrites
250       * @declaredat /home/jesper/git/extendj/java4/backend/Java2Rewrites.jrag:121
251       */
252      public FieldDeclaration createStaticClassField(String name) {
253        return methodHolder().createStaticClassField(name);
254      }
255      /**
256       * @aspect Java2Rewrites
257       * @declaredat /home/jesper/git/extendj/java4/backend/Java2Rewrites.jrag:124
258       */
259      public MethodDecl createStaticClassMethod() {
260        return methodHolder().createStaticClassMethod();
261      }
262      /**
263       * @aspect Java2Rewrites
264       * @declaredat /home/jesper/git/extendj/java4/backend/Java2Rewrites.jrag:128
265       */
266      private TypeDecl methodHolder = null;
267      /**
268       * @aspect Java2Rewrites
269       * @declaredat /home/jesper/git/extendj/java4/backend/Java2Rewrites.jrag:129
270       */
271      public TypeDecl methodHolder() {
272        if (methodHolder != null) {
273          return methodHolder;
274        }
275        String name = "$" + nextAnonymousIndex();
276        ClassDecl c = addMemberClass(new ClassDecl(
277          new Modifiers(new List()),
278          name,
279          new Opt(),
280          new List(),
281          new List()
282        ));
283        methodHolder = c;
284        return c;
285      }
286      /**
287       * @aspect Generics
288       * @declaredat /home/jesper/git/extendj/java5/frontend/Generics.jrag:273
289       */
290      public TypeDecl makeGeneric(Signatures.ClassSignature s) {
291        if (s.hasFormalTypeParameters()) {
292          ASTNode node = getParent();
293          int index = node.getIndexOfChild(this);
294          node.setChild(
295              new GenericInterfaceDecl(
296                getModifiersNoTransform(),
297                getID(),
298                s.hasSuperinterfaceSignature()
299                    ? s.superinterfaceSignature()
300                    : getSuperInterfaceListNoTransform(),
301                getBodyDeclListNoTransform(),
302                s.typeParameters()
303              ),
304              index
305          );
306          return (TypeDecl) node.getChildNoTransform(index);
307        } else {
308          if (s.hasSuperinterfaceSignature()) {
309            setSuperInterfaceList(s.superinterfaceSignature());
310          }
311          return this;
312        }
313      }
314      /**
315       * @aspect LookupParTypeDecl
316       * @declaredat /home/jesper/git/extendj/java5/frontend/Generics.jrag:1445
317       */
318      public InterfaceDecl substitutedInterfaceDecl(Parameterization parTypeDecl) {
319        return new InterfaceDeclSubstituted(
320          (Modifiers) getModifiers().treeCopyNoTransform(),
321          getID(),
322          getSuperInterfaceList().substitute(parTypeDecl),
323          this
324        );
325      }
326      /**
327       * @declaredat ASTNode:1
328       */
329      public InterfaceDecl() {
330        super();
331      }
332      /**
333       * Initializes the child array to the correct size.
334       * Initializes List and Opt nta children.
335       * @apilevel internal
336       * @ast method
337       * @declaredat ASTNode:10
338       */
339      public void init$Children() {
340        children = new ASTNode[3];
341        setChild(new List(), 1);
342        setChild(new List(), 2);
343      }
344      /**
345       * @declaredat ASTNode:15
346       */
347      public InterfaceDecl(Modifiers p0, String p1, List<Access> p2, List<BodyDecl> p3) {
348        setChild(p0, 0);
349        setID(p1);
350        setChild(p2, 1);
351        setChild(p3, 2);
352      }
353      /**
354       * @declaredat ASTNode:21
355       */
356      public InterfaceDecl(Modifiers p0, beaver.Symbol p1, List<Access> p2, List<BodyDecl> p3) {
357        setChild(p0, 0);
358        setID(p1);
359        setChild(p2, 1);
360        setChild(p3, 2);
361      }
362      /**
363       * @apilevel low-level
364       * @declaredat ASTNode:30
365       */
366      protected int numChildren() {
367        return 3;
368      }
369      /**
370       * @apilevel internal
371       * @declaredat ASTNode:36
372       */
373      public boolean mayHaveRewrite() {
374        return false;
375      }
376      /**
377       * @apilevel internal
378       * @declaredat ASTNode:42
379       */
380      public void flushAttrCache() {
381        super.flushAttrCache();
382        methodsSignatureMap_reset();
383        ancestorMethods_String_reset();
384        memberTypes_String_reset();
385        memberFieldsMap_reset();
386        memberFields_String_reset();
387        isStatic_reset();
388        castingConversionTo_TypeDecl_reset();
389        instanceOf_TypeDecl_reset();
390        isCircular_reset();
391        typeDescriptor_reset();
392        erasedAncestorMethodsMap_reset();
393        implementedInterfaces_reset();
394        subtype_TypeDecl_reset();
395        needsSignatureAttribute_reset();
396        classSignature_reset();
397        hasAnnotationFunctionalInterface_reset();
398        hasFunctionDescriptor_reset();
399        functionDescriptor_reset();
400        isFunctionalInterface_reset();
401        isFunctional_reset();
402        collectAbstractMethods_reset();
403        strictSubtype_TypeDecl_reset();
404        hasOverridingMethodInSuper_MethodDecl_reset();
405      }
406      /**
407       * @apilevel internal
408       * @declaredat ASTNode:71
409       */
410      public void flushCollectionCache() {
411        super.flushCollectionCache();
412      }
413      /**
414       * @apilevel internal
415       * @declaredat ASTNode:77
416       */
417      public void flushRewriteCache() {
418        super.flushRewriteCache();
419      }
420      /**
421       * @apilevel internal
422       * @declaredat ASTNode:83
423       */
424      public InterfaceDecl clone() throws CloneNotSupportedException {
425        InterfaceDecl node = (InterfaceDecl) super.clone();
426        return node;
427      }
428      /**
429       * @apilevel internal
430       * @declaredat ASTNode:90
431       */
432      public InterfaceDecl copy() {
433        try {
434          InterfaceDecl node = (InterfaceDecl) clone();
435          node.parent = null;
436          if (children != null) {
437            node.children = (ASTNode[]) children.clone();
438          }
439          return node;
440        } catch (CloneNotSupportedException e) {
441          throw new Error("Error: clone not supported for " + getClass().getName());
442        }
443      }
444      /**
445       * Create a deep copy of the AST subtree at this node.
446       * The copy is dangling, i.e. has no parent.
447       * @return dangling copy of the subtree at this node
448       * @apilevel low-level
449       * @deprecated Please use treeCopy or treeCopyNoTransform instead
450       * @declaredat ASTNode:109
451       */
452      @Deprecated
453      public InterfaceDecl fullCopy() {
454        return treeCopyNoTransform();
455      }
456      /**
457       * Create a deep copy of the AST subtree at this node.
458       * The copy is dangling, i.e. has no parent.
459       * @return dangling copy of the subtree at this node
460       * @apilevel low-level
461       * @declaredat ASTNode:119
462       */
463      public InterfaceDecl treeCopyNoTransform() {
464        InterfaceDecl tree = (InterfaceDecl) copy();
465        if (children != null) {
466          for (int i = 0; i < children.length; ++i) {
467            ASTNode child = (ASTNode) children[i];
468            if (child != null) {
469              child = child.treeCopyNoTransform();
470              tree.setChild(child, i);
471            }
472          }
473        }
474        return tree;
475      }
476      /**
477       * Create a deep copy of the AST subtree at this node.
478       * The subtree of this node is traversed to trigger rewrites before copy.
479       * The copy is dangling, i.e. has no parent.
480       * @return dangling copy of the subtree at this node
481       * @apilevel low-level
482       * @declaredat ASTNode:139
483       */
484      public InterfaceDecl treeCopy() {
485        doFullTraversal();
486        return treeCopyNoTransform();
487      }
488      /**
489       * @apilevel internal
490       * @declaredat ASTNode:146
491       */
492      protected boolean is$Equal(ASTNode node) {
493        return super.is$Equal(node) && (tokenString_ID == ((InterfaceDecl)node).tokenString_ID);    
494      }
495      /**
496       * Replaces the Modifiers child.
497       * @param node The new node to replace the Modifiers child.
498       * @apilevel high-level
499       */
500      public void setModifiers(Modifiers node) {
501        setChild(node, 0);
502      }
503      /**
504       * Retrieves the Modifiers child.
505       * @return The current node used as the Modifiers child.
506       * @apilevel high-level
507       */
508      @ASTNodeAnnotation.Child(name="Modifiers")
509      public Modifiers getModifiers() {
510        return (Modifiers) getChild(0);
511      }
512      /**
513       * Retrieves the Modifiers child.
514       * <p><em>This method does not invoke AST transformations.</em></p>
515       * @return The current node used as the Modifiers child.
516       * @apilevel low-level
517       */
518      public Modifiers getModifiersNoTransform() {
519        return (Modifiers) getChildNoTransform(0);
520      }
521      /**
522       * Replaces the lexeme ID.
523       * @param value The new value for the lexeme ID.
524       * @apilevel high-level
525       */
526      public void setID(String value) {
527        tokenString_ID = value;
528      }
529      /**
530       * JastAdd-internal setter for lexeme ID using the Beaver parser.
531       * @param symbol Symbol containing the new value for the lexeme ID
532       * @apilevel internal
533       */
534      public void setID(beaver.Symbol symbol) {
535        if (symbol.value != null && !(symbol.value instanceof String))
536        throw new UnsupportedOperationException("setID is only valid for String lexemes");
537        tokenString_ID = (String)symbol.value;
538        IDstart = symbol.getStart();
539        IDend = symbol.getEnd();
540      }
541      /**
542       * Retrieves the value for the lexeme ID.
543       * @return The value for the lexeme ID.
544       * @apilevel high-level
545       */
546      @ASTNodeAnnotation.Token(name="ID")
547      public String getID() {
548        return tokenString_ID != null ? tokenString_ID : "";
549      }
550      /**
551       * Replaces the SuperInterface list.
552       * @param list The new list node to be used as the SuperInterface list.
553       * @apilevel high-level
554       */
555      public void setSuperInterfaceList(List<Access> list) {
556        setChild(list, 1);
557      }
558      /**
559       * Retrieves the number of children in the SuperInterface list.
560       * @return Number of children in the SuperInterface list.
561       * @apilevel high-level
562       */
563      public int getNumSuperInterface() {
564        return getSuperInterfaceList().getNumChild();
565      }
566      /**
567       * Retrieves the number of children in the SuperInterface list.
568       * Calling this method will not trigger rewrites.
569       * @return Number of children in the SuperInterface list.
570       * @apilevel low-level
571       */
572      public int getNumSuperInterfaceNoTransform() {
573        return getSuperInterfaceListNoTransform().getNumChildNoTransform();
574      }
575      /**
576       * Retrieves the element at index {@code i} in the SuperInterface list.
577       * @param i Index of the element to return.
578       * @return The element at position {@code i} in the SuperInterface list.
579       * @apilevel high-level
580       */
581      public Access getSuperInterface(int i) {
582        return (Access) getSuperInterfaceList().getChild(i);
583      }
584      /**
585       * Check whether the SuperInterface list has any children.
586       * @return {@code true} if it has at least one child, {@code false} otherwise.
587       * @apilevel high-level
588       */
589      public boolean hasSuperInterface() {
590        return getSuperInterfaceList().getNumChild() != 0;
591      }
592      /**
593       * Append an element to the SuperInterface list.
594       * @param node The element to append to the SuperInterface list.
595       * @apilevel high-level
596       */
597      public void addSuperInterface(Access node) {
598        List<Access> list = (parent == null) ? getSuperInterfaceListNoTransform() : getSuperInterfaceList();
599        list.addChild(node);
600      }
601      /**
602       * @apilevel low-level
603       */
604      public void addSuperInterfaceNoTransform(Access node) {
605        List<Access> list = getSuperInterfaceListNoTransform();
606        list.addChild(node);
607      }
608      /**
609       * Replaces the SuperInterface list element at index {@code i} with the new node {@code node}.
610       * @param node The new node to replace the old list element.
611       * @param i The list index of the node to be replaced.
612       * @apilevel high-level
613       */
614      public void setSuperInterface(Access node, int i) {
615        List<Access> list = getSuperInterfaceList();
616        list.setChild(node, i);
617      }
618      /**
619       * Retrieves the SuperInterface list.
620       * @return The node representing the SuperInterface list.
621       * @apilevel high-level
622       */
623      @ASTNodeAnnotation.ListChild(name="SuperInterface")
624      public List<Access> getSuperInterfaceList() {
625        List<Access> list = (List<Access>) getChild(1);
626        return list;
627      }
628      /**
629       * Retrieves the SuperInterface list.
630       * <p><em>This method does not invoke AST transformations.</em></p>
631       * @return The node representing the SuperInterface list.
632       * @apilevel low-level
633       */
634      public List<Access> getSuperInterfaceListNoTransform() {
635        return (List<Access>) getChildNoTransform(1);
636      }
637      /**
638       * Retrieves the SuperInterface list.
639       * @return The node representing the SuperInterface list.
640       * @apilevel high-level
641       */
642      public List<Access> getSuperInterfaces() {
643        return getSuperInterfaceList();
644      }
645      /**
646       * Retrieves the SuperInterface list.
647       * <p><em>This method does not invoke AST transformations.</em></p>
648       * @return The node representing the SuperInterface list.
649       * @apilevel low-level
650       */
651      public List<Access> getSuperInterfacesNoTransform() {
652        return getSuperInterfaceListNoTransform();
653      }
654      /**
655       * Replaces the BodyDecl list.
656       * @param list The new list node to be used as the BodyDecl list.
657       * @apilevel high-level
658       */
659      public void setBodyDeclList(List<BodyDecl> list) {
660        setChild(list, 2);
661      }
662      /**
663       * Retrieves the number of children in the BodyDecl list.
664       * @return Number of children in the BodyDecl list.
665       * @apilevel high-level
666       */
667      public int getNumBodyDecl() {
668        return getBodyDeclList().getNumChild();
669      }
670      /**
671       * Retrieves the number of children in the BodyDecl list.
672       * Calling this method will not trigger rewrites.
673       * @return Number of children in the BodyDecl list.
674       * @apilevel low-level
675       */
676      public int getNumBodyDeclNoTransform() {
677        return getBodyDeclListNoTransform().getNumChildNoTransform();
678      }
679      /**
680       * Retrieves the element at index {@code i} in the BodyDecl list.
681       * @param i Index of the element to return.
682       * @return The element at position {@code i} in the BodyDecl list.
683       * @apilevel high-level
684       */
685      public BodyDecl getBodyDecl(int i) {
686        return (BodyDecl) getBodyDeclList().getChild(i);
687      }
688      /**
689       * Check whether the BodyDecl list has any children.
690       * @return {@code true} if it has at least one child, {@code false} otherwise.
691       * @apilevel high-level
692       */
693      public boolean hasBodyDecl() {
694        return getBodyDeclList().getNumChild() != 0;
695      }
696      /**
697       * Append an element to the BodyDecl list.
698       * @param node The element to append to the BodyDecl list.
699       * @apilevel high-level
700       */
701      public void addBodyDecl(BodyDecl node) {
702        List<BodyDecl> list = (parent == null) ? getBodyDeclListNoTransform() : getBodyDeclList();
703        list.addChild(node);
704      }
705      /**
706       * @apilevel low-level
707       */
708      public void addBodyDeclNoTransform(BodyDecl node) {
709        List<BodyDecl> list = getBodyDeclListNoTransform();
710        list.addChild(node);
711      }
712      /**
713       * Replaces the BodyDecl list element at index {@code i} with the new node {@code node}.
714       * @param node The new node to replace the old list element.
715       * @param i The list index of the node to be replaced.
716       * @apilevel high-level
717       */
718      public void setBodyDecl(BodyDecl node, int i) {
719        List<BodyDecl> list = getBodyDeclList();
720        list.setChild(node, i);
721      }
722      /**
723       * Retrieves the BodyDecl list.
724       * @return The node representing the BodyDecl list.
725       * @apilevel high-level
726       */
727      @ASTNodeAnnotation.ListChild(name="BodyDecl")
728      public List<BodyDecl> getBodyDeclList() {
729        List<BodyDecl> list = (List<BodyDecl>) getChild(2);
730        return list;
731      }
732      /**
733       * Retrieves the BodyDecl list.
734       * <p><em>This method does not invoke AST transformations.</em></p>
735       * @return The node representing the BodyDecl list.
736       * @apilevel low-level
737       */
738      public List<BodyDecl> getBodyDeclListNoTransform() {
739        return (List<BodyDecl>) getChildNoTransform(2);
740      }
741      /**
742       * Retrieves the BodyDecl list.
743       * @return The node representing the BodyDecl list.
744       * @apilevel high-level
745       */
746      public List<BodyDecl> getBodyDecls() {
747        return getBodyDeclList();
748      }
749      /**
750       * Retrieves the BodyDecl list.
751       * <p><em>This method does not invoke AST transformations.</em></p>
752       * @return The node representing the BodyDecl list.
753       * @apilevel low-level
754       */
755      public List<BodyDecl> getBodyDeclsNoTransform() {
756        return getBodyDeclListNoTransform();
757      }
758      /**
759       * @aspect Java8NameCheck
760       * @declaredat /home/jesper/git/extendj/java8/frontend/NameCheck.jrag:339
761       */
762       
763      public void nameCheck() {
764        super.nameCheck();
765    
766        //9.6.3.8
767          if (hasAnnotationFunctionalInterface() && !isFunctional()) {
768            errorf("%s is not a functional interface", name());
769          }
770    
771        if (isCircular()) {
772          errorf("circular inheritance dependency in %s", typeName());
773        } else {
774          for (int i = 0; i < getNumSuperInterface(); i++) {
775            TypeDecl typeDecl = getSuperInterface(i).type();
776            if (typeDecl.isCircular()) {
777              errorf("circular inheritance dependency in %s", typeName());
778            }
779          }
780        }
781        for (Iterator<SimpleSet> iter = methodsSignatureMap().values().iterator(); iter.hasNext(); ) {
782          SimpleSet set = iter.next();
783          if (set.size() > 1) {
784            Iterator i2 = set.iterator();
785            MethodDecl m = (MethodDecl) i2.next();
786            while (i2.hasNext()) {
787              MethodDecl n = (MethodDecl) i2.next();
788              checkInterfaceMethodDecls(m, n);
789            }
790          }
791        }
792      }
793      /**
794       * @aspect Generics
795       * @declaredat /home/jesper/git/extendj/java5/frontend/Generics.jrag:102
796       */
797      private boolean refined_Generics_InterfaceDecl_castingConversionTo_TypeDecl(TypeDecl type)
798    {
799        TypeDecl S = this;
800        TypeDecl T = type;
801        if (T.isArrayDecl()) {
802          return T.instanceOf(S);
803        } else if (T.isReferenceType() && !T.isFinal()) {
804          return true;
805        } else {
806          return T.instanceOf(S);
807        }
808      }
809      /**
810       * @attribute syn
811       * @aspect ConstructScope
812       * @declaredat /home/jesper/git/extendj/java4/frontend/LookupConstructor.jrag:42
813       */
814      @ASTNodeAnnotation.Attribute
815      public Collection lookupSuperConstructor() {
816        Collection lookupSuperConstructor_value = typeObject().constructors();
817    
818        return lookupSuperConstructor_value;
819      }
820      /**
821       * @apilevel internal
822       */
823      protected boolean methodsSignatureMap_computed = false;
824      /**
825       * @apilevel internal
826       */
827      protected Map<String,SimpleSet> methodsSignatureMap_value;
828      /**
829       * @apilevel internal
830       */
831      private void methodsSignatureMap_reset() {
832        methodsSignatureMap_computed = false;
833        methodsSignatureMap_value = null;
834      }
835      /**
836       * @attribute syn
837       * @aspect MemberMethods
838       * @declaredat /home/jesper/git/extendj/java4/frontend/LookupMethod.jrag:466
839       */
840      @ASTNodeAnnotation.Attribute
841      public Map<String,SimpleSet> methodsSignatureMap() {
842        ASTNode$State state = state();
843        if (methodsSignatureMap_computed) {
844          return methodsSignatureMap_value;
845        }
846        boolean intermediate = state.INTERMEDIATE_VALUE;
847        state.INTERMEDIATE_VALUE = false;
848        int num = state.boundariesCrossed;
849        boolean isFinal = this.is$Final();
850        methodsSignatureMap_value = methodsSignatureMap_compute();
851        if (isFinal && num == state().boundariesCrossed) {
852          methodsSignatureMap_computed = true;
853        } else {
854        }
855        state.INTERMEDIATE_VALUE |= intermediate;
856    
857        return methodsSignatureMap_value;
858      }
859      /**
860       * @apilevel internal
861       */
862      private Map<String,SimpleSet> methodsSignatureMap_compute() {
863          Map<String,SimpleSet> localMap = localMethodsSignatureMap();
864          Map<String,SimpleSet> map = new HashMap<String,SimpleSet>(localMap);
865          for (Iterator<MethodDecl> iter = interfacesMethodsIterator(); iter.hasNext(); ) {
866            MethodDecl m = iter.next();
867            if (!m.isStatic() && m.accessibleFrom(this)
868                && !localMap.containsKey(m.signature())
869                && !hasOverridingMethodInSuper(m)) {
870              putSimpleSetElement(map, m.signature(), m);
871            }
872          }
873          for (Iterator<MethodDecl> iter = typeObject().methodsIterator(); iter.hasNext(); ) {
874            MethodDecl m = iter.next();
875            if (m.isPublic() && !map.containsKey(m.signature())) {
876              putSimpleSetElement(map, m.signature(), m);
877            }
878          }
879          return map;
880        }
881      /**
882       * @apilevel internal
883       */
884      protected java.util.Map ancestorMethods_String_values;
885      /**
886       * @apilevel internal
887       */
888      private void ancestorMethods_String_reset() {
889        ancestorMethods_String_values = null;
890      }
891      /**
892       * @attribute syn
893       * @aspect AncestorMethods
894       * @declaredat /home/jesper/git/extendj/java4/frontend/LookupMethod.jrag:536
895       */
896      @ASTNodeAnnotation.Attribute
897      public SimpleSet ancestorMethods(String signature) {
898        Object _parameters = signature;
899        if (ancestorMethods_String_values == null) ancestorMethods_String_values = new org.jastadd.util.RobustMap(new java.util.HashMap());
900        ASTNode$State state = state();
901        if (ancestorMethods_String_values.containsKey(_parameters)) {
902          return (SimpleSet) ancestorMethods_String_values.get(_parameters);
903        }
904        boolean intermediate = state.INTERMEDIATE_VALUE;
905        state.INTERMEDIATE_VALUE = false;
906        int num = state.boundariesCrossed;
907        boolean isFinal = this.is$Final();
908        SimpleSet ancestorMethods_String_value = ancestorMethods_compute(signature);
909        if (isFinal && num == state().boundariesCrossed) {
910          ancestorMethods_String_values.put(_parameters, ancestorMethods_String_value);
911        } else {
912        }
913        state.INTERMEDIATE_VALUE |= intermediate;
914    
915        return ancestorMethods_String_value;
916      }
917      /**
918       * @apilevel internal
919       */
920      private SimpleSet ancestorMethods_compute(String signature) {
921          SimpleSet set = SimpleSet.emptySet;
922          for (Iterator<TypeDecl> outerIter = interfacesIterator(); outerIter.hasNext(); ) {
923            TypeDecl typeDecl = outerIter.next();
924            for (Iterator iter = typeDecl.methodsSignature(signature).iterator(); iter.hasNext(); ) {
925              MethodDecl m = (MethodDecl) iter.next();
926              set = set.add(m);
927            }
928          }
929          if (!interfacesIterator().hasNext()) {
930            for (Iterator iter = typeObject().methodsSignature(signature).iterator(); iter.hasNext(); ) {
931              MethodDecl m = (MethodDecl) iter.next();
932              if (m.isPublic()) {
933                set = set.add(m);
934              }
935            }
936          }
937          return set;
938        }
939      /**
940       * @apilevel internal
941       */
942      protected java.util.Map memberTypes_String_values;
943      /**
944       * @apilevel internal
945       */
946      private void memberTypes_String_reset() {
947        memberTypes_String_values = null;
948      }
949      /**
950       * @attribute syn
951       * @aspect TypeScopePropagation
952       * @declaredat /home/jesper/git/extendj/java4/frontend/LookupType.jrag:619
953       */
954      @ASTNodeAnnotation.Attribute
955      public SimpleSet memberTypes(String name) {
956        Object _parameters = name;
957        if (memberTypes_String_values == null) memberTypes_String_values = new org.jastadd.util.RobustMap(new java.util.HashMap());
958        ASTNode$State state = state();
959        if (memberTypes_String_values.containsKey(_parameters)) {
960          return (SimpleSet) memberTypes_String_values.get(_parameters);
961        }
962        boolean intermediate = state.INTERMEDIATE_VALUE;
963        state.INTERMEDIATE_VALUE = false;
964        int num = state.boundariesCrossed;
965        boolean isFinal = this.is$Final();
966        SimpleSet memberTypes_String_value = memberTypes_compute(name);
967        if (isFinal && num == state().boundariesCrossed) {
968          memberTypes_String_values.put(_parameters, memberTypes_String_value);
969        } else {
970        }
971        state.INTERMEDIATE_VALUE |= intermediate;
972    
973        return memberTypes_String_value;
974      }
975      /**
976       * @apilevel internal
977       */
978      private SimpleSet memberTypes_compute(String name) {
979          SimpleSet set = localTypeDecls(name);
980          if (!set.isEmpty()) {
981            return set;
982          }
983          for (Iterator<TypeDecl> outerIter = interfacesIterator(); outerIter.hasNext(); ) {
984            TypeDecl typeDecl = outerIter.next();
985            for (Iterator iter = typeDecl.memberTypes(name).iterator(); iter.hasNext(); ) {
986              TypeDecl decl = (TypeDecl) iter.next();
987              if (!decl.isPrivate()) {
988                set = set.add(decl);
989              }
990            }
991          }
992          return set;
993        }
994      /**
995       * @apilevel internal
996       */
997      protected boolean memberFieldsMap_computed = false;
998      /**
999       * @apilevel internal
1000       */
1001      protected HashMap memberFieldsMap_value;
1002      /**
1003       * @apilevel internal
1004       */
1005      private void memberFieldsMap_reset() {
1006        memberFieldsMap_computed = false;
1007        memberFieldsMap_value = null;
1008      }
1009      /**
1010       * @attribute syn
1011       * @aspect Fields
1012       * @declaredat /home/jesper/git/extendj/java4/frontend/LookupVariable.jrag:383
1013       */
1014      @ASTNodeAnnotation.Attribute
1015      public HashMap memberFieldsMap() {
1016        ASTNode$State state = state();
1017        if (memberFieldsMap_computed) {
1018          return memberFieldsMap_value;
1019        }
1020        boolean intermediate = state.INTERMEDIATE_VALUE;
1021        state.INTERMEDIATE_VALUE = false;
1022        int num = state.boundariesCrossed;
1023        boolean isFinal = this.is$Final();
1024        memberFieldsMap_value = memberFieldsMap_compute();
1025        if (isFinal && num == state().boundariesCrossed) {
1026          memberFieldsMap_computed = true;
1027        } else {
1028        }
1029        state.INTERMEDIATE_VALUE |= intermediate;
1030    
1031        return memberFieldsMap_value;
1032      }
1033      /**
1034       * @apilevel internal
1035       */
1036      private HashMap memberFieldsMap_compute() {
1037          HashMap map = new HashMap(localFieldsMap());
1038          for (Iterator<TypeDecl> outerIter = interfacesIterator(); outerIter.hasNext(); ) {
1039            TypeDecl typeDecl = outerIter.next();
1040            for (Iterator iter = typeDecl.fieldsIterator(); iter.hasNext(); ) {
1041              FieldDeclaration f = (FieldDeclaration) iter.next();
1042              if (f.accessibleFrom(this) && !f.isPrivate() && !localFieldsMap().containsKey(f.name())) {
1043                putSimpleSetElement(map, f.name(), f);
1044              }
1045            }
1046          }
1047          return map;
1048        }
1049      /**
1050       * @apilevel internal
1051       */
1052      protected java.util.Map memberFields_String_values;
1053      /**
1054       * @apilevel internal
1055       */
1056      private void memberFields_String_reset() {
1057        memberFields_String_values = null;
1058      }
1059      /**
1060       * @attribute syn
1061       * @aspect Fields
1062       * @declaredat /home/jesper/git/extendj/java4/frontend/LookupVariable.jrag:435
1063       */
1064      @ASTNodeAnnotation.Attribute
1065      public SimpleSet memberFields(String name) {
1066        Object _parameters = name;
1067        if (memberFields_String_values == null) memberFields_String_values = new org.jastadd.util.RobustMap(new java.util.HashMap());
1068        ASTNode$State state = state();
1069        if (memberFields_String_values.containsKey(_parameters)) {
1070          return (SimpleSet) memberFields_String_values.get(_parameters);
1071        }
1072        boolean intermediate = state.INTERMEDIATE_VALUE;
1073        state.INTERMEDIATE_VALUE = false;
1074        int num = state.boundariesCrossed;
1075        boolean isFinal = this.is$Final();
1076        SimpleSet memberFields_String_value = memberFields_compute(name);
1077        if (isFinal && num == state().boundariesCrossed) {
1078          memberFields_String_values.put(_parameters, memberFields_String_value);
1079        } else {
1080        }
1081        state.INTERMEDIATE_VALUE |= intermediate;
1082    
1083        return memberFields_String_value;
1084      }
1085      /**
1086       * @apilevel internal
1087       */
1088      private SimpleSet memberFields_compute(String name) {
1089          SimpleSet fields = localFields(name);
1090          if (!fields.isEmpty()) {
1091            return fields;
1092          }
1093          for (Iterator<TypeDecl> outerIter = interfacesIterator(); outerIter.hasNext(); ) {
1094            TypeDecl typeDecl = (TypeDecl) outerIter.next();
1095            for (Iterator iter = typeDecl.memberFields(name).iterator(); iter.hasNext(); ) {
1096              FieldDeclaration f = (FieldDeclaration) iter.next();
1097              if (f.accessibleFrom(this) && !f.isPrivate()) {
1098                fields = fields.add(f);
1099              }
1100            }
1101          }
1102          return fields;
1103        }
1104      /**
1105       * @attribute syn
1106       * @aspect Modifiers
1107       * @declaredat /home/jesper/git/extendj/java4/frontend/Modifiers.jrag:245
1108       */
1109      @ASTNodeAnnotation.Attribute
1110      public boolean isAbstract() {
1111        boolean isAbstract_value = true;
1112    
1113        return isAbstract_value;
1114      }
1115      /**
1116       * @apilevel internal
1117       */
1118      protected boolean isStatic_computed = false;
1119      /**
1120       * @apilevel internal
1121       */
1122      protected boolean isStatic_value;
1123      /**
1124       * @apilevel internal
1125       */
1126      private void isStatic_reset() {
1127        isStatic_computed = false;
1128      }
1129      /**
1130       * @attribute syn
1131       * @aspect Modifiers
1132       * @declaredat /home/jesper/git/extendj/java4/frontend/Modifiers.jrag:247
1133       */
1134      @ASTNodeAnnotation.Attribute
1135      public boolean isStatic() {
1136        ASTNode$State state = state();
1137        if (isStatic_computed) {
1138          return isStatic_value;
1139        }
1140        boolean intermediate = state.INTERMEDIATE_VALUE;
1141        state.INTERMEDIATE_VALUE = false;
1142        int num = state.boundariesCrossed;
1143        boolean isFinal = this.is$Final();
1144        isStatic_value = getModifiers().isStatic() || isMemberType();
1145        if (isFinal && num == state().boundariesCrossed) {
1146          isStatic_computed = true;
1147        } else {
1148        }
1149        state.INTERMEDIATE_VALUE |= intermediate;
1150    
1151        return isStatic_value;
1152      }
1153      /**
1154       * @attribute syn
1155       * @aspect PrettyPrintUtil
1156       * @declaredat /home/jesper/git/extendj/java4/frontend/PrettyPrintUtil.jrag:243
1157       */
1158      @ASTNodeAnnotation.Attribute
1159      public boolean hasModifiers() {
1160        boolean hasModifiers_value = getModifiers().getNumModifier() > 0;
1161    
1162        return hasModifiers_value;
1163      }
1164      /**
1165       * @apilevel internal
1166       */
1167      protected java.util.Map castingConversionTo_TypeDecl_values;
1168      /**
1169       * @apilevel internal
1170       */
1171      private void castingConversionTo_TypeDecl_reset() {
1172        castingConversionTo_TypeDecl_values = null;
1173      }
1174      /**
1175       * @attribute syn
1176       * @aspect TypeConversion
1177       * @declaredat /home/jesper/git/extendj/java4/frontend/TypeAnalysis.jrag:109
1178       */
1179      @ASTNodeAnnotation.Attribute
1180      public boolean castingConversionTo(TypeDecl type) {
1181        Object _parameters = type;
1182        if (castingConversionTo_TypeDecl_values == null) castingConversionTo_TypeDecl_values = new org.jastadd.util.RobustMap(new java.util.HashMap());
1183        ASTNode$State state = state();
1184        if (castingConversionTo_TypeDecl_values.containsKey(_parameters)) {
1185          return (Boolean) castingConversionTo_TypeDecl_values.get(_parameters);
1186        }
1187        boolean intermediate = state.INTERMEDIATE_VALUE;
1188        state.INTERMEDIATE_VALUE = false;
1189        int num = state.boundariesCrossed;
1190        boolean isFinal = this.is$Final();
1191        boolean castingConversionTo_TypeDecl_value = castingConversionTo_compute(type);
1192        if (isFinal && num == state().boundariesCrossed) {
1193          castingConversionTo_TypeDecl_values.put(_parameters, castingConversionTo_TypeDecl_value);
1194        } else {
1195        }
1196        state.INTERMEDIATE_VALUE |= intermediate;
1197    
1198        return castingConversionTo_TypeDecl_value;
1199      }
1200      /**
1201       * @apilevel internal
1202       */
1203      private boolean castingConversionTo_compute(TypeDecl type) {
1204          if (refined_Generics_InterfaceDecl_castingConversionTo_TypeDecl(type)) {
1205            return true;
1206          }
1207          boolean canUnboxThis = !unboxed().isUnknown();
1208          boolean canUnboxType = !type.unboxed().isUnknown();
1209          if (canUnboxThis && !canUnboxType) {
1210            return unboxed().wideningConversionTo(type);
1211          }
1212          return false;
1213          /*
1214          else if (unboxingConversionTo(type)) {
1215            return true;
1216          }
1217          return false;
1218          */
1219        }
1220      /**
1221       * @attribute syn
1222       * @aspect TypeAnalysis
1223       * @declaredat /home/jesper/git/extendj/java4/frontend/TypeAnalysis.jrag:235
1224       */
1225      @ASTNodeAnnotation.Attribute
1226      public boolean isInterfaceDecl() {
1227        boolean isInterfaceDecl_value = true;
1228    
1229        return isInterfaceDecl_value;
1230      }
1231      /**
1232       * @apilevel internal
1233       */
1234      protected java.util.Map instanceOf_TypeDecl_values;
1235      /**
1236       * @apilevel internal
1237       */
1238      private void instanceOf_TypeDecl_reset() {
1239        instanceOf_TypeDecl_values = null;
1240      }
1241      /**
1242       * @attribute syn
1243       * @aspect TypeWideningAndIdentity
1244       * @declaredat /home/jesper/git/extendj/java4/frontend/TypeAnalysis.jrag:442
1245       */
1246      @ASTNodeAnnotation.Attribute
1247      public boolean instanceOf(TypeDecl type) {
1248        Object _parameters = type;
1249        if (instanceOf_TypeDecl_values == null) instanceOf_TypeDecl_values = new org.jastadd.util.RobustMap(new java.util.HashMap());
1250        ASTNode$State state = state();
1251        if (instanceOf_TypeDecl_values.containsKey(_parameters)) {
1252          return (Boolean) instanceOf_TypeDecl_values.get(_parameters);
1253        }
1254        boolean intermediate = state.INTERMEDIATE_VALUE;
1255        state.INTERMEDIATE_VALUE = false;
1256        int num = state.boundariesCrossed;
1257        boolean isFinal = this.is$Final();
1258        boolean instanceOf_TypeDecl_value = instanceOf_compute(type);
1259        if (isFinal && num == state().boundariesCrossed) {
1260          instanceOf_TypeDecl_values.put(_parameters, instanceOf_TypeDecl_value);
1261        } else {
1262        }
1263        state.INTERMEDIATE_VALUE |= intermediate;
1264    
1265        return instanceOf_TypeDecl_value;
1266      }
1267      /**
1268       * @apilevel internal
1269       */
1270      private boolean instanceOf_compute(TypeDecl type) { return subtype(type); }
1271      /**
1272       * @attribute syn
1273       * @aspect TypeWideningAndIdentity
1274       * @declaredat /home/jesper/git/extendj/java4/frontend/TypeAnalysis.jrag:458
1275       */
1276      @ASTNodeAnnotation.Attribute
1277      public boolean isSupertypeOfClassDecl(ClassDecl type) {
1278        {
1279            if (super.isSupertypeOfClassDecl(type)) {
1280              return true;
1281            }
1282            for (Iterator<TypeDecl> iter = type.interfacesIterator(); iter.hasNext(); ) {
1283              TypeDecl typeDecl = (TypeDecl) iter.next();
1284              if (typeDecl.instanceOf(this)) {
1285                return true;
1286              }
1287            }
1288            return type.hasSuperclass() && type.superclass().instanceOf(this);
1289          }
1290      }
1291      /**
1292       * @attribute syn
1293       * @aspect TypeWideningAndIdentity
1294       * @declaredat /home/jesper/git/extendj/java4/frontend/TypeAnalysis.jrag:478
1295       */
1296      @ASTNodeAnnotation.Attribute
1297      public boolean isSupertypeOfInterfaceDecl(InterfaceDecl type) {
1298        {
1299            if (super.isSupertypeOfInterfaceDecl(type)) {
1300              return true;
1301            }
1302            for (Iterator<TypeDecl> iter = type.interfacesIterator(); iter.hasNext(); ) {
1303              TypeDecl superinterface = (TypeDecl) iter.next();
1304              if (superinterface.instanceOf(this)) {
1305                return true;
1306              }
1307            }
1308            return false;
1309          }
1310      }
1311      /**
1312       * @attribute syn
1313       * @aspect TypeWideningAndIdentity
1314       * @declaredat /home/jesper/git/extendj/java4/frontend/TypeAnalysis.jrag:493
1315       */
1316      @ASTNodeAnnotation.Attribute
1317      public boolean isSupertypeOfArrayDecl(ArrayDecl type) {
1318        {
1319            if (super.isSupertypeOfArrayDecl(type)) {
1320              return true;
1321            }
1322            for (Iterator<TypeDecl> iter = type.interfacesIterator(); iter.hasNext(); ) {
1323              TypeDecl typeDecl = (TypeDecl) iter.next();
1324              if (typeDecl.instanceOf(this)) {
1325                return true;
1326              }
1327            }
1328            return false;
1329          }
1330      }
1331      /**
1332       * @apilevel internal
1333       */
1334      protected int isCircular_visited = -1;
1335      /**
1336       * @apilevel internal
1337       */
1338      private void isCircular_reset() {
1339        isCircular_computed = false;
1340        isCircular_initialized = false;
1341        isCircular_visited = -1;
1342      }
1343      /**
1344       * @apilevel internal
1345       */
1346      protected boolean isCircular_computed = false;
1347      /**
1348       * @apilevel internal
1349       */
1350      protected boolean isCircular_initialized = false;
1351      /**
1352       * @apilevel internal
1353       */
1354      protected boolean isCircular_value;
1355      @ASTNodeAnnotation.Attribute
1356      public boolean isCircular() {
1357        if (isCircular_computed) {
1358          return isCircular_value;
1359        }
1360        ASTNode$State state = state();
1361        boolean new_isCircular_value;
1362        if (!isCircular_initialized) {
1363          isCircular_initialized = true;
1364          isCircular_value = true;
1365        }
1366        if (!state.IN_CIRCLE) {
1367          state.IN_CIRCLE = true;
1368          int num = state.boundariesCrossed;
1369          boolean isFinal = this.is$Final();
1370          do {
1371            isCircular_visited = state.CIRCLE_INDEX;
1372            state.CHANGE = false;
1373            new_isCircular_value = isCircular_compute();
1374            if (new_isCircular_value != isCircular_value) {
1375              state.CHANGE = true;
1376            }
1377            isCircular_value = new_isCircular_value;
1378            state.CIRCLE_INDEX++;
1379          } while (state.CHANGE);
1380          if (isFinal && num == state().boundariesCrossed) {
1381            isCircular_computed = true;
1382          } else {
1383            state.RESET_CYCLE = true;
1384            boolean $tmp = isCircular_compute();
1385            state.RESET_CYCLE = false;
1386            isCircular_computed = false;
1387            isCircular_initialized = false;
1388          }
1389          state.IN_CIRCLE = false;
1390          state.INTERMEDIATE_VALUE = false;
1391          return isCircular_value;
1392        }
1393        if (isCircular_visited != state.CIRCLE_INDEX) {
1394          isCircular_visited = state.CIRCLE_INDEX;
1395          if (state.RESET_CYCLE) {
1396            isCircular_computed = false;
1397            isCircular_initialized = false;
1398            isCircular_visited = -1;
1399            return isCircular_value;
1400          }
1401          new_isCircular_value = isCircular_compute();
1402          if (new_isCircular_value != isCircular_value) {
1403            state.CHANGE = true;
1404          }
1405          isCircular_value = new_isCircular_value;
1406          state.INTERMEDIATE_VALUE = true;
1407          return isCircular_value;
1408        }
1409        state.INTERMEDIATE_VALUE = true;
1410        return isCircular_value;
1411      }
1412      /**
1413       * @apilevel internal
1414       */
1415      private boolean isCircular_compute() {
1416          for (int i = 0; i < getNumSuperInterface(); i++) {
1417            Access a = getSuperInterface(i).lastAccess();
1418            while (a != null) {
1419              if (a.type().isCircular()) {
1420                return true;
1421              }
1422              a = (a.isQualified() && a.qualifier().isTypeAccess()) ? (Access) a.qualifier() : null;
1423            }
1424          }
1425          return false;
1426        }
1427      /**
1428       * @apilevel internal
1429       */
1430      protected boolean typeDescriptor_computed = false;
1431      /**
1432       * @apilevel internal
1433       */
1434      protected String typeDescriptor_value;
1435      /**
1436       * @apilevel internal
1437       */
1438      private void typeDescriptor_reset() {
1439        typeDescriptor_computed = false;
1440        typeDescriptor_value = null;
1441      }
1442      /**
1443       * @attribute syn
1444       * @aspect ConstantPoolNames
1445       * @declaredat /home/jesper/git/extendj/java4/backend/ConstantPoolNames.jrag:77
1446       */
1447      @ASTNodeAnnotation.Attribute
1448      public String typeDescriptor() {
1449        ASTNode$State state = state();
1450        if (typeDescriptor_computed) {
1451          return typeDescriptor_value;
1452        }
1453        boolean intermediate = state.INTERMEDIATE_VALUE;
1454        state.INTERMEDIATE_VALUE = false;
1455        int num = state.boundariesCrossed;
1456        boolean isFinal = this.is$Final();
1457        typeDescriptor_value = "L" + constantPoolName() + ";";
1458        if (isFinal && num == state().boundariesCrossed) {
1459          typeDescriptor_computed = true;
1460        } else {
1461        }
1462        state.INTERMEDIATE_VALUE |= intermediate;
1463    
1464        return typeDescriptor_value;
1465      }
1466      /**
1467       * @attribute syn
1468       * @aspect CreateBCode
1469       * @declaredat /home/jesper/git/extendj/java4/backend/CreateBCode.jrag:900
1470       */
1471      @ASTNodeAnnotation.Attribute
1472      public String arrayTypeDescriptor() {
1473        String arrayTypeDescriptor_value = constantPoolName();
1474    
1475        return arrayTypeDescriptor_value;
1476      }
1477      /**
1478       * @apilevel internal
1479       */
1480      protected boolean erasedAncestorMethodsMap_computed = false;
1481      /**
1482       * @apilevel internal
1483       */
1484      protected Map<String,SimpleSet> erasedAncestorMethodsMap_value;
1485      /**
1486       * @apilevel internal
1487       */
1488      private void erasedAncestorMethodsMap_reset() {
1489        erasedAncestorMethodsMap_computed = false;
1490        erasedAncestorMethodsMap_value = null;
1491      }
1492      /**
1493       * @attribute syn
1494       * @aspect GenericsTypeCheck
1495       * @declaredat /home/jesper/git/extendj/java5/frontend/Generics.jrag:496
1496       */
1497      @ASTNodeAnnotation.Attribute
1498      public Map<String,SimpleSet> erasedAncestorMethodsMap() {
1499        ASTNode$State state = state();
1500        if (erasedAncestorMethodsMap_computed) {
1501          return erasedAncestorMethodsMap_value;
1502        }
1503        boolean intermediate = state.INTERMEDIATE_VALUE;
1504        state.INTERMEDIATE_VALUE = false;
1505        int num = state.boundariesCrossed;
1506        boolean isFinal = this.is$Final();
1507        erasedAncestorMethodsMap_value = erasedAncestorMethodsMap_compute();
1508        if (isFinal && num == state().boundariesCrossed) {
1509          erasedAncestorMethodsMap_computed = true;
1510        } else {
1511        }
1512        state.INTERMEDIATE_VALUE |= intermediate;
1513    
1514        return erasedAncestorMethodsMap_value;
1515      }
1516      /**
1517       * @apilevel internal
1518       */
1519      private Map<String,SimpleSet> erasedAncestorMethodsMap_compute() {
1520          Map<String,SimpleSet> localMap = localMethodsSignatureMap();
1521          Map<String,SimpleSet> map = new HashMap<String,SimpleSet>(localMap);
1522          for (Iterator<MethodDecl> iter = interfacesMethodsIterator(); iter.hasNext(); ) {
1523            MethodDecl m = (MethodDecl) iter.next();
1524            if (m.accessibleFrom(this) && m.erasedMethod() != m) {
1525              String erasedSignature = m.erasedMethod().signature();
1526              if (!localMap.containsKey(erasedSignature)) {
1527                // map erased signature to substituted method
1528                putSimpleSetElement(map, m.erasedMethod().signature(), m);
1529              }
1530            }
1531          }
1532          for (Iterator<MethodDecl> iter = typeObject().methodsIterator(); iter.hasNext(); ) {
1533            MethodDecl m = (MethodDecl) iter.next();
1534            if (m.isPublic() && m.erasedMethod() != m) {
1535              String erasedSignature = m.erasedMethod().signature();
1536              if (!localMap.containsKey(erasedSignature)) {
1537                // map erased signature to substituted method
1538                putSimpleSetElement(map, m.erasedMethod().signature(), m);
1539              }
1540            }
1541          }
1542          return map;
1543        }
1544      /**
1545       * @apilevel internal
1546       */
1547      protected boolean implementedInterfaces_computed = false;
1548      /**
1549       * @apilevel internal
1550       */
1551      protected HashSet<InterfaceDecl> implementedInterfaces_value;
1552      /**
1553       * @apilevel internal
1554       */
1555      private void implementedInterfaces_reset() {
1556        implementedInterfaces_computed = false;
1557        implementedInterfaces_value = null;
1558      }
1559      /**
1560       * @attribute syn
1561       * @aspect GenericsTypeCheck
1562       * @declaredat /home/jesper/git/extendj/java5/frontend/Generics.jrag:614
1563       */
1564      @ASTNodeAnnotation.Attribute
1565      public HashSet<InterfaceDecl> implementedInterfaces() {
1566        ASTNode$State state = state();
1567        if (implementedInterfaces_computed) {
1568          return implementedInterfaces_value;
1569        }
1570        boolean intermediate = state.INTERMEDIATE_VALUE;
1571        state.INTERMEDIATE_VALUE = false;
1572        int num = state.boundariesCrossed;
1573        boolean isFinal = this.is$Final();
1574        implementedInterfaces_value = implementedInterfaces_compute();
1575        if (isFinal && num == state().boundariesCrossed) {
1576          implementedInterfaces_computed = true;
1577        } else {
1578        }
1579        state.INTERMEDIATE_VALUE |= intermediate;
1580    
1581        return implementedInterfaces_value;
1582      }
1583      /**
1584       * @apilevel internal
1585       */
1586      private HashSet<InterfaceDecl> implementedInterfaces_compute() {
1587          HashSet<InterfaceDecl> set= new HashSet<InterfaceDecl>();
1588          set.addAll(typeObject().implementedInterfaces());
1589          for (Iterator<TypeDecl> iter = interfacesIterator(); iter.hasNext(); ) {
1590            InterfaceDecl decl = (InterfaceDecl) iter.next();
1591            set.add(decl);
1592            set.addAll(decl.implementedInterfaces());
1593          }
1594          return set;
1595        }
1596      /**
1597       * @apilevel internal
1598       */
1599      private void subtype_TypeDecl_reset() {
1600        subtype_TypeDecl_values = null;
1601      }
1602      protected java.util.Map subtype_TypeDecl_values;
1603      @ASTNodeAnnotation.Attribute
1604      public boolean subtype(TypeDecl type) {
1605        Object _parameters = type;
1606        if (subtype_TypeDecl_values == null) subtype_TypeDecl_values = new org.jastadd.util.RobustMap(new java.util.HashMap());
1607        ASTNode$State.CircularValue _value;
1608        if (subtype_TypeDecl_values.containsKey(_parameters)) {
1609          Object _o = subtype_TypeDecl_values.get(_parameters);
1610          if (!(_o instanceof ASTNode$State.CircularValue)) {
1611            return (Boolean) _o;
1612          } else {
1613            _value = (ASTNode$State.CircularValue) _o;
1614          }
1615        } else {
1616          _value = new ASTNode$State.CircularValue();
1617          subtype_TypeDecl_values.put(_parameters, _value);
1618          _value.value = true;
1619        }
1620        ASTNode$State state = state();
1621        boolean new_subtype_TypeDecl_value;
1622        if (!state.IN_CIRCLE) {
1623          state.IN_CIRCLE = true;
1624          int num = state.boundariesCrossed;
1625          boolean isFinal = this.is$Final();
1626          // TODO: fixme
1627          // state().CIRCLE_INDEX = 1;
1628          do {
1629            _value.visited = state.CIRCLE_INDEX;
1630            state.CHANGE = false;
1631            new_subtype_TypeDecl_value = type.supertypeInterfaceDecl(this);
1632            if (new_subtype_TypeDecl_value != ((Boolean)_value.value)) {
1633              state.CHANGE = true;
1634              _value.value = new_subtype_TypeDecl_value;
1635            }
1636            state.CIRCLE_INDEX++;
1637          } while (state.CHANGE);
1638          if (isFinal && num == state().boundariesCrossed) {
1639            subtype_TypeDecl_values.put(_parameters, new_subtype_TypeDecl_value);
1640          } else {
1641            subtype_TypeDecl_values.remove(_parameters);
1642            state.RESET_CYCLE = true;
1643            boolean $tmp = type.supertypeInterfaceDecl(this);
1644            state.RESET_CYCLE = false;
1645          }
1646          state.IN_CIRCLE = false;
1647          state.INTERMEDIATE_VALUE = false;
1648          return new_subtype_TypeDecl_value;
1649        }
1650        if (state.CIRCLE_INDEX != _value.visited) {
1651          _value.visited = state.CIRCLE_INDEX;
1652          new_subtype_TypeDecl_value = type.supertypeInterfaceDecl(this);
1653          if (state.RESET_CYCLE) {
1654            subtype_TypeDecl_values.remove(_parameters);
1655          }
1656          else if (new_subtype_TypeDecl_value != ((Boolean)_value.value)) {
1657            state.CHANGE = true;
1658            _value.value = new_subtype_TypeDecl_value;
1659          }
1660          state.INTERMEDIATE_VALUE = true;
1661          return new_subtype_TypeDecl_value;
1662        }
1663        state.INTERMEDIATE_VALUE = true;
1664        return (Boolean) _value.value;
1665      }
1666      /**
1667       * @attribute syn
1668       * @aspect GenericsSubtype
1669       * @declaredat /home/jesper/git/extendj/java5/frontend/GenericsSubtype.jrag:448
1670       */
1671      @ASTNodeAnnotation.Attribute
1672      public boolean supertypeClassDecl(ClassDecl type) {
1673        {
1674            if (super.supertypeClassDecl(type)) {
1675              return true;
1676            }
1677            for (Iterator<TypeDecl> iter = type.interfacesIterator(); iter.hasNext(); ) {
1678              TypeDecl typeDecl = iter.next();
1679              if (typeDecl.subtype(this)) {
1680                return true;
1681              }
1682            }
1683            return type.hasSuperclass() && type.superclass().subtype(this);
1684          }
1685      }
1686      /**
1687       * @attribute syn
1688       * @aspect GenericsSubtype
1689       * @declaredat /home/jesper/git/extendj/java5/frontend/GenericsSubtype.jrag:465
1690       */
1691      @ASTNodeAnnotation.Attribute
1692      public boolean supertypeInterfaceDecl(InterfaceDecl type) {
1693        {
1694            if (super.supertypeInterfaceDecl(type)) {
1695              return true;
1696            }
1697            for (Iterator<TypeDecl> iter = type.interfacesIterator(); iter.hasNext(); ) {
1698              TypeDecl superinterface = iter.next();
1699              if (superinterface.subtype(this)) {
1700                return true;
1701              }
1702            }
1703            return false;
1704          }
1705      }
1706      /**
1707       * @attribute syn
1708       * @aspect GenericsSubtype
1709       * @declaredat /home/jesper/git/extendj/java5/frontend/GenericsSubtype.jrag:480
1710       */
1711      @ASTNodeAnnotation.Attribute
1712      public boolean supertypeArrayDecl(ArrayDecl type) {
1713        {
1714            if (super.supertypeArrayDecl(type)) {
1715              return true;
1716            }
1717            for (Iterator<TypeDecl> iter = type.interfacesIterator(); iter.hasNext(); ) {
1718              TypeDecl typeDecl = iter.next();
1719              if (typeDecl.subtype(this)) {
1720                return true;
1721              }
1722            }
1723            return false;
1724          }
1725      }
1726      /**
1727       * @attribute syn
1728       * @aspect GenericsCodegen
1729       * @declaredat /home/jesper/git/extendj/java5/backend/GenericsCodegen.jrag:228
1730       */
1731      @ASTNodeAnnotation.Attribute
1732      public SimpleSet bridgeCandidates(String signature) {
1733        SimpleSet bridgeCandidates_String_value = ancestorMethods(signature);
1734    
1735        return bridgeCandidates_String_value;
1736      }
1737      /**
1738       * @apilevel internal
1739       */
1740      protected boolean needsSignatureAttribute_computed = false;
1741      /**
1742       * @apilevel internal
1743       */
1744      protected boolean needsSignatureAttribute_value;
1745      /**
1746       * @apilevel internal
1747       */
1748      private void needsSignatureAttribute_reset() {
1749        needsSignatureAttribute_computed = false;
1750      }
1751      /**
1752       * @attribute syn
1753       * @aspect GenericsCodegen
1754       * @declaredat /home/jesper/git/extendj/java5/backend/GenericsCodegen.jrag:345
1755       */
1756      @ASTNodeAnnotation.Attribute
1757      public boolean needsSignatureAttribute() {
1758        ASTNode$State state = state();
1759        if (needsSignatureAttribute_computed) {
1760          return needsSignatureAttribute_value;
1761        }
1762        boolean intermediate = state.INTERMEDIATE_VALUE;
1763        state.INTERMEDIATE_VALUE = false;
1764        int num = state.boundariesCrossed;
1765        boolean isFinal = this.is$Final();
1766        needsSignatureAttribute_value = needsSignatureAttribute_compute();
1767        if (isFinal && num == state().boundariesCrossed) {
1768          needsSignatureAttribute_computed = true;
1769        } else {
1770        }
1771        state.INTERMEDIATE_VALUE |= intermediate;
1772    
1773        return needsSignatureAttribute_value;
1774      }
1775      /**
1776       * @apilevel internal
1777       */
1778      private boolean needsSignatureAttribute_compute() {
1779          for (Iterator<TypeDecl> iter = interfacesIterator(); iter.hasNext(); ) {
1780            if (iter.next().needsSignatureAttribute()) {
1781              return true;
1782            }
1783          }
1784          return false;
1785        }
1786      /**
1787       * @apilevel internal
1788       */
1789      protected boolean classSignature_computed = false;
1790      /**
1791       * @apilevel internal
1792       */
1793      protected String classSignature_value;
1794      /**
1795       * @apilevel internal
1796       */
1797      private void classSignature_reset() {
1798        classSignature_computed = false;
1799        classSignature_value = null;
1800      }
1801      /**
1802       * @attribute syn
1803       * @aspect GenericsCodegen
1804       * @declaredat /home/jesper/git/extendj/java5/backend/GenericsCodegen.jrag:401
1805       */
1806      @ASTNodeAnnotation.Attribute
1807      public String classSignature() {
1808        ASTNode$State state = state();
1809        if (classSignature_computed) {
1810          return classSignature_value;
1811        }
1812        boolean intermediate = state.INTERMEDIATE_VALUE;
1813        state.INTERMEDIATE_VALUE = false;
1814        int num = state.boundariesCrossed;
1815        boolean isFinal = this.is$Final();
1816        classSignature_value = classSignature_compute();
1817        if (isFinal && num == state().boundariesCrossed) {
1818          classSignature_computed = true;
1819        } else {
1820        }
1821        state.INTERMEDIATE_VALUE |= intermediate;
1822    
1823        return classSignature_value;
1824      }
1825      /**
1826       * @apilevel internal
1827       */
1828      private String classSignature_compute() {
1829          StringBuilder buf = new StringBuilder();
1830          // SuperclassSignature
1831          buf.append(typeObject().classTypeSignature());
1832          // SuperinterfaceSignature*
1833          for (Iterator<TypeDecl> iter = interfacesIterator(); iter.hasNext(); ) {
1834            buf.append(iter.next().classTypeSignature());
1835          }
1836          return buf.toString();
1837        }
1838      /**
1839       * @apilevel internal
1840       */
1841      protected boolean hasAnnotationFunctionalInterface_computed = false;
1842      /**
1843       * @apilevel internal
1844       */
1845      protected boolean hasAnnotationFunctionalInterface_value;
1846      /**
1847       * @apilevel internal
1848       */
1849      private void hasAnnotationFunctionalInterface_reset() {
1850        hasAnnotationFunctionalInterface_computed = false;
1851      }
1852      /**
1853       * @attribute syn
1854       * @aspect Annotations
1855       * @declaredat /home/jesper/git/extendj/java8/frontend/Annotations.jrag:29
1856       */
1857      @ASTNodeAnnotation.Attribute
1858      public boolean hasAnnotationFunctionalInterface() {
1859        ASTNode$State state = state();
1860        if (hasAnnotationFunctionalInterface_computed) {
1861          return hasAnnotationFunctionalInterface_value;
1862        }
1863        boolean intermediate = state.INTERMEDIATE_VALUE;
1864        state.INTERMEDIATE_VALUE = false;
1865        int num = state.boundariesCrossed;
1866        boolean isFinal = this.is$Final();
1867        hasAnnotationFunctionalInterface_value = getModifiers().hasAnnotationFunctionalInterface();
1868        if (isFinal && num == state().boundariesCrossed) {
1869          hasAnnotationFunctionalInterface_computed = true;
1870        } else {
1871        }
1872        state.INTERMEDIATE_VALUE |= intermediate;
1873    
1874        return hasAnnotationFunctionalInterface_value;
1875      }
1876      /**
1877       * @apilevel internal
1878       */
1879      protected boolean hasFunctionDescriptor_computed = false;
1880      /**
1881       * @apilevel internal
1882       */
1883      protected boolean hasFunctionDescriptor_value;
1884      /**
1885       * @apilevel internal
1886       */
1887      private void hasFunctionDescriptor_reset() {
1888        hasFunctionDescriptor_computed = false;
1889      }
1890      /**
1891       * @attribute syn
1892       * @aspect FunctionDescriptor
1893       * @declaredat /home/jesper/git/extendj/java8/frontend/FunctionDescriptor.jrag:84
1894       */
1895      @ASTNodeAnnotation.Attribute
1896      public boolean hasFunctionDescriptor() {
1897        ASTNode$State state = state();
1898        if (hasFunctionDescriptor_computed) {
1899          return hasFunctionDescriptor_value;
1900        }
1901        boolean intermediate = state.INTERMEDIATE_VALUE;
1902        state.INTERMEDIATE_VALUE = false;
1903        int num = state.boundariesCrossed;
1904        boolean isFinal = this.is$Final();
1905        hasFunctionDescriptor_value = hasFunctionDescriptor_compute();
1906        if (isFinal && num == state().boundariesCrossed) {
1907          hasFunctionDescriptor_computed = true;
1908        } else {
1909        }
1910        state.INTERMEDIATE_VALUE |= intermediate;
1911    
1912        return hasFunctionDescriptor_value;
1913      }
1914      /**
1915       * @apilevel internal
1916       */
1917      private boolean hasFunctionDescriptor_compute() {
1918          return functionDescriptor() != null;
1919        }
1920      /**
1921       * @apilevel internal
1922       */
1923      protected boolean functionDescriptor_computed = false;
1924      /**
1925       * @apilevel internal
1926       */
1927      protected FunctionDescriptor functionDescriptor_value;
1928      /**
1929       * @apilevel internal
1930       */
1931      private void functionDescriptor_reset() {
1932        functionDescriptor_computed = false;
1933        functionDescriptor_value = null;
1934      }
1935      /**
1936       * @attribute syn
1937       * @aspect FunctionDescriptor
1938       * @declaredat /home/jesper/git/extendj/java8/frontend/FunctionDescriptor.jrag:97
1939       */
1940      @ASTNodeAnnotation.Attribute
1941      public FunctionDescriptor functionDescriptor() {
1942        ASTNode$State state = state();
1943        if (functionDescriptor_computed) {
1944          return functionDescriptor_value;
1945        }
1946        boolean intermediate = state.INTERMEDIATE_VALUE;
1947        state.INTERMEDIATE_VALUE = false;
1948        int num = state.boundariesCrossed;
1949        boolean isFinal = this.is$Final();
1950        functionDescriptor_value = functionDescriptor_compute();
1951        if (isFinal && num == state().boundariesCrossed) {
1952          functionDescriptor_computed = true;
1953        } else {
1954        }
1955        state.INTERMEDIATE_VALUE |= intermediate;
1956    
1957        return functionDescriptor_value;
1958      }
1959      /**
1960       * @apilevel internal
1961       */
1962      private FunctionDescriptor functionDescriptor_compute() {
1963          LinkedList<MethodDecl> methods = collectAbstractMethods();
1964      
1965          if (methods.size() == 0) {
1966            return null;
1967          } else if (methods.size() == 1) {
1968            MethodDecl m = methods.getFirst();
1969            FunctionDescriptor f = new FunctionDescriptor(this);
1970            f.method = m;
1971            ArrayList<TypeDecl> throwsList = new ArrayList<TypeDecl>();
1972            for (Access exception : m.getExceptionList()) {
1973              throwsList.add(exception.type());
1974            }
1975            f.throwsList = throwsList;
1976            return f;
1977          } else {
1978            FunctionDescriptor f = null;
1979            MethodDecl foundMethod = null;
1980      
1981            for (MethodDecl current : methods) {
1982              foundMethod = current;
1983              for (MethodDecl inner : methods) {
1984                if (!current.subsignatureTo(inner) || !current.returnTypeSubstitutableFor(inner)) {
1985                  foundMethod = null;
1986                }
1987              }
1988              if (foundMethod != null) {
1989                break;
1990              }
1991            }
1992      
1993            ArrayList<Access> descriptorThrows = new ArrayList<Access>();
1994            if (foundMethod != null) {
1995              // Now the throws-list needs to be computed as stated in 9.8
1996              for (MethodDecl current : methods) {
1997                for (Access exception : current.getExceptionList()) {
1998                  boolean alreadyInserted = false;
1999                  for (Access found : descriptorThrows) {
2000                    if (found.sameType(exception)) {
2001                      alreadyInserted = true;
2002                      break;
2003                    }
2004                  }
2005                  if (alreadyInserted) {
2006                    continue;
2007                  }
2008      
2009                  boolean foundIncompatibleClause = false;
2010                  // Has to be the subtype to at least one exception in each clause
2011                  if (foundMethod.isGeneric()) {
2012                    for (MethodDecl inner : methods) {
2013                      if (!inner.subtypeThrowsClause(exception)) {
2014                        foundIncompatibleClause = true;
2015                        break;
2016                      }
2017                    }
2018                  } else {
2019                    for (MethodDecl inner : methods) {
2020                      if (!inner.subtypeThrowsClauseErased(exception)) {
2021                        foundIncompatibleClause = true;
2022                        break;
2023                      }
2024                    }
2025                  }
2026      
2027                  if (!foundIncompatibleClause) {
2028                    // Was subtype to one exception in every clause
2029                    descriptorThrows.add(exception);
2030                  }
2031                }
2032              }
2033      
2034              /* Found a suitable method and finished building throws-list,
2035              now the descriptor just needs to be put together */
2036              f = new FunctionDescriptor(this);
2037              f.method = foundMethod;
2038              if (descriptorThrows.size() == 0) {
2039                f.throwsList = new ArrayList<TypeDecl>();
2040              } else {
2041                ArrayList<TypeDecl> throwsList = new ArrayList<TypeDecl>();
2042      
2043                /* All type variables must be replaced with foundMethods
2044                    type variables if the descriptor is generic */
2045                if (foundMethod.isGeneric()) {
2046                  GenericMethodDecl foundGeneric = foundMethod.genericDecl();
2047                  for (Access exception : descriptorThrows) {
2048                    if (exception.type() instanceof TypeVariable) {
2049                      TypeVariable foundVar = (TypeVariable) exception.type();
2050                      TypeVariable original = foundGeneric.getTypeParameter(foundVar.typeVarPosition());
2051                      throwsList.add(original);
2052                    } else {
2053                      throwsList.add(exception.type());
2054                    }
2055                  }
2056                } else {
2057                  // All throwed types must be erased if the descriptor is not generic.
2058                  for (Access exception : descriptorThrows) {
2059                    throwsList.add(exception.type().erasure());
2060                  }
2061                }
2062                f.throwsList = throwsList;
2063              }
2064            }
2065            return f;
2066          }
2067        }
2068      /**
2069       * @apilevel internal
2070       */
2071      protected boolean isFunctionalInterface_computed = false;
2072      /**
2073       * @apilevel internal
2074       */
2075      protected boolean isFunctionalInterface_value;
2076      /**
2077       * @apilevel internal
2078       */
2079      private void isFunctionalInterface_reset() {
2080        isFunctionalInterface_computed = false;
2081      }
2082      /**
2083       * @attribute syn
2084       * @aspect FunctionalInterface
2085       * @declaredat /home/jesper/git/extendj/java8/frontend/FunctionalInterface.jrag:30
2086       */
2087      @ASTNodeAnnotation.Attribute
2088      public boolean isFunctionalInterface() {
2089        ASTNode$State state = state();
2090        if (isFunctionalInterface_computed) {
2091          return isFunctionalInterface_value;
2092        }
2093        boolean intermediate = state.INTERMEDIATE_VALUE;
2094        state.INTERMEDIATE_VALUE = false;
2095        int num = state.boundariesCrossed;
2096        boolean isFinal = this.is$Final();
2097        isFunctionalInterface_value = isFunctional();
2098        if (isFinal && num == state().boundariesCrossed) {
2099          isFunctionalInterface_computed = true;
2100        } else {
2101        }
2102        state.INTERMEDIATE_VALUE |= intermediate;
2103    
2104        return isFunctionalInterface_value;
2105      }
2106      /**
2107       * @apilevel internal
2108       */
2109      protected boolean isFunctional_computed = false;
2110      /**
2111       * @apilevel internal
2112       */
2113      protected boolean isFunctional_value;
2114      /**
2115       * @apilevel internal
2116       */
2117      private void isFunctional_reset() {
2118        isFunctional_computed = false;
2119      }
2120      /**
2121       * @attribute syn
2122       * @aspect FunctionalInterface
2123       * @declaredat /home/jesper/git/extendj/java8/frontend/FunctionalInterface.jrag:33
2124       */
2125      @ASTNodeAnnotation.Attribute
2126      public boolean isFunctional() {
2127        ASTNode$State state = state();
2128        if (isFunctional_computed) {
2129          return isFunctional_value;
2130        }
2131        boolean intermediate = state.INTERMEDIATE_VALUE;
2132        state.INTERMEDIATE_VALUE = false;
2133        int num = state.boundariesCrossed;
2134        boolean isFinal = this.is$Final();
2135        isFunctional_value = isFunctional_compute();
2136        if (isFinal && num == state().boundariesCrossed) {
2137          isFunctional_computed = true;
2138        } else {
2139        }
2140        state.INTERMEDIATE_VALUE |= intermediate;
2141    
2142        return isFunctional_value;
2143      }
2144      /**
2145       * @apilevel internal
2146       */
2147      private boolean isFunctional_compute() {
2148          LinkedList<MethodDecl> methods = collectAbstractMethods();
2149          boolean foundMethod = false;
2150      
2151          if (methods.size() == 0) {
2152            return false;
2153          } else if (methods.size() == 1) {
2154            return true;
2155          } else {
2156            for (MethodDecl current : methods) {
2157              foundMethod = true;
2158              for (MethodDecl inner : methods) {
2159                if (!current.subsignatureTo(inner) || !current.returnTypeSubstitutableFor(inner)) {
2160                  foundMethod = false;
2161                }
2162              }
2163              if (foundMethod) {
2164                break;
2165              }
2166            }
2167          }
2168          return foundMethod;
2169        }
2170      /**
2171       * @apilevel internal
2172       */
2173      protected boolean collectAbstractMethods_computed = false;
2174      /**
2175       * @apilevel internal
2176       */
2177      protected LinkedList<MethodDecl> collectAbstractMethods_value;
2178      /**
2179       * @apilevel internal
2180       */
2181      private void collectAbstractMethods_reset() {
2182        collectAbstractMethods_computed = false;
2183        collectAbstractMethods_value = null;
2184      }
2185      /**
2186       * @attribute syn
2187       * @aspect FunctionalInterface
2188       * @declaredat /home/jesper/git/extendj/java8/frontend/FunctionalInterface.jrag:305
2189       */
2190      @ASTNodeAnnotation.Attribute
2191      public LinkedList<MethodDecl> collectAbstractMethods() {
2192        ASTNode$State state = state();
2193        if (collectAbstractMethods_computed) {
2194          return collectAbstractMethods_value;
2195        }
2196        boolean intermediate = state.INTERMEDIATE_VALUE;
2197        state.INTERMEDIATE_VALUE = false;
2198        int num = state.boundariesCrossed;
2199        boolean isFinal = this.is$Final();
2200        collectAbstractMethods_value = collectAbstractMethods_compute();
2201        if (isFinal && num == state().boundariesCrossed) {
2202          collectAbstractMethods_computed = true;
2203        } else {
2204        }
2205        state.INTERMEDIATE_VALUE |= intermediate;
2206    
2207        return collectAbstractMethods_value;
2208      }
2209      /**
2210       * @apilevel internal
2211       */
2212      private LinkedList<MethodDecl> collectAbstractMethods_compute() {
2213          LinkedList<MethodDecl> methods = new LinkedList<MethodDecl>();
2214          Map<String, SimpleSet> map = localMethodsSignatureMap();
2215          Map<String, SimpleSet> objectMethods = typeObject().methodsSignatureMap();
2216          MethodDecl inObject;
2217      
2218          for (Map.Entry<String,SimpleSet> entry: map.entrySet()) {
2219            SimpleSet set = entry.getValue();
2220            MethodDecl m = (MethodDecl) set.iterator().next();
2221      
2222            SimpleSet objectSet = objectMethods.get(m.signature());
2223            if (m.isAbstract()) {
2224              if (objectSet == null || objectSet.isEmpty()) {
2225                methods.add(m);
2226              } else {
2227                inObject = (MethodDecl) objectSet.iterator().next();
2228                if (!inObject.isPublic()) {
2229                  methods.add(m);
2230                }
2231              }
2232            }
2233          }
2234      
2235          for (Iterator outerIter = interfacesIterator(); outerIter.hasNext();) {
2236            TypeDecl typeDecl = (TypeDecl) outerIter.next();
2237            for (Iterator iter = typeDecl.methodsIterator(); iter.hasNext();) {
2238              MethodDecl m = (MethodDecl) iter.next();
2239      
2240              if (m.isAbstract() && !m.isPrivate() && m.accessibleFrom(this)) {
2241                SimpleSet objectSet = objectMethods.get(m.signature());
2242                if (objectSet == null || objectSet.isEmpty()) {
2243                  methods.add(m);
2244                } else {
2245                  inObject = (MethodDecl) objectSet.iterator().next();
2246                  if (!inObject.isPublic()) {
2247                    methods.add(m);
2248                  }
2249                }
2250              }
2251            }
2252          }
2253          return methods;
2254        }
2255      /**
2256       * @apilevel internal
2257       */
2258      private void strictSubtype_TypeDecl_reset() {
2259        strictSubtype_TypeDecl_values = null;
2260      }
2261      protected java.util.Map strictSubtype_TypeDecl_values;
2262      @ASTNodeAnnotation.Attribute
2263      public boolean strictSubtype(TypeDecl type) {
2264        Object _parameters = type;
2265        if (strictSubtype_TypeDecl_values == null) strictSubtype_TypeDecl_values = new org.jastadd.util.RobustMap(new java.util.HashMap());
2266        ASTNode$State.CircularValue _value;
2267        if (strictSubtype_TypeDecl_values.containsKey(_parameters)) {
2268          Object _o = strictSubtype_TypeDecl_values.get(_parameters);
2269          if (!(_o instanceof ASTNode$State.CircularValue)) {
2270            return (Boolean) _o;
2271          } else {
2272            _value = (ASTNode$State.CircularValue) _o;
2273          }
2274        } else {
2275          _value = new ASTNode$State.CircularValue();
2276          strictSubtype_TypeDecl_values.put(_parameters, _value);
2277          _value.value = true;
2278        }
2279        ASTNode$State state = state();
2280        boolean new_strictSubtype_TypeDecl_value;
2281        if (!state.IN_CIRCLE) {
2282          state.IN_CIRCLE = true;
2283          int num = state.boundariesCrossed;
2284          boolean isFinal = this.is$Final();
2285          // TODO: fixme
2286          // state().CIRCLE_INDEX = 1;
2287          do {
2288            _value.visited = state.CIRCLE_INDEX;
2289            state.CHANGE = false;
2290            new_strictSubtype_TypeDecl_value = type.strictSupertypeInterfaceDecl(this);
2291            if (new_strictSubtype_TypeDecl_value != ((Boolean)_value.value)) {
2292              state.CHANGE = true;
2293              _value.value = new_strictSubtype_TypeDecl_value;
2294            }
2295            state.CIRCLE_INDEX++;
2296          } while (state.CHANGE);
2297          if (isFinal && num == state().boundariesCrossed) {
2298            strictSubtype_TypeDecl_values.put(_parameters, new_strictSubtype_TypeDecl_value);
2299          } else {
2300            strictSubtype_TypeDecl_values.remove(_parameters);
2301            state.RESET_CYCLE = true;
2302            boolean $tmp = type.strictSupertypeInterfaceDecl(this);
2303            state.RESET_CYCLE = false;
2304          }
2305          state.IN_CIRCLE = false;
2306          state.INTERMEDIATE_VALUE = false;
2307          return new_strictSubtype_TypeDecl_value;
2308        }
2309        if (state.CIRCLE_INDEX != _value.visited) {
2310          _value.visited = state.CIRCLE_INDEX;
2311          new_strictSubtype_TypeDecl_value = type.strictSupertypeInterfaceDecl(this);
2312          if (state.RESET_CYCLE) {
2313            strictSubtype_TypeDecl_values.remove(_parameters);
2314          }
2315          else if (new_strictSubtype_TypeDecl_value != ((Boolean)_value.value)) {
2316            state.CHANGE = true;
2317            _value.value = new_strictSubtype_TypeDecl_value;
2318          }
2319          state.INTERMEDIATE_VALUE = true;
2320          return new_strictSubtype_TypeDecl_value;
2321        }
2322        state.INTERMEDIATE_VALUE = true;
2323        return (Boolean) _value.value;
2324      }
2325      /**
2326       * @attribute syn
2327       * @aspect StrictSubtype
2328       * @declaredat /home/jesper/git/extendj/java8/frontend/GenericsSubtype.jrag:370
2329       */
2330      @ASTNodeAnnotation.Attribute
2331      public boolean strictSupertypeClassDecl(ClassDecl type) {
2332        {
2333            if (super.strictSupertypeClassDecl(type)) {
2334              return true;
2335            }
2336            for (Iterator<TypeDecl> iter = type.interfacesIterator(); iter.hasNext(); ) {
2337              TypeDecl typeDecl = iter.next();
2338              if (typeDecl.strictSubtype(this)) {
2339                return true;
2340              }
2341            }
2342            return type.hasSuperclass() && type.superclass() != null
2343                && type.superclass().strictSubtype(this);
2344          }
2345      }
2346      /**
2347       * @attribute syn
2348       * @aspect StrictSubtype
2349       * @declaredat /home/jesper/git/extendj/java8/frontend/GenericsSubtype.jrag:390
2350       */
2351      @ASTNodeAnnotation.Attribute
2352      public boolean strictSupertypeInterfaceDecl(InterfaceDecl type) {
2353        {
2354            if (super.strictSupertypeInterfaceDecl(type)) {
2355              return true;
2356            }
2357            for (Iterator<TypeDecl> iter = type.interfacesIterator(); iter.hasNext(); ) {
2358              TypeDecl superinterface = iter.next();
2359              if (superinterface.strictSubtype(this)) {
2360                return true;
2361              }
2362            }
2363            return false;
2364          }
2365      }
2366      /**
2367       * @attribute syn
2368       * @aspect StrictSubtype
2369       * @declaredat /home/jesper/git/extendj/java8/frontend/GenericsSubtype.jrag:407
2370       */
2371      @ASTNodeAnnotation.Attribute
2372      public boolean strictSupertypeArrayDecl(ArrayDecl type) {
2373        {
2374            if (super.strictSupertypeArrayDecl(type)) {
2375              return true;
2376            }
2377            for (Iterator<TypeDecl> iter = type.interfacesIterator(); iter.hasNext(); ) {
2378              TypeDecl typeDecl = iter.next();
2379              if (typeDecl.strictSubtype(this)) {
2380                return true;
2381              }
2382            }
2383            return false;
2384          }
2385      }
2386      /**
2387       * @apilevel internal
2388       */
2389      protected java.util.Map hasOverridingMethodInSuper_MethodDecl_values;
2390      /**
2391       * @apilevel internal
2392       */
2393      private void hasOverridingMethodInSuper_MethodDecl_reset() {
2394        hasOverridingMethodInSuper_MethodDecl_values = null;
2395      }
2396      /**
2397       * @attribute syn
2398       * @aspect MethodSignature18
2399       * @declaredat /home/jesper/git/extendj/java8/frontend/MethodSignature.jrag:1053
2400       */
2401      @ASTNodeAnnotation.Attribute
2402      public boolean hasOverridingMethodInSuper(MethodDecl m) {
2403        Object _parameters = m;
2404        if (hasOverridingMethodInSuper_MethodDecl_values == null) hasOverridingMethodInSuper_MethodDecl_values = new org.jastadd.util.RobustMap(new java.util.HashMap());
2405        ASTNode$State state = state();
2406        if (hasOverridingMethodInSuper_MethodDecl_values.containsKey(_parameters)) {
2407          return (Boolean) hasOverridingMethodInSuper_MethodDecl_values.get(_parameters);
2408        }
2409        boolean intermediate = state.INTERMEDIATE_VALUE;
2410        state.INTERMEDIATE_VALUE = false;
2411        int num = state.boundariesCrossed;
2412        boolean isFinal = this.is$Final();
2413        boolean hasOverridingMethodInSuper_MethodDecl_value = hasOverridingMethodInSuper_compute(m);
2414        if (isFinal && num == state().boundariesCrossed) {
2415          hasOverridingMethodInSuper_MethodDecl_values.put(_parameters, hasOverridingMethodInSuper_MethodDecl_value);
2416        } else {
2417        }
2418        state.INTERMEDIATE_VALUE |= intermediate;
2419    
2420        return hasOverridingMethodInSuper_MethodDecl_value;
2421      }
2422      /**
2423       * @apilevel internal
2424       */
2425      private boolean hasOverridingMethodInSuper_compute(MethodDecl m) {
2426          for (Iterator<TypeDecl> outerIter = interfacesIterator(); outerIter.hasNext(); ) {
2427            TypeDecl typeDecl = outerIter.next();
2428            for (Iterator iter = typeDecl.methodsIterator(); iter.hasNext(); ) {
2429              MethodDecl superMethod = (MethodDecl) iter.next();
2430              if (m != superMethod && superMethod.overrides(m)) {
2431                return true;
2432              }
2433            }
2434          }
2435          return false;
2436        }
2437      /**
2438       * @attribute inh
2439       * @aspect TypeConversion
2440       * @declaredat /home/jesper/git/extendj/java4/frontend/TypeAnalysis.jrag:122
2441       */
2442      /**
2443       * @attribute inh
2444       * @aspect TypeConversion
2445       * @declaredat /home/jesper/git/extendj/java4/frontend/TypeAnalysis.jrag:122
2446       */
2447      @ASTNodeAnnotation.Attribute
2448      public MethodDecl unknownMethod() {
2449        MethodDecl unknownMethod_value = getParent().Define_unknownMethod(this, null);
2450    
2451        return unknownMethod_value;
2452      }
2453      /**
2454       * @declaredat /home/jesper/git/extendj/java4/frontend/SyntacticClassification.jrag:36
2455       * @apilevel internal
2456       */
2457      public NameType Define_nameType(ASTNode caller, ASTNode child) {
2458        if (caller == getSuperInterfaceListNoTransform()) {
2459          // @declaredat /home/jesper/git/extendj/java4/frontend/SyntacticClassification.jrag:102
2460          int childIndex = caller.getIndexOfChild(child);
2461          return NameType.TYPE_NAME;
2462        }
2463        else {
2464          return super.Define_nameType(caller, child);
2465        }
2466      }
2467      protected boolean canDefine_nameType(ASTNode caller, ASTNode child) {
2468        return true;
2469      }
2470      /**
2471       * @declaredat /home/jesper/git/extendj/java7/frontend/MultiCatch.jrag:71
2472       * @apilevel internal
2473       */
2474      public TypeDecl Define_hostType(ASTNode caller, ASTNode child) {
2475        if (caller == getSuperInterfaceListNoTransform()) {
2476          // @declaredat /home/jesper/git/extendj/java4/frontend/TypeAnalysis.jrag:632
2477          int childIndex = caller.getIndexOfChild(child);
2478          return hostType();
2479        }
2480        else {
2481          return super.Define_hostType(caller, child);
2482        }
2483      }
2484      protected boolean canDefine_hostType(ASTNode caller, ASTNode child) {
2485        return true;
2486      }
2487      /**
2488       * @declaredat /home/jesper/git/extendj/java7/frontend/SuppressWarnings.jrag:38
2489       * @apilevel internal
2490       */
2491      public boolean Define_withinSuppressWarnings(ASTNode caller, ASTNode child, String annot) {
2492        if (caller == getSuperInterfaceListNoTransform()) {
2493          // @declaredat /home/jesper/git/extendj/java5/frontend/Annotations.jrag:351
2494          int childIndex = caller.getIndexOfChild(child);
2495          return hasAnnotationSuppressWarnings(annot) || withinSuppressWarnings(annot);
2496        }
2497        else {
2498          return getParent().Define_withinSuppressWarnings(this, caller, annot);
2499        }
2500      }
2501      protected boolean canDefine_withinSuppressWarnings(ASTNode caller, ASTNode child, String annot) {
2502        return true;
2503      }
2504      /**
2505       * @declaredat /home/jesper/git/extendj/java5/frontend/Annotations.jrag:449
2506       * @apilevel internal
2507       */
2508      public boolean Define_withinDeprecatedAnnotation(ASTNode caller, ASTNode child) {
2509        if (caller == getSuperInterfaceListNoTransform()) {
2510          // @declaredat /home/jesper/git/extendj/java5/frontend/Annotations.jrag:455
2511          int childIndex = caller.getIndexOfChild(child);
2512          return isDeprecated() || withinDeprecatedAnnotation();
2513        }
2514        else {
2515          return getParent().Define_withinDeprecatedAnnotation(this, caller);
2516        }
2517      }
2518      protected boolean canDefine_withinDeprecatedAnnotation(ASTNode caller, ASTNode child) {
2519        return true;
2520      }
2521      /**
2522       * @declaredat /home/jesper/git/extendj/java5/frontend/Generics.jrag:338
2523       * @apilevel internal
2524       */
2525      public boolean Define_inExtendsOrImplements(ASTNode caller, ASTNode child) {
2526        if (caller == getSuperInterfaceListNoTransform()) {
2527          // @declaredat /home/jesper/git/extendj/java5/frontend/Generics.jrag:337
2528          int childIndex = caller.getIndexOfChild(child);
2529          return true;
2530        }
2531        else {
2532          return getParent().Define_inExtendsOrImplements(this, caller);
2533        }
2534      }
2535      protected boolean canDefine_inExtendsOrImplements(ASTNode caller, ASTNode child) {
2536        return true;
2537      }
2538      /**
2539       * @apilevel internal
2540       */
2541      public ASTNode rewriteTo() {
2542        return super.rewriteTo();
2543      }
2544    }