001    /* This file was generated with JastAdd2 (http://jastadd.org) version R20130213 */
002    package AST;
003    
004    import java.util.HashSet;
005    import java.io.File;
006    import java.util.*;
007    import beaver.*;
008    import java.util.ArrayList;
009    import java.util.zip.*;
010    import java.io.*;
011    import java.io.FileNotFoundException;
012    import java.util.Collection;
013    /**
014     * @production MethodAccess : {@link Access} ::= <span class="component">&lt;ID:String&gt;</span> <span class="component">Arg:{@link Expr}*</span>;
015     * @ast node
016     * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/java.ast:20
017     */
018    public class MethodAccess extends Access implements Cloneable {
019      /**
020       * @apilevel low-level
021       */
022      public void flushCache() {
023      }
024      /**
025       * @apilevel internal
026       */
027      public void flushCollectionCache() {
028      }
029      /**
030       * @apilevel internal
031       */
032      @SuppressWarnings({"unchecked", "cast"})
033      public MethodAccess clone() throws CloneNotSupportedException {
034        MethodAccess node = (MethodAccess)super.clone();
035        node.computeDAbefore_int_Variable_values = null;
036        node.exceptionCollection_computed = false;
037        node.exceptionCollection_value = null;
038        node.decls_computed = false;
039        node.decls_value = null;
040        node.decl_computed = false;
041        node.decl_value = null;
042        node.type_computed = false;
043        node.type_value = null;
044        node.typeArguments_MethodDecl_values = null;
045        node.in$Circle(false);
046        node.is$Final(false);
047        return node;
048      }
049    /**
050     * @apilevel internal
051     */
052      @SuppressWarnings({"unchecked", "cast"})
053    public MethodAccess copy() {
054      
055      try {
056        MethodAccess node = (MethodAccess) clone();
057        node.parent = null;
058        if(children != null)
059          node.children = (ASTNode[]) children.clone();
060        
061        return node;
062      } catch (CloneNotSupportedException e) {
063        throw new Error("Error: clone not supported for " + getClass().getName());
064      }
065      
066    }/**
067     * Create a deep copy of the AST subtree at this node.
068     * The copy is dangling, i.e. has no parent.
069     * @return dangling copy of the subtree at this node
070     * @apilevel low-level
071     */
072      @SuppressWarnings({"unchecked", "cast"})
073    public MethodAccess fullCopy() {
074      
075      MethodAccess tree = (MethodAccess) copy();
076      if (children != null) {
077        for (int i = 0; i < children.length; ++i) {
078          
079          ASTNode child = (ASTNode) children[i];
080          if(child != null) {
081            child = child.fullCopy();
082            tree.setChild(child, i);
083          }
084        }
085      }
086      return tree;
087      
088    }  /**
089       * @ast method 
090       * @aspect AnonymousClasses
091       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/AnonymousClasses.jrag:215
092       */
093      protected void collectExceptions(Collection c, ASTNode target) {
094        super.collectExceptions(c, target);
095        for(int i = 0; i < decl().getNumException(); i++)
096          c.add(decl().getException(i).type());
097      }
098      /**
099       * @ast method 
100       * @aspect ExceptionHandling
101       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/ExceptionHandling.jrag:57
102       */
103      public void exceptionHandling() {
104        for(Iterator iter = exceptionCollection().iterator(); iter.hasNext(); ) {
105          TypeDecl exceptionType = (TypeDecl)iter.next();
106          if(!handlesException(exceptionType))
107            error("" + decl().hostType().fullName() + "." + this + " invoked in " + hostType().fullName() + " may throw uncaught exception " + exceptionType.fullName());
108        }
109      }
110      /**
111       * @ast method 
112       * @aspect ExceptionHandling
113       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/ExceptionHandling.jrag:253
114       */
115      protected boolean reachedException(TypeDecl catchType) {
116        for(Iterator iter = exceptionCollection().iterator(); iter.hasNext(); ) {
117          TypeDecl exceptionType = (TypeDecl)iter.next();
118          if(catchType.mayCatch(exceptionType))
119            return true;
120        }
121        return super.reachedException(catchType);
122      }
123      /**
124       * @ast method 
125       * @aspect LookupMethod
126       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/LookupMethod.jrag:119
127       */
128      private static SimpleSet removeInstanceMethods(SimpleSet c) {
129        SimpleSet set = SimpleSet.emptySet;
130        for(Iterator iter = c.iterator(); iter.hasNext(); ) {
131          MethodDecl m = (MethodDecl)iter.next();
132          if(m.isStatic())
133            set = set.add(m);
134        }
135        return set;
136      }
137      /**
138       * @ast method 
139       * @aspect MethodDecl
140       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/LookupMethod.jrag:158
141       */
142      public boolean applicable(MethodDecl decl) {
143        if(getNumArg() != decl.getNumParameter())
144          return false;
145        if(!name().equals(decl.name()))
146          return false;
147        for(int i = 0; i < getNumArg(); i++) {
148          if(!getArg(i).type().instanceOf(decl.getParameter(i).type()))
149            return false;
150        }
151        return true;
152      }
153      /**
154       * @ast method 
155       * @aspect NodeConstructors
156       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/NodeConstructors.jrag:56
157       */
158      public MethodAccess(String name, List args, int start, int end) {
159        this(name, args);
160        setStart(start);
161        setEnd(end);
162      }
163      /**
164       * @ast method 
165       * @aspect PrettyPrint
166       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/PrettyPrint.jadd:457
167       */
168      public void toString(StringBuffer s) {
169        s.append(name());
170        s.append("(");
171        if(getNumArg() > 0) {
172          getArg(0).toString(s);
173          for(int i = 1; i < getNumArg(); i++) {
174            s.append(", ");
175            getArg(i).toString(s);
176          }
177        }
178        s.append(")");
179      }
180      /**
181       * @ast method 
182       * @aspect TypeHierarchyCheck
183       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/TypeHierarchyCheck.jrag:23
184       */
185      public void nameCheck() {
186        if(isQualified() && qualifier().isPackageAccess() && !qualifier().isUnknown())
187          error("The method " + decl().signature() + 
188              " can not be qualified by a package name.");
189        if(isQualified() && decl().isAbstract() && qualifier().isSuperAccess())
190          error("may not access abstract methods in superclass");
191        if(decls().isEmpty() && (!isQualified() || !qualifier().isUnknown())) {
192          StringBuffer s = new StringBuffer();
193          s.append("no method named " + name());
194          s.append("(");
195          for(int i = 0; i < getNumArg(); i++) {
196            if(i != 0)
197              s.append(", ");
198            s.append(getArg(i).type().typeName());
199          }
200          s.append(")" + " in " + methodHost() + " matches.");
201          if(singleCandidateDecl() != null)
202            s.append(" However, there is a method " + singleCandidateDecl().signature());
203          error(s.toString());
204        }
205        if(decls().size() > 1) {
206          boolean allAbstract = true;
207          for(Iterator iter = decls().iterator(); iter.hasNext() && allAbstract; ) {
208             MethodDecl m = (MethodDecl)iter.next();
209            if(!m.isAbstract() && !m.hostType().isObject())
210              allAbstract = false;
211          }
212          if(!allAbstract && validArgs()) {
213            StringBuffer s = new StringBuffer();
214            s.append("several most specific methods for " + this + "\n");
215            for(Iterator iter = decls().iterator(); iter.hasNext(); ) {
216              MethodDecl m = (MethodDecl)iter.next();
217              s.append("    " + m.signature() + " in " + m.hostType().typeName() + "\n");
218            }
219            error(s.toString());
220          }
221           
222        }
223      }
224      /**
225       * @ast method 
226       * @aspect CreateBCode
227       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Backend/CreateBCode.jrag:548
228       */
229      protected void createLoadQualifier(CodeGeneration gen) {
230        MethodDecl m = decl();
231        if(hasPrevExpr()) {
232          // load explicit qualifier
233          prevExpr().createBCode(gen);
234          // pop qualifier stack element for class variables
235          // this qualifier must be computed to ensure side effects
236          if(m.isStatic() && !prevExpr().isTypeAccess())
237            prevExpr().type().emitPop(gen);
238        }
239        else if(!m.isStatic()) {
240          // load implicit this qualifier
241          emitThis(gen, methodQualifierType());
242        }
243      }
244      /**
245       * @ast method 
246       * @aspect InnerClasses
247       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Backend/InnerClasses.jrag:48
248       */
249      private TypeDecl refined_InnerClasses_MethodAccess_methodQualifierType() {
250        if(hasPrevExpr())
251          return prevExpr().type();
252        TypeDecl typeDecl = hostType();
253        while(typeDecl != null && !typeDecl.hasMethod(name()))
254          typeDecl = typeDecl.enclosingType();
255        if(typeDecl != null)
256          return typeDecl;
257        return decl().hostType();
258      }
259      /**
260       * @ast method 
261       * @aspect InnerClasses
262       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Backend/InnerClasses.jrag:113
263       */
264      public TypeDecl superAccessorTarget() {
265        TypeDecl targetDecl = prevExpr().type();
266        TypeDecl enclosing = hostType();
267        do {
268          enclosing = enclosing.enclosingType();
269        } while (!enclosing.instanceOf(targetDecl));
270        return enclosing;
271      }
272      /**
273       * @ast method 
274       * @aspect Transformations
275       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Backend/Transformations.jrag:69
276       */
277      public void refined_Transformations_MethodAccess_transformation() {
278        MethodDecl m = decl();
279    
280    
281        /*if(!isQualified() && !m.isStatic()) {
282          TypeDecl typeDecl = hostType();
283          while(typeDecl != null && !typeDecl.hasMethod(name()))
284            typeDecl = typeDecl.enclosingType();
285          ASTNode result = replace(this).with(typeDecl.createQualifiedAccess().qualifiesAccess(new ThisAccess("this")).qualifiesAccess(new MethodAccess(name(), getArgList())));
286          result.transformation();
287          return;
288        }*/
289        
290        if(requiresAccessor()) {
291          /* Access to private methods in enclosing types:
292          The original MethodAccess is replaced with an access to an accessor method
293          built by createAccessor(). This method is built lazily and differs from
294          normal MethodDeclarations in the following ways:
295          1) The method in the class file should always be static and the signature
296             is thus changed to include a possible this reference as the first argument. 
297          2) The method is always invoked using INVOKESTATIC
298          3) The flags must indicate that the method is static and package private
299          */
300          super.transformation();
301          replace(this).with(decl().createAccessor(methodQualifierType()).createBoundAccess(getArgList()));
302          return;
303        }
304        else if(!m.isStatic() && isQualified() && prevExpr().isSuperAccess() && !hostType().instanceOf(prevExpr().type())) {
305          decl().createSuperAccessor(superAccessorTarget());
306        }
307        super.transformation();
308      }
309      /**
310       * @ast method 
311       * @aspect Annotations
312       * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Annotations.jrag:336
313       */
314      public void checkModifiers() {
315        if(decl().isDeprecated() &&
316          !withinDeprecatedAnnotation() &&
317          hostType().topLevelType() != decl().hostType().topLevelType() &&
318          !withinSuppressWarnings("deprecation"))
319            warning(decl().signature() + " in " + decl().hostType().typeName() + " has been deprecated");
320      }
321      /**
322       * @ast method 
323       * @aspect GenericMethodsInference
324       * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/GenericMethodsInference.jrag:46
325       */
326      public Collection computeConstraints(GenericMethodDecl decl) {
327        Constraints c = new Constraints();
328        // store type parameters
329        for(int i = 0; i < decl.original().getNumTypeParameter(); i++)
330          c.addTypeVariable(decl.original().getTypeParameter(i));
331        
332        // add initial constraints
333        for(int i = 0; i < getNumArg(); i++) {
334          TypeDecl A = getArg(i).type();
335          int index = i >= decl.getNumParameter() ? decl.getNumParameter() - 1 : i;
336          TypeDecl F = decl.getParameter(index).type();
337          if(decl.getParameter(index) instanceof VariableArityParameterDeclaration 
338             && (getNumArg() != decl.getNumParameter() || !A.isArrayDecl())) {
339            F = F.componentType();
340          }
341          c.convertibleTo(A, F);
342        }
343        if(c.rawAccess)
344          return new ArrayList();
345        
346        //c.printConstraints();
347        //System.err.println("Resolving equality constraints");
348        c.resolveEqualityConstraints();
349        //c.printConstraints();
350    
351        //System.err.println("Resolving supertype constraints");
352        c.resolveSupertypeConstraints();
353        //c.printConstraints();
354    
355        //System.err.println("Resolving unresolved type arguments");
356        //c.resolveBounds();
357        //c.printConstraints();
358    
359        if(c.unresolvedTypeArguments()) {
360          TypeDecl S = assignConvertedType();
361          if(S.isUnboxedPrimitive())
362            S = S.boxed();
363          TypeDecl R = decl.type();
364          // TODO: replace all uses of type variables in R with their inferred types
365          TypeDecl Rprime = R;
366          if(R.isVoid())
367            R = typeObject();
368          c.convertibleFrom(S, R);
369          // TODO: additional constraints
370    
371          c.resolveEqualityConstraints();
372          c.resolveSupertypeConstraints();
373          //c.resolveBounds();
374    
375          c.resolveSubtypeConstraints();
376        }
377    
378        return c.typeArguments();
379      }
380      /**
381       * @ast method 
382       * @aspect MethodSignature15
383       * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/MethodSignature.jrag:23
384       */
385      protected SimpleSet potentiallyApplicable(Collection candidates) {
386        SimpleSet potentiallyApplicable = SimpleSet.emptySet;
387        // select potentially applicable methods
388        for(Iterator iter = candidates.iterator(); iter.hasNext(); ) {
389          MethodDecl decl = (MethodDecl)iter.next();
390          if(potentiallyApplicable(decl) && accessible(decl)) {
391            if(decl instanceof GenericMethodDecl) {
392              decl = ((GenericMethodDecl)decl).lookupParMethodDecl(typeArguments(decl));
393            }
394            potentiallyApplicable = potentiallyApplicable.add(decl);
395          }
396        }
397        return potentiallyApplicable;
398      }
399      /**
400       * @ast method 
401       * @aspect MethodSignature15
402       * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/MethodSignature.jrag:38
403       */
404      protected SimpleSet applicableBySubtyping(SimpleSet potentiallyApplicable) {
405        SimpleSet maxSpecific = SimpleSet.emptySet;
406        for(Iterator iter = potentiallyApplicable.iterator(); iter.hasNext(); ) {
407          MethodDecl decl = (MethodDecl)iter.next();
408          if(applicableBySubtyping(decl))
409            maxSpecific = mostSpecific(maxSpecific, decl);
410        }
411        return maxSpecific;
412      }
413      /**
414       * @ast method 
415       * @aspect MethodSignature15
416       * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/MethodSignature.jrag:48
417       */
418      protected SimpleSet applicableByMethodInvocationConversion(SimpleSet potentiallyApplicable, SimpleSet maxSpecific) {
419        if(maxSpecific.isEmpty()) {
420          for(Iterator iter = potentiallyApplicable.iterator(); iter.hasNext(); ) {
421            MethodDecl decl = (MethodDecl)iter.next();
422            if(applicableByMethodInvocationConversion(decl))
423              maxSpecific = mostSpecific(maxSpecific, decl);
424          }
425        }
426        return maxSpecific;
427      }
428      /**
429       * @ast method 
430       * @aspect MethodSignature15
431       * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/MethodSignature.jrag:59
432       */
433      protected SimpleSet applicableVariableArity(SimpleSet potentiallyApplicable, SimpleSet maxSpecific) {
434        if(maxSpecific.isEmpty()) {
435          for(Iterator iter = potentiallyApplicable.iterator(); iter.hasNext(); ) {
436            MethodDecl decl = (MethodDecl)iter.next();
437            if(decl.isVariableArity() && applicableVariableArity(decl))
438              maxSpecific = mostSpecific(maxSpecific, decl);
439          }
440        }
441        return maxSpecific;
442      }
443      /**
444       * @ast method 
445       * @aspect MethodSignature15
446       * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/MethodSignature.jrag:140
447       */
448      private static SimpleSet mostSpecific(SimpleSet maxSpecific, MethodDecl decl) {
449        if(maxSpecific.isEmpty())
450          maxSpecific = maxSpecific.add(decl);
451        else {
452          if(decl.moreSpecificThan((MethodDecl)maxSpecific.iterator().next()))
453            maxSpecific = SimpleSet.emptySet.add(decl);
454          else if(!((MethodDecl)maxSpecific.iterator().next()).moreSpecificThan(decl))
455            maxSpecific = maxSpecific.add(decl);
456        }
457        return maxSpecific;
458      }
459      /**
460       * @ast method 
461       * @aspect SafeVarargs
462       * @declaredat /home/jesper/svn/JastAddJ/Java7Frontend/SafeVarargs.jrag:73
463       */
464      public void checkWarnings() {
465    
466               MethodDecl decl = decl();
467               if (decl.getNumParameter() == 0) return;
468               if (decl.getNumParameter() > getNumArg()) return;
469    
470               ParameterDeclaration param = decl.getParameter(
471                               decl.getNumParameter()-1);
472               if (!withinSuppressWarnings("unchecked") &&
473                               !decl.hasAnnotationSafeVarargs() &&
474                               param.isVariableArity() &&
475                               !param.type().isReifiable())
476                       warning("unchecked array creation for variable " +
477                               "arity parameter of " + decl().name());
478       }
479      /**
480       * @ast method 
481       * 
482       */
483      public MethodAccess() {
484        super();
485    
486    
487      }
488      /**
489       * Initializes the child array to the correct size.
490       * Initializes List and Opt nta children.
491       * @apilevel internal
492       * @ast method
493       * @ast method 
494       * 
495       */
496      public void init$Children() {
497        children = new ASTNode[1];
498        setChild(new List(), 0);
499      }
500      /**
501       * @ast method 
502       * 
503       */
504      public MethodAccess(String p0, List<Expr> p1) {
505        setID(p0);
506        setChild(p1, 0);
507      }
508      /**
509       * @ast method 
510       * 
511       */
512      public MethodAccess(beaver.Symbol p0, List<Expr> p1) {
513        setID(p0);
514        setChild(p1, 0);
515      }
516      /**
517       * @apilevel low-level
518       * @ast method 
519       * 
520       */
521      protected int numChildren() {
522        return 1;
523      }
524      /**
525       * @apilevel internal
526       * @ast method 
527       * 
528       */
529      public boolean mayHaveRewrite() {
530        return false;
531      }
532      /**
533       * Replaces the lexeme ID.
534       * @param value The new value for the lexeme ID.
535       * @apilevel high-level
536       * @ast method 
537       * 
538       */
539      public void setID(String value) {
540        tokenString_ID = value;
541      }
542      /**
543       * @apilevel internal
544       * @ast method 
545       * 
546       */
547      
548      /**
549       * @apilevel internal
550       */
551      protected String tokenString_ID;
552      /**
553       * @ast method 
554       * 
555       */
556      
557      public int IDstart;
558      /**
559       * @ast method 
560       * 
561       */
562      
563      public int IDend;
564      /**
565       * JastAdd-internal setter for lexeme ID using the Beaver parser.
566       * @apilevel internal
567       * @ast method 
568       * 
569       */
570      public void setID(beaver.Symbol symbol) {
571        if(symbol.value != null && !(symbol.value instanceof String))
572          throw new UnsupportedOperationException("setID is only valid for String lexemes");
573        tokenString_ID = (String)symbol.value;
574        IDstart = symbol.getStart();
575        IDend = symbol.getEnd();
576      }
577      /**
578       * Retrieves the value for the lexeme ID.
579       * @return The value for the lexeme ID.
580       * @apilevel high-level
581       * @ast method 
582       * 
583       */
584      public String getID() {
585        return tokenString_ID != null ? tokenString_ID : "";
586      }
587      /**
588       * Replaces the Arg list.
589       * @param list The new list node to be used as the Arg list.
590       * @apilevel high-level
591       * @ast method 
592       * 
593       */
594      public void setArgList(List<Expr> list) {
595        setChild(list, 0);
596      }
597      /**
598       * Retrieves the number of children in the Arg list.
599       * @return Number of children in the Arg list.
600       * @apilevel high-level
601       * @ast method 
602       * 
603       */
604      public int getNumArg() {
605        return getArgList().getNumChild();
606      }
607      /**
608       * Retrieves the number of children in the Arg list.
609       * Calling this method will not trigger rewrites..
610       * @return Number of children in the Arg list.
611       * @apilevel low-level
612       * @ast method 
613       * 
614       */
615      public int getNumArgNoTransform() {
616        return getArgListNoTransform().getNumChildNoTransform();
617      }
618      /**
619       * Retrieves the element at index {@code i} in the Arg list..
620       * @param i Index of the element to return.
621       * @return The element at position {@code i} in the Arg list.
622       * @apilevel high-level
623       * @ast method 
624       * 
625       */
626      @SuppressWarnings({"unchecked", "cast"})
627      public Expr getArg(int i) {
628        return (Expr)getArgList().getChild(i);
629      }
630      /**
631       * Append an element to the Arg list.
632       * @param node The element to append to the Arg list.
633       * @apilevel high-level
634       * @ast method 
635       * 
636       */
637      public void addArg(Expr node) {
638        List<Expr> list = (parent == null || state == null) ? getArgListNoTransform() : getArgList();
639        list.addChild(node);
640      }
641      /**
642       * @apilevel low-level
643       * @ast method 
644       * 
645       */
646      public void addArgNoTransform(Expr node) {
647        List<Expr> list = getArgListNoTransform();
648        list.addChild(node);
649      }
650      /**
651       * Replaces the Arg list element at index {@code i} with the new node {@code node}.
652       * @param node The new node to replace the old list element.
653       * @param i The list index of the node to be replaced.
654       * @apilevel high-level
655       * @ast method 
656       * 
657       */
658      public void setArg(Expr node, int i) {
659        List<Expr> list = getArgList();
660        list.setChild(node, i);
661      }
662      /**
663       * Retrieves the Arg list.
664       * @return The node representing the Arg list.
665       * @apilevel high-level
666       * @ast method 
667       * 
668       */
669      public List<Expr> getArgs() {
670        return getArgList();
671      }
672      /**
673       * Retrieves the Arg list.
674       * <p><em>This method does not invoke AST transformations.</em></p>
675       * @return The node representing the Arg list.
676       * @apilevel low-level
677       * @ast method 
678       * 
679       */
680      public List<Expr> getArgsNoTransform() {
681        return getArgListNoTransform();
682      }
683      /**
684       * Retrieves the Arg list.
685       * @return The node representing the Arg list.
686       * @apilevel high-level
687       * @ast method 
688       * 
689       */
690      @SuppressWarnings({"unchecked", "cast"})
691      public List<Expr> getArgList() {
692        List<Expr> list = (List<Expr>)getChild(0);
693        list.getNumChild();
694        return list;
695      }
696      /**
697       * Retrieves the Arg list.
698       * <p><em>This method does not invoke AST transformations.</em></p>
699       * @return The node representing the Arg list.
700       * @apilevel low-level
701       * @ast method 
702       * 
703       */
704      @SuppressWarnings({"unchecked", "cast"})
705      public List<Expr> getArgListNoTransform() {
706        return (List<Expr>)getChildNoTransform(0);
707      }
708      /**
709       * @ast method 
710       * @aspect MethodSignature15
711       * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/MethodSignature.jrag:11
712       */
713        protected SimpleSet maxSpecific(Collection candidates) {
714        SimpleSet potentiallyApplicable = potentiallyApplicable(candidates);
715        // first phase
716        SimpleSet maxSpecific = applicableBySubtyping(potentiallyApplicable);
717        // second phase
718        maxSpecific = applicableByMethodInvocationConversion(potentiallyApplicable,
719            maxSpecific);
720        // third phase
721        maxSpecific = applicableVariableArity(potentiallyApplicable, maxSpecific);
722        return maxSpecific;
723      }
724      /**
725       * @ast method 
726       * @aspect MethodSignature15
727       * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/MethodSignature.jrag:331
728       */
729        public void typeCheck() {
730        if(isQualified() && decl().isAbstract() && qualifier().isSuperAccess())
731          error("may not access abstract methods in superclass");
732        if(!decl().isVariableArity() || invokesVariableArityAsArray()) {
733          for(int i = 0; i < decl().getNumParameter(); i++) {
734            TypeDecl exprType = getArg(i).type();
735            TypeDecl parmType = decl().getParameter(i).type();
736            if(!exprType.methodInvocationConversionTo(parmType) && !exprType.isUnknown() && !parmType.isUnknown()) {
737              error("#The type " + exprType.typeName() + " of expr " +
738                getArg(i) + " is not compatible with the method parameter " +
739                decl().getParameter(i));
740            }
741          }
742        }
743      }
744      /**
745       * @ast method 
746       * @aspect GenericsCodegen
747       * @declaredat /home/jesper/svn/JastAddJ/Java1.5Backend/GenericsCodegen.jrag:112
748       */
749        public void createBCode(CodeGeneration gen) {
750        MethodDecl decl = decl().erasedMethod();
751        createLoadQualifier(gen);
752    
753        if(decl.type().isUnknown()) {
754          System.err.println("Could not bind " + this);
755          for (int i = 0; i < getNumArg(); ++i) {
756            System.err.println("Argument " + getArg(i) + " is of type " + getArg(i).type().typeName());
757            if(getArg(i).varDecl() != null) System.err.println(getArg(i).varDecl() + " in " + getArg(i).varDecl().hostType().typeName());
758          }
759          if(isQualified())
760            System.err.println("Qualifier " + qualifier() + " is of type " + qualifier().type().typeName());
761          throw new Error("Could not bind " + this);
762        }
763        if(decl.getNumParameter() != getNumArg()) {
764          System.out.println(this + " does not have the same number of arguments as " + decl);
765        }
766    
767        for (int i = 0; i < getNumArg(); ++i) {
768          getArg(i).createBCode(gen);
769          // the cast or boxing/unboxing operation must know the bound rather than the erased type
770          getArg(i).type().emitCastTo(gen, decl().getParameter(i).type()); // MethodInvocationConversion
771        }
772        if(!decl.isStatic() && isQualified() && prevExpr().isSuperAccess()) {
773          if(!hostType().instanceOf(prevExpr().type()))
774            decl().createSuperAccessor(superAccessorTarget()).emitInvokeMethod(gen, superAccessorTarget());
775          else
776            decl.emitInvokeSpecialMethod(gen, methodQualifierType());
777        }
778        else
779          decl.emitInvokeMethod(gen, methodQualifierType());
780    
781        if(decl.type() != decl().type())
782          gen.emitCheckCast(decl().type());
783      }
784      /**
785       * @ast method 
786       * @aspect GenericsCodegen
787       * @declaredat /home/jesper/svn/JastAddJ/Java1.5Backend/GenericsCodegen.jrag:148
788       */
789        protected TypeDecl refined_GenericsCodegen_MethodAccess_methodQualifierType() {
790        TypeDecl typeDecl = refined_InnerClasses_MethodAccess_methodQualifierType();
791        if(typeDecl == null)
792          return null;
793        typeDecl = typeDecl.erasure();
794        MethodDecl m = decl().sourceMethodDecl();
795        Collection methods = typeDecl.memberMethods(m.name());
796        if(!methods.contains(decl()) && !methods.contains(m))
797          return m.hostType();
798        return typeDecl.erasure();
799      }
800      /**
801       * @ast method 
802       * @aspect VariableArityParametersCodegen
803       * @declaredat /home/jesper/svn/JastAddJ/Java1.5Backend/VariableArityParametersCodegen.jrag:16
804       */
805        public void transformation() {
806        if(decl().isVariableArity() && !invokesVariableArityAsArray()) {
807          // arguments to normal parameters
808          List list = new List();
809          for(int i = 0; i < decl().getNumParameter() - 1; i++)
810            list.add(getArg(i).fullCopy());
811          // arguments to variable arity parameters
812          List last = new List();
813          for(int i = decl().getNumParameter() - 1; i < getNumArg(); i++)
814            last.add(getArg(i).fullCopy());
815          // build an array holding arguments
816          Access typeAccess = decl().lastParameter().type().elementType().createQualifiedAccess();
817          for(int i = 0; i < decl().lastParameter().type().dimension(); i++)
818            typeAccess = new ArrayTypeAccess(typeAccess);
819          list.add(new ArrayCreationExpr(typeAccess, new Opt(new ArrayInit(last))));
820          // replace argument list with augemented argument list
821          setArgList(list);
822        }
823        refined_Transformations_MethodAccess_transformation();
824      }
825      /**
826       * @ast method 
827       * @aspect StaticImportsCodegen
828       * @declaredat /home/jesper/svn/JastAddJ/Java1.5Backend/StaticImportsCodegen.jrag:18
829       */
830        protected TypeDecl methodQualifierType() {
831        TypeDecl typeDecl = refined_GenericsCodegen_MethodAccess_methodQualifierType();
832        if(typeDecl != null)
833          return typeDecl;
834        return decl().hostType();
835      }
836      /**
837       * @ast method 
838       * @aspect TypeAnalysis
839       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/TypeAnalysis.jrag:284
840       */
841      private TypeDecl refined_TypeAnalysis_MethodAccess_type()
842    { return decl().type(); }
843      protected java.util.Map computeDAbefore_int_Variable_values;
844      /**
845       * @attribute syn
846       * @aspect DA
847       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/DefiniteAssignment.jrag:410
848       */
849      @SuppressWarnings({"unchecked", "cast"})
850      public boolean computeDAbefore(int i, Variable v) {
851        java.util.List _parameters = new java.util.ArrayList(2);
852        _parameters.add(Integer.valueOf(i));
853        _parameters.add(v);
854        if(computeDAbefore_int_Variable_values == null) computeDAbefore_int_Variable_values = new java.util.HashMap(4);
855        if(computeDAbefore_int_Variable_values.containsKey(_parameters)) {
856          return ((Boolean)computeDAbefore_int_Variable_values.get(_parameters)).booleanValue();
857        }
858          ASTNode$State state = state();
859      int num = state.boundariesCrossed;
860      boolean isFinal = this.is$Final();
861        boolean computeDAbefore_int_Variable_value = computeDAbefore_compute(i, v);
862      if(isFinal && num == state().boundariesCrossed){ computeDAbefore_int_Variable_values.put(_parameters, Boolean.valueOf(computeDAbefore_int_Variable_value)); }
863            return computeDAbefore_int_Variable_value;
864      }
865      /**
866       * @apilevel internal
867       */
868      private boolean computeDAbefore_compute(int i, Variable v) {  return i == 0 ? isDAbefore(v) : getArg(i-1).isDAafter(v);  }
869      /**
870       * @attribute syn
871       * @aspect DA
872       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/DefiniteAssignment.jrag:235
873       */
874      public boolean isDAafter(Variable v) {
875        ASTNode$State state = state();
876        try {  return getNumArg() == 0 ? isDAbefore(v) : getArg(getNumArg()-1).isDAafter(v);  }
877        finally {
878        }
879      }
880      /*eq Stmt.isDAafter(Variable v) {
881        //System.out.println("### isDAafter reached in " + getClass().getName());
882        //throw new NullPointerException();
883        throw new Error("Can not compute isDAafter for " + getClass().getName() + " at " + errorPrefix());
884      }* @attribute syn
885       * @aspect DA
886       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/DefiniteAssignment.jrag:332
887       */
888      public boolean isDAafterTrue(Variable v) {
889        ASTNode$State state = state();
890        try {  return (getNumArg() == 0 ? isDAbefore(v) : getArg(getNumArg()-1).isDAafter(v)) || isFalse();  }
891        finally {
892        }
893      }
894      /**
895       * @attribute syn
896       * @aspect DA
897       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/DefiniteAssignment.jrag:333
898       */
899      public boolean isDAafterFalse(Variable v) {
900        ASTNode$State state = state();
901        try {  return (getNumArg() == 0 ? isDAbefore(v) : getArg(getNumArg()-1).isDAafter(v)) || isTrue();  }
902        finally {
903        }
904      }
905      /**
906       * @apilevel internal
907       */
908      protected boolean exceptionCollection_computed = false;
909      /**
910       * @apilevel internal
911       */
912      protected Collection exceptionCollection_value;
913      /**
914       * @attribute syn
915       * @aspect ExceptionHandling
916       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/ExceptionHandling.jrag:65
917       */
918      @SuppressWarnings({"unchecked", "cast"})
919      public Collection exceptionCollection() {
920        if(exceptionCollection_computed) {
921          return exceptionCollection_value;
922        }
923          ASTNode$State state = state();
924      int num = state.boundariesCrossed;
925      boolean isFinal = this.is$Final();
926        exceptionCollection_value = exceptionCollection_compute();
927      if(isFinal && num == state().boundariesCrossed){ exceptionCollection_computed = true; }
928            return exceptionCollection_value;
929      }
930      /**
931       * @apilevel internal
932       */
933      private Collection exceptionCollection_compute() {
934        //System.out.println("Computing exceptionCollection for " + name());
935        HashSet set = new HashSet();
936        Iterator iter = decls().iterator();
937        if(!iter.hasNext())
938          return set;
939    
940        MethodDecl m = (MethodDecl)iter.next();
941        //System.out.println("Processing first found method " + m.signature() + " in " + m.hostType().fullName());
942    
943        for(int i = 0; i < m.getNumException(); i++) {
944          TypeDecl exceptionType = m.getException(i).type();
945          set.add(exceptionType);
946        }
947        while(iter.hasNext()) {
948          HashSet first = new HashSet();
949          first.addAll(set);
950          HashSet second = new HashSet();
951          m = (MethodDecl)iter.next();
952          //System.out.println("Processing the next method " + m.signature() + " in " + m.hostType().fullName());
953          for(int i = 0; i < m.getNumException(); i++) {
954            TypeDecl exceptionType = m.getException(i).type();
955            second.add(exceptionType);
956          }
957          set = new HashSet();
958          for(Iterator i1 = first.iterator(); i1.hasNext(); ) {
959            TypeDecl firstType = (TypeDecl)i1.next(); 
960            for(Iterator i2 = second.iterator(); i2.hasNext(); ) {
961              TypeDecl secondType = (TypeDecl)i2.next();
962              if(firstType.instanceOf(secondType)) {
963                set.add(firstType);
964              }
965              else if(secondType.instanceOf(firstType)) {
966                set.add(secondType);
967              }
968            }
969          }
970        }
971        return set;
972      }
973      /**
974       * @attribute syn
975       * @aspect LookupMethod
976       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/LookupMethod.jrag:66
977       */
978      public MethodDecl singleCandidateDecl() {
979        ASTNode$State state = state();
980        try {
981        MethodDecl result = null;
982        for(Iterator iter = lookupMethod(name()).iterator(); iter.hasNext(); ) {
983          MethodDecl m = (MethodDecl)iter.next();
984          if(result == null)
985            result = m;
986          else if(m.getNumParameter() == getNumArg() && result.getNumParameter() != getNumArg())
987            result = m;
988        }
989        return result;
990      }
991        finally {
992        }
993      }
994      /**
995       * @apilevel internal
996       */
997      protected boolean decls_computed = false;
998      /**
999       * @apilevel internal
1000       */
1001      protected SimpleSet decls_value;
1002      /**
1003       * @attribute syn
1004       * @aspect LookupMethod
1005       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/LookupMethod.jrag:96
1006       */
1007      @SuppressWarnings({"unchecked", "cast"})
1008      public SimpleSet decls() {
1009        if(decls_computed) {
1010          return decls_value;
1011        }
1012          ASTNode$State state = state();
1013      int num = state.boundariesCrossed;
1014      boolean isFinal = this.is$Final();
1015        decls_value = decls_compute();
1016      if(isFinal && num == state().boundariesCrossed){ decls_computed = true; }
1017            return decls_value;
1018      }
1019      /**
1020       * @apilevel internal
1021       */
1022      private SimpleSet decls_compute() {
1023        SimpleSet maxSpecific = maxSpecific(lookupMethod(name()));
1024        if(isQualified() ? qualifier().staticContextQualifier() : inStaticContext())
1025          maxSpecific = removeInstanceMethods(maxSpecific);
1026        return maxSpecific;
1027      }
1028      /**
1029       * @apilevel internal
1030       */
1031      protected boolean decl_computed = false;
1032      /**
1033       * @apilevel internal
1034       */
1035      protected MethodDecl decl_value;
1036      /**
1037       * @attribute syn
1038       * @aspect LookupMethod
1039       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/LookupMethod.jrag:103
1040       */
1041      @SuppressWarnings({"unchecked", "cast"})
1042      public MethodDecl decl() {
1043        if(decl_computed) {
1044          return decl_value;
1045        }
1046          ASTNode$State state = state();
1047      int num = state.boundariesCrossed;
1048      boolean isFinal = this.is$Final();
1049        decl_value = decl_compute();
1050      if(isFinal && num == state().boundariesCrossed){ decl_computed = true; }
1051            return decl_value;
1052      }
1053      /**
1054       * @apilevel internal
1055       */
1056      private MethodDecl decl_compute() {
1057        SimpleSet decls = decls();
1058        if(decls.size() == 1)
1059          return (MethodDecl)decls.iterator().next();
1060    
1061        // 8.4.6.4 - only return the first method in case of multply inherited abstract methods
1062        boolean allAbstract = true;
1063        for(Iterator iter = decls.iterator(); iter.hasNext() && allAbstract; ) {
1064          MethodDecl m = (MethodDecl)iter.next();
1065          if(!m.isAbstract() && !m.hostType().isObject())
1066            allAbstract = false;
1067        }
1068        if(decls.size() > 1 && allAbstract)
1069          return (MethodDecl)decls.iterator().next();
1070        return unknownMethod();
1071      }
1072      /**
1073       * @attribute syn
1074       * @aspect MethodDecl
1075       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/LookupMethod.jrag:170
1076       */
1077      public boolean accessible(MethodDecl m) {
1078        ASTNode$State state = state();
1079        try {
1080        if(!isQualified())
1081          return true;
1082        if(!m.accessibleFrom(hostType()))
1083          return false;
1084        // the method is not accessible if the type is not accessible
1085        if(!qualifier().type().accessibleFrom(hostType()))
1086          return false;
1087        // 6.6.2.1 -  include qualifier type for protected access
1088        if(m.isProtected() && !m.hostPackage().equals(hostPackage())
1089            && !m.isStatic() && !qualifier().isSuperAccess()) {
1090          return hostType().mayAccess(this, m);
1091        }
1092        return true;
1093      }
1094        finally {
1095        }
1096      }
1097      /**
1098       * @attribute syn
1099       * @aspect NameCheck
1100       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/NameCheck.jrag:65
1101       */
1102      public boolean validArgs() {
1103        ASTNode$State state = state();
1104        try {
1105        for(int i = 0; i < getNumArg(); i++)
1106          if(getArg(i).type().isUnknown())
1107            return false;
1108        return true;
1109      }
1110        finally {
1111        }
1112      }
1113      /**
1114       * @attribute syn
1115       * @aspect PrettyPrint
1116       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/PrettyPrint.jadd:800
1117       */
1118      public String dumpString() {
1119        ASTNode$State state = state();
1120        try {  return getClass().getName() + " [" + getID() + "]";  }
1121        finally {
1122        }
1123      }
1124      /**
1125       * @attribute syn
1126       * @aspect Names
1127       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/QualifiedNames.jrag:18
1128       */
1129      public String name() {
1130        ASTNode$State state = state();
1131        try {  return getID();  }
1132        finally {
1133        }
1134      }
1135      /**
1136       * @attribute syn
1137       * @aspect AccessTypes
1138       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/ResolveAmbiguousNames.jrag:17
1139       */
1140      public boolean isMethodAccess() {
1141        ASTNode$State state = state();
1142        try {  return true;  }
1143        finally {
1144        }
1145      }
1146      /**
1147       * @attribute syn
1148       * @aspect SyntacticClassification
1149       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/SyntacticClassification.jrag:56
1150       */
1151      public NameType predNameType() {
1152        ASTNode$State state = state();
1153        try {  return NameType.AMBIGUOUS_NAME;  }
1154        finally {
1155        }
1156      }
1157      /**
1158       * @apilevel internal
1159       */
1160      protected boolean type_computed = false;
1161      /**
1162       * @apilevel internal
1163       */
1164      protected TypeDecl type_value;
1165      /**
1166       * @attribute syn
1167       * @aspect Generics
1168       * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Generics.jrag:32
1169       */
1170      @SuppressWarnings({"unchecked", "cast"})
1171      public TypeDecl type() {
1172        if(type_computed) {
1173          return type_value;
1174        }
1175          ASTNode$State state = state();
1176      int num = state.boundariesCrossed;
1177      boolean isFinal = this.is$Final();
1178        type_value = type_compute();
1179      if(isFinal && num == state().boundariesCrossed){ type_computed = true; }
1180            return type_value;
1181      }
1182      /**
1183       * @apilevel internal
1184       */
1185      private TypeDecl type_compute() {
1186        if(getNumArg() == 0 && name().equals("getClass") && decl().hostType().isObject()) {
1187          TypeDecl bound = isQualified() ? qualifier().type() : hostType();
1188          ArrayList args = new ArrayList();
1189          args.add(bound.erasure().asWildcardExtends());
1190          return ((GenericClassDecl)lookupType("java.lang", "Class")).lookupParTypeDecl(args);
1191        }
1192        else
1193          return refined_TypeAnalysis_MethodAccess_type();
1194      }
1195      /**
1196       * @attribute syn
1197       * @aspect InnerClasses
1198       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Backend/InnerClasses.jrag:385
1199       */
1200      public boolean requiresAccessor() {
1201        ASTNode$State state = state();
1202        try {
1203        MethodDecl m = decl();
1204        if(m.isPrivate() && m.hostType() != hostType())
1205          return true;
1206        if(m.isProtected() && !m.hostPackage().equals(hostPackage()) && !hostType().hasMethod(m.name()))
1207          return true;
1208        return false;
1209      }
1210        finally {
1211        }
1212      }
1213      /**
1214       * @attribute syn
1215       * @aspect MethodSignature15
1216       * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/MethodSignature.jrag:181
1217       */
1218      public boolean applicableBySubtyping(MethodDecl m) {
1219        ASTNode$State state = state();
1220        try {
1221        if(m.getNumParameter() != getNumArg())
1222          return false;
1223        for(int i = 0; i < m.getNumParameter(); i++)
1224          if(!getArg(i).type().instanceOf(m.getParameter(i).type()))
1225            return false;
1226        return true;
1227      }
1228        finally {
1229        }
1230      }
1231      /**
1232       * @attribute syn
1233       * @aspect MethodSignature15
1234       * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/MethodSignature.jrag:201
1235       */
1236      public boolean applicableByMethodInvocationConversion(MethodDecl m) {
1237        ASTNode$State state = state();
1238        try {
1239        if(m.getNumParameter() != getNumArg())
1240          return false;
1241        for(int i = 0; i < m.getNumParameter(); i++)
1242          if(!getArg(i).type().methodInvocationConversionTo(m.getParameter(i).type()))
1243            return false;
1244        return true;
1245      }
1246        finally {
1247        }
1248      }
1249      /**
1250       * @attribute syn
1251       * @aspect MethodSignature15
1252       * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/MethodSignature.jrag:221
1253       */
1254      public boolean applicableVariableArity(MethodDecl m) {
1255        ASTNode$State state = state();
1256        try {
1257        for(int i = 0; i < m.getNumParameter() - 1; i++)
1258          if(!getArg(i).type().methodInvocationConversionTo(m.getParameter(i).type()))
1259            return false;
1260        for(int i = m.getNumParameter() - 1; i < getNumArg(); i++)
1261          if(!getArg(i).type().methodInvocationConversionTo(m.lastParameter().type().componentType()))
1262            return false;
1263        return true;
1264      }
1265        finally {
1266        }
1267      }
1268      /**
1269       * @attribute syn
1270       * @aspect MethodSignature15
1271       * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/MethodSignature.jrag:262
1272       */
1273      public boolean potentiallyApplicable(MethodDecl m) {
1274        ASTNode$State state = state();
1275        try {
1276        if(!m.name().equals(name()))
1277          return false;
1278        if(!m.accessibleFrom(hostType()))
1279          return false;
1280        if(m.isVariableArity() && !(arity() >= m.arity()-1))
1281          return false;
1282        if(!m.isVariableArity() && !(m.arity() == arity()))
1283          return false;
1284        if(m instanceof GenericMethodDecl) {
1285          GenericMethodDecl gm = (GenericMethodDecl)m;
1286          ArrayList list = typeArguments(m);
1287          if(list.size() != 0) {
1288            if(gm.getNumTypeParameter() != list.size())
1289              return false;
1290            for(int i = 0; i < gm.getNumTypeParameter(); i++)
1291              if(!((TypeDecl)list.get(i)).subtype(gm.original().getTypeParameter(i)))
1292                return false;
1293          }
1294        }
1295        return true;
1296      }
1297        finally {
1298        }
1299      }
1300      /**
1301       * @attribute syn
1302       * @aspect MethodSignature15
1303       * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/MethodSignature.jrag:285
1304       */
1305      public int arity() {
1306        ASTNode$State state = state();
1307        try {  return getNumArg();  }
1308        finally {
1309        }
1310      }
1311      protected java.util.Map typeArguments_MethodDecl_values;
1312      /**
1313       * @attribute syn
1314       * @aspect MethodSignature15
1315       * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/MethodSignature.jrag:287
1316       */
1317      @SuppressWarnings({"unchecked", "cast"})
1318      public ArrayList typeArguments(MethodDecl m) {
1319        Object _parameters = m;
1320        if(typeArguments_MethodDecl_values == null) typeArguments_MethodDecl_values = new java.util.HashMap(4);
1321        if(typeArguments_MethodDecl_values.containsKey(_parameters)) {
1322          return (ArrayList)typeArguments_MethodDecl_values.get(_parameters);
1323        }
1324          ASTNode$State state = state();
1325      int num = state.boundariesCrossed;
1326      boolean isFinal = this.is$Final();
1327        ArrayList typeArguments_MethodDecl_value = typeArguments_compute(m);
1328      if(isFinal && num == state().boundariesCrossed){ typeArguments_MethodDecl_values.put(_parameters, typeArguments_MethodDecl_value); }
1329            return typeArguments_MethodDecl_value;
1330      }
1331      /**
1332       * @apilevel internal
1333       */
1334      private ArrayList typeArguments_compute(MethodDecl m) {
1335        ArrayList typeArguments = new ArrayList();
1336        if(m instanceof GenericMethodDecl) {
1337          GenericMethodDecl g = (GenericMethodDecl)m;
1338          Collection arguments = computeConstraints(g);
1339          if(arguments.isEmpty())
1340            return typeArguments;
1341          int i = 0;
1342          for(Iterator iter = arguments.iterator(); iter.hasNext(); i++) {
1343            TypeDecl typeDecl = (TypeDecl)iter.next();
1344            if(typeDecl == null) {
1345              TypeVariable v = g.original().getTypeParameter(i);
1346              if(v.getNumTypeBound() == 0)
1347                typeDecl = typeObject();
1348              else if(v.getNumTypeBound() == 1)
1349                typeDecl = v.getTypeBound(0).type();
1350              else
1351                typeDecl = v.lubType();
1352            }
1353            typeArguments.add(typeDecl);
1354          }
1355        }
1356        return typeArguments;
1357      }
1358      /**
1359       * @attribute syn
1360       * @aspect VariableArityParameters
1361       * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/VariableArityParameters.jrag:40
1362       */
1363      public boolean invokesVariableArityAsArray() {
1364        ASTNode$State state = state();
1365        try {
1366        if(!decl().isVariableArity())
1367          return false;
1368        if(arity() != decl().arity())
1369          return false;
1370        return getArg(getNumArg()-1).type().methodInvocationConversionTo(decl().lastParameter().type());
1371      }
1372        finally {
1373        }
1374      }
1375      /**
1376       * @attribute inh
1377       * @aspect ExceptionHandling
1378       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/ExceptionHandling.jrag:43
1379       */
1380      @SuppressWarnings({"unchecked", "cast"})
1381      public boolean handlesException(TypeDecl exceptionType) {
1382          ASTNode$State state = state();
1383        boolean handlesException_TypeDecl_value = getParent().Define_boolean_handlesException(this, null, exceptionType);
1384            return handlesException_TypeDecl_value;
1385      }
1386      /**
1387       * @attribute inh
1388       * @aspect LookupMethod
1389       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/LookupMethod.jrag:15
1390       */
1391      @SuppressWarnings({"unchecked", "cast"})
1392      public MethodDecl unknownMethod() {
1393          ASTNode$State state = state();
1394        MethodDecl unknownMethod_value = getParent().Define_MethodDecl_unknownMethod(this, null);
1395            return unknownMethod_value;
1396      }
1397      /**
1398       * @attribute inh
1399       * @aspect TypeHierarchyCheck
1400       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/TypeHierarchyCheck.jrag:123
1401       */
1402      @SuppressWarnings({"unchecked", "cast"})
1403      public boolean inExplicitConstructorInvocation() {
1404          ASTNode$State state = state();
1405        boolean inExplicitConstructorInvocation_value = getParent().Define_boolean_inExplicitConstructorInvocation(this, null);
1406            return inExplicitConstructorInvocation_value;
1407      }
1408      /**
1409       * @attribute inh
1410       * @aspect GenericMethodsInference
1411       * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/GenericMethodsInference.jrag:43
1412       */
1413      @SuppressWarnings({"unchecked", "cast"})
1414      public TypeDecl typeObject() {
1415          ASTNode$State state = state();
1416        TypeDecl typeObject_value = getParent().Define_TypeDecl_typeObject(this, null);
1417            return typeObject_value;
1418      }
1419      /**
1420       * @attribute inh
1421       * @aspect SuppressWarnings
1422       * @declaredat /home/jesper/svn/JastAddJ/Java7Frontend/SuppressWarnings.jrag:18
1423       */
1424      @SuppressWarnings({"unchecked", "cast"})
1425      public boolean withinSuppressWarnings(String s) {
1426          ASTNode$State state = state();
1427        boolean withinSuppressWarnings_String_value = getParent().Define_boolean_withinSuppressWarnings(this, null, s);
1428            return withinSuppressWarnings_String_value;
1429      }
1430      /**
1431       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/DefiniteAssignment.jrag:409
1432       * @apilevel internal
1433       */
1434      public boolean Define_boolean_isDAbefore(ASTNode caller, ASTNode child, Variable v) {
1435        if(caller == getArgListNoTransform())  {
1436        int i = caller.getIndexOfChild(child);
1437        return computeDAbefore(i, v);
1438      }
1439        else {      return getParent().Define_boolean_isDAbefore(this, caller, v);
1440        }
1441      }
1442      /**
1443       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/LookupMethod.jrag:28
1444       * @apilevel internal
1445       */
1446      public Collection Define_Collection_lookupMethod(ASTNode caller, ASTNode child, String name) {
1447        if(caller == getArgListNoTransform())  {
1448        int childIndex = caller.getIndexOfChild(child);
1449        return unqualifiedScope().lookupMethod(name);
1450      }
1451        else {      return getParent().Define_Collection_lookupMethod(this, caller, name);
1452        }
1453      }
1454      /**
1455       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/LookupType.jrag:87
1456       * @apilevel internal
1457       */
1458      public boolean Define_boolean_hasPackage(ASTNode caller, ASTNode child, String packageName) {
1459        if(caller == getArgListNoTransform())  {
1460        int childIndex = caller.getIndexOfChild(child);
1461        return unqualifiedScope().hasPackage(packageName);
1462      }
1463        else {      return getParent().Define_boolean_hasPackage(this, caller, packageName);
1464        }
1465      }
1466      /**
1467       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/LookupType.jrag:253
1468       * @apilevel internal
1469       */
1470      public SimpleSet Define_SimpleSet_lookupType(ASTNode caller, ASTNode child, String name) {
1471        if(caller == getArgListNoTransform())  {
1472        int childIndex = caller.getIndexOfChild(child);
1473        return unqualifiedScope().lookupType(name);
1474      }
1475        else {      return getParent().Define_SimpleSet_lookupType(this, caller, name);
1476        }
1477      }
1478      /**
1479       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/LookupVariable.jrag:132
1480       * @apilevel internal
1481       */
1482      public SimpleSet Define_SimpleSet_lookupVariable(ASTNode caller, ASTNode child, String name) {
1483        if(caller == getArgListNoTransform())  {
1484        int childIndex = caller.getIndexOfChild(child);
1485        return unqualifiedScope().lookupVariable(name);
1486      }
1487        else {      return getParent().Define_SimpleSet_lookupVariable(this, caller, name);
1488        }
1489      }
1490      /**
1491       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/SyntacticClassification.jrag:120
1492       * @apilevel internal
1493       */
1494      public NameType Define_NameType_nameType(ASTNode caller, ASTNode child) {
1495        if(caller == getArgListNoTransform())  {
1496        int childIndex = caller.getIndexOfChild(child);
1497        return NameType.EXPRESSION_NAME;
1498      }
1499        else {      return getParent().Define_NameType_nameType(this, caller);
1500        }
1501      }
1502      /**
1503       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/TypeHierarchyCheck.jrag:17
1504       * @apilevel internal
1505       */
1506      public String Define_String_methodHost(ASTNode caller, ASTNode child) {
1507         {
1508          int childIndex = this.getIndexOfChild(caller);
1509          return unqualifiedScope().methodHost();
1510        }
1511      }
1512      /**
1513       * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/GenericMethodsInference.jrag:41
1514       * @apilevel internal
1515       */
1516      public TypeDecl Define_TypeDecl_assignConvertedType(ASTNode caller, ASTNode child) {
1517        if(caller == getArgListNoTransform())  {
1518        int childIndex = caller.getIndexOfChild(child);
1519        return typeObject();
1520      }
1521        else {      return getParent().Define_TypeDecl_assignConvertedType(this, caller);
1522        }
1523      }
1524      /**
1525       * @apilevel internal
1526       */
1527      public ASTNode rewriteTo() {
1528        return super.rewriteTo();
1529      }
1530    }