1 /*
   2  * Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.tools.javac.tree;
  27 
  28 import java.io.IOException;
  29 import java.io.StringWriter;
  30 import java.util.*;
  31 
  32 import javax.lang.model.element.Modifier;
  33 import javax.lang.model.type.TypeKind;
  34 import javax.tools.JavaFileObject;
  35 
  36 import com.sun.source.tree.*;
  37 import com.sun.tools.javac.code.*;
  38 import com.sun.tools.javac.code.Directive.RequiresDirective;
  39 import com.sun.tools.javac.code.Scope.*;
  40 import com.sun.tools.javac.code.Symbol.*;
  41 import com.sun.tools.javac.util.*;
  42 import com.sun.tools.javac.util.DefinedBy.Api;
  43 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
  44 import com.sun.tools.javac.util.List;
  45 
  46 import static com.sun.tools.javac.tree.JCTree.Tag.*;
  47 
  48 import javax.tools.JavaFileManager.Location;
  49 
  50 import com.sun.source.tree.ModuleTree.ModuleKind;
  51 import com.sun.tools.javac.code.Directive.ExportsDirective;
  52 import com.sun.tools.javac.code.Directive.OpensDirective;
  53 import com.sun.tools.javac.code.Type.ModuleType;
  54 
  55 /**
  56  * Root class for abstract syntax tree nodes. It provides definitions
  57  * for specific tree nodes as subclasses nested inside.
  58  *
  59  * <p>Each subclass is highly standardized.  It generally contains
  60  * only tree fields for the syntactic subcomponents of the node.  Some
  61  * classes that represent identifier uses or definitions also define a
  62  * Symbol field that denotes the represented identifier.  Classes for
  63  * non-local jumps also carry the jump target as a field.  The root
  64  * class Tree itself defines fields for the tree's type and position.
  65  * No other fields are kept in a tree node; instead parameters are
  66  * passed to methods accessing the node.
  67  *
  68  * <p>Except for the methods defined by com.sun.source, the only
  69  * method defined in subclasses is `visit' which applies a given
  70  * visitor to the tree. The actual tree processing is done by visitor
  71  * classes in other packages. The abstract class Visitor, as well as
  72  * an Factory interface for trees, are defined as inner classes in
  73  * Tree.
  74  *
  75  * <p>To avoid ambiguities with the Tree API in com.sun.source all sub
  76  * classes should, by convention, start with JC (javac).
  77  *
  78  * <p><b>This is NOT part of any supported API.
  79  * If you write code that depends on this, you do so at your own risk.
  80  * This code and its internal interfaces are subject to change or
  81  * deletion without notice.</b>
  82  *
  83  * @see TreeMaker
  84  * @see TreeInfo
  85  * @see TreeTranslator
  86  * @see Pretty
  87  */
  88 public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
  89 
  90     /* Tree tag values, identifying kinds of trees */
  91     public enum Tag {
  92         /** For methods that return an invalid tag if a given condition is not met
  93          */
  94         NO_TAG,
  95 
  96         /** Toplevel nodes, of type TopLevel, representing entire source files.
  97         */
  98         TOPLEVEL,
  99 
 100         /** Package level definitions.
 101          */
 102         PACKAGEDEF,
 103 
 104         /** Import clauses, of type Import.
 105          */
 106         IMPORT,
 107 
 108         /** Class definitions, of type ClassDef.
 109          */
 110         CLASSDEF,
 111 
 112         /** Method definitions, of type MethodDef.
 113          */
 114         METHODDEF,
 115 
 116         /** Variable definitions, of type VarDef.
 117          */
 118         VARDEF,
 119 
 120         /** The no-op statement ";", of type Skip
 121          */
 122         SKIP,
 123 
 124         /** Blocks, of type Block.
 125          */
 126         BLOCK,
 127 
 128         /** Do-while loops, of type DoLoop.
 129          */
 130         DOLOOP,
 131 
 132         /** While-loops, of type WhileLoop.
 133          */
 134         WHILELOOP,
 135 
 136         /** For-loops, of type ForLoop.
 137          */
 138         FORLOOP,
 139 
 140         /** Foreach-loops, of type ForeachLoop.
 141          */
 142         FOREACHLOOP,
 143 
 144         /** Labelled statements, of type Labelled.
 145          */
 146         LABELLED,
 147 
 148         /** Switch statements, of type Switch.
 149          */
 150         SWITCH,
 151 
 152         /** Case parts in switch statements/expressions, of type Case.
 153          */
 154         CASE,
 155 
 156         /** Switch expression statements, of type Switch.
 157          */
 158         SWITCH_EXPRESSION,
 159 
 160         /** Synchronized statements, of type Synchronized.
 161          */
 162         SYNCHRONIZED,
 163 
 164         /** Try statements, of type Try.
 165          */
 166         TRY,
 167 
 168         /** Catch clauses in try statements, of type Catch.
 169          */
 170         CATCH,
 171 
 172         /** Conditional expressions, of type Conditional.
 173          */
 174         CONDEXPR,
 175 
 176         /** Conditional statements, of type If.
 177          */
 178         IF,
 179 
 180         /** Expression statements, of type Exec.
 181          */
 182         EXEC,
 183 
 184         /** Break statements, of type Break.
 185          */
 186         BREAK,
 187 
 188         /** Yield statements, of type Yield.
 189          */
 190         YIELD,
 191 
 192         /** Continue statements, of type Continue.
 193          */
 194         CONTINUE,
 195 
 196         /** Return statements, of type Return.
 197          */
 198         RETURN,
 199 
 200         /** Throw statements, of type Throw.
 201          */
 202         THROW,
 203 
 204         /** Assert statements, of type Assert.
 205          */
 206         ASSERT,
 207 
 208         /** Method invocation expressions, of type Apply.
 209          */
 210         APPLY,
 211 
 212         /** Class instance creation expressions, of type NewClass.
 213          */
 214         NEWCLASS,
 215 
 216         /** Array creation expressions, of type NewArray.
 217          */
 218         NEWARRAY,
 219 
 220         /** Lambda expression, of type Lambda.
 221          */
 222         LAMBDA,
 223 
 224         /** Parenthesized subexpressions, of type Parens.
 225          */
 226         PARENS,
 227 
 228         /** Assignment expressions, of type Assign.
 229          */
 230         ASSIGN,
 231 
 232         /** Type cast expressions, of type TypeCast.
 233          */
 234         TYPECAST,
 235 
 236         /** Type test expressions, of type TypeTest.
 237          */
 238         TYPETEST,
 239 
 240         /** Patterns.
 241          */
 242         BINDINGPATTERN,
 243         PARENTHESIZEDPATTERN,
 244         RECORDPATTERN,
 245 
 246         /* Case labels.
 247          */
 248         DEFAULTCASELABEL,
 249         CONSTANTCASELABEL,
 250         PATTERNCASELABEL,
 251 
 252         /** Indexed array expressions, of type Indexed.
 253          */
 254         INDEXED,
 255 
 256         /** Selections, of type Select.
 257          */
 258         SELECT,
 259 
 260         /** Member references, of type Reference.
 261          */
 262         REFERENCE,
 263 
 264         /** Simple identifiers, of type Ident.
 265          */
 266         IDENT,
 267 
 268         /** Literals, of type Literal.
 269          */
 270         LITERAL,
 271 
 272         /** Basic type identifiers, of type TypeIdent.
 273          */
 274         TYPEIDENT,
 275 
 276         /** Array types, of type TypeArray.
 277          */
 278         TYPEARRAY,
 279 
 280         /** Parameterized types, of type TypeApply.
 281          */
 282         TYPEAPPLY,
 283 
 284         /** Union types, of type TypeUnion.
 285          */
 286         TYPEUNION,
 287 
 288         /** Intersection types, of type TypeIntersection.
 289          */
 290         TYPEINTERSECTION,
 291 
 292         /** Formal type parameters, of type TypeParameter.
 293          */
 294         TYPEPARAMETER,
 295 
 296         /** Type argument.
 297          */
 298         WILDCARD,
 299 
 300         /** Bound kind: extends, super, exact, or unbound
 301          */
 302         TYPEBOUNDKIND,
 303 
 304         /** metadata: Annotation.
 305          */
 306         ANNOTATION,
 307 
 308         /** metadata: Type annotation.
 309          */
 310         TYPE_ANNOTATION,
 311 
 312         /** metadata: Modifiers
 313          */
 314         MODIFIERS,
 315 
 316         /** An annotated type tree.
 317          */
 318         ANNOTATED_TYPE,
 319 
 320         /** Error trees, of type Erroneous.
 321          */
 322         ERRONEOUS,
 323 
 324         /** Unary operators, of type Unary.
 325          */
 326         POS,                             // +
 327         NEG,                             // -
 328         NOT,                             // !
 329         COMPL,                           // ~
 330         PREINC,                          // ++ _
 331         PREDEC,                          // -- _
 332         POSTINC,                         // _ ++
 333         POSTDEC,                         // _ --
 334 
 335         /** unary operator for null reference checks, only used internally.
 336          */
 337         NULLCHK,
 338 
 339         /** Binary operators, of type Binary.
 340          */
 341         OR,                              // ||
 342         AND,                             // &&
 343         BITOR,                           // |
 344         BITXOR,                          // ^
 345         BITAND,                          // &
 346         EQ,                              // ==
 347         NE,                              // !=
 348         LT,                              // <
 349         GT,                              // >
 350         LE,                              // <=
 351         GE,                              // >=
 352         SL,                              // <<
 353         SR,                              // >>
 354         USR,                             // >>>
 355         PLUS,                            // +
 356         MINUS,                           // -
 357         MUL,                             // *
 358         DIV,                             // /
 359         MOD,                             // %
 360 
 361         /** Assignment operators, of type Assignop.
 362          */
 363         BITOR_ASG(BITOR),                // |=
 364         BITXOR_ASG(BITXOR),              // ^=
 365         BITAND_ASG(BITAND),              // &=
 366 
 367         SL_ASG(SL),                      // <<=
 368         SR_ASG(SR),                      // >>=
 369         USR_ASG(USR),                    // >>>=
 370         PLUS_ASG(PLUS),                  // +=
 371         MINUS_ASG(MINUS),                // -=
 372         MUL_ASG(MUL),                    // *=
 373         DIV_ASG(DIV),                    // /=
 374         MOD_ASG(MOD),                    // %=
 375 
 376         MODULEDEF,
 377         EXPORTS,
 378         OPENS,
 379         PROVIDES,
 380         REQUIRES,
 381         USES,
 382 
 383         /** A synthetic let expression, of type LetExpr.
 384          */
 385         LETEXPR;                         // ala scheme
 386 
 387         private final Tag noAssignTag;
 388 
 389         private static final int numberOfOperators = MOD.ordinal() - POS.ordinal() + 1;
 390 
 391         private Tag(Tag noAssignTag) {
 392             this.noAssignTag = noAssignTag;
 393         }
 394 
 395         private Tag() {
 396             this(null);
 397         }
 398 
 399         public static int getNumberOfOperators() {
 400             return numberOfOperators;
 401         }
 402 
 403         public Tag noAssignOp() {
 404             if (noAssignTag != null)
 405                 return noAssignTag;
 406             throw new AssertionError("noAssignOp() method is not available for non assignment tags");
 407         }
 408 
 409         public boolean isPostUnaryOp() {
 410             return (this == POSTINC || this == POSTDEC);
 411         }
 412 
 413         public boolean isIncOrDecUnaryOp() {
 414             return (this == PREINC || this == PREDEC || this == POSTINC || this == POSTDEC);
 415         }
 416 
 417         public boolean isAssignop() {
 418             return noAssignTag != null;
 419         }
 420 
 421         public int operatorIndex() {
 422             return (this.ordinal() - POS.ordinal());
 423         }
 424     }
 425 
 426     /* The (encoded) position in the source file. @see util.Position.
 427      */
 428     public int pos;
 429 
 430     /* The type of this node.
 431      */
 432     public Type type;
 433 
 434     /* The tag of this node -- one of the constants declared above.
 435      */
 436     public abstract Tag getTag();
 437 
 438     /* Returns true if the tag of this node is equals to tag.
 439      */
 440     public boolean hasTag(Tag tag) {
 441         return tag == getTag();
 442     }
 443 
 444     /** Convert a tree to a pretty-printed string. */
 445     @Override
 446     public String toString() {
 447         StringWriter s = new StringWriter();
 448         try {
 449             new Pretty(s, false).printExpr(this);
 450         }
 451         catch (IOException e) {
 452             // should never happen, because StringWriter is defined
 453             // never to throw any IOExceptions
 454             throw new AssertionError(e);
 455         }
 456         return s.toString();
 457     }
 458 
 459     /** Set position field and return this tree.
 460      */
 461     public JCTree setPos(int pos) {
 462         this.pos = pos;
 463         return this;
 464     }
 465 
 466     /** Set type field and return this tree.
 467      */
 468     public JCTree setType(Type type) {
 469         this.type = type;
 470         return this;
 471     }
 472 
 473     /** Visit this tree with a given visitor.
 474      */
 475     public abstract void accept(Visitor v);
 476 
 477     @DefinedBy(Api.COMPILER_TREE)
 478     public abstract <R,D> R accept(TreeVisitor<R,D> v, D d);
 479 
 480     /** Return a shallow copy of this tree.
 481      */
 482     @Override
 483     public Object clone() {
 484         try {
 485             return super.clone();
 486         } catch(CloneNotSupportedException e) {
 487             throw new RuntimeException(e);
 488         }
 489     }
 490 
 491     /** Get a default position for this tree node.
 492      */
 493     public DiagnosticPosition pos() {
 494         return this;
 495     }
 496 
 497     // for default DiagnosticPosition
 498     public JCTree getTree() {
 499         return this;
 500     }
 501 
 502     // for default DiagnosticPosition
 503     public int getStartPosition() {
 504         return TreeInfo.getStartPos(this);
 505     }
 506 
 507     // for default DiagnosticPosition
 508     public int getPreferredPosition() {
 509         return pos;
 510     }
 511 
 512     // for default DiagnosticPosition
 513     public int getEndPosition(EndPosTable endPosTable) {
 514         return TreeInfo.getEndPos(this, endPosTable);
 515     }
 516 
 517     /**
 518      * Everything in one source file is kept in a {@linkplain JCCompilationUnit} structure.
 519      */
 520     public static class JCCompilationUnit extends JCTree implements CompilationUnitTree {
 521         /** All definitions in this file (ClassDef, Import, and Skip) */
 522         public List<JCTree> defs;
 523         /** The source file name. */
 524         public JavaFileObject sourcefile;
 525         /** The module to which this compilation unit belongs. */
 526         public ModuleSymbol modle;
 527         /** The location in which this compilation unit was found. */
 528         public Location locn;
 529         /** The package to which this compilation unit belongs. */
 530         public PackageSymbol packge;
 531         /** A scope containing top level classes. */
 532         public WriteableScope toplevelScope;
 533         /** A scope for all named imports. */
 534         public NamedImportScope namedImportScope;
 535         /** A scope for all import-on-demands. */
 536         public StarImportScope starImportScope;
 537         /** Line starting positions, defined only if option -g is set. */
 538         public Position.LineMap lineMap = null;
 539         /** A table that stores all documentation comments indexed by the tree
 540          * nodes they refer to. defined only if option -s is set. */
 541         public DocCommentTable docComments = null;
 542         /* An object encapsulating ending positions of source ranges indexed by
 543          * the tree nodes they belong to. Defined only if option -Xjcov is set. */
 544         public EndPosTable endPositions = null;
 545         protected JCCompilationUnit(List<JCTree> defs) {
 546             this.defs = defs;
 547         }
 548         @Override
 549         public void accept(Visitor v) { v.visitTopLevel(this); }
 550 
 551         @DefinedBy(Api.COMPILER_TREE)
 552         public Kind getKind() { return Kind.COMPILATION_UNIT; }
 553 
 554         public JCModuleDecl getModuleDecl() {
 555             for (JCTree tree : defs) {
 556                 if (tree.hasTag(MODULEDEF)) {
 557                     return (JCModuleDecl) tree;
 558                 }
 559             }
 560 
 561             return null;
 562         }
 563 
 564         @DefinedBy(Api.COMPILER_TREE)
 565         public JCModuleDecl getModule() {
 566             return getModuleDecl();
 567         }
 568 
 569         @DefinedBy(Api.COMPILER_TREE)
 570         public JCPackageDecl getPackage() {
 571             // PackageDecl must be the first entry if it exists
 572             if (!defs.isEmpty() && defs.head.hasTag(PACKAGEDEF))
 573                 return (JCPackageDecl)defs.head;
 574             return null;
 575         }
 576         @DefinedBy(Api.COMPILER_TREE)
 577         public List<JCAnnotation> getPackageAnnotations() {
 578             JCPackageDecl pd = getPackage();
 579             return pd != null ? pd.getAnnotations() : List.nil();
 580         }
 581         @DefinedBy(Api.COMPILER_TREE)
 582         public ExpressionTree getPackageName() {
 583             JCPackageDecl pd = getPackage();
 584             return pd != null ? pd.getPackageName() : null;
 585         }
 586 
 587         @DefinedBy(Api.COMPILER_TREE)
 588         public List<JCImport> getImports() {
 589             ListBuffer<JCImport> imports = new ListBuffer<>();
 590             for (JCTree tree : defs) {
 591                 if (tree.hasTag(IMPORT))
 592                     imports.append((JCImport)tree);
 593                 else if (!tree.hasTag(PACKAGEDEF) && !tree.hasTag(SKIP))
 594                     break;
 595             }
 596             return imports.toList();
 597         }
 598         @DefinedBy(Api.COMPILER_TREE)
 599         public JavaFileObject getSourceFile() {
 600             return sourcefile;
 601         }
 602         @DefinedBy(Api.COMPILER_TREE)
 603         public Position.LineMap getLineMap() {
 604             return lineMap;
 605         }
 606         @DefinedBy(Api.COMPILER_TREE)
 607         public List<JCTree> getTypeDecls() {
 608             List<JCTree> typeDefs;
 609             for (typeDefs = defs; !typeDefs.isEmpty(); typeDefs = typeDefs.tail) {
 610                 if (!typeDefs.head.hasTag(MODULEDEF)
 611                         && !typeDefs.head.hasTag(PACKAGEDEF) && !typeDefs.head.hasTag(IMPORT)) {
 612                     break;
 613                 }
 614             }
 615             return typeDefs;
 616         }
 617         @Override @DefinedBy(Api.COMPILER_TREE)
 618         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
 619             return v.visitCompilationUnit(this, d);
 620         }
 621 
 622         @Override
 623         public Tag getTag() {
 624             return TOPLEVEL;
 625         }
 626     }
 627 
 628     /**
 629      * Package definition.
 630      */
 631     public static class JCPackageDecl extends JCTree implements PackageTree {
 632         public List<JCAnnotation> annotations;
 633         /** The tree representing the package clause. */
 634         public JCExpression pid;
 635         public PackageSymbol packge;
 636         public JCPackageDecl(List<JCAnnotation> annotations, JCExpression pid) {
 637             this.annotations = annotations;
 638             this.pid = pid;
 639         }
 640         @Override
 641         public void accept(Visitor v) { v.visitPackageDef(this); }
 642         @DefinedBy(Api.COMPILER_TREE)
 643         public Kind getKind() {
 644             return Kind.PACKAGE;
 645         }
 646         @DefinedBy(Api.COMPILER_TREE)
 647         public List<JCAnnotation> getAnnotations() {
 648             return annotations;
 649         }
 650         @DefinedBy(Api.COMPILER_TREE)
 651         public JCExpression getPackageName() {
 652             return pid;
 653         }
 654         @Override @DefinedBy(Api.COMPILER_TREE)
 655         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
 656             return v.visitPackage(this, d);
 657         }
 658         @Override
 659         public Tag getTag() {
 660             return PACKAGEDEF;
 661         }
 662     }
 663 
 664     /**
 665      * An import clause.
 666      */
 667     public static class JCImport extends JCTree implements ImportTree {
 668         public boolean staticImport;
 669         /** The imported class(es). */
 670         public JCTree qualid;
 671         public com.sun.tools.javac.code.Scope importScope;
 672         protected JCImport(JCTree qualid, boolean importStatic) {
 673             this.qualid = qualid;
 674             this.staticImport = importStatic;
 675         }
 676         @Override
 677         public void accept(Visitor v) { v.visitImport(this); }
 678 
 679         @DefinedBy(Api.COMPILER_TREE)
 680         public boolean isStatic() { return staticImport; }
 681         @DefinedBy(Api.COMPILER_TREE)
 682         public JCTree getQualifiedIdentifier() { return qualid; }
 683 
 684         @DefinedBy(Api.COMPILER_TREE)
 685         public Kind getKind() { return Kind.IMPORT; }
 686         @Override @DefinedBy(Api.COMPILER_TREE)
 687         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
 688             return v.visitImport(this, d);
 689         }
 690 
 691         @Override
 692         public Tag getTag() {
 693             return IMPORT;
 694         }
 695     }
 696 
 697     public abstract static class JCStatement extends JCTree implements StatementTree {
 698         @Override
 699         public JCStatement setType(Type type) {
 700             super.setType(type);
 701             return this;
 702         }
 703         @Override
 704         public JCStatement setPos(int pos) {
 705             super.setPos(pos);
 706             return this;
 707         }
 708     }
 709 
 710     public abstract static class JCCaseLabel extends JCTree implements CaseLabelTree {
 711     }
 712 
 713     public abstract static class JCExpression extends JCTree implements ExpressionTree {
 714         @Override
 715         public JCExpression setType(Type type) {
 716             super.setType(type);
 717             return this;
 718         }
 719         @Override
 720         public JCExpression setPos(int pos) {
 721             super.setPos(pos);
 722             return this;
 723         }
 724 
 725         public boolean isPoly() { return false; }
 726         public boolean isStandalone() { return true; }
 727 
 728     }
 729 
 730     /**
 731      * Common supertype for all poly expression trees (lambda, method references,
 732      * conditionals, method and constructor calls)
 733      */
 734     public abstract static class JCPolyExpression extends JCExpression {
 735 
 736         /**
 737          * A poly expression can only be truly 'poly' in certain contexts
 738          */
 739         public enum PolyKind {
 740             /** poly expression to be treated as a standalone expression */
 741             STANDALONE,
 742             /** true poly expression */
 743             POLY
 744         }
 745 
 746         /** is this poly expression a 'true' poly expression? */
 747         public PolyKind polyKind;
 748 
 749         @Override public boolean isPoly() { return polyKind == PolyKind.POLY; }
 750         @Override public boolean isStandalone() { return polyKind == PolyKind.STANDALONE; }
 751     }
 752 
 753     /**
 754      * Common supertype for all functional expression trees (lambda and method references)
 755      */
 756     public abstract static class JCFunctionalExpression extends JCPolyExpression {
 757 
 758         public JCFunctionalExpression() {
 759             //a functional expression is always a 'true' poly
 760             polyKind = PolyKind.POLY;
 761         }
 762 
 763         /** list of target types inferred for this functional expression. */
 764         public Type target;
 765 
 766         public Type getDescriptorType(Types types) {
 767             return target != null ? types.findDescriptorType(target) : types.createErrorType(null);
 768         }
 769     }
 770 
 771     /**
 772      * A class definition.
 773      */
 774     public static class JCClassDecl extends JCStatement implements ClassTree {
 775         /** the modifiers */
 776         public JCModifiers mods;
 777         /** the name of the class */
 778         public Name name;
 779         /** formal class parameters */
 780         public List<JCTypeParameter> typarams;
 781         /** the classes this class extends */
 782         public JCExpression extending;
 783         /** the interfaces implemented by this class */
 784         public List<JCExpression> implementing;
 785         /** the subclasses allowed to extend this class, if sealed */
 786         public List<JCExpression> permitting;
 787         /** all variables and methods defined in this class */
 788         public List<JCTree> defs;
 789         /** the symbol */
 790         public ClassSymbol sym;
 791         protected JCClassDecl(JCModifiers mods,
 792                            Name name,
 793                            List<JCTypeParameter> typarams,
 794                            JCExpression extending,
 795                            List<JCExpression> implementing,
 796                            List<JCExpression> permitting,
 797                            List<JCTree> defs,
 798                            ClassSymbol sym)
 799         {
 800             this.mods = mods;
 801             this.name = name;
 802             this.typarams = typarams;
 803             this.extending = extending;
 804             this.implementing = implementing;
 805             this.permitting = permitting;
 806             this.defs = defs;
 807             this.sym = sym;
 808         }
 809         @Override
 810         public void accept(Visitor v) { v.visitClassDef(this); }
 811 
 812         @DefinedBy(Api.COMPILER_TREE)
 813         public Kind getKind() {
 814             if ((mods.flags & Flags.ANNOTATION) != 0)
 815                 return Kind.ANNOTATION_TYPE;
 816             else if ((mods.flags & Flags.INTERFACE) != 0)
 817                 return Kind.INTERFACE;
 818             else if ((mods.flags & Flags.ENUM) != 0)
 819                 return Kind.ENUM;
 820             else if ((mods.flags & Flags.RECORD) != 0)
 821                 return Kind.RECORD;
 822             else
 823                 return Kind.CLASS;
 824         }
 825 
 826         @DefinedBy(Api.COMPILER_TREE)
 827         public JCModifiers getModifiers() { return mods; }
 828         @DefinedBy(Api.COMPILER_TREE)
 829         public Name getSimpleName() { return name; }
 830         @DefinedBy(Api.COMPILER_TREE)
 831         public List<JCTypeParameter> getTypeParameters() {
 832             return typarams;
 833         }
 834         @DefinedBy(Api.COMPILER_TREE)
 835         public JCExpression getExtendsClause() { return extending; }
 836         @DefinedBy(Api.COMPILER_TREE)
 837         public List<JCExpression> getImplementsClause() {
 838             return implementing;
 839         }
 840         @SuppressWarnings("removal")
 841         @DefinedBy(Api.COMPILER_TREE)
 842         public List<JCExpression> getPermitsClause() {
 843             return permitting;
 844         }
 845         @DefinedBy(Api.COMPILER_TREE)
 846         public List<JCTree> getMembers() {
 847             return defs;
 848         }
 849         @Override @DefinedBy(Api.COMPILER_TREE)
 850         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
 851             return v.visitClass(this, d);
 852         }
 853 
 854         @Override
 855         public Tag getTag() {
 856             return CLASSDEF;
 857         }
 858     }
 859 
 860     /**
 861      * A method definition.
 862      */
 863     public static class JCMethodDecl extends JCTree implements MethodTree {
 864         /** method modifiers */
 865         public JCModifiers mods;
 866         /** method name */
 867         public Name name;
 868         /** type of method return value */
 869         public JCExpression restype;
 870         /** type parameters */
 871         public List<JCTypeParameter> typarams;
 872         /** receiver parameter */
 873         public JCVariableDecl recvparam;
 874         /** value parameters */
 875         public List<JCVariableDecl> params;
 876         /** exceptions thrown by this method */
 877         public List<JCExpression> thrown;
 878         /** statements in the method */
 879         public JCBlock body;
 880         /** default value, for annotation types */
 881         public JCExpression defaultValue;
 882         /** method symbol */
 883         public MethodSymbol sym;
 884         /** does this method completes normally */
 885         public boolean completesNormally;
 886 
 887         protected JCMethodDecl(JCModifiers mods,
 888                             Name name,
 889                             JCExpression restype,
 890                             List<JCTypeParameter> typarams,
 891                             JCVariableDecl recvparam,
 892                             List<JCVariableDecl> params,
 893                             List<JCExpression> thrown,
 894                             JCBlock body,
 895                             JCExpression defaultValue,
 896                             MethodSymbol sym)
 897         {
 898             this.mods = mods;
 899             this.name = name;
 900             this.restype = restype;
 901             this.typarams = typarams;
 902             this.params = params;
 903             this.recvparam = recvparam;
 904             // TODO: do something special if the given type is null?
 905             // receiver != null ? receiver : List.<JCTypeAnnotation>nil());
 906             this.thrown = thrown;
 907             this.body = body;
 908             this.defaultValue = defaultValue;
 909             this.sym = sym;
 910         }
 911         @Override
 912         public void accept(Visitor v) { v.visitMethodDef(this); }
 913 
 914         @DefinedBy(Api.COMPILER_TREE)
 915         public Kind getKind() { return Kind.METHOD; }
 916         @DefinedBy(Api.COMPILER_TREE)
 917         public JCModifiers getModifiers() { return mods; }
 918         @DefinedBy(Api.COMPILER_TREE)
 919         public Name getName() { return name; }
 920         @DefinedBy(Api.COMPILER_TREE)
 921         public JCTree getReturnType() { return restype; }
 922         @DefinedBy(Api.COMPILER_TREE)
 923         public List<JCTypeParameter> getTypeParameters() {
 924             return typarams;
 925         }
 926         @DefinedBy(Api.COMPILER_TREE)
 927         public List<JCVariableDecl> getParameters() {
 928             return params;
 929         }
 930         @DefinedBy(Api.COMPILER_TREE)
 931         public JCVariableDecl getReceiverParameter() { return recvparam; }
 932         @DefinedBy(Api.COMPILER_TREE)
 933         public List<JCExpression> getThrows() {
 934             return thrown;
 935         }
 936         @DefinedBy(Api.COMPILER_TREE)
 937         public JCBlock getBody() { return body; }
 938         @DefinedBy(Api.COMPILER_TREE)
 939         public JCTree getDefaultValue() { // for annotation types
 940             return defaultValue;
 941         }
 942         @Override @DefinedBy(Api.COMPILER_TREE)
 943         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
 944             return v.visitMethod(this, d);
 945         }
 946 
 947         @Override
 948         public Tag getTag() {
 949             return METHODDEF;
 950         }
 951   }
 952 
 953     /**
 954      * A variable definition.
 955      */
 956     public static class JCVariableDecl extends JCStatement implements VariableTree {
 957         /** variable modifiers */
 958         public JCModifiers mods;
 959         /** variable name */
 960         public Name name;
 961         /** variable name expression */
 962         public JCExpression nameexpr;
 963         /** type of the variable */
 964         public JCExpression vartype;
 965         /** variable's initial value */
 966         public JCExpression init;
 967         /** symbol */
 968         public VarSymbol sym;
 969         /** explicit start pos */
 970         public int startPos = Position.NOPOS;
 971         /** declared using `var` */
 972         private boolean declaredUsingVar;
 973 
 974         protected JCVariableDecl(JCModifiers mods,
 975                          Name name,
 976                          JCExpression vartype,
 977                          JCExpression init,
 978                          VarSymbol sym) {
 979             this(mods, name, vartype, init, sym, false);
 980         }
 981 
 982         protected JCVariableDecl(JCModifiers mods,
 983                                  Name name,
 984                                  JCExpression vartype,
 985                                  JCExpression init,
 986                                  VarSymbol sym,
 987                                  boolean declaredUsingVar) {
 988             this.mods = mods;
 989             this.name = name;
 990             this.vartype = vartype;
 991             this.init = init;
 992             this.sym = sym;
 993             this.declaredUsingVar = declaredUsingVar;
 994         }
 995 
 996         protected JCVariableDecl(JCModifiers mods,
 997                          JCExpression nameexpr,
 998                          JCExpression vartype) {
 999             this(mods, null, vartype, null, null, false);
1000             this.nameexpr = nameexpr;
1001             if (nameexpr.hasTag(Tag.IDENT)) {
1002                 this.name = ((JCIdent)nameexpr).name;
1003             } else {
1004                 // Only other option is qualified name x.y.this;
1005                 this.name = ((JCFieldAccess)nameexpr).name;
1006             }
1007         }
1008 
1009         public boolean isImplicitlyTyped() {
1010             return vartype == null;
1011         }
1012 
1013         public boolean declaredUsingVar() {
1014             return declaredUsingVar;
1015         }
1016 
1017         @Override
1018         public void accept(Visitor v) { v.visitVarDef(this); }
1019 
1020         @DefinedBy(Api.COMPILER_TREE)
1021         public Kind getKind() { return Kind.VARIABLE; }
1022         @DefinedBy(Api.COMPILER_TREE)
1023         public JCModifiers getModifiers() { return mods; }
1024         @DefinedBy(Api.COMPILER_TREE)
1025         public Name getName() { return name; }
1026         @DefinedBy(Api.COMPILER_TREE)
1027         public JCExpression getNameExpression() { return nameexpr; }
1028         @DefinedBy(Api.COMPILER_TREE)
1029         public JCTree getType() { return vartype; }
1030         @DefinedBy(Api.COMPILER_TREE)
1031         public JCExpression getInitializer() {
1032             return init;
1033         }
1034         @Override @DefinedBy(Api.COMPILER_TREE)
1035         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1036             return v.visitVariable(this, d);
1037         }
1038 
1039         @Override
1040         public Tag getTag() {
1041             return VARDEF;
1042         }
1043     }
1044 
1045     /**
1046      * A no-op statement ";".
1047      */
1048     public static class JCSkip extends JCStatement implements EmptyStatementTree {
1049         protected JCSkip() {
1050         }
1051         @Override
1052         public void accept(Visitor v) { v.visitSkip(this); }
1053 
1054         @DefinedBy(Api.COMPILER_TREE)
1055         public Kind getKind() { return Kind.EMPTY_STATEMENT; }
1056         @Override @DefinedBy(Api.COMPILER_TREE)
1057         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1058             return v.visitEmptyStatement(this, d);
1059         }
1060 
1061         @Override
1062         public Tag getTag() {
1063             return SKIP;
1064         }
1065     }
1066 
1067     /**
1068      * A statement block.
1069      */
1070     public static class JCBlock extends JCStatement implements BlockTree {
1071         /** flags */
1072         public long flags;
1073         /** statements */
1074         public List<JCStatement> stats;
1075         /** Position of closing brace, optional. */
1076         public int endpos = Position.NOPOS;
1077         protected JCBlock(long flags, List<JCStatement> stats) {
1078             this.stats = stats;
1079             this.flags = flags;
1080         }
1081         @Override
1082         public void accept(Visitor v) { v.visitBlock(this); }
1083 
1084         @DefinedBy(Api.COMPILER_TREE)
1085         public Kind getKind() { return Kind.BLOCK; }
1086         @DefinedBy(Api.COMPILER_TREE)
1087         public List<JCStatement> getStatements() {
1088             return stats;
1089         }
1090         @DefinedBy(Api.COMPILER_TREE)
1091         public boolean isStatic() { return (flags & Flags.STATIC) != 0; }
1092         @Override @DefinedBy(Api.COMPILER_TREE)
1093         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1094             return v.visitBlock(this, d);
1095         }
1096 
1097         @Override
1098         public Tag getTag() {
1099             return BLOCK;
1100         }
1101     }
1102 
1103     /**
1104      * A do loop
1105      */
1106     public static class JCDoWhileLoop extends JCStatement implements DoWhileLoopTree {
1107         public JCStatement body;
1108         public JCExpression cond;
1109         protected JCDoWhileLoop(JCStatement body, JCExpression cond) {
1110             this.body = body;
1111             this.cond = cond;
1112         }
1113         @Override
1114         public void accept(Visitor v) { v.visitDoLoop(this); }
1115 
1116         @DefinedBy(Api.COMPILER_TREE)
1117         public Kind getKind() { return Kind.DO_WHILE_LOOP; }
1118         @DefinedBy(Api.COMPILER_TREE)
1119         public JCExpression getCondition() { return cond; }
1120         @DefinedBy(Api.COMPILER_TREE)
1121         public JCStatement getStatement() { return body; }
1122         @Override @DefinedBy(Api.COMPILER_TREE)
1123         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1124             return v.visitDoWhileLoop(this, d);
1125         }
1126 
1127         @Override
1128         public Tag getTag() {
1129             return DOLOOP;
1130         }
1131     }
1132 
1133     /**
1134      * A while loop
1135      */
1136     public static class JCWhileLoop extends JCStatement implements WhileLoopTree {
1137         public JCExpression cond;
1138         public JCStatement body;
1139         protected JCWhileLoop(JCExpression cond, JCStatement body) {
1140             this.cond = cond;
1141             this.body = body;
1142         }
1143         @Override
1144         public void accept(Visitor v) { v.visitWhileLoop(this); }
1145 
1146         @DefinedBy(Api.COMPILER_TREE)
1147         public Kind getKind() { return Kind.WHILE_LOOP; }
1148         @DefinedBy(Api.COMPILER_TREE)
1149         public JCExpression getCondition() { return cond; }
1150         @DefinedBy(Api.COMPILER_TREE)
1151         public JCStatement getStatement() { return body; }
1152         @Override @DefinedBy(Api.COMPILER_TREE)
1153         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1154             return v.visitWhileLoop(this, d);
1155         }
1156 
1157         @Override
1158         public Tag getTag() {
1159             return WHILELOOP;
1160         }
1161     }
1162 
1163     /**
1164      * A for loop.
1165      */
1166     public static class JCForLoop extends JCStatement implements ForLoopTree {
1167         public List<JCStatement> init;
1168         public JCExpression cond;
1169         public List<JCExpressionStatement> step;
1170         public JCStatement body;
1171         protected JCForLoop(List<JCStatement> init,
1172                           JCExpression cond,
1173                           List<JCExpressionStatement> update,
1174                           JCStatement body)
1175         {
1176             this.init = init;
1177             this.cond = cond;
1178             this.step = update;
1179             this.body = body;
1180         }
1181         @Override
1182         public void accept(Visitor v) { v.visitForLoop(this); }
1183 
1184         @DefinedBy(Api.COMPILER_TREE)
1185         public Kind getKind() { return Kind.FOR_LOOP; }
1186         @DefinedBy(Api.COMPILER_TREE)
1187         public JCExpression getCondition() { return cond; }
1188         @DefinedBy(Api.COMPILER_TREE)
1189         public JCStatement getStatement() { return body; }
1190         @DefinedBy(Api.COMPILER_TREE)
1191         public List<JCStatement> getInitializer() {
1192             return init;
1193         }
1194         @DefinedBy(Api.COMPILER_TREE)
1195         public List<JCExpressionStatement> getUpdate() {
1196             return step;
1197         }
1198         @Override @DefinedBy(Api.COMPILER_TREE)
1199         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1200             return v.visitForLoop(this, d);
1201         }
1202 
1203         @Override
1204         public Tag getTag() {
1205             return FORLOOP;
1206         }
1207     }
1208 
1209     /**
1210      * The enhanced for loop.
1211      */
1212     public static class JCEnhancedForLoop extends JCStatement implements EnhancedForLoopTree {
1213         public JCVariableDecl var;
1214         public JCExpression expr;
1215         public JCStatement body;
1216         protected JCEnhancedForLoop(JCVariableDecl var, JCExpression expr, JCStatement body) {
1217             this.var = var;
1218             this.expr = expr;
1219             this.body = body;
1220         }
1221         @Override
1222         public void accept(Visitor v) { v.visitForeachLoop(this); }
1223 
1224         @DefinedBy(Api.COMPILER_TREE)
1225         public Kind getKind() { return Kind.ENHANCED_FOR_LOOP; }
1226         @DefinedBy(Api.COMPILER_TREE)
1227         public JCVariableDecl getVariable() { return var; }
1228         @DefinedBy(Api.COMPILER_TREE)
1229         public JCExpression getExpression() { return expr; }
1230         @DefinedBy(Api.COMPILER_TREE)
1231         public JCStatement getStatement() { return body; }
1232         @Override @DefinedBy(Api.COMPILER_TREE)
1233         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1234             return v.visitEnhancedForLoop(this, d);
1235         }
1236         @Override
1237         public Tag getTag() {
1238             return FOREACHLOOP;
1239         }
1240     }
1241 
1242     /**
1243      * A labelled expression or statement.
1244      */
1245     public static class JCLabeledStatement extends JCStatement implements LabeledStatementTree {
1246         public Name label;
1247         public JCStatement body;
1248         protected JCLabeledStatement(Name label, JCStatement body) {
1249             this.label = label;
1250             this.body = body;
1251         }
1252         @Override
1253         public void accept(Visitor v) { v.visitLabelled(this); }
1254         @DefinedBy(Api.COMPILER_TREE)
1255         public Kind getKind() { return Kind.LABELED_STATEMENT; }
1256         @DefinedBy(Api.COMPILER_TREE)
1257         public Name getLabel() { return label; }
1258         @DefinedBy(Api.COMPILER_TREE)
1259         public JCStatement getStatement() { return body; }
1260         @Override @DefinedBy(Api.COMPILER_TREE)
1261         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1262             return v.visitLabeledStatement(this, d);
1263         }
1264         @Override
1265         public Tag getTag() {
1266             return LABELLED;
1267         }
1268     }
1269 
1270     /**
1271      * A "switch ( ) { }" construction.
1272      */
1273     public static class JCSwitch extends JCStatement implements SwitchTree {
1274         public JCExpression selector;
1275         public List<JCCase> cases;
1276         /** Position of closing brace, optional. */
1277         public int endpos = Position.NOPOS;
1278         public boolean hasUnconditionalPattern;
1279         public boolean isExhaustive;
1280         public boolean patternSwitch;
1281         public boolean wasEnumSelector;
1282         protected JCSwitch(JCExpression selector, List<JCCase> cases) {
1283             this.selector = selector;
1284             this.cases = cases;
1285         }
1286         @Override
1287         public void accept(Visitor v) { v.visitSwitch(this); }
1288 
1289         @DefinedBy(Api.COMPILER_TREE)
1290         public Kind getKind() { return Kind.SWITCH; }
1291         @DefinedBy(Api.COMPILER_TREE)
1292         public JCExpression getExpression() { return selector; }
1293         @DefinedBy(Api.COMPILER_TREE)
1294         public List<JCCase> getCases() { return cases; }
1295         @Override @DefinedBy(Api.COMPILER_TREE)
1296         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1297             return v.visitSwitch(this, d);
1298         }
1299         @Override
1300         public Tag getTag() {
1301             return SWITCH;
1302         }
1303     }
1304 
1305     /**
1306      * A "case  :" of a switch.
1307      */
1308     public static class JCCase extends JCStatement implements CaseTree {
1309         //as CaseKind is deprecated for removal (as it is part of a preview feature),
1310         //using indirection through these fields to avoid unnecessary @SuppressWarnings:
1311         public static final CaseKind STATEMENT = CaseKind.STATEMENT;
1312         public static final CaseKind RULE = CaseKind.RULE;
1313         public final CaseKind caseKind;
1314         public List<JCCaseLabel> labels;
1315         public List<JCStatement> stats;
1316         public JCTree body;
1317         public boolean completesNormally;
1318         protected JCCase(CaseKind caseKind, List<JCCaseLabel> labels,
1319                          List<JCStatement> stats, JCTree body) {
1320             Assert.checkNonNull(labels);
1321             Assert.check(labels.isEmpty() || labels.head != null);
1322             this.caseKind = caseKind;
1323             this.labels = labels;
1324             this.stats = stats;
1325             this.body = body;
1326         }
1327         @Override
1328         public void accept(Visitor v) { v.visitCase(this); }
1329 
1330         @Override @DefinedBy(Api.COMPILER_TREE)
1331         public Kind getKind() { return Kind.CASE; }
1332         @Override @Deprecated @DefinedBy(Api.COMPILER_TREE)
1333         public JCExpression getExpression() { return getExpressions().head; }
1334 
1335         @Override @DefinedBy(Api.COMPILER_TREE)
1336         public List<JCExpression> getExpressions() {
1337             return labels.stream()
1338                          .filter(p -> p.hasTag(CONSTANTCASELABEL))
1339                          .map(p -> ((JCConstantCaseLabel) p).expr)
1340                          .collect(List.collector());
1341         }
1342 
1343         @Override @DefinedBy(Api.COMPILER_TREE)
1344         public List<JCCaseLabel> getLabels() { return labels; }
1345         @Override @DefinedBy(Api.COMPILER_TREE)
1346         public List<JCStatement> getStatements() {
1347             return caseKind == CaseKind.STATEMENT ? stats : null;
1348         }
1349         @Override @DefinedBy(Api.COMPILER_TREE)
1350         public JCTree getBody() { return body; }
1351         @Override @DefinedBy(Api.COMPILER_TREE)
1352         public CaseKind getCaseKind() {
1353             return caseKind;
1354         }
1355         @Override @DefinedBy(Api.COMPILER_TREE)
1356         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1357             return v.visitCase(this, d);
1358         }
1359         @Override
1360         public Tag getTag() {
1361             return CASE;
1362         }
1363     }
1364 
1365     /**
1366      * A "switch ( ) { }" construction.
1367      */
1368     public static class JCSwitchExpression extends JCPolyExpression implements SwitchExpressionTree {
1369         public JCExpression selector;
1370         public List<JCCase> cases;
1371         /** Position of closing brace, optional. */
1372         public int endpos = Position.NOPOS;
1373         public boolean hasUnconditionalPattern;
1374         public boolean isExhaustive;
1375         public boolean patternSwitch;
1376         public boolean wasEnumSelector;
1377         protected JCSwitchExpression(JCExpression selector, List<JCCase> cases) {
1378             this.selector = selector;
1379             this.cases = cases;
1380         }
1381         @Override
1382         public void accept(Visitor v) { v.visitSwitchExpression(this); }
1383 
1384         @DefinedBy(Api.COMPILER_TREE)
1385         public Kind getKind() { return Kind.SWITCH_EXPRESSION; }
1386         @DefinedBy(Api.COMPILER_TREE)
1387         public JCExpression getExpression() { return selector; }
1388         @DefinedBy(Api.COMPILER_TREE)
1389         public List<JCCase> getCases() { return cases; }
1390         @Override @DefinedBy(Api.COMPILER_TREE)
1391         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1392             return v.visitSwitchExpression(this, d);
1393         }
1394         @Override
1395         public Tag getTag() {
1396             return SWITCH_EXPRESSION;
1397         }
1398     }
1399 
1400     /**
1401      * A synchronized block.
1402      */
1403     public static class JCSynchronized extends JCStatement implements SynchronizedTree {
1404         public JCExpression lock;
1405         public JCBlock body;
1406         protected JCSynchronized(JCExpression lock, JCBlock body) {
1407             this.lock = lock;
1408             this.body = body;
1409         }
1410         @Override
1411         public void accept(Visitor v) { v.visitSynchronized(this); }
1412 
1413         @DefinedBy(Api.COMPILER_TREE)
1414         public Kind getKind() { return Kind.SYNCHRONIZED; }
1415         @DefinedBy(Api.COMPILER_TREE)
1416         public JCExpression getExpression() { return lock; }
1417         @DefinedBy(Api.COMPILER_TREE)
1418         public JCBlock getBlock() { return body; }
1419         @Override @DefinedBy(Api.COMPILER_TREE)
1420         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1421             return v.visitSynchronized(this, d);
1422         }
1423         @Override
1424         public Tag getTag() {
1425             return SYNCHRONIZED;
1426         }
1427     }
1428 
1429     /**
1430      * A "try { } catch ( ) { } finally { }" block.
1431      */
1432     public static class JCTry extends JCStatement implements TryTree {
1433         public JCBlock body;
1434         public List<JCCatch> catchers;
1435         public JCBlock finalizer;
1436         public List<JCTree> resources;
1437         public boolean finallyCanCompleteNormally;
1438         protected JCTry(List<JCTree> resources,
1439                         JCBlock body,
1440                         List<JCCatch> catchers,
1441                         JCBlock finalizer) {
1442             this.body = body;
1443             this.catchers = catchers;
1444             this.finalizer = finalizer;
1445             this.resources = resources;
1446         }
1447         @Override
1448         public void accept(Visitor v) { v.visitTry(this); }
1449 
1450         @DefinedBy(Api.COMPILER_TREE)
1451         public Kind getKind() { return Kind.TRY; }
1452         @DefinedBy(Api.COMPILER_TREE)
1453         public JCBlock getBlock() { return body; }
1454         @DefinedBy(Api.COMPILER_TREE)
1455         public List<JCCatch> getCatches() {
1456             return catchers;
1457         }
1458         @DefinedBy(Api.COMPILER_TREE)
1459         public JCBlock getFinallyBlock() { return finalizer; }
1460         @Override @DefinedBy(Api.COMPILER_TREE)
1461         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1462             return v.visitTry(this, d);
1463         }
1464         @Override @DefinedBy(Api.COMPILER_TREE)
1465         public List<JCTree> getResources() {
1466             return resources;
1467         }
1468         @Override
1469         public Tag getTag() {
1470             return TRY;
1471         }
1472     }
1473 
1474     /**
1475      * A catch block.
1476      */
1477     public static class JCCatch extends JCTree implements CatchTree {
1478         public JCVariableDecl param;
1479         public JCBlock body;
1480         protected JCCatch(JCVariableDecl param, JCBlock body) {
1481             this.param = param;
1482             this.body = body;
1483         }
1484         @Override
1485         public void accept(Visitor v) { v.visitCatch(this); }
1486 
1487         @DefinedBy(Api.COMPILER_TREE)
1488         public Kind getKind() { return Kind.CATCH; }
1489         @DefinedBy(Api.COMPILER_TREE)
1490         public JCVariableDecl getParameter() { return param; }
1491         @DefinedBy(Api.COMPILER_TREE)
1492         public JCBlock getBlock() { return body; }
1493         @Override @DefinedBy(Api.COMPILER_TREE)
1494         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1495             return v.visitCatch(this, d);
1496         }
1497         @Override
1498         public Tag getTag() {
1499             return CATCH;
1500         }
1501     }
1502 
1503     /**
1504      * A ( ) ? ( ) : ( ) conditional expression
1505      */
1506     public static class JCConditional extends JCPolyExpression implements ConditionalExpressionTree {
1507         public JCExpression cond;
1508         public JCExpression truepart;
1509         public JCExpression falsepart;
1510         protected JCConditional(JCExpression cond,
1511                               JCExpression truepart,
1512                               JCExpression falsepart)
1513         {
1514             this.cond = cond;
1515             this.truepart = truepart;
1516             this.falsepart = falsepart;
1517         }
1518         @Override
1519         public void accept(Visitor v) { v.visitConditional(this); }
1520 
1521         @DefinedBy(Api.COMPILER_TREE)
1522         public Kind getKind() { return Kind.CONDITIONAL_EXPRESSION; }
1523         @DefinedBy(Api.COMPILER_TREE)
1524         public JCExpression getCondition() { return cond; }
1525         @DefinedBy(Api.COMPILER_TREE)
1526         public JCExpression getTrueExpression() { return truepart; }
1527         @DefinedBy(Api.COMPILER_TREE)
1528         public JCExpression getFalseExpression() { return falsepart; }
1529         @Override @DefinedBy(Api.COMPILER_TREE)
1530         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1531             return v.visitConditionalExpression(this, d);
1532         }
1533         @Override
1534         public Tag getTag() {
1535             return CONDEXPR;
1536         }
1537     }
1538 
1539     /**
1540      * An "if ( ) { } else { }" block
1541      */
1542     public static class JCIf extends JCStatement implements IfTree {
1543         public JCExpression cond;
1544         public JCStatement thenpart;
1545         public JCStatement elsepart;
1546         protected JCIf(JCExpression cond,
1547                      JCStatement thenpart,
1548                      JCStatement elsepart)
1549         {
1550             this.cond = cond;
1551             this.thenpart = thenpart;
1552             this.elsepart = elsepart;
1553         }
1554         @Override
1555         public void accept(Visitor v) { v.visitIf(this); }
1556 
1557         @DefinedBy(Api.COMPILER_TREE)
1558         public Kind getKind() { return Kind.IF; }
1559         @DefinedBy(Api.COMPILER_TREE)
1560         public JCExpression getCondition() { return cond; }
1561         @DefinedBy(Api.COMPILER_TREE)
1562         public JCStatement getThenStatement() { return thenpart; }
1563         @DefinedBy(Api.COMPILER_TREE)
1564         public JCStatement getElseStatement() { return elsepart; }
1565         @Override @DefinedBy(Api.COMPILER_TREE)
1566         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1567             return v.visitIf(this, d);
1568         }
1569         @Override
1570         public Tag getTag() {
1571             return IF;
1572         }
1573     }
1574 
1575     /**
1576      * an expression statement
1577      */
1578     public static class JCExpressionStatement extends JCStatement implements ExpressionStatementTree {
1579         /** expression structure */
1580         public JCExpression expr;
1581         protected JCExpressionStatement(JCExpression expr)
1582         {
1583             this.expr = expr;
1584         }
1585         @Override
1586         public void accept(Visitor v) { v.visitExec(this); }
1587 
1588         @DefinedBy(Api.COMPILER_TREE)
1589         public Kind getKind() { return Kind.EXPRESSION_STATEMENT; }
1590         @DefinedBy(Api.COMPILER_TREE)
1591         public JCExpression getExpression() { return expr; }
1592         @Override @DefinedBy(Api.COMPILER_TREE)
1593         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1594             return v.visitExpressionStatement(this, d);
1595         }
1596         @Override
1597         public Tag getTag() {
1598             return EXEC;
1599         }
1600 
1601         /** Convert a expression-statement tree to a pretty-printed string. */
1602         @Override
1603         public String toString() {
1604             StringWriter s = new StringWriter();
1605             try {
1606                 new Pretty(s, false).printStat(this);
1607             }
1608             catch (IOException e) {
1609                 // should never happen, because StringWriter is defined
1610                 // never to throw any IOExceptions
1611                 throw new AssertionError(e);
1612             }
1613             return s.toString();
1614         }
1615     }
1616 
1617     /**
1618      * A break from a loop or switch.
1619      */
1620     public static class JCBreak extends JCStatement implements BreakTree {
1621         public Name label;
1622         public JCTree target;
1623         protected JCBreak(Name label, JCTree target) {
1624             this.label = label;
1625             this.target = target;
1626         }
1627         @Override
1628         public void accept(Visitor v) { v.visitBreak(this); }
1629         public boolean isValueBreak() {
1630             return target != null && target.hasTag(SWITCH_EXPRESSION);
1631         }
1632 
1633         @DefinedBy(Api.COMPILER_TREE)
1634         public Kind getKind() { return Kind.BREAK; }
1635         @DefinedBy(Api.COMPILER_TREE)
1636         public Name getLabel() {
1637             return label;
1638         }
1639         @Override @DefinedBy(Api.COMPILER_TREE)
1640         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1641             return v.visitBreak(this, d);
1642         }
1643         @Override
1644         public Tag getTag() {
1645             return BREAK;
1646         }
1647     }
1648 
1649     /**
1650      * A break-with from a switch expression.
1651      */
1652     public static class JCYield extends JCStatement implements YieldTree {
1653         public JCExpression value;
1654         public JCTree target;
1655         protected JCYield(JCExpression value, JCTree target) {
1656             this.value = value;
1657             this.target = target;
1658         }
1659         @Override
1660         public void accept(Visitor v) { v.visitYield(this); }
1661         @DefinedBy(Api.COMPILER_TREE)
1662         public Kind getKind() { return Kind.YIELD; }
1663         @DefinedBy(Api.COMPILER_TREE)
1664         public JCExpression getValue() { return value; }
1665         @Override @DefinedBy(Api.COMPILER_TREE)
1666         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1667             return v.visitYield(this, d);
1668         }
1669         @Override
1670         public Tag getTag() {
1671             return YIELD;
1672         }
1673     }
1674 
1675     /**
1676      * A continue of a loop.
1677      */
1678     public static class JCContinue extends JCStatement implements ContinueTree {
1679         public Name label;
1680         public JCTree target;
1681         protected JCContinue(Name label, JCTree target) {
1682             this.label = label;
1683             this.target = target;
1684         }
1685         @Override
1686         public void accept(Visitor v) { v.visitContinue(this); }
1687 
1688         @DefinedBy(Api.COMPILER_TREE)
1689         public Kind getKind() { return Kind.CONTINUE; }
1690         @DefinedBy(Api.COMPILER_TREE)
1691         public Name getLabel() { return label; }
1692         @Override @DefinedBy(Api.COMPILER_TREE)
1693         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1694             return v.visitContinue(this, d);
1695         }
1696         @Override
1697         public Tag getTag() {
1698             return CONTINUE;
1699         }
1700     }
1701 
1702     /**
1703      * A return statement.
1704      */
1705     public static class JCReturn extends JCStatement implements ReturnTree {
1706         public JCExpression expr;
1707         protected JCReturn(JCExpression expr) {
1708             this.expr = expr;
1709         }
1710         @Override
1711         public void accept(Visitor v) { v.visitReturn(this); }
1712 
1713         @DefinedBy(Api.COMPILER_TREE)
1714         public Kind getKind() { return Kind.RETURN; }
1715         @DefinedBy(Api.COMPILER_TREE)
1716         public JCExpression getExpression() { return expr; }
1717         @Override @DefinedBy(Api.COMPILER_TREE)
1718         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1719             return v.visitReturn(this, d);
1720         }
1721         @Override
1722         public Tag getTag() {
1723             return RETURN;
1724         }
1725     }
1726 
1727     /**
1728      * A throw statement.
1729      */
1730     public static class JCThrow extends JCStatement implements ThrowTree {
1731         public JCExpression expr;
1732         protected JCThrow(JCExpression expr) {
1733             this.expr = expr;
1734         }
1735         @Override
1736         public void accept(Visitor v) { v.visitThrow(this); }
1737 
1738         @DefinedBy(Api.COMPILER_TREE)
1739         public Kind getKind() { return Kind.THROW; }
1740         @DefinedBy(Api.COMPILER_TREE)
1741         public JCExpression getExpression() { return expr; }
1742         @Override @DefinedBy(Api.COMPILER_TREE)
1743         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1744             return v.visitThrow(this, d);
1745         }
1746         @Override
1747         public Tag getTag() {
1748             return THROW;
1749         }
1750     }
1751 
1752     /**
1753      * An assert statement.
1754      */
1755     public static class JCAssert extends JCStatement implements AssertTree {
1756         public JCExpression cond;
1757         public JCExpression detail;
1758         protected JCAssert(JCExpression cond, JCExpression detail) {
1759             this.cond = cond;
1760             this.detail = detail;
1761         }
1762         @Override
1763         public void accept(Visitor v) { v.visitAssert(this); }
1764 
1765         @DefinedBy(Api.COMPILER_TREE)
1766         public Kind getKind() { return Kind.ASSERT; }
1767         @DefinedBy(Api.COMPILER_TREE)
1768         public JCExpression getCondition() { return cond; }
1769         @DefinedBy(Api.COMPILER_TREE)
1770         public JCExpression getDetail() { return detail; }
1771         @Override @DefinedBy(Api.COMPILER_TREE)
1772         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1773             return v.visitAssert(this, d);
1774         }
1775         @Override
1776         public Tag getTag() {
1777             return ASSERT;
1778         }
1779     }
1780 
1781     /**
1782      * A method invocation
1783      */
1784     public static class JCMethodInvocation extends JCPolyExpression implements MethodInvocationTree {
1785         public List<JCExpression> typeargs;
1786         public JCExpression meth;
1787         public List<JCExpression> args;
1788         public Type varargsElement;
1789         protected JCMethodInvocation(List<JCExpression> typeargs,
1790                         JCExpression meth,
1791                         List<JCExpression> args)
1792         {
1793             this.typeargs = (typeargs == null) ? List.nil()
1794                                                : typeargs;
1795             this.meth = meth;
1796             this.args = args;
1797         }
1798         @Override
1799         public void accept(Visitor v) { v.visitApply(this); }
1800 
1801         @DefinedBy(Api.COMPILER_TREE)
1802         public Kind getKind() { return Kind.METHOD_INVOCATION; }
1803         @DefinedBy(Api.COMPILER_TREE)
1804         public List<JCExpression> getTypeArguments() {
1805             return typeargs;
1806         }
1807         @DefinedBy(Api.COMPILER_TREE)
1808         public JCExpression getMethodSelect() { return meth; }
1809         @DefinedBy(Api.COMPILER_TREE)
1810         public List<JCExpression> getArguments() {
1811             return args;
1812         }
1813         @Override @DefinedBy(Api.COMPILER_TREE)
1814         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1815             return v.visitMethodInvocation(this, d);
1816         }
1817         @Override
1818         public JCMethodInvocation setType(Type type) {
1819             super.setType(type);
1820             return this;
1821         }
1822         @Override
1823         public Tag getTag() {
1824             return(APPLY);
1825         }
1826     }
1827 
1828     /**
1829      * A new(...) operation.
1830      */
1831     public static class JCNewClass extends JCPolyExpression implements NewClassTree {
1832         public JCExpression encl;
1833         public List<JCExpression> typeargs;
1834         public JCExpression clazz;
1835         public List<JCExpression> args;
1836         public JCClassDecl def;
1837         public Symbol constructor;
1838         public Type varargsElement;
1839         public Type constructorType;
1840         protected JCNewClass(JCExpression encl,
1841                            List<JCExpression> typeargs,
1842                            JCExpression clazz,
1843                            List<JCExpression> args,
1844                            JCClassDecl def)
1845         {
1846             this.encl = encl;
1847             this.typeargs = (typeargs == null) ? List.nil()
1848                                                : typeargs;
1849             this.clazz = clazz;
1850             this.args = args;
1851             this.def = def;
1852         }
1853         @Override
1854         public void accept(Visitor v) { v.visitNewClass(this); }
1855 
1856         @DefinedBy(Api.COMPILER_TREE)
1857         public Kind getKind() { return Kind.NEW_CLASS; }
1858         @DefinedBy(Api.COMPILER_TREE)
1859         public JCExpression getEnclosingExpression() { // expr.new C< ... > ( ... )
1860             return encl;
1861         }
1862         @DefinedBy(Api.COMPILER_TREE)
1863         public List<JCExpression> getTypeArguments() {
1864             return typeargs;
1865         }
1866         @DefinedBy(Api.COMPILER_TREE)
1867         public JCExpression getIdentifier() { return clazz; }
1868         @DefinedBy(Api.COMPILER_TREE)
1869         public List<JCExpression> getArguments() {
1870             return args;
1871         }
1872         @DefinedBy(Api.COMPILER_TREE)
1873         public JCClassDecl getClassBody() { return def; }
1874         @Override @DefinedBy(Api.COMPILER_TREE)
1875         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1876             return v.visitNewClass(this, d);
1877         }
1878         @Override
1879         public Tag getTag() {
1880             return NEWCLASS;
1881         }
1882 
1883         public boolean classDeclRemoved() {
1884             return false;
1885         }
1886     }
1887 
1888     /**
1889      * A new[...] operation.
1890      */
1891     public static class JCNewArray extends JCExpression implements NewArrayTree {
1892         public JCExpression elemtype;
1893         public List<JCExpression> dims;
1894         // type annotations on inner-most component
1895         public List<JCAnnotation> annotations;
1896         // type annotations on dimensions
1897         public List<List<JCAnnotation>> dimAnnotations;
1898         public List<JCExpression> elems;
1899         protected JCNewArray(JCExpression elemtype,
1900                            List<JCExpression> dims,
1901                            List<JCExpression> elems)
1902         {
1903             this.elemtype = elemtype;
1904             this.dims = dims;
1905             this.annotations = List.nil();
1906             this.dimAnnotations = List.nil();
1907             this.elems = elems;
1908         }
1909         @Override
1910         public void accept(Visitor v) { v.visitNewArray(this); }
1911 
1912         @DefinedBy(Api.COMPILER_TREE)
1913         public Kind getKind() { return Kind.NEW_ARRAY; }
1914         @DefinedBy(Api.COMPILER_TREE)
1915         public JCExpression getType() { return elemtype; }
1916         @DefinedBy(Api.COMPILER_TREE)
1917         public List<JCExpression> getDimensions() {
1918             return dims;
1919         }
1920         @DefinedBy(Api.COMPILER_TREE)
1921         public List<JCExpression> getInitializers() {
1922             return elems;
1923         }
1924         @Override @DefinedBy(Api.COMPILER_TREE)
1925         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1926             return v.visitNewArray(this, d);
1927         }
1928         @Override
1929         public Tag getTag() {
1930             return NEWARRAY;
1931         }
1932 
1933         @Override @DefinedBy(Api.COMPILER_TREE)
1934         public List<JCAnnotation> getAnnotations() {
1935             return annotations;
1936         }
1937 
1938         @Override @DefinedBy(Api.COMPILER_TREE)
1939         public List<List<JCAnnotation>> getDimAnnotations() {
1940             return dimAnnotations;
1941         }
1942     }
1943 
1944     /**
1945      * A lambda expression.
1946      */
1947     public static class JCLambda extends JCFunctionalExpression implements LambdaExpressionTree {
1948 
1949         public enum ParameterKind {
1950             IMPLICIT,
1951             EXPLICIT
1952         }
1953 
1954         public List<JCVariableDecl> params;
1955         public JCTree body;
1956         public boolean canCompleteNormally = true;
1957         public ParameterKind paramKind;
1958 
1959         public JCLambda(List<JCVariableDecl> params,
1960                         JCTree body) {
1961             this.params = params;
1962             this.body = body;
1963             if (params.isEmpty() ||
1964                 params.head.vartype != null) {
1965                 paramKind = ParameterKind.EXPLICIT;
1966             } else {
1967                 paramKind = ParameterKind.IMPLICIT;
1968             }
1969         }
1970         @Override
1971         public Tag getTag() {
1972             return LAMBDA;
1973         }
1974         @Override
1975         public void accept(Visitor v) {
1976             v.visitLambda(this);
1977         }
1978         @Override @DefinedBy(Api.COMPILER_TREE)
1979         public <R, D> R accept(TreeVisitor<R, D> v, D d) {
1980             return v.visitLambdaExpression(this, d);
1981         }
1982         @DefinedBy(Api.COMPILER_TREE)
1983         public Kind getKind() {
1984             return Kind.LAMBDA_EXPRESSION;
1985         }
1986         @DefinedBy(Api.COMPILER_TREE)
1987         public JCTree getBody() {
1988             return body;
1989         }
1990         @DefinedBy(Api.COMPILER_TREE)
1991         public java.util.List<? extends VariableTree> getParameters() {
1992             return params;
1993         }
1994         @Override
1995         public JCLambda setType(Type type) {
1996             super.setType(type);
1997             return this;
1998         }
1999         @Override @DefinedBy(Api.COMPILER_TREE)
2000         public BodyKind getBodyKind() {
2001             return body.hasTag(BLOCK) ?
2002                     BodyKind.STATEMENT :
2003                     BodyKind.EXPRESSION;
2004         }
2005     }
2006 
2007     /**
2008      * A parenthesized subexpression ( ... )
2009      */
2010     public static class JCParens extends JCExpression implements ParenthesizedTree {
2011         public JCExpression expr;
2012         protected JCParens(JCExpression expr) {
2013             this.expr = expr;
2014         }
2015         @Override
2016         public void accept(Visitor v) { v.visitParens(this); }
2017 
2018         @DefinedBy(Api.COMPILER_TREE)
2019         public Kind getKind() { return Kind.PARENTHESIZED; }
2020         @DefinedBy(Api.COMPILER_TREE)
2021         public JCExpression getExpression() { return expr; }
2022         @Override @DefinedBy(Api.COMPILER_TREE)
2023         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2024             return v.visitParenthesized(this, d);
2025         }
2026         @Override
2027         public Tag getTag() {
2028             return PARENS;
2029         }
2030     }
2031 
2032     /**
2033      * A assignment with "=".
2034      */
2035     public static class JCAssign extends JCExpression implements AssignmentTree {
2036         public JCExpression lhs;
2037         public JCExpression rhs;
2038         protected JCAssign(JCExpression lhs, JCExpression rhs) {
2039             this.lhs = lhs;
2040             this.rhs = rhs;
2041         }
2042         @Override
2043         public void accept(Visitor v) { v.visitAssign(this); }
2044 
2045         @DefinedBy(Api.COMPILER_TREE)
2046         public Kind getKind() { return Kind.ASSIGNMENT; }
2047         @DefinedBy(Api.COMPILER_TREE)
2048         public JCExpression getVariable() { return lhs; }
2049         @DefinedBy(Api.COMPILER_TREE)
2050         public JCExpression getExpression() { return rhs; }
2051         @Override @DefinedBy(Api.COMPILER_TREE)
2052         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2053             return v.visitAssignment(this, d);
2054         }
2055         @Override
2056         public Tag getTag() {
2057             return ASSIGN;
2058         }
2059     }
2060 
2061     public abstract static class JCOperatorExpression extends JCExpression {
2062         public enum OperandPos {
2063             LEFT,
2064             RIGHT
2065         }
2066 
2067         protected Tag opcode;
2068         public OperatorSymbol operator;
2069 
2070         public OperatorSymbol getOperator() {
2071             return operator;
2072         }
2073 
2074         @Override
2075         public Tag getTag() {
2076             return opcode;
2077         }
2078 
2079         public abstract JCExpression getOperand(OperandPos pos);
2080     }
2081 
2082     /**
2083      * An assignment with "+=", "|=" ...
2084      */
2085     public static class JCAssignOp extends JCOperatorExpression implements CompoundAssignmentTree {
2086         public JCExpression lhs;
2087         public JCExpression rhs;
2088         protected JCAssignOp(Tag opcode, JCTree lhs, JCTree rhs, OperatorSymbol operator) {
2089             this.opcode = opcode;
2090             this.lhs = (JCExpression)lhs;
2091             this.rhs = (JCExpression)rhs;
2092             this.operator = operator;
2093         }
2094         @Override
2095         public void accept(Visitor v) { v.visitAssignop(this); }
2096 
2097         @DefinedBy(Api.COMPILER_TREE)
2098         public Kind getKind() { return TreeInfo.tagToKind(getTag()); }
2099         @DefinedBy(Api.COMPILER_TREE)
2100         public JCExpression getVariable() { return lhs; }
2101         @DefinedBy(Api.COMPILER_TREE)
2102         public JCExpression getExpression() { return rhs; }
2103         @Override @DefinedBy(Api.COMPILER_TREE)
2104         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2105             return v.visitCompoundAssignment(this, d);
2106         }
2107         @Override
2108         public JCExpression getOperand(OperandPos pos) {
2109             return pos == OperandPos.LEFT ? lhs : rhs;
2110         }
2111     }
2112 
2113     /**
2114      * A unary operation.
2115      */
2116     public static class JCUnary extends JCOperatorExpression implements UnaryTree {
2117         public JCExpression arg;
2118         protected JCUnary(Tag opcode, JCExpression arg) {
2119             this.opcode = opcode;
2120             this.arg = arg;
2121         }
2122         @Override
2123         public void accept(Visitor v) { v.visitUnary(this); }
2124 
2125         @DefinedBy(Api.COMPILER_TREE)
2126         public Kind getKind() { return TreeInfo.tagToKind(getTag()); }
2127         @DefinedBy(Api.COMPILER_TREE)
2128         public JCExpression getExpression() { return arg; }
2129         @Override @DefinedBy(Api.COMPILER_TREE)
2130         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2131             return v.visitUnary(this, d);
2132         }
2133         public void setTag(Tag tag) {
2134             opcode = tag;
2135         }
2136         @Override
2137         public JCExpression getOperand(OperandPos pos) {
2138             return arg;
2139         }
2140     }
2141 
2142     /**
2143      * A binary operation.
2144      */
2145     public static class JCBinary extends JCOperatorExpression implements BinaryTree {
2146         public JCExpression lhs;
2147         public JCExpression rhs;
2148         protected JCBinary(Tag opcode,
2149                          JCExpression lhs,
2150                          JCExpression rhs,
2151                          OperatorSymbol operator) {
2152             this.opcode = opcode;
2153             this.lhs = lhs;
2154             this.rhs = rhs;
2155             this.operator = operator;
2156         }
2157         @Override
2158         public void accept(Visitor v) { v.visitBinary(this); }
2159 
2160         @DefinedBy(Api.COMPILER_TREE)
2161         public Kind getKind() { return TreeInfo.tagToKind(getTag()); }
2162         @DefinedBy(Api.COMPILER_TREE)
2163         public JCExpression getLeftOperand() { return lhs; }
2164         @DefinedBy(Api.COMPILER_TREE)
2165         public JCExpression getRightOperand() { return rhs; }
2166         @Override @DefinedBy(Api.COMPILER_TREE)
2167         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2168             return v.visitBinary(this, d);
2169         }
2170         @Override
2171         public JCExpression getOperand(OperandPos pos) {
2172             return pos == OperandPos.LEFT ? lhs : rhs;
2173         }
2174     }
2175 
2176     /**
2177      * A type cast.
2178      */
2179     public static class JCTypeCast extends JCExpression implements TypeCastTree {
2180         public JCTree clazz;
2181         public JCExpression expr;
2182         protected JCTypeCast(JCTree clazz, JCExpression expr) {
2183             this.clazz = clazz;
2184             this.expr = expr;
2185         }
2186         @Override
2187         public void accept(Visitor v) { v.visitTypeCast(this); }
2188 
2189         @DefinedBy(Api.COMPILER_TREE)
2190         public Kind getKind() { return Kind.TYPE_CAST; }
2191         @DefinedBy(Api.COMPILER_TREE)
2192         public JCTree getType() { return clazz; }
2193         @DefinedBy(Api.COMPILER_TREE)
2194         public JCExpression getExpression() { return expr; }
2195         @Override @DefinedBy(Api.COMPILER_TREE)
2196         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2197             return v.visitTypeCast(this, d);
2198         }
2199         @Override
2200         public Tag getTag() {
2201             return TYPECAST;
2202         }
2203     }
2204 
2205     /**
2206      * A type test.
2207      */
2208     public static class JCInstanceOf extends JCExpression implements InstanceOfTree {
2209         public JCExpression expr;
2210         public JCTree pattern;
2211         protected JCInstanceOf(JCExpression expr, JCTree pattern) {
2212             this.expr = expr;
2213             this.pattern = pattern;
2214         }
2215         @Override
2216         public void accept(Visitor v) { v.visitTypeTest(this); }
2217 
2218         @DefinedBy(Api.COMPILER_TREE)
2219         public Kind getKind() { return Kind.INSTANCE_OF; }
2220         @DefinedBy(Api.COMPILER_TREE)
2221         public JCTree getType() { return pattern instanceof JCPattern ? pattern.hasTag(BINDINGPATTERN) ? ((JCBindingPattern) pattern).var.vartype : null : pattern; }
2222 
2223         @Override @DefinedBy(Api.COMPILER_TREE)
2224         public JCPattern getPattern() {
2225             return pattern instanceof JCPattern jcPattern ? jcPattern : null;
2226         }
2227 
2228         @DefinedBy(Api.COMPILER_TREE)
2229         public JCExpression getExpression() { return expr; }
2230         @Override @DefinedBy(Api.COMPILER_TREE)
2231         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2232             return v.visitInstanceOf(this, d);
2233         }
2234         @Override
2235         public Tag getTag() {
2236             return TYPETEST;
2237         }
2238     }
2239 
2240     /**
2241      * Pattern matching forms.
2242      */
2243     public abstract static class JCPattern extends JCTree
2244             implements PatternTree {
2245     }
2246 
2247     public static class JCBindingPattern extends JCPattern
2248             implements BindingPatternTree {
2249         public JCVariableDecl var;
2250 
2251         protected JCBindingPattern(JCVariableDecl var) {
2252             this.var = var;
2253         }
2254 
2255         @Override @DefinedBy(Api.COMPILER_TREE)
2256         public VariableTree getVariable() {
2257             return var;
2258         }
2259 
2260         @Override
2261         public void accept(Visitor v) {
2262             v.visitBindingPattern(this);
2263         }
2264 
2265         @DefinedBy(Api.COMPILER_TREE)
2266         public Kind getKind() {
2267             return Kind.BINDING_PATTERN;
2268         }
2269 
2270         @Override
2271         @DefinedBy(Api.COMPILER_TREE)
2272         public <R, D> R accept(TreeVisitor<R, D> v, D d) {
2273             return v.visitBindingPattern(this, d);
2274         }
2275 
2276         @Override
2277         public Tag getTag() {
2278             return BINDINGPATTERN;
2279         }
2280     }
2281 
2282     public static class JCDefaultCaseLabel extends JCCaseLabel
2283             implements DefaultCaseLabelTree {
2284 
2285         protected JCDefaultCaseLabel() {
2286         }
2287 
2288         @Override
2289         public void accept(Visitor v) {
2290             v.visitDefaultCaseLabel(this);
2291         }
2292 
2293         @DefinedBy(Api.COMPILER_TREE)
2294         public Kind getKind() {
2295             return Kind.DEFAULT_CASE_LABEL;
2296         }
2297 
2298         @Override
2299         @DefinedBy(Api.COMPILER_TREE)
2300         public <R, D> R accept(TreeVisitor<R, D> v, D d) {
2301             return v.visitDefaultCaseLabel(this, d);
2302         }
2303 
2304         @Override
2305         public Tag getTag() {
2306             return DEFAULTCASELABEL;
2307         }
2308 
2309     }
2310 
2311     public static class JCConstantCaseLabel extends JCCaseLabel
2312             implements ConstantCaseLabelTree {
2313 
2314         public JCExpression expr;
2315 
2316         protected JCConstantCaseLabel(JCExpression expr) {
2317             this.expr = expr;
2318         }
2319 
2320         @Override @DefinedBy(Api.COMPILER_TREE)
2321         public JCExpression getConstantExpression() {
2322             return expr;
2323         }
2324 
2325         @Override
2326         public void accept(Visitor v) {
2327             v.visitConstantCaseLabel(this);
2328         }
2329 
2330         @DefinedBy(Api.COMPILER_TREE)
2331         public Kind getKind() {
2332             return Kind.CONSTANT_CASE_LABEL;
2333         }
2334 
2335         @Override
2336         @DefinedBy(Api.COMPILER_TREE)
2337         public <R, D> R accept(TreeVisitor<R, D> v, D d) {
2338             return v.visitConstantCaseLabel(this, d);
2339         }
2340 
2341         @Override
2342         public Tag getTag() {
2343             return CONSTANTCASELABEL;
2344         }
2345 
2346     }
2347 
2348     public static class JCPatternCaseLabel extends JCCaseLabel
2349             implements PatternCaseLabelTree {
2350 
2351         public JCPattern pat;
2352         public JCExpression guard;
2353 
2354         protected JCPatternCaseLabel(JCPattern pat, JCExpression guard) {
2355             this.pat = pat;
2356             this.guard = guard;
2357         }
2358 
2359         @Override @DefinedBy(Api.COMPILER_TREE)
2360         public JCPattern getPattern() {
2361             return pat;
2362         }
2363 
2364         @Override @DefinedBy(Api.COMPILER_TREE)
2365         public JCExpression getGuard() {
2366             return guard;
2367         }
2368 
2369         @Override
2370         public void accept(Visitor v) {
2371             v.visitPatternCaseLabel(this);
2372         }
2373 
2374         @DefinedBy(Api.COMPILER_TREE)
2375         public Kind getKind() {
2376             return Kind.PATTERN_CASE_LABEL;
2377         }
2378 
2379         @Override
2380         @DefinedBy(Api.COMPILER_TREE)
2381         public <R, D> R accept(TreeVisitor<R, D> v, D d) {
2382             return v.visitPatternCaseLabel(this, d);
2383         }
2384 
2385         @Override
2386         public Tag getTag() {
2387             return PATTERNCASELABEL;
2388         }
2389 
2390     }
2391 
2392     public static class JCParenthesizedPattern extends JCPattern
2393             implements ParenthesizedPatternTree {
2394         public JCPattern pattern;
2395 
2396         public JCParenthesizedPattern(JCPattern pattern) {
2397             this.pattern = pattern;
2398         }
2399 
2400         @Override @DefinedBy(Api.COMPILER_TREE)
2401         public PatternTree getPattern() {
2402             return pattern;
2403         }
2404 
2405         @Override
2406         public void accept(Visitor v) {
2407             v.visitParenthesizedPattern(this);
2408         }
2409 
2410         @DefinedBy(Api.COMPILER_TREE)
2411         public Kind getKind() {
2412             return Kind.PARENTHESIZED_PATTERN;
2413         }
2414 
2415         @Override
2416         @DefinedBy(Api.COMPILER_TREE)
2417         public <R, D> R accept(TreeVisitor<R, D> v, D d) {
2418             return v.visitParenthesizedPattern(this, d);
2419         }
2420 
2421         @Override
2422         public Tag getTag() {
2423             return PARENTHESIZEDPATTERN;
2424         }
2425     }
2426 
2427     public static class JCRecordPattern extends JCPattern
2428             implements DeconstructionPatternTree {
2429         public JCExpression deconstructor;
2430         public List<JCPattern> nested;
2431         public JCVariableDecl var;
2432         public ClassSymbol record;
2433         public List<Type> fullComponentTypes;
2434 
2435         protected JCRecordPattern(JCExpression deconstructor, List<JCPattern> nested,
2436                                   JCVariableDecl var) {
2437             this.deconstructor = deconstructor;
2438             this.nested = nested;
2439             this.var = var;
2440         }
2441 
2442         @DefinedBy(Api.COMPILER_TREE)
2443         public Name getBinding() {
2444             return null;
2445         }
2446 
2447         @Override @DefinedBy(Api.COMPILER_TREE)
2448         public ExpressionTree getDeconstructor() {
2449             return deconstructor;
2450         }
2451 
2452         @Override @DefinedBy(Api.COMPILER_TREE)
2453         public List<? extends JCPattern> getNestedPatterns() {
2454             return nested;
2455         }
2456 
2457         @Override
2458         public void accept(Visitor v) {
2459             v.visitRecordPattern(this);
2460         }
2461 
2462         @DefinedBy(Api.COMPILER_TREE)
2463         public Kind getKind() {
2464             return Kind.DECONSTRUCTION_PATTERN;
2465         }
2466 
2467         @Override
2468         @DefinedBy(Api.COMPILER_TREE)
2469         public <R, D> R accept(TreeVisitor<R, D> v, D d) {
2470             return v.visitDeconstructionPattern(this, d);
2471         }
2472 
2473         @Override
2474         public Tag getTag() {
2475             return RECORDPATTERN;
2476         }
2477 
2478         @Override @DefinedBy(Api.COMPILER_TREE)
2479         public VariableTree getVariable() {
2480             return var;
2481         }
2482 
2483     }
2484 
2485     /**
2486      * An array selection
2487      */
2488     public static class JCArrayAccess extends JCExpression implements ArrayAccessTree {
2489         public JCExpression indexed;
2490         public JCExpression index;
2491         protected JCArrayAccess(JCExpression indexed, JCExpression index) {
2492             this.indexed = indexed;
2493             this.index = index;
2494         }
2495         @Override
2496         public void accept(Visitor v) { v.visitIndexed(this); }
2497 
2498         @DefinedBy(Api.COMPILER_TREE)
2499         public Kind getKind() { return Kind.ARRAY_ACCESS; }
2500         @DefinedBy(Api.COMPILER_TREE)
2501         public JCExpression getExpression() { return indexed; }
2502         @DefinedBy(Api.COMPILER_TREE)
2503         public JCExpression getIndex() { return index; }
2504         @Override @DefinedBy(Api.COMPILER_TREE)
2505         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2506             return v.visitArrayAccess(this, d);
2507         }
2508         @Override
2509         public Tag getTag() {
2510             return INDEXED;
2511         }
2512     }
2513 
2514     /**
2515      * Selects through packages and classes
2516      */
2517     public static class JCFieldAccess extends JCExpression implements MemberSelectTree {
2518         /** selected Tree hierarchy */
2519         public JCExpression selected;
2520         /** name of field to select thru */
2521         public Name name;
2522         /** symbol of the selected class */
2523         public Symbol sym;
2524         protected JCFieldAccess(JCExpression selected, Name name, Symbol sym) {
2525             this.selected = selected;
2526             this.name = name;
2527             this.sym = sym;
2528         }
2529         @Override
2530         public void accept(Visitor v) { v.visitSelect(this); }
2531 
2532         @DefinedBy(Api.COMPILER_TREE)
2533         public Kind getKind() { return Kind.MEMBER_SELECT; }
2534         @DefinedBy(Api.COMPILER_TREE)
2535         public JCExpression getExpression() { return selected; }
2536         @Override @DefinedBy(Api.COMPILER_TREE)
2537         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2538             return v.visitMemberSelect(this, d);
2539         }
2540         @DefinedBy(Api.COMPILER_TREE)
2541         public Name getIdentifier() { return name; }
2542         @Override
2543         public Tag getTag() {
2544             return SELECT;
2545         }
2546     }
2547 
2548     /**
2549      * Selects a member expression.
2550      */
2551     public static class JCMemberReference extends JCFunctionalExpression implements MemberReferenceTree {
2552 
2553         public ReferenceMode mode;
2554         public ReferenceKind kind;
2555         public Name name;
2556         public JCExpression expr;
2557         public List<JCExpression> typeargs;
2558         public Symbol sym;
2559         public Type varargsElement;
2560         public PolyKind refPolyKind;
2561         public boolean ownerAccessible;
2562         private OverloadKind overloadKind;
2563         public Type referentType;
2564 
2565         public enum OverloadKind {
2566             OVERLOADED,
2567             UNOVERLOADED,
2568             ERROR
2569         }
2570 
2571         /**
2572          * Javac-dependent classification for member references, based
2573          * on relevant properties w.r.t. code-generation
2574          */
2575         public enum ReferenceKind {
2576             /** super # instMethod */
2577             SUPER(ReferenceMode.INVOKE, false),
2578             /** Type # instMethod */
2579             UNBOUND(ReferenceMode.INVOKE, true),
2580             /** Type # staticMethod */
2581             STATIC(ReferenceMode.INVOKE, false),
2582             /** Expr # instMethod */
2583             BOUND(ReferenceMode.INVOKE, false),
2584             /** Inner # new */
2585             IMPLICIT_INNER(ReferenceMode.NEW, false),
2586             /** Toplevel # new */
2587             TOPLEVEL(ReferenceMode.NEW, false),
2588             /** ArrayType # new */
2589             ARRAY_CTOR(ReferenceMode.NEW, false);
2590 
2591             final ReferenceMode mode;
2592             final boolean unbound;
2593 
2594             private ReferenceKind(ReferenceMode mode, boolean unbound) {
2595                 this.mode = mode;
2596                 this.unbound = unbound;
2597             }
2598 
2599             public boolean isUnbound() {
2600                 return unbound;
2601             }
2602         }
2603 
2604         public JCMemberReference(ReferenceMode mode, Name name, JCExpression expr, List<JCExpression> typeargs) {
2605             this.mode = mode;
2606             this.name = name;
2607             this.expr = expr;
2608             this.typeargs = typeargs;
2609         }
2610         @Override
2611         public void accept(Visitor v) { v.visitReference(this); }
2612 
2613         @DefinedBy(Api.COMPILER_TREE)
2614         public Kind getKind() { return Kind.MEMBER_REFERENCE; }
2615         @Override @DefinedBy(Api.COMPILER_TREE)
2616         public ReferenceMode getMode() { return mode; }
2617         @Override @DefinedBy(Api.COMPILER_TREE)
2618         public JCExpression getQualifierExpression() { return expr; }
2619         @Override @DefinedBy(Api.COMPILER_TREE)
2620         public Name getName() { return name; }
2621         @Override @DefinedBy(Api.COMPILER_TREE)
2622         public List<JCExpression> getTypeArguments() { return typeargs; }
2623 
2624         @Override @DefinedBy(Api.COMPILER_TREE)
2625         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2626             return v.visitMemberReference(this, d);
2627         }
2628         @Override
2629         public Tag getTag() {
2630             return REFERENCE;
2631         }
2632         public boolean hasKind(ReferenceKind kind) {
2633             return this.kind == kind;
2634         }
2635 
2636         /**
2637          * @return the overloadKind
2638          */
2639         public OverloadKind getOverloadKind() {
2640             return overloadKind;
2641         }
2642 
2643         /**
2644          * @param overloadKind the overloadKind to set
2645          */
2646         public void setOverloadKind(OverloadKind overloadKind) {
2647             this.overloadKind = overloadKind;
2648         }
2649     }
2650 
2651     /**
2652      * An identifier
2653      */
2654     public static class JCIdent extends JCExpression implements IdentifierTree {
2655         /** the name */
2656         public Name name;
2657         /** the symbol */
2658         public Symbol sym;
2659         protected JCIdent(Name name, Symbol sym) {
2660             this.name = name;
2661             this.sym = sym;
2662         }
2663         @Override
2664         public void accept(Visitor v) { v.visitIdent(this); }
2665 
2666         @DefinedBy(Api.COMPILER_TREE)
2667         public Kind getKind() { return Kind.IDENTIFIER; }
2668         @DefinedBy(Api.COMPILER_TREE)
2669         public Name getName() { return name; }
2670         @Override @DefinedBy(Api.COMPILER_TREE)
2671         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2672             return v.visitIdentifier(this, d);
2673         }
2674         @Override
2675         public Tag getTag() {
2676             return IDENT;
2677         }
2678     }
2679 
2680     /**
2681      * A constant value given literally.
2682      */
2683     public static class JCLiteral extends JCExpression implements LiteralTree {
2684         public TypeTag typetag;
2685         /** value representation */
2686         public Object value;
2687         protected JCLiteral(TypeTag typetag, Object value) {
2688             this.typetag = typetag;
2689             this.value = value;
2690         }
2691         @Override
2692         public void accept(Visitor v) { v.visitLiteral(this); }
2693 
2694         @DefinedBy(Api.COMPILER_TREE)
2695         public Kind getKind() {
2696             return typetag.getKindLiteral();
2697         }
2698 
2699         @DefinedBy(Api.COMPILER_TREE)
2700         public Object getValue() {
2701             switch (typetag) {
2702                 case BOOLEAN:
2703                     int bi = (Integer) value;
2704                     return (bi != 0);
2705                 case CHAR:
2706                     int ci = (Integer) value;
2707                     char c = (char) ci;
2708                     if (c != ci)
2709                         throw new AssertionError("bad value for char literal");
2710                     return c;
2711                 default:
2712                     return value;
2713             }
2714         }
2715         @Override @DefinedBy(Api.COMPILER_TREE)
2716         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2717             return v.visitLiteral(this, d);
2718         }
2719         @Override
2720         public JCLiteral setType(Type type) {
2721             super.setType(type);
2722             return this;
2723         }
2724         @Override
2725         public Tag getTag() {
2726             return LITERAL;
2727         }
2728     }
2729 
2730     /**
2731      * Identifies a basic type.
2732      * @see TypeTag
2733      */
2734     public static class JCPrimitiveTypeTree extends JCExpression implements PrimitiveTypeTree {
2735         /** the basic type id */
2736         public TypeTag typetag;
2737         protected JCPrimitiveTypeTree(TypeTag typetag) {
2738             this.typetag = typetag;
2739         }
2740         @Override
2741         public void accept(Visitor v) { v.visitTypeIdent(this); }
2742 
2743         @DefinedBy(Api.COMPILER_TREE)
2744         public Kind getKind() { return Kind.PRIMITIVE_TYPE; }
2745         @DefinedBy(Api.COMPILER_TREE)
2746         public TypeKind getPrimitiveTypeKind() {
2747             return typetag.getPrimitiveTypeKind();
2748         }
2749 
2750         @Override @DefinedBy(Api.COMPILER_TREE)
2751         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2752             return v.visitPrimitiveType(this, d);
2753         }
2754         @Override
2755         public Tag getTag() {
2756             return TYPEIDENT;
2757         }
2758     }
2759 
2760     /**
2761      * An array type, A[]
2762      */
2763     public static class JCArrayTypeTree extends JCExpression implements ArrayTypeTree {
2764         public JCExpression elemtype;
2765         protected JCArrayTypeTree(JCExpression elemtype) {
2766             this.elemtype = elemtype;
2767         }
2768         @Override
2769         public void accept(Visitor v) { v.visitTypeArray(this); }
2770 
2771         @DefinedBy(Api.COMPILER_TREE)
2772         public Kind getKind() { return Kind.ARRAY_TYPE; }
2773         @DefinedBy(Api.COMPILER_TREE)
2774         public JCTree getType() { return elemtype; }
2775         @Override @DefinedBy(Api.COMPILER_TREE)
2776         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2777             return v.visitArrayType(this, d);
2778         }
2779         @Override
2780         public Tag getTag() {
2781             return TYPEARRAY;
2782         }
2783     }
2784 
2785     /**
2786      * A parameterized type, {@literal T<...>}
2787      */
2788     public static class JCTypeApply extends JCExpression implements ParameterizedTypeTree {
2789         public JCExpression clazz;
2790         public List<JCExpression> arguments;
2791         protected JCTypeApply(JCExpression clazz, List<JCExpression> arguments) {
2792             this.clazz = clazz;
2793             this.arguments = arguments;
2794         }
2795         @Override
2796         public void accept(Visitor v) { v.visitTypeApply(this); }
2797 
2798         @DefinedBy(Api.COMPILER_TREE)
2799         public Kind getKind() { return Kind.PARAMETERIZED_TYPE; }
2800         @DefinedBy(Api.COMPILER_TREE)
2801         public JCTree getType() { return clazz; }
2802         @DefinedBy(Api.COMPILER_TREE)
2803         public List<JCExpression> getTypeArguments() {
2804             return arguments;
2805         }
2806         @Override @DefinedBy(Api.COMPILER_TREE)
2807         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2808             return v.visitParameterizedType(this, d);
2809         }
2810         @Override
2811         public Tag getTag() {
2812             return TYPEAPPLY;
2813         }
2814     }
2815 
2816     /**
2817      * A union type, T1 | T2 | ... Tn (used in multicatch statements)
2818      */
2819     public static class JCTypeUnion extends JCExpression implements UnionTypeTree {
2820 
2821         public List<JCExpression> alternatives;
2822 
2823         protected JCTypeUnion(List<JCExpression> components) {
2824             this.alternatives = components;
2825         }
2826         @Override
2827         public void accept(Visitor v) { v.visitTypeUnion(this); }
2828 
2829         @DefinedBy(Api.COMPILER_TREE)
2830         public Kind getKind() { return Kind.UNION_TYPE; }
2831 
2832         @DefinedBy(Api.COMPILER_TREE)
2833         public List<JCExpression> getTypeAlternatives() {
2834             return alternatives;
2835         }
2836         @Override @DefinedBy(Api.COMPILER_TREE)
2837         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2838             return v.visitUnionType(this, d);
2839         }
2840         @Override
2841         public Tag getTag() {
2842             return TYPEUNION;
2843         }
2844     }
2845 
2846     /**
2847      * An intersection type, {@code T1 & T2 & ... Tn} (used in cast expressions)
2848      */
2849     public static class JCTypeIntersection extends JCExpression implements IntersectionTypeTree {
2850 
2851         public List<JCExpression> bounds;
2852 
2853         protected JCTypeIntersection(List<JCExpression> bounds) {
2854             this.bounds = bounds;
2855         }
2856         @Override
2857         public void accept(Visitor v) { v.visitTypeIntersection(this); }
2858 
2859         @DefinedBy(Api.COMPILER_TREE)
2860         public Kind getKind() { return Kind.INTERSECTION_TYPE; }
2861 
2862         @DefinedBy(Api.COMPILER_TREE)
2863         public List<JCExpression> getBounds() {
2864             return bounds;
2865         }
2866         @Override @DefinedBy(Api.COMPILER_TREE)
2867         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2868             return v.visitIntersectionType(this, d);
2869         }
2870         @Override
2871         public Tag getTag() {
2872             return TYPEINTERSECTION;
2873         }
2874     }
2875 
2876     /**
2877      * A formal class parameter.
2878      */
2879     public static class JCTypeParameter extends JCTree implements TypeParameterTree {
2880         /** name */
2881         public Name name;
2882         /** bounds */
2883         public List<JCExpression> bounds;
2884         /** type annotations on type parameter */
2885         public List<JCAnnotation> annotations;
2886         protected JCTypeParameter(Name name, List<JCExpression> bounds, List<JCAnnotation> annotations) {
2887             this.name = name;
2888             this.bounds = bounds;
2889             this.annotations = annotations;
2890         }
2891         @Override
2892         public void accept(Visitor v) { v.visitTypeParameter(this); }
2893 
2894         @DefinedBy(Api.COMPILER_TREE)
2895         public Kind getKind() { return Kind.TYPE_PARAMETER; }
2896         @DefinedBy(Api.COMPILER_TREE)
2897         public Name getName() { return name; }
2898         @DefinedBy(Api.COMPILER_TREE)
2899         public List<JCExpression> getBounds() {
2900             return bounds;
2901         }
2902         @DefinedBy(Api.COMPILER_TREE)
2903         public List<JCAnnotation> getAnnotations() {
2904             return annotations;
2905         }
2906         @Override @DefinedBy(Api.COMPILER_TREE)
2907         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2908             return v.visitTypeParameter(this, d);
2909         }
2910         @Override
2911         public Tag getTag() {
2912             return TYPEPARAMETER;
2913         }
2914     }
2915 
2916     public static class JCWildcard extends JCExpression implements WildcardTree {
2917         public TypeBoundKind kind;
2918         public JCTree inner;
2919         protected JCWildcard(TypeBoundKind kind, JCTree inner) {
2920             this.kind = Assert.checkNonNull(kind);
2921             this.inner = inner;
2922         }
2923         @Override
2924         public void accept(Visitor v) { v.visitWildcard(this); }
2925 
2926         @DefinedBy(Api.COMPILER_TREE)
2927         public Kind getKind() {
2928             switch (kind.kind) {
2929             case UNBOUND:
2930                 return Kind.UNBOUNDED_WILDCARD;
2931             case EXTENDS:
2932                 return Kind.EXTENDS_WILDCARD;
2933             case SUPER:
2934                 return Kind.SUPER_WILDCARD;
2935             default:
2936                 throw new AssertionError("Unknown wildcard bound " + kind);
2937             }
2938         }
2939         @DefinedBy(Api.COMPILER_TREE)
2940         public JCTree getBound() { return inner; }
2941         @Override @DefinedBy(Api.COMPILER_TREE)
2942         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2943             return v.visitWildcard(this, d);
2944         }
2945         @Override
2946         public Tag getTag() {
2947             return Tag.WILDCARD;
2948         }
2949     }
2950 
2951     public static class TypeBoundKind extends JCTree {
2952         public BoundKind kind;
2953         protected TypeBoundKind(BoundKind kind) {
2954             this.kind = kind;
2955         }
2956         @Override
2957         public void accept(Visitor v) { v.visitTypeBoundKind(this); }
2958 
2959         @DefinedBy(Api.COMPILER_TREE)
2960         public Kind getKind() {
2961             throw new AssertionError("TypeBoundKind is not part of a public API");
2962         }
2963         @Override @DefinedBy(Api.COMPILER_TREE)
2964         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2965             throw new AssertionError("TypeBoundKind is not part of a public API");
2966         }
2967         @Override
2968         public Tag getTag() {
2969             return TYPEBOUNDKIND;
2970         }
2971     }
2972 
2973     public static class JCAnnotation extends JCExpression implements AnnotationTree {
2974         // Either Tag.ANNOTATION or Tag.TYPE_ANNOTATION
2975         private Tag tag;
2976 
2977         public JCTree annotationType;
2978         public List<JCExpression> args;
2979         public Attribute.Compound attribute;
2980 
2981         protected JCAnnotation(Tag tag, JCTree annotationType, List<JCExpression> args) {
2982             this.tag = tag;
2983             this.annotationType = annotationType;
2984             this.args = args;
2985         }
2986 
2987         @Override
2988         public void accept(Visitor v) { v.visitAnnotation(this); }
2989 
2990         @DefinedBy(Api.COMPILER_TREE)
2991         public Kind getKind() { return TreeInfo.tagToKind(getTag()); }
2992 
2993         @DefinedBy(Api.COMPILER_TREE)
2994         public JCTree getAnnotationType() { return annotationType; }
2995         @DefinedBy(Api.COMPILER_TREE)
2996         public List<JCExpression> getArguments() {
2997             return args;
2998         }
2999         @Override @DefinedBy(Api.COMPILER_TREE)
3000         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
3001             return v.visitAnnotation(this, d);
3002         }
3003         @Override
3004         public Tag getTag() {
3005             return tag;
3006         }
3007     }
3008 
3009     public static class JCModifiers extends JCTree implements com.sun.source.tree.ModifiersTree {
3010         public long flags;
3011         public List<JCAnnotation> annotations;
3012         protected JCModifiers(long flags, List<JCAnnotation> annotations) {
3013             this.flags = flags;
3014             this.annotations = annotations;
3015         }
3016         @Override
3017         public void accept(Visitor v) { v.visitModifiers(this); }
3018 
3019         @DefinedBy(Api.COMPILER_TREE)
3020         public Kind getKind() { return Kind.MODIFIERS; }
3021         @DefinedBy(Api.COMPILER_TREE)
3022         public Set<Modifier> getFlags() {
3023             return Flags.asModifierSet(flags);
3024         }
3025         @DefinedBy(Api.COMPILER_TREE)
3026         public List<JCAnnotation> getAnnotations() {
3027             return annotations;
3028         }
3029         @Override @DefinedBy(Api.COMPILER_TREE)
3030         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
3031             return v.visitModifiers(this, d);
3032         }
3033         @Override
3034         public Tag getTag() {
3035             return MODIFIERS;
3036         }
3037     }
3038 
3039     public static class JCAnnotatedType extends JCExpression implements com.sun.source.tree.AnnotatedTypeTree {
3040         // type annotations
3041         public List<JCAnnotation> annotations;
3042         public JCExpression underlyingType;
3043 
3044         protected JCAnnotatedType(List<JCAnnotation> annotations, JCExpression underlyingType) {
3045             Assert.check(annotations != null && annotations.nonEmpty());
3046             this.annotations = annotations;
3047             this.underlyingType = underlyingType;
3048         }
3049         @Override
3050         public void accept(Visitor v) { v.visitAnnotatedType(this); }
3051 
3052         @DefinedBy(Api.COMPILER_TREE)
3053         public Kind getKind() { return Kind.ANNOTATED_TYPE; }
3054         @DefinedBy(Api.COMPILER_TREE)
3055         public List<JCAnnotation> getAnnotations() {
3056             return annotations;
3057         }
3058         @DefinedBy(Api.COMPILER_TREE)
3059         public JCExpression getUnderlyingType() {
3060             return underlyingType;
3061         }
3062         @Override @DefinedBy(Api.COMPILER_TREE)
3063         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
3064             return v.visitAnnotatedType(this, d);
3065         }
3066         @Override
3067         public Tag getTag() {
3068             return ANNOTATED_TYPE;
3069         }
3070     }
3071 
3072     public abstract static class JCDirective extends JCTree
3073         implements DirectiveTree {
3074     }
3075 
3076     public static class JCModuleDecl extends JCTree implements ModuleTree {
3077         public JCModifiers mods;
3078         public ModuleType type;
3079         private final ModuleKind kind;
3080         public JCExpression qualId;
3081         public List<JCDirective> directives;
3082         public ModuleSymbol sym;
3083 
3084         protected JCModuleDecl(JCModifiers mods, ModuleKind kind,
3085                 JCExpression qualId, List<JCDirective> directives) {
3086             this.mods = mods;
3087             this.kind = kind;
3088             this.qualId = qualId;
3089             this.directives = directives;
3090         }
3091 
3092         @Override
3093         public void accept(Visitor v) { v.visitModuleDef(this); }
3094 
3095         @Override @DefinedBy(Api.COMPILER_TREE)
3096         public Kind getKind() {
3097             return Kind.MODULE;
3098         }
3099 
3100         @Override @DefinedBy(Api.COMPILER_TREE)
3101         public List<? extends AnnotationTree> getAnnotations() {
3102             return mods.annotations;
3103         }
3104 
3105         @Override @DefinedBy(Api.COMPILER_TREE)
3106         public ModuleKind getModuleType() {
3107             return kind;
3108         }
3109 
3110         @Override @DefinedBy(Api.COMPILER_TREE)
3111         public JCExpression getName() {
3112             return qualId;
3113         }
3114 
3115         @Override @DefinedBy(Api.COMPILER_TREE)
3116         public List<JCDirective> getDirectives() {
3117             return directives;
3118         }
3119 
3120         @Override @DefinedBy(Api.COMPILER_TREE)
3121         public <R, D> R accept(TreeVisitor<R, D> v, D d) {
3122             return v.visitModule(this, d);
3123         }
3124 
3125         @Override
3126         public Tag getTag() {
3127             return MODULEDEF;
3128         }
3129     }
3130 
3131     public static class JCExports extends JCDirective
3132             implements ExportsTree {
3133         public JCExpression qualid;
3134         public List<JCExpression> moduleNames;
3135         public ExportsDirective directive;
3136 
3137         protected JCExports(JCExpression qualId, List<JCExpression> moduleNames) {
3138             this.qualid = qualId;
3139             this.moduleNames = moduleNames;
3140         }
3141 
3142         @Override
3143         public void accept(Visitor v) { v.visitExports(this); }
3144 
3145         @Override @DefinedBy(Api.COMPILER_TREE)
3146         public Kind getKind() {
3147             return Kind.EXPORTS;
3148         }
3149 
3150         @Override @DefinedBy(Api.COMPILER_TREE)
3151         public JCExpression getPackageName() {
3152             return qualid;
3153         }
3154 
3155         @Override @DefinedBy(Api.COMPILER_TREE)
3156         public List<JCExpression> getModuleNames() {
3157             return moduleNames;
3158         }
3159 
3160         @Override @DefinedBy(Api.COMPILER_TREE)
3161         public <R, D> R accept(TreeVisitor<R, D> v, D d) {
3162             return v.visitExports(this, d);
3163         }
3164 
3165         @Override
3166         public Tag getTag() {
3167             return Tag.EXPORTS;
3168         }
3169     }
3170 
3171     public static class JCOpens extends JCDirective
3172             implements OpensTree {
3173         public JCExpression qualid;
3174         public List<JCExpression> moduleNames;
3175         public OpensDirective directive;
3176 
3177         protected JCOpens(JCExpression qualId, List<JCExpression> moduleNames) {
3178             this.qualid = qualId;
3179             this.moduleNames = moduleNames;
3180         }
3181 
3182         @Override
3183         public void accept(Visitor v) { v.visitOpens(this); }
3184 
3185         @Override @DefinedBy(Api.COMPILER_TREE)
3186         public Kind getKind() {
3187             return Kind.OPENS;
3188         }
3189 
3190         @Override @DefinedBy(Api.COMPILER_TREE)
3191         public JCExpression getPackageName() {
3192             return qualid;
3193         }
3194 
3195         @Override @DefinedBy(Api.COMPILER_TREE)
3196         public List<JCExpression> getModuleNames() {
3197             return moduleNames;
3198         }
3199 
3200         @Override @DefinedBy(Api.COMPILER_TREE)
3201         public <R, D> R accept(TreeVisitor<R, D> v, D d) {
3202             return v.visitOpens(this, d);
3203         }
3204 
3205         @Override
3206         public Tag getTag() {
3207             return Tag.OPENS;
3208         }
3209     }
3210 
3211     public static class JCProvides extends JCDirective
3212             implements ProvidesTree {
3213         public JCExpression serviceName;
3214         public List<JCExpression> implNames;
3215 
3216         protected JCProvides(JCExpression serviceName, List<JCExpression> implNames) {
3217             this.serviceName = serviceName;
3218             this.implNames = implNames;
3219         }
3220 
3221         @Override
3222         public void accept(Visitor v) { v.visitProvides(this); }
3223 
3224         @Override @DefinedBy(Api.COMPILER_TREE)
3225         public Kind getKind() {
3226             return Kind.PROVIDES;
3227         }
3228 
3229         @Override @DefinedBy(Api.COMPILER_TREE)
3230         public <R, D> R accept(TreeVisitor<R, D> v, D d) {
3231             return v.visitProvides(this, d);
3232         }
3233 
3234         @Override @DefinedBy(Api.COMPILER_TREE)
3235         public JCExpression getServiceName() {
3236             return serviceName;
3237         }
3238 
3239         @Override @DefinedBy(Api.COMPILER_TREE)
3240         public List<JCExpression> getImplementationNames() {
3241             return implNames;
3242         }
3243 
3244         @Override
3245         public Tag getTag() {
3246             return PROVIDES;
3247         }
3248     }
3249 
3250     public static class JCRequires extends JCDirective
3251             implements RequiresTree {
3252         public boolean isTransitive;
3253         public boolean isStaticPhase;
3254         public JCExpression moduleName;
3255         public RequiresDirective directive;
3256 
3257         protected JCRequires(boolean isTransitive, boolean isStaticPhase, JCExpression moduleName) {
3258             this.isTransitive = isTransitive;
3259             this.isStaticPhase = isStaticPhase;
3260             this.moduleName = moduleName;
3261         }
3262 
3263         @Override
3264         public void accept(Visitor v) { v.visitRequires(this); }
3265 
3266         @Override @DefinedBy(Api.COMPILER_TREE)
3267         public Kind getKind() {
3268             return Kind.REQUIRES;
3269         }
3270 
3271         @Override @DefinedBy(Api.COMPILER_TREE)
3272         public <R, D> R accept(TreeVisitor<R, D> v, D d) {
3273             return v.visitRequires(this, d);
3274         }
3275 
3276         @Override @DefinedBy(Api.COMPILER_TREE)
3277         public boolean isTransitive() {
3278             return isTransitive;
3279         }
3280 
3281         @Override @DefinedBy(Api.COMPILER_TREE)
3282         public boolean isStatic() {
3283             return isStaticPhase;
3284         }
3285 
3286         @Override @DefinedBy(Api.COMPILER_TREE)
3287         public JCExpression getModuleName() {
3288             return moduleName;
3289         }
3290 
3291         @Override
3292         public Tag getTag() {
3293             return REQUIRES;
3294         }
3295     }
3296 
3297     public static class JCUses extends JCDirective
3298             implements UsesTree {
3299         public JCExpression qualid;
3300 
3301         protected JCUses(JCExpression qualId) {
3302             this.qualid = qualId;
3303         }
3304 
3305         @Override
3306         public void accept(Visitor v) { v.visitUses(this); }
3307 
3308         @Override @DefinedBy(Api.COMPILER_TREE)
3309         public Kind getKind() {
3310             return Kind.USES;
3311         }
3312 
3313         @Override @DefinedBy(Api.COMPILER_TREE)
3314         public JCExpression getServiceName() {
3315             return qualid;
3316         }
3317 
3318         @Override @DefinedBy(Api.COMPILER_TREE)
3319         public <R, D> R accept(TreeVisitor<R, D> v, D d) {
3320             return v.visitUses(this, d);
3321         }
3322 
3323         @Override
3324         public Tag getTag() {
3325             return USES;
3326         }
3327     }
3328 
3329     public static class JCErroneous extends JCExpression
3330             implements ErroneousTree {
3331         public List<? extends JCTree> errs;
3332         protected JCErroneous(List<? extends JCTree> errs) {
3333             this.errs = errs;
3334         }
3335         @Override
3336         public void accept(Visitor v) { v.visitErroneous(this); }
3337 
3338         @DefinedBy(Api.COMPILER_TREE)
3339         public Kind getKind() { return Kind.ERRONEOUS; }
3340 
3341         @DefinedBy(Api.COMPILER_TREE)
3342         public List<? extends JCTree> getErrorTrees() {
3343             return errs;
3344         }
3345 
3346         @Override @DefinedBy(Api.COMPILER_TREE)
3347         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
3348             return v.visitErroneous(this, d);
3349         }
3350         @Override
3351         public Tag getTag() {
3352             return ERRONEOUS;
3353         }
3354     }
3355 
3356     /** (let int x = 3; in x+2) */
3357     public static class LetExpr extends JCExpression {
3358         public List<JCStatement> defs;
3359         public JCExpression expr;
3360         /**true if a expr should be run through Gen.genCond:*/
3361         public boolean needsCond;
3362         protected LetExpr(List<JCStatement> defs, JCExpression expr) {
3363             this.defs = defs;
3364             this.expr = expr;
3365         }
3366         @Override
3367         public void accept(Visitor v) { v.visitLetExpr(this); }
3368 
3369         @DefinedBy(Api.COMPILER_TREE)
3370         public Kind getKind() {
3371             throw new AssertionError("LetExpr is not part of a public API");
3372         }
3373         @Override @DefinedBy(Api.COMPILER_TREE)
3374         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
3375             throw new AssertionError("LetExpr is not part of a public API");
3376         }
3377         @Override
3378         public Tag getTag() {
3379             return LETEXPR;
3380         }
3381     }
3382 
3383     /** An interface for tree factories
3384      */
3385     public interface Factory {
3386         JCCompilationUnit TopLevel(List<JCTree> defs);
3387         JCPackageDecl PackageDecl(List<JCAnnotation> annotations,
3388                                   JCExpression pid);
3389         JCImport Import(JCTree qualid, boolean staticImport);
3390         JCClassDecl ClassDef(JCModifiers mods,
3391                           Name name,
3392                           List<JCTypeParameter> typarams,
3393                           JCExpression extending,
3394                           List<JCExpression> implementing,
3395                           List<JCTree> defs);
3396         JCMethodDecl MethodDef(JCModifiers mods,
3397                             Name name,
3398                             JCExpression restype,
3399                             List<JCTypeParameter> typarams,
3400                             JCVariableDecl recvparam,
3401                             List<JCVariableDecl> params,
3402                             List<JCExpression> thrown,
3403                             JCBlock body,
3404                             JCExpression defaultValue);
3405         JCVariableDecl VarDef(JCModifiers mods,
3406                       Name name,
3407                       JCExpression vartype,
3408                       JCExpression init);
3409         JCSkip Skip();
3410         JCBlock Block(long flags, List<JCStatement> stats);
3411         JCDoWhileLoop DoLoop(JCStatement body, JCExpression cond);
3412         JCWhileLoop WhileLoop(JCExpression cond, JCStatement body);
3413         JCForLoop ForLoop(List<JCStatement> init,
3414                         JCExpression cond,
3415                         List<JCExpressionStatement> step,
3416                         JCStatement body);
3417         JCEnhancedForLoop ForeachLoop(JCVariableDecl var, JCExpression expr, JCStatement body);
3418         JCLabeledStatement Labelled(Name label, JCStatement body);
3419         JCSwitch Switch(JCExpression selector, List<JCCase> cases);
3420         JCSwitchExpression SwitchExpression(JCExpression selector, List<JCCase> cases);
3421         JCCase Case(CaseTree.CaseKind caseKind, List<JCCaseLabel> labels,
3422                     List<JCStatement> stats, JCTree body);
3423         JCSynchronized Synchronized(JCExpression lock, JCBlock body);
3424         JCTry Try(JCBlock body, List<JCCatch> catchers, JCBlock finalizer);
3425         JCTry Try(List<JCTree> resources,
3426                   JCBlock body,
3427                   List<JCCatch> catchers,
3428                   JCBlock finalizer);
3429         JCCatch Catch(JCVariableDecl param, JCBlock body);
3430         JCConditional Conditional(JCExpression cond,
3431                                 JCExpression thenpart,
3432                                 JCExpression elsepart);
3433         JCIf If(JCExpression cond, JCStatement thenpart, JCStatement elsepart);
3434         JCExpressionStatement Exec(JCExpression expr);
3435         JCBreak Break(Name label);
3436         JCYield Yield(JCExpression value);
3437         JCContinue Continue(Name label);
3438         JCReturn Return(JCExpression expr);
3439         JCThrow Throw(JCExpression expr);
3440         JCAssert Assert(JCExpression cond, JCExpression detail);
3441         JCMethodInvocation Apply(List<JCExpression> typeargs,
3442                     JCExpression fn,
3443                     List<JCExpression> args);
3444         JCNewClass NewClass(JCExpression encl,
3445                           List<JCExpression> typeargs,
3446                           JCExpression clazz,
3447                           List<JCExpression> args,
3448                           JCClassDecl def);
3449         JCNewArray NewArray(JCExpression elemtype,
3450                           List<JCExpression> dims,
3451                           List<JCExpression> elems);
3452         JCParens Parens(JCExpression expr);
3453         JCAssign Assign(JCExpression lhs, JCExpression rhs);
3454         JCAssignOp Assignop(Tag opcode, JCTree lhs, JCTree rhs);
3455         JCUnary Unary(Tag opcode, JCExpression arg);
3456         JCBinary Binary(Tag opcode, JCExpression lhs, JCExpression rhs);
3457         JCTypeCast TypeCast(JCTree expr, JCExpression type);
3458         JCInstanceOf TypeTest(JCExpression expr, JCTree clazz);
3459         JCBindingPattern BindingPattern(JCVariableDecl var);
3460         JCArrayAccess Indexed(JCExpression indexed, JCExpression index);
3461         JCFieldAccess Select(JCExpression selected, Name selector);
3462         JCIdent Ident(Name idname);
3463         JCLiteral Literal(TypeTag tag, Object value);
3464         JCPrimitiveTypeTree TypeIdent(TypeTag typetag);
3465         JCArrayTypeTree TypeArray(JCExpression elemtype);
3466         JCTypeApply TypeApply(JCExpression clazz, List<JCExpression> arguments);
3467         JCTypeParameter TypeParameter(Name name, List<JCExpression> bounds);
3468         JCWildcard Wildcard(TypeBoundKind kind, JCTree type);
3469         TypeBoundKind TypeBoundKind(BoundKind kind);
3470         JCAnnotation Annotation(JCTree annotationType, List<JCExpression> args);
3471         JCModifiers Modifiers(long flags, List<JCAnnotation> annotations);
3472         JCErroneous Erroneous(List<? extends JCTree> errs);
3473         JCModuleDecl ModuleDef(JCModifiers mods, ModuleKind kind, JCExpression qualId, List<JCDirective> directives);
3474         JCExports Exports(JCExpression qualId, List<JCExpression> moduleNames);
3475         JCOpens Opens(JCExpression qualId, List<JCExpression> moduleNames);
3476         JCProvides Provides(JCExpression serviceName, List<JCExpression> implNames);
3477         JCRequires Requires(boolean isTransitive, boolean isStaticPhase, JCExpression qualId);
3478         JCUses Uses(JCExpression qualId);
3479         LetExpr LetExpr(List<JCStatement> defs, JCExpression expr);
3480     }
3481 
3482     /** A generic visitor class for trees.
3483      */
3484     public abstract static class Visitor {
3485         public void visitTopLevel(JCCompilationUnit that)    { visitTree(that); }
3486         public void visitPackageDef(JCPackageDecl that)      { visitTree(that); }
3487         public void visitImport(JCImport that)               { visitTree(that); }
3488         public void visitClassDef(JCClassDecl that)          { visitTree(that); }
3489         public void visitMethodDef(JCMethodDecl that)        { visitTree(that); }
3490         public void visitVarDef(JCVariableDecl that)         { visitTree(that); }
3491         public void visitSkip(JCSkip that)                   { visitTree(that); }
3492         public void visitBlock(JCBlock that)                 { visitTree(that); }
3493         public void visitDoLoop(JCDoWhileLoop that)          { visitTree(that); }
3494         public void visitWhileLoop(JCWhileLoop that)         { visitTree(that); }
3495         public void visitForLoop(JCForLoop that)             { visitTree(that); }
3496         public void visitForeachLoop(JCEnhancedForLoop that) { visitTree(that); }
3497         public void visitLabelled(JCLabeledStatement that)   { visitTree(that); }
3498         public void visitSwitch(JCSwitch that)               { visitTree(that); }
3499         public void visitCase(JCCase that)                   { visitTree(that); }
3500         public void visitSwitchExpression(JCSwitchExpression that)               { visitTree(that); }
3501         public void visitSynchronized(JCSynchronized that)   { visitTree(that); }
3502         public void visitTry(JCTry that)                     { visitTree(that); }
3503         public void visitCatch(JCCatch that)                 { visitTree(that); }
3504         public void visitConditional(JCConditional that)     { visitTree(that); }
3505         public void visitIf(JCIf that)                       { visitTree(that); }
3506         public void visitExec(JCExpressionStatement that)    { visitTree(that); }
3507         public void visitBreak(JCBreak that)                 { visitTree(that); }
3508         public void visitYield(JCYield that)                 { visitTree(that); }
3509         public void visitContinue(JCContinue that)           { visitTree(that); }
3510         public void visitReturn(JCReturn that)               { visitTree(that); }
3511         public void visitThrow(JCThrow that)                 { visitTree(that); }
3512         public void visitAssert(JCAssert that)               { visitTree(that); }
3513         public void visitApply(JCMethodInvocation that)      { visitTree(that); }
3514         public void visitNewClass(JCNewClass that)           { visitTree(that); }
3515         public void visitNewArray(JCNewArray that)           { visitTree(that); }
3516         public void visitLambda(JCLambda that)               { visitTree(that); }
3517         public void visitParens(JCParens that)               { visitTree(that); }
3518         public void visitAssign(JCAssign that)               { visitTree(that); }
3519         public void visitAssignop(JCAssignOp that)           { visitTree(that); }
3520         public void visitUnary(JCUnary that)                 { visitTree(that); }
3521         public void visitBinary(JCBinary that)               { visitTree(that); }
3522         public void visitTypeCast(JCTypeCast that)           { visitTree(that); }
3523         public void visitTypeTest(JCInstanceOf that)         { visitTree(that); }
3524         public void visitBindingPattern(JCBindingPattern that) { visitTree(that); }
3525         public void visitDefaultCaseLabel(JCDefaultCaseLabel that) { visitTree(that); }
3526         public void visitConstantCaseLabel(JCConstantCaseLabel that) { visitTree(that); }
3527         public void visitPatternCaseLabel(JCPatternCaseLabel that) { visitTree(that); }
3528         public void visitParenthesizedPattern(JCParenthesizedPattern that) { visitTree(that); }
3529         public void visitRecordPattern(JCRecordPattern that) { visitTree(that); }
3530         public void visitIndexed(JCArrayAccess that)         { visitTree(that); }
3531         public void visitSelect(JCFieldAccess that)          { visitTree(that); }
3532         public void visitReference(JCMemberReference that)   { visitTree(that); }
3533         public void visitIdent(JCIdent that)                 { visitTree(that); }
3534         public void visitLiteral(JCLiteral that)             { visitTree(that); }
3535         public void visitTypeIdent(JCPrimitiveTypeTree that) { visitTree(that); }
3536         public void visitTypeArray(JCArrayTypeTree that)     { visitTree(that); }
3537         public void visitTypeApply(JCTypeApply that)         { visitTree(that); }
3538         public void visitTypeUnion(JCTypeUnion that)         { visitTree(that); }
3539         public void visitTypeIntersection(JCTypeIntersection that)  { visitTree(that); }
3540         public void visitTypeParameter(JCTypeParameter that) { visitTree(that); }
3541         public void visitWildcard(JCWildcard that)           { visitTree(that); }
3542         public void visitTypeBoundKind(TypeBoundKind that)   { visitTree(that); }
3543         public void visitAnnotation(JCAnnotation that)       { visitTree(that); }
3544         public void visitModifiers(JCModifiers that)         { visitTree(that); }
3545         public void visitAnnotatedType(JCAnnotatedType that) { visitTree(that); }
3546         public void visitErroneous(JCErroneous that)         { visitTree(that); }
3547         public void visitModuleDef(JCModuleDecl that)        { visitTree(that); }
3548         public void visitExports(JCExports that)             { visitTree(that); }
3549         public void visitOpens(JCOpens that)                 { visitTree(that); }
3550         public void visitProvides(JCProvides that)           { visitTree(that); }
3551         public void visitRequires(JCRequires that)           { visitTree(that); }
3552         public void visitUses(JCUses that)                   { visitTree(that); }
3553         public void visitLetExpr(LetExpr that)               { visitTree(that); }
3554 
3555         public void visitTree(JCTree that)                   { Assert.error(); }
3556     }
3557 
3558 }