1 /*
   2  * Copyright (c) 1999, 2024, 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         ANYPATTERN,
 243         BINDINGPATTERN,
 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 JCFieldAccess qualid;
 671         public com.sun.tools.javac.code.Scope importScope;
 672         protected JCImport(JCFieldAccess 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 JCFieldAccess 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         /** If this block contains record pattern, it is necessary to catch
1078          *  exceptions from the deconstructors and wrap them.
1079          * The {@code patternMatchingCatch} keeps the list of the deconstructor
1080          * invocations, and the additional catch block that wraps the exceptions.
1081          */
1082         public PatternMatchingCatch patternMatchingCatch;
1083         protected JCBlock(long flags, List<JCStatement> stats) {
1084             this.stats = stats;
1085             this.flags = flags;
1086         }
1087         @Override
1088         public void accept(Visitor v) { v.visitBlock(this); }
1089 
1090         @DefinedBy(Api.COMPILER_TREE)
1091         public Kind getKind() { return Kind.BLOCK; }
1092         @DefinedBy(Api.COMPILER_TREE)
1093         public List<JCStatement> getStatements() {
1094             return stats;
1095         }
1096         @DefinedBy(Api.COMPILER_TREE)
1097         public boolean isStatic() { return (flags & Flags.STATIC) != 0; }
1098         @Override @DefinedBy(Api.COMPILER_TREE)
1099         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1100             return v.visitBlock(this, d);
1101         }
1102 
1103         @Override
1104         public Tag getTag() {
1105             return BLOCK;
1106         }
1107 
1108         public record PatternMatchingCatch(JCCatch handler, Set<JCMethodInvocation> calls2Handle) {}
1109     }
1110 
1111     /**
1112      * A do loop
1113      */
1114     public static class JCDoWhileLoop extends JCStatement implements DoWhileLoopTree {
1115         public JCStatement body;
1116         public JCExpression cond;
1117         protected JCDoWhileLoop(JCStatement body, JCExpression cond) {
1118             this.body = body;
1119             this.cond = cond;
1120         }
1121         @Override
1122         public void accept(Visitor v) { v.visitDoLoop(this); }
1123 
1124         @DefinedBy(Api.COMPILER_TREE)
1125         public Kind getKind() { return Kind.DO_WHILE_LOOP; }
1126         @DefinedBy(Api.COMPILER_TREE)
1127         public JCExpression getCondition() { return cond; }
1128         @DefinedBy(Api.COMPILER_TREE)
1129         public JCStatement getStatement() { return body; }
1130         @Override @DefinedBy(Api.COMPILER_TREE)
1131         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1132             return v.visitDoWhileLoop(this, d);
1133         }
1134 
1135         @Override
1136         public Tag getTag() {
1137             return DOLOOP;
1138         }
1139     }
1140 
1141     /**
1142      * A while loop
1143      */
1144     public static class JCWhileLoop extends JCStatement implements WhileLoopTree {
1145         public JCExpression cond;
1146         public JCStatement body;
1147         protected JCWhileLoop(JCExpression cond, JCStatement body) {
1148             this.cond = cond;
1149             this.body = body;
1150         }
1151         @Override
1152         public void accept(Visitor v) { v.visitWhileLoop(this); }
1153 
1154         @DefinedBy(Api.COMPILER_TREE)
1155         public Kind getKind() { return Kind.WHILE_LOOP; }
1156         @DefinedBy(Api.COMPILER_TREE)
1157         public JCExpression getCondition() { return cond; }
1158         @DefinedBy(Api.COMPILER_TREE)
1159         public JCStatement getStatement() { return body; }
1160         @Override @DefinedBy(Api.COMPILER_TREE)
1161         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1162             return v.visitWhileLoop(this, d);
1163         }
1164 
1165         @Override
1166         public Tag getTag() {
1167             return WHILELOOP;
1168         }
1169     }
1170 
1171     /**
1172      * A for loop.
1173      */
1174     public static class JCForLoop extends JCStatement implements ForLoopTree {
1175         public List<JCStatement> init;
1176         public JCExpression cond;
1177         public List<JCExpressionStatement> step;
1178         public JCStatement body;
1179         protected JCForLoop(List<JCStatement> init,
1180                           JCExpression cond,
1181                           List<JCExpressionStatement> update,
1182                           JCStatement body)
1183         {
1184             this.init = init;
1185             this.cond = cond;
1186             this.step = update;
1187             this.body = body;
1188         }
1189         @Override
1190         public void accept(Visitor v) { v.visitForLoop(this); }
1191 
1192         @DefinedBy(Api.COMPILER_TREE)
1193         public Kind getKind() { return Kind.FOR_LOOP; }
1194         @DefinedBy(Api.COMPILER_TREE)
1195         public JCExpression getCondition() { return cond; }
1196         @DefinedBy(Api.COMPILER_TREE)
1197         public JCStatement getStatement() { return body; }
1198         @DefinedBy(Api.COMPILER_TREE)
1199         public List<JCStatement> getInitializer() {
1200             return init;
1201         }
1202         @DefinedBy(Api.COMPILER_TREE)
1203         public List<JCExpressionStatement> getUpdate() {
1204             return step;
1205         }
1206         @Override @DefinedBy(Api.COMPILER_TREE)
1207         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1208             return v.visitForLoop(this, d);
1209         }
1210 
1211         @Override
1212         public Tag getTag() {
1213             return FORLOOP;
1214         }
1215     }
1216 
1217     /**
1218      * The enhanced for loop.
1219      */
1220     public static class JCEnhancedForLoop extends JCStatement implements EnhancedForLoopTree {
1221         public JCVariableDecl var;
1222         public JCExpression expr;
1223         public JCStatement body;
1224         protected JCEnhancedForLoop(JCVariableDecl var, JCExpression expr, JCStatement body) {
1225             this.var = var;
1226             this.expr = expr;
1227             this.body = body;
1228         }
1229         @Override
1230         public void accept(Visitor v) { v.visitForeachLoop(this); }
1231 
1232         @DefinedBy(Api.COMPILER_TREE)
1233         public Kind getKind() { return Kind.ENHANCED_FOR_LOOP; }
1234         @DefinedBy(Api.COMPILER_TREE)
1235         public JCVariableDecl getVariable() { return var; }
1236         @DefinedBy(Api.COMPILER_TREE)
1237         public JCExpression getExpression() { return expr; }
1238         @DefinedBy(Api.COMPILER_TREE)
1239         public JCStatement getStatement() { return body; }
1240         @Override @DefinedBy(Api.COMPILER_TREE)
1241         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1242             return v.visitEnhancedForLoop(this, d);
1243         }
1244         @Override
1245         public Tag getTag() {
1246             return FOREACHLOOP;
1247         }
1248     }
1249 
1250     /**
1251      * A labelled expression or statement.
1252      */
1253     public static class JCLabeledStatement extends JCStatement implements LabeledStatementTree {
1254         public Name label;
1255         public JCStatement body;
1256         protected JCLabeledStatement(Name label, JCStatement body) {
1257             this.label = label;
1258             this.body = body;
1259         }
1260         @Override
1261         public void accept(Visitor v) { v.visitLabelled(this); }
1262         @DefinedBy(Api.COMPILER_TREE)
1263         public Kind getKind() { return Kind.LABELED_STATEMENT; }
1264         @DefinedBy(Api.COMPILER_TREE)
1265         public Name getLabel() { return label; }
1266         @DefinedBy(Api.COMPILER_TREE)
1267         public JCStatement getStatement() { return body; }
1268         @Override @DefinedBy(Api.COMPILER_TREE)
1269         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1270             return v.visitLabeledStatement(this, d);
1271         }
1272         @Override
1273         public Tag getTag() {
1274             return LABELLED;
1275         }
1276     }
1277 
1278     /**
1279      * A "switch ( ) { }" construction.
1280      */
1281     public static class JCSwitch extends JCStatement implements SwitchTree {
1282         public JCExpression selector;
1283         public List<JCCase> cases;
1284         /** Position of closing brace, optional. */
1285         public int endpos = Position.NOPOS;
1286         public boolean hasUnconditionalPattern;
1287         public boolean isExhaustive;
1288         public boolean patternSwitch;
1289         public boolean wasEnumSelector;
1290         protected JCSwitch(JCExpression selector, List<JCCase> cases) {
1291             this.selector = selector;
1292             this.cases = cases;
1293         }
1294         @Override
1295         public void accept(Visitor v) { v.visitSwitch(this); }
1296 
1297         @DefinedBy(Api.COMPILER_TREE)
1298         public Kind getKind() { return Kind.SWITCH; }
1299         @DefinedBy(Api.COMPILER_TREE)
1300         public JCExpression getExpression() { return selector; }
1301         @DefinedBy(Api.COMPILER_TREE)
1302         public List<JCCase> getCases() { return cases; }
1303         @Override @DefinedBy(Api.COMPILER_TREE)
1304         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1305             return v.visitSwitch(this, d);
1306         }
1307         @Override
1308         public Tag getTag() {
1309             return SWITCH;
1310         }
1311     }
1312 
1313     /**
1314      * A "case  :" of a switch.
1315      */
1316     public static class JCCase extends JCStatement implements CaseTree {
1317         //as CaseKind is deprecated for removal (as it is part of a preview feature),
1318         //using indirection through these fields to avoid unnecessary @SuppressWarnings:
1319         public static final CaseKind STATEMENT = CaseKind.STATEMENT;
1320         public static final CaseKind RULE = CaseKind.RULE;
1321         public final CaseKind caseKind;
1322         public List<JCCaseLabel> labels;
1323         public JCExpression guard;
1324         public List<JCStatement> stats;
1325         public JCTree body;
1326         public boolean completesNormally;
1327         protected JCCase(CaseKind caseKind, List<JCCaseLabel> labels,
1328                          JCExpression guard,
1329                          List<JCStatement> stats, JCTree body) {
1330             Assert.checkNonNull(labels);
1331             Assert.check(labels.isEmpty() || labels.head != null);
1332             this.caseKind = caseKind;
1333             this.labels = labels;
1334             this.guard = guard;
1335             this.stats = stats;
1336             this.body = body;
1337         }
1338         @Override
1339         public void accept(Visitor v) { v.visitCase(this); }
1340 
1341         @Override @DefinedBy(Api.COMPILER_TREE)
1342         public Kind getKind() { return Kind.CASE; }
1343         @Override @Deprecated @DefinedBy(Api.COMPILER_TREE)
1344         public JCExpression getExpression() { return getExpressions().head; }
1345 
1346         @Override @DefinedBy(Api.COMPILER_TREE)
1347         public List<JCExpression> getExpressions() {
1348             return labels.stream()
1349                          .filter(p -> p.hasTag(CONSTANTCASELABEL))
1350                          .map(p -> ((JCConstantCaseLabel) p).expr)
1351                          .collect(List.collector());
1352         }
1353 
1354         @Override @DefinedBy(Api.COMPILER_TREE)
1355         public List<JCCaseLabel> getLabels() { return labels; }
1356         @Override @DefinedBy(Api.COMPILER_TREE)
1357         public JCExpression getGuard() { return guard; }
1358         @Override @DefinedBy(Api.COMPILER_TREE)
1359         public List<JCStatement> getStatements() {
1360             return caseKind == CaseKind.STATEMENT ? stats : null;
1361         }
1362         @Override @DefinedBy(Api.COMPILER_TREE)
1363         public JCTree getBody() { return body; }
1364         @Override @DefinedBy(Api.COMPILER_TREE)
1365         public CaseKind getCaseKind() {
1366             return caseKind;
1367         }
1368         @Override @DefinedBy(Api.COMPILER_TREE)
1369         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1370             return v.visitCase(this, d);
1371         }
1372         @Override
1373         public Tag getTag() {
1374             return CASE;
1375         }
1376     }
1377 
1378     /**
1379      * A "switch ( ) { }" construction.
1380      */
1381     public static class JCSwitchExpression extends JCPolyExpression implements SwitchExpressionTree {
1382         public JCExpression selector;
1383         public List<JCCase> cases;
1384         /** Position of closing brace, optional. */
1385         public int endpos = Position.NOPOS;
1386         public boolean hasUnconditionalPattern;
1387         public boolean isExhaustive;
1388         public boolean patternSwitch;
1389         public boolean wasEnumSelector;
1390         protected JCSwitchExpression(JCExpression selector, List<JCCase> cases) {
1391             this.selector = selector;
1392             this.cases = cases;
1393         }
1394         @Override
1395         public void accept(Visitor v) { v.visitSwitchExpression(this); }
1396 
1397         @DefinedBy(Api.COMPILER_TREE)
1398         public Kind getKind() { return Kind.SWITCH_EXPRESSION; }
1399         @DefinedBy(Api.COMPILER_TREE)
1400         public JCExpression getExpression() { return selector; }
1401         @DefinedBy(Api.COMPILER_TREE)
1402         public List<JCCase> getCases() { return cases; }
1403         @Override @DefinedBy(Api.COMPILER_TREE)
1404         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1405             return v.visitSwitchExpression(this, d);
1406         }
1407         @Override
1408         public Tag getTag() {
1409             return SWITCH_EXPRESSION;
1410         }
1411     }
1412 
1413     /**
1414      * A synchronized block.
1415      */
1416     public static class JCSynchronized extends JCStatement implements SynchronizedTree {
1417         public JCExpression lock;
1418         public JCBlock body;
1419         protected JCSynchronized(JCExpression lock, JCBlock body) {
1420             this.lock = lock;
1421             this.body = body;
1422         }
1423         @Override
1424         public void accept(Visitor v) { v.visitSynchronized(this); }
1425 
1426         @DefinedBy(Api.COMPILER_TREE)
1427         public Kind getKind() { return Kind.SYNCHRONIZED; }
1428         @DefinedBy(Api.COMPILER_TREE)
1429         public JCExpression getExpression() { return lock; }
1430         @DefinedBy(Api.COMPILER_TREE)
1431         public JCBlock getBlock() { return body; }
1432         @Override @DefinedBy(Api.COMPILER_TREE)
1433         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1434             return v.visitSynchronized(this, d);
1435         }
1436         @Override
1437         public Tag getTag() {
1438             return SYNCHRONIZED;
1439         }
1440     }
1441 
1442     /**
1443      * A "try { } catch ( ) { } finally { }" block.
1444      */
1445     public static class JCTry extends JCStatement implements TryTree {
1446         public JCBlock body;
1447         public List<JCCatch> catchers;
1448         public JCBlock finalizer;
1449         public List<JCTree> resources;
1450         public boolean finallyCanCompleteNormally;
1451         protected JCTry(List<JCTree> resources,
1452                         JCBlock body,
1453                         List<JCCatch> catchers,
1454                         JCBlock finalizer) {
1455             this.body = body;
1456             this.catchers = catchers;
1457             this.finalizer = finalizer;
1458             this.resources = resources;
1459         }
1460         @Override
1461         public void accept(Visitor v) { v.visitTry(this); }
1462 
1463         @DefinedBy(Api.COMPILER_TREE)
1464         public Kind getKind() { return Kind.TRY; }
1465         @DefinedBy(Api.COMPILER_TREE)
1466         public JCBlock getBlock() { return body; }
1467         @DefinedBy(Api.COMPILER_TREE)
1468         public List<JCCatch> getCatches() {
1469             return catchers;
1470         }
1471         @DefinedBy(Api.COMPILER_TREE)
1472         public JCBlock getFinallyBlock() { return finalizer; }
1473         @Override @DefinedBy(Api.COMPILER_TREE)
1474         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1475             return v.visitTry(this, d);
1476         }
1477         @Override @DefinedBy(Api.COMPILER_TREE)
1478         public List<JCTree> getResources() {
1479             return resources;
1480         }
1481         @Override
1482         public Tag getTag() {
1483             return TRY;
1484         }
1485     }
1486 
1487     /**
1488      * A catch block.
1489      */
1490     public static class JCCatch extends JCTree implements CatchTree {
1491         public JCVariableDecl param;
1492         public JCBlock body;
1493         protected JCCatch(JCVariableDecl param, JCBlock body) {
1494             this.param = param;
1495             this.body = body;
1496         }
1497         @Override
1498         public void accept(Visitor v) { v.visitCatch(this); }
1499 
1500         @DefinedBy(Api.COMPILER_TREE)
1501         public Kind getKind() { return Kind.CATCH; }
1502         @DefinedBy(Api.COMPILER_TREE)
1503         public JCVariableDecl getParameter() { return param; }
1504         @DefinedBy(Api.COMPILER_TREE)
1505         public JCBlock getBlock() { return body; }
1506         @Override @DefinedBy(Api.COMPILER_TREE)
1507         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1508             return v.visitCatch(this, d);
1509         }
1510         @Override
1511         public Tag getTag() {
1512             return CATCH;
1513         }
1514     }
1515 
1516     /**
1517      * A ( ) ? ( ) : ( ) conditional expression
1518      */
1519     public static class JCConditional extends JCPolyExpression implements ConditionalExpressionTree {
1520         public JCExpression cond;
1521         public JCExpression truepart;
1522         public JCExpression falsepart;
1523         protected JCConditional(JCExpression cond,
1524                               JCExpression truepart,
1525                               JCExpression falsepart)
1526         {
1527             this.cond = cond;
1528             this.truepart = truepart;
1529             this.falsepart = falsepart;
1530         }
1531         @Override
1532         public void accept(Visitor v) { v.visitConditional(this); }
1533 
1534         @DefinedBy(Api.COMPILER_TREE)
1535         public Kind getKind() { return Kind.CONDITIONAL_EXPRESSION; }
1536         @DefinedBy(Api.COMPILER_TREE)
1537         public JCExpression getCondition() { return cond; }
1538         @DefinedBy(Api.COMPILER_TREE)
1539         public JCExpression getTrueExpression() { return truepart; }
1540         @DefinedBy(Api.COMPILER_TREE)
1541         public JCExpression getFalseExpression() { return falsepart; }
1542         @Override @DefinedBy(Api.COMPILER_TREE)
1543         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1544             return v.visitConditionalExpression(this, d);
1545         }
1546         @Override
1547         public Tag getTag() {
1548             return CONDEXPR;
1549         }
1550     }
1551 
1552     /**
1553      * An "if ( ) { } else { }" block
1554      */
1555     public static class JCIf extends JCStatement implements IfTree {
1556         public JCExpression cond;
1557         public JCStatement thenpart;
1558         public JCStatement elsepart;
1559         protected JCIf(JCExpression cond,
1560                      JCStatement thenpart,
1561                      JCStatement elsepart)
1562         {
1563             this.cond = cond;
1564             this.thenpart = thenpart;
1565             this.elsepart = elsepart;
1566         }
1567         @Override
1568         public void accept(Visitor v) { v.visitIf(this); }
1569 
1570         @DefinedBy(Api.COMPILER_TREE)
1571         public Kind getKind() { return Kind.IF; }
1572         @DefinedBy(Api.COMPILER_TREE)
1573         public JCExpression getCondition() { return cond; }
1574         @DefinedBy(Api.COMPILER_TREE)
1575         public JCStatement getThenStatement() { return thenpart; }
1576         @DefinedBy(Api.COMPILER_TREE)
1577         public JCStatement getElseStatement() { return elsepart; }
1578         @Override @DefinedBy(Api.COMPILER_TREE)
1579         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1580             return v.visitIf(this, d);
1581         }
1582         @Override
1583         public Tag getTag() {
1584             return IF;
1585         }
1586     }
1587 
1588     /**
1589      * an expression statement
1590      */
1591     public static class JCExpressionStatement extends JCStatement implements ExpressionStatementTree {
1592         /** expression structure */
1593         public JCExpression expr;
1594         protected JCExpressionStatement(JCExpression expr)
1595         {
1596             this.expr = expr;
1597         }
1598         @Override
1599         public void accept(Visitor v) { v.visitExec(this); }
1600 
1601         @DefinedBy(Api.COMPILER_TREE)
1602         public Kind getKind() { return Kind.EXPRESSION_STATEMENT; }
1603         @DefinedBy(Api.COMPILER_TREE)
1604         public JCExpression getExpression() { return expr; }
1605         @Override @DefinedBy(Api.COMPILER_TREE)
1606         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1607             return v.visitExpressionStatement(this, d);
1608         }
1609         @Override
1610         public Tag getTag() {
1611             return EXEC;
1612         }
1613 
1614         /** Convert a expression-statement tree to a pretty-printed string. */
1615         @Override
1616         public String toString() {
1617             StringWriter s = new StringWriter();
1618             try {
1619                 new Pretty(s, false).printStat(this);
1620             }
1621             catch (IOException e) {
1622                 // should never happen, because StringWriter is defined
1623                 // never to throw any IOExceptions
1624                 throw new AssertionError(e);
1625             }
1626             return s.toString();
1627         }
1628     }
1629 
1630     /**
1631      * A break from a loop or switch.
1632      */
1633     public static class JCBreak extends JCStatement implements BreakTree {
1634         public Name label;
1635         public JCTree target;
1636         protected JCBreak(Name label, JCTree target) {
1637             this.label = label;
1638             this.target = target;
1639         }
1640         @Override
1641         public void accept(Visitor v) { v.visitBreak(this); }
1642         public boolean isValueBreak() {
1643             return target != null && target.hasTag(SWITCH_EXPRESSION);
1644         }
1645 
1646         @DefinedBy(Api.COMPILER_TREE)
1647         public Kind getKind() { return Kind.BREAK; }
1648         @DefinedBy(Api.COMPILER_TREE)
1649         public Name getLabel() {
1650             return label;
1651         }
1652         @Override @DefinedBy(Api.COMPILER_TREE)
1653         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1654             return v.visitBreak(this, d);
1655         }
1656         @Override
1657         public Tag getTag() {
1658             return BREAK;
1659         }
1660     }
1661 
1662     /**
1663      * A break-with from a switch expression.
1664      */
1665     public static class JCYield extends JCStatement implements YieldTree {
1666         public JCExpression value;
1667         public JCTree target;
1668         protected JCYield(JCExpression value, JCTree target) {
1669             this.value = value;
1670             this.target = target;
1671         }
1672         @Override
1673         public void accept(Visitor v) { v.visitYield(this); }
1674         @DefinedBy(Api.COMPILER_TREE)
1675         public Kind getKind() { return Kind.YIELD; }
1676         @DefinedBy(Api.COMPILER_TREE)
1677         public JCExpression getValue() { return value; }
1678         @Override @DefinedBy(Api.COMPILER_TREE)
1679         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1680             return v.visitYield(this, d);
1681         }
1682         @Override
1683         public Tag getTag() {
1684             return YIELD;
1685         }
1686     }
1687 
1688     /**
1689      * A continue of a loop.
1690      */
1691     public static class JCContinue extends JCStatement implements ContinueTree {
1692         public Name label;
1693         public JCTree target;
1694         protected JCContinue(Name label, JCTree target) {
1695             this.label = label;
1696             this.target = target;
1697         }
1698         @Override
1699         public void accept(Visitor v) { v.visitContinue(this); }
1700 
1701         @DefinedBy(Api.COMPILER_TREE)
1702         public Kind getKind() { return Kind.CONTINUE; }
1703         @DefinedBy(Api.COMPILER_TREE)
1704         public Name getLabel() { return label; }
1705         @Override @DefinedBy(Api.COMPILER_TREE)
1706         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1707             return v.visitContinue(this, d);
1708         }
1709         @Override
1710         public Tag getTag() {
1711             return CONTINUE;
1712         }
1713     }
1714 
1715     /**
1716      * A return statement.
1717      */
1718     public static class JCReturn extends JCStatement implements ReturnTree {
1719         public JCExpression expr;
1720         protected JCReturn(JCExpression expr) {
1721             this.expr = expr;
1722         }
1723         @Override
1724         public void accept(Visitor v) { v.visitReturn(this); }
1725 
1726         @DefinedBy(Api.COMPILER_TREE)
1727         public Kind getKind() { return Kind.RETURN; }
1728         @DefinedBy(Api.COMPILER_TREE)
1729         public JCExpression getExpression() { return expr; }
1730         @Override @DefinedBy(Api.COMPILER_TREE)
1731         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1732             return v.visitReturn(this, d);
1733         }
1734         @Override
1735         public Tag getTag() {
1736             return RETURN;
1737         }
1738     }
1739 
1740     /**
1741      * A throw statement.
1742      */
1743     public static class JCThrow extends JCStatement implements ThrowTree {
1744         public JCExpression expr;
1745         protected JCThrow(JCExpression expr) {
1746             this.expr = expr;
1747         }
1748         @Override
1749         public void accept(Visitor v) { v.visitThrow(this); }
1750 
1751         @DefinedBy(Api.COMPILER_TREE)
1752         public Kind getKind() { return Kind.THROW; }
1753         @DefinedBy(Api.COMPILER_TREE)
1754         public JCExpression getExpression() { return expr; }
1755         @Override @DefinedBy(Api.COMPILER_TREE)
1756         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1757             return v.visitThrow(this, d);
1758         }
1759         @Override
1760         public Tag getTag() {
1761             return THROW;
1762         }
1763     }
1764 
1765     /**
1766      * An assert statement.
1767      */
1768     public static class JCAssert extends JCStatement implements AssertTree {
1769         public JCExpression cond;
1770         public JCExpression detail;
1771         protected JCAssert(JCExpression cond, JCExpression detail) {
1772             this.cond = cond;
1773             this.detail = detail;
1774         }
1775         @Override
1776         public void accept(Visitor v) { v.visitAssert(this); }
1777 
1778         @DefinedBy(Api.COMPILER_TREE)
1779         public Kind getKind() { return Kind.ASSERT; }
1780         @DefinedBy(Api.COMPILER_TREE)
1781         public JCExpression getCondition() { return cond; }
1782         @DefinedBy(Api.COMPILER_TREE)
1783         public JCExpression getDetail() { return detail; }
1784         @Override @DefinedBy(Api.COMPILER_TREE)
1785         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1786             return v.visitAssert(this, d);
1787         }
1788         @Override
1789         public Tag getTag() {
1790             return ASSERT;
1791         }
1792     }
1793 
1794     /**
1795      * A method invocation
1796      */
1797     public static class JCMethodInvocation extends JCPolyExpression implements MethodInvocationTree {
1798         public List<JCExpression> typeargs;
1799         public JCExpression meth;
1800         public List<JCExpression> args;
1801         public Type varargsElement;
1802         protected JCMethodInvocation(List<JCExpression> typeargs,
1803                         JCExpression meth,
1804                         List<JCExpression> args)
1805         {
1806             this.typeargs = (typeargs == null) ? List.nil()
1807                                                : typeargs;
1808             this.meth = meth;
1809             this.args = args;
1810         }
1811         @Override
1812         public void accept(Visitor v) { v.visitApply(this); }
1813 
1814         @DefinedBy(Api.COMPILER_TREE)
1815         public Kind getKind() { return Kind.METHOD_INVOCATION; }
1816         @DefinedBy(Api.COMPILER_TREE)
1817         public List<JCExpression> getTypeArguments() {
1818             return typeargs;
1819         }
1820         @DefinedBy(Api.COMPILER_TREE)
1821         public JCExpression getMethodSelect() { return meth; }
1822         @DefinedBy(Api.COMPILER_TREE)
1823         public List<JCExpression> getArguments() {
1824             return args;
1825         }
1826         @Override @DefinedBy(Api.COMPILER_TREE)
1827         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1828             return v.visitMethodInvocation(this, d);
1829         }
1830         @Override
1831         public JCMethodInvocation setType(Type type) {
1832             super.setType(type);
1833             return this;
1834         }
1835         @Override
1836         public Tag getTag() {
1837             return(APPLY);
1838         }
1839     }
1840 
1841     /**
1842      * A new(...) operation.
1843      */
1844     public static class JCNewClass extends JCPolyExpression implements NewClassTree {
1845         public JCExpression encl;
1846         public List<JCExpression> typeargs;
1847         public JCExpression clazz;
1848         public List<JCExpression> args;
1849         public JCClassDecl def;
1850         public Symbol constructor;
1851         public Type varargsElement;
1852         public Type constructorType;
1853         protected JCNewClass(JCExpression encl,
1854                            List<JCExpression> typeargs,
1855                            JCExpression clazz,
1856                            List<JCExpression> args,
1857                            JCClassDecl def)
1858         {
1859             this.encl = encl;
1860             this.typeargs = (typeargs == null) ? List.nil()
1861                                                : typeargs;
1862             this.clazz = clazz;
1863             this.args = args;
1864             this.def = def;
1865         }
1866         @Override
1867         public void accept(Visitor v) { v.visitNewClass(this); }
1868 
1869         @DefinedBy(Api.COMPILER_TREE)
1870         public Kind getKind() { return Kind.NEW_CLASS; }
1871         @DefinedBy(Api.COMPILER_TREE)
1872         public JCExpression getEnclosingExpression() { // expr.new C< ... > ( ... )
1873             return encl;
1874         }
1875         @DefinedBy(Api.COMPILER_TREE)
1876         public List<JCExpression> getTypeArguments() {
1877             return typeargs;
1878         }
1879         @DefinedBy(Api.COMPILER_TREE)
1880         public JCExpression getIdentifier() { return clazz; }
1881         @DefinedBy(Api.COMPILER_TREE)
1882         public List<JCExpression> getArguments() {
1883             return args;
1884         }
1885         @DefinedBy(Api.COMPILER_TREE)
1886         public JCClassDecl getClassBody() { return def; }
1887         @Override @DefinedBy(Api.COMPILER_TREE)
1888         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1889             return v.visitNewClass(this, d);
1890         }
1891         @Override
1892         public Tag getTag() {
1893             return NEWCLASS;
1894         }
1895 
1896         public boolean classDeclRemoved() {
1897             return false;
1898         }
1899     }
1900 
1901     /**
1902      * A new[...] operation.
1903      */
1904     public static class JCNewArray extends JCExpression implements NewArrayTree {
1905         public JCExpression elemtype;
1906         public List<JCExpression> dims;
1907         // type annotations on inner-most component
1908         public List<JCAnnotation> annotations;
1909         // type annotations on dimensions
1910         public List<List<JCAnnotation>> dimAnnotations;
1911         public List<JCExpression> elems;
1912         protected JCNewArray(JCExpression elemtype,
1913                            List<JCExpression> dims,
1914                            List<JCExpression> elems)
1915         {
1916             this.elemtype = elemtype;
1917             this.dims = dims;
1918             this.annotations = List.nil();
1919             this.dimAnnotations = List.nil();
1920             this.elems = elems;
1921         }
1922         @Override
1923         public void accept(Visitor v) { v.visitNewArray(this); }
1924 
1925         @DefinedBy(Api.COMPILER_TREE)
1926         public Kind getKind() { return Kind.NEW_ARRAY; }
1927         @DefinedBy(Api.COMPILER_TREE)
1928         public JCExpression getType() { return elemtype; }
1929         @DefinedBy(Api.COMPILER_TREE)
1930         public List<JCExpression> getDimensions() {
1931             return dims;
1932         }
1933         @DefinedBy(Api.COMPILER_TREE)
1934         public List<JCExpression> getInitializers() {
1935             return elems;
1936         }
1937         @Override @DefinedBy(Api.COMPILER_TREE)
1938         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1939             return v.visitNewArray(this, d);
1940         }
1941         @Override
1942         public Tag getTag() {
1943             return NEWARRAY;
1944         }
1945 
1946         @Override @DefinedBy(Api.COMPILER_TREE)
1947         public List<JCAnnotation> getAnnotations() {
1948             return annotations;
1949         }
1950 
1951         @Override @DefinedBy(Api.COMPILER_TREE)
1952         public List<List<JCAnnotation>> getDimAnnotations() {
1953             return dimAnnotations;
1954         }
1955     }
1956 
1957     /**
1958      * A lambda expression.
1959      */
1960     public static class JCLambda extends JCFunctionalExpression implements LambdaExpressionTree {
1961 
1962         public enum ParameterKind {
1963             IMPLICIT,
1964             EXPLICIT
1965         }
1966 
1967         public List<JCVariableDecl> params;
1968         public JCTree body;
1969         public boolean canCompleteNormally = true;
1970         public ParameterKind paramKind;
1971 
1972         public JCLambda(List<JCVariableDecl> params,
1973                         JCTree body) {
1974             this.params = params;
1975             this.body = body;
1976             if (params.isEmpty() ||
1977                 params.head.vartype != null) {
1978                 paramKind = ParameterKind.EXPLICIT;
1979             } else {
1980                 paramKind = ParameterKind.IMPLICIT;
1981             }
1982         }
1983         @Override
1984         public Tag getTag() {
1985             return LAMBDA;
1986         }
1987         @Override
1988         public void accept(Visitor v) {
1989             v.visitLambda(this);
1990         }
1991         @Override @DefinedBy(Api.COMPILER_TREE)
1992         public <R, D> R accept(TreeVisitor<R, D> v, D d) {
1993             return v.visitLambdaExpression(this, d);
1994         }
1995         @DefinedBy(Api.COMPILER_TREE)
1996         public Kind getKind() {
1997             return Kind.LAMBDA_EXPRESSION;
1998         }
1999         @DefinedBy(Api.COMPILER_TREE)
2000         public JCTree getBody() {
2001             return body;
2002         }
2003         @DefinedBy(Api.COMPILER_TREE)
2004         public java.util.List<? extends VariableTree> getParameters() {
2005             return params;
2006         }
2007         @Override
2008         public JCLambda setType(Type type) {
2009             super.setType(type);
2010             return this;
2011         }
2012         @Override @DefinedBy(Api.COMPILER_TREE)
2013         public BodyKind getBodyKind() {
2014             return body.hasTag(BLOCK) ?
2015                     BodyKind.STATEMENT :
2016                     BodyKind.EXPRESSION;
2017         }
2018     }
2019 
2020     /**
2021      * A parenthesized subexpression ( ... )
2022      */
2023     public static class JCParens extends JCExpression implements ParenthesizedTree {
2024         public JCExpression expr;
2025         protected JCParens(JCExpression expr) {
2026             this.expr = expr;
2027         }
2028         @Override
2029         public void accept(Visitor v) { v.visitParens(this); }
2030 
2031         @DefinedBy(Api.COMPILER_TREE)
2032         public Kind getKind() { return Kind.PARENTHESIZED; }
2033         @DefinedBy(Api.COMPILER_TREE)
2034         public JCExpression getExpression() { return expr; }
2035         @Override @DefinedBy(Api.COMPILER_TREE)
2036         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2037             return v.visitParenthesized(this, d);
2038         }
2039         @Override
2040         public Tag getTag() {
2041             return PARENS;
2042         }
2043     }
2044 
2045     /**
2046      * A assignment with "=".
2047      */
2048     public static class JCAssign extends JCExpression implements AssignmentTree {
2049         public JCExpression lhs;
2050         public JCExpression rhs;
2051         protected JCAssign(JCExpression lhs, JCExpression rhs) {
2052             this.lhs = lhs;
2053             this.rhs = rhs;
2054         }
2055         @Override
2056         public void accept(Visitor v) { v.visitAssign(this); }
2057 
2058         @DefinedBy(Api.COMPILER_TREE)
2059         public Kind getKind() { return Kind.ASSIGNMENT; }
2060         @DefinedBy(Api.COMPILER_TREE)
2061         public JCExpression getVariable() { return lhs; }
2062         @DefinedBy(Api.COMPILER_TREE)
2063         public JCExpression getExpression() { return rhs; }
2064         @Override @DefinedBy(Api.COMPILER_TREE)
2065         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2066             return v.visitAssignment(this, d);
2067         }
2068         @Override
2069         public Tag getTag() {
2070             return ASSIGN;
2071         }
2072     }
2073 
2074     public abstract static class JCOperatorExpression extends JCExpression {
2075         public enum OperandPos {
2076             LEFT,
2077             RIGHT
2078         }
2079 
2080         protected Tag opcode;
2081         public OperatorSymbol operator;
2082 
2083         public OperatorSymbol getOperator() {
2084             return operator;
2085         }
2086 
2087         @Override
2088         public Tag getTag() {
2089             return opcode;
2090         }
2091 
2092         public abstract JCExpression getOperand(OperandPos pos);
2093     }
2094 
2095     /**
2096      * An assignment with "+=", "|=" ...
2097      */
2098     public static class JCAssignOp extends JCOperatorExpression implements CompoundAssignmentTree {
2099         public JCExpression lhs;
2100         public JCExpression rhs;
2101         protected JCAssignOp(Tag opcode, JCTree lhs, JCTree rhs, OperatorSymbol operator) {
2102             this.opcode = opcode;
2103             this.lhs = (JCExpression)lhs;
2104             this.rhs = (JCExpression)rhs;
2105             this.operator = operator;
2106         }
2107         @Override
2108         public void accept(Visitor v) { v.visitAssignop(this); }
2109 
2110         @DefinedBy(Api.COMPILER_TREE)
2111         public Kind getKind() { return TreeInfo.tagToKind(getTag()); }
2112         @DefinedBy(Api.COMPILER_TREE)
2113         public JCExpression getVariable() { return lhs; }
2114         @DefinedBy(Api.COMPILER_TREE)
2115         public JCExpression getExpression() { return rhs; }
2116         @Override @DefinedBy(Api.COMPILER_TREE)
2117         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2118             return v.visitCompoundAssignment(this, d);
2119         }
2120         @Override
2121         public JCExpression getOperand(OperandPos pos) {
2122             return pos == OperandPos.LEFT ? lhs : rhs;
2123         }
2124     }
2125 
2126     /**
2127      * A unary operation.
2128      */
2129     public static class JCUnary extends JCOperatorExpression implements UnaryTree {
2130         public JCExpression arg;
2131         protected JCUnary(Tag opcode, JCExpression arg) {
2132             this.opcode = opcode;
2133             this.arg = arg;
2134         }
2135         @Override
2136         public void accept(Visitor v) { v.visitUnary(this); }
2137 
2138         @DefinedBy(Api.COMPILER_TREE)
2139         public Kind getKind() { return TreeInfo.tagToKind(getTag()); }
2140         @DefinedBy(Api.COMPILER_TREE)
2141         public JCExpression getExpression() { return arg; }
2142         @Override @DefinedBy(Api.COMPILER_TREE)
2143         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2144             return v.visitUnary(this, d);
2145         }
2146         public void setTag(Tag tag) {
2147             opcode = tag;
2148         }
2149         @Override
2150         public JCExpression getOperand(OperandPos pos) {
2151             return arg;
2152         }
2153     }
2154 
2155     /**
2156      * A binary operation.
2157      */
2158     public static class JCBinary extends JCOperatorExpression implements BinaryTree {
2159         public JCExpression lhs;
2160         public JCExpression rhs;
2161         protected JCBinary(Tag opcode,
2162                          JCExpression lhs,
2163                          JCExpression rhs,
2164                          OperatorSymbol operator) {
2165             this.opcode = opcode;
2166             this.lhs = lhs;
2167             this.rhs = rhs;
2168             this.operator = operator;
2169         }
2170         @Override
2171         public void accept(Visitor v) { v.visitBinary(this); }
2172 
2173         @DefinedBy(Api.COMPILER_TREE)
2174         public Kind getKind() { return TreeInfo.tagToKind(getTag()); }
2175         @DefinedBy(Api.COMPILER_TREE)
2176         public JCExpression getLeftOperand() { return lhs; }
2177         @DefinedBy(Api.COMPILER_TREE)
2178         public JCExpression getRightOperand() { return rhs; }
2179         @Override @DefinedBy(Api.COMPILER_TREE)
2180         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2181             return v.visitBinary(this, d);
2182         }
2183         @Override
2184         public JCExpression getOperand(OperandPos pos) {
2185             return pos == OperandPos.LEFT ? lhs : rhs;
2186         }
2187     }
2188 
2189     /**
2190      * A type cast.
2191      */
2192     public static class JCTypeCast extends JCExpression implements TypeCastTree {
2193         public JCTree clazz;
2194         public JCExpression expr;
2195         protected JCTypeCast(JCTree clazz, JCExpression expr) {
2196             this.clazz = clazz;
2197             this.expr = expr;
2198         }
2199         @Override
2200         public void accept(Visitor v) { v.visitTypeCast(this); }
2201 
2202         @DefinedBy(Api.COMPILER_TREE)
2203         public Kind getKind() { return Kind.TYPE_CAST; }
2204         @DefinedBy(Api.COMPILER_TREE)
2205         public JCTree getType() { return clazz; }
2206         @DefinedBy(Api.COMPILER_TREE)
2207         public JCExpression getExpression() { return expr; }
2208         @Override @DefinedBy(Api.COMPILER_TREE)
2209         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2210             return v.visitTypeCast(this, d);
2211         }
2212         @Override
2213         public Tag getTag() {
2214             return TYPECAST;
2215         }
2216     }
2217 
2218     /**
2219      * A type test.
2220      */
2221     public static class JCInstanceOf extends JCExpression implements InstanceOfTree {
2222         public JCExpression expr;
2223         public JCTree pattern;
2224         /**{@code true} if this instanceof test should have
2225          * value {@code true} when the {@code expr} is {@code null}.*/
2226         public boolean allowNull;
2227         protected JCInstanceOf(JCExpression expr, JCTree pattern) {
2228             this.expr = expr;
2229             this.pattern = pattern;
2230         }
2231         @Override
2232         public void accept(Visitor v) { v.visitTypeTest(this); }
2233 
2234         @DefinedBy(Api.COMPILER_TREE)
2235         public Kind getKind() { return Kind.INSTANCE_OF; }
2236         @DefinedBy(Api.COMPILER_TREE)
2237         public JCTree getType() { return pattern instanceof JCPattern ? pattern.hasTag(BINDINGPATTERN) ? ((JCBindingPattern) pattern).var.vartype : null : pattern; }
2238 
2239         @Override @DefinedBy(Api.COMPILER_TREE)
2240         public JCPattern getPattern() {
2241             return pattern instanceof JCPattern jcPattern ? jcPattern : null;
2242         }
2243 
2244         @DefinedBy(Api.COMPILER_TREE)
2245         public JCExpression getExpression() { return expr; }
2246         @Override @DefinedBy(Api.COMPILER_TREE)
2247         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2248             return v.visitInstanceOf(this, d);
2249         }
2250         @Override
2251         public Tag getTag() {
2252             return TYPETEST;
2253         }
2254     }
2255 
2256     /**
2257      * Pattern matching forms.
2258      */
2259     public abstract static class JCPattern extends JCTree
2260             implements PatternTree {
2261     }
2262 
2263     public static class JCAnyPattern extends JCPattern
2264             implements AnyPatternTree {
2265 
2266         protected JCAnyPattern() {
2267         }
2268 
2269         @Override
2270         public void accept(Visitor v) {
2271             v.visitAnyPattern(this);
2272         }
2273 
2274         @DefinedBy(Api.COMPILER_TREE)
2275         public Kind getKind() {
2276             return Kind.ANY_PATTERN;
2277         }
2278 
2279         @Override
2280         @DefinedBy(Api.COMPILER_TREE)
2281         public <R, D> R accept(TreeVisitor<R, D> v, D d) {
2282             return v.visitAnyPattern(this, d);
2283         }
2284 
2285         @Override
2286         public Tag getTag() {
2287             return ANYPATTERN;
2288         }
2289     }
2290 
2291     public static class JCBindingPattern extends JCPattern
2292             implements BindingPatternTree {
2293         public JCVariableDecl var;
2294 
2295         protected JCBindingPattern(JCVariableDecl var) {
2296             this.var = var;
2297         }
2298 
2299         @Override @DefinedBy(Api.COMPILER_TREE)
2300         public VariableTree getVariable() {
2301             return var;
2302         }
2303 
2304         @Override
2305         public void accept(Visitor v) {
2306             v.visitBindingPattern(this);
2307         }
2308 
2309         @DefinedBy(Api.COMPILER_TREE)
2310         public Kind getKind() {
2311             return Kind.BINDING_PATTERN;
2312         }
2313 
2314         @Override
2315         @DefinedBy(Api.COMPILER_TREE)
2316         public <R, D> R accept(TreeVisitor<R, D> v, D d) {
2317             return v.visitBindingPattern(this, d);
2318         }
2319 
2320         @Override
2321         public Tag getTag() {
2322             return BINDINGPATTERN;
2323         }
2324     }
2325 
2326     public static class JCDefaultCaseLabel extends JCCaseLabel
2327             implements DefaultCaseLabelTree {
2328 
2329         protected JCDefaultCaseLabel() {
2330         }
2331 
2332         @Override
2333         public void accept(Visitor v) {
2334             v.visitDefaultCaseLabel(this);
2335         }
2336 
2337         @DefinedBy(Api.COMPILER_TREE)
2338         public Kind getKind() {
2339             return Kind.DEFAULT_CASE_LABEL;
2340         }
2341 
2342         @Override
2343         @DefinedBy(Api.COMPILER_TREE)
2344         public <R, D> R accept(TreeVisitor<R, D> v, D d) {
2345             return v.visitDefaultCaseLabel(this, d);
2346         }
2347 
2348         @Override
2349         public Tag getTag() {
2350             return DEFAULTCASELABEL;
2351         }
2352 
2353     }
2354 
2355     public static class JCConstantCaseLabel extends JCCaseLabel
2356             implements ConstantCaseLabelTree {
2357 
2358         public JCExpression expr;
2359 
2360         protected JCConstantCaseLabel(JCExpression expr) {
2361             this.expr = expr;
2362         }
2363 
2364         @Override @DefinedBy(Api.COMPILER_TREE)
2365         public JCExpression getConstantExpression() {
2366             return expr;
2367         }
2368 
2369         @Override
2370         public void accept(Visitor v) {
2371             v.visitConstantCaseLabel(this);
2372         }
2373 
2374         @DefinedBy(Api.COMPILER_TREE)
2375         public Kind getKind() {
2376             return Kind.CONSTANT_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.visitConstantCaseLabel(this, d);
2383         }
2384 
2385         @Override
2386         public Tag getTag() {
2387             return CONSTANTCASELABEL;
2388         }
2389 
2390     }
2391 
2392     public static class JCPatternCaseLabel extends JCCaseLabel
2393             implements PatternCaseLabelTree {
2394 
2395         public JCPattern pat;
2396         public JCExpression syntheticGuard;
2397 
2398         protected JCPatternCaseLabel(JCPattern pat) {
2399             this.pat = pat;
2400         }
2401 
2402         @Override @DefinedBy(Api.COMPILER_TREE)
2403         public JCPattern getPattern() {
2404             return pat;
2405         }
2406 
2407         @Override
2408         public void accept(Visitor v) {
2409             v.visitPatternCaseLabel(this);
2410         }
2411 
2412         @DefinedBy(Api.COMPILER_TREE)
2413         public Kind getKind() {
2414             return Kind.PATTERN_CASE_LABEL;
2415         }
2416 
2417         @Override
2418         @DefinedBy(Api.COMPILER_TREE)
2419         public <R, D> R accept(TreeVisitor<R, D> v, D d) {
2420             return v.visitPatternCaseLabel(this, d);
2421         }
2422 
2423         @Override
2424         public Tag getTag() {
2425             return PATTERNCASELABEL;
2426         }
2427 
2428     }
2429 
2430     public static class JCRecordPattern extends JCPattern
2431             implements DeconstructionPatternTree {
2432         public JCExpression deconstructor;
2433         public List<JCPattern> nested;
2434         public ClassSymbol record;
2435         public List<Type> fullComponentTypes;
2436 
2437         protected JCRecordPattern(JCExpression deconstructor, List<JCPattern> nested) {
2438             this.deconstructor = deconstructor;
2439             this.nested = nested;
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     }
2479 
2480     /**
2481      * An array selection
2482      */
2483     public static class JCArrayAccess extends JCExpression implements ArrayAccessTree {
2484         public JCExpression indexed;
2485         public JCExpression index;
2486         protected JCArrayAccess(JCExpression indexed, JCExpression index) {
2487             this.indexed = indexed;
2488             this.index = index;
2489         }
2490         @Override
2491         public void accept(Visitor v) { v.visitIndexed(this); }
2492 
2493         @DefinedBy(Api.COMPILER_TREE)
2494         public Kind getKind() { return Kind.ARRAY_ACCESS; }
2495         @DefinedBy(Api.COMPILER_TREE)
2496         public JCExpression getExpression() { return indexed; }
2497         @DefinedBy(Api.COMPILER_TREE)
2498         public JCExpression getIndex() { return index; }
2499         @Override @DefinedBy(Api.COMPILER_TREE)
2500         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2501             return v.visitArrayAccess(this, d);
2502         }
2503         @Override
2504         public Tag getTag() {
2505             return INDEXED;
2506         }
2507     }
2508 
2509     /**
2510      * Selects through packages and classes
2511      */
2512     public static class JCFieldAccess extends JCExpression implements MemberSelectTree {
2513         /** selected Tree hierarchy */
2514         public JCExpression selected;
2515         /** name of field to select thru */
2516         public Name name;
2517         /** symbol of the selected class */
2518         public Symbol sym;
2519         protected JCFieldAccess(JCExpression selected, Name name, Symbol sym) {
2520             this.selected = selected;
2521             this.name = name;
2522             this.sym = sym;
2523         }
2524         @Override
2525         public void accept(Visitor v) { v.visitSelect(this); }
2526 
2527         @DefinedBy(Api.COMPILER_TREE)
2528         public Kind getKind() { return Kind.MEMBER_SELECT; }
2529         @DefinedBy(Api.COMPILER_TREE)
2530         public JCExpression getExpression() { return selected; }
2531         @Override @DefinedBy(Api.COMPILER_TREE)
2532         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2533             return v.visitMemberSelect(this, d);
2534         }
2535         @DefinedBy(Api.COMPILER_TREE)
2536         public Name getIdentifier() { return name; }
2537         @Override
2538         public Tag getTag() {
2539             return SELECT;
2540         }
2541     }
2542 
2543     /**
2544      * Selects a member expression.
2545      */
2546     public static class JCMemberReference extends JCFunctionalExpression implements MemberReferenceTree {
2547 
2548         public ReferenceMode mode;
2549         public ReferenceKind kind;
2550         public Name name;
2551         public JCExpression expr;
2552         public List<JCExpression> typeargs;
2553         public Symbol sym;
2554         public Type varargsElement;
2555         public PolyKind refPolyKind;
2556         public boolean ownerAccessible;
2557         private OverloadKind overloadKind;
2558         public Type referentType;
2559 
2560         public enum OverloadKind {
2561             OVERLOADED,
2562             UNOVERLOADED,
2563             ERROR
2564         }
2565 
2566         /**
2567          * Javac-dependent classification for member references, based
2568          * on relevant properties w.r.t. code-generation
2569          */
2570         public enum ReferenceKind {
2571             /** super # instMethod */
2572             SUPER(ReferenceMode.INVOKE, false),
2573             /** Type # instMethod */
2574             UNBOUND(ReferenceMode.INVOKE, true),
2575             /** Type # staticMethod */
2576             STATIC(ReferenceMode.INVOKE, false),
2577             /** Expr # instMethod */
2578             BOUND(ReferenceMode.INVOKE, false),
2579             /** Inner # new */
2580             IMPLICIT_INNER(ReferenceMode.NEW, false),
2581             /** Toplevel # new */
2582             TOPLEVEL(ReferenceMode.NEW, false),
2583             /** ArrayType # new */
2584             ARRAY_CTOR(ReferenceMode.NEW, false);
2585 
2586             final ReferenceMode mode;
2587             final boolean unbound;
2588 
2589             private ReferenceKind(ReferenceMode mode, boolean unbound) {
2590                 this.mode = mode;
2591                 this.unbound = unbound;
2592             }
2593 
2594             public boolean isUnbound() {
2595                 return unbound;
2596             }
2597         }
2598 
2599         public JCMemberReference(ReferenceMode mode, Name name, JCExpression expr, List<JCExpression> typeargs) {
2600             this.mode = mode;
2601             this.name = name;
2602             this.expr = expr;
2603             this.typeargs = typeargs;
2604         }
2605         @Override
2606         public void accept(Visitor v) { v.visitReference(this); }
2607 
2608         @DefinedBy(Api.COMPILER_TREE)
2609         public Kind getKind() { return Kind.MEMBER_REFERENCE; }
2610         @Override @DefinedBy(Api.COMPILER_TREE)
2611         public ReferenceMode getMode() { return mode; }
2612         @Override @DefinedBy(Api.COMPILER_TREE)
2613         public JCExpression getQualifierExpression() { return expr; }
2614         @Override @DefinedBy(Api.COMPILER_TREE)
2615         public Name getName() { return name; }
2616         @Override @DefinedBy(Api.COMPILER_TREE)
2617         public List<JCExpression> getTypeArguments() { return typeargs; }
2618 
2619         @Override @DefinedBy(Api.COMPILER_TREE)
2620         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2621             return v.visitMemberReference(this, d);
2622         }
2623         @Override
2624         public Tag getTag() {
2625             return REFERENCE;
2626         }
2627         public boolean hasKind(ReferenceKind kind) {
2628             return this.kind == kind;
2629         }
2630 
2631         /**
2632          * @return the overloadKind
2633          */
2634         public OverloadKind getOverloadKind() {
2635             return overloadKind;
2636         }
2637 
2638         /**
2639          * @param overloadKind the overloadKind to set
2640          */
2641         public void setOverloadKind(OverloadKind overloadKind) {
2642             this.overloadKind = overloadKind;
2643         }
2644     }
2645 
2646     /**
2647      * An identifier
2648      */
2649     public static class JCIdent extends JCExpression implements IdentifierTree {
2650         /** the name */
2651         public Name name;
2652         /** the symbol */
2653         public Symbol sym;
2654         protected JCIdent(Name name, Symbol sym) {
2655             this.name = name;
2656             this.sym = sym;
2657         }
2658         @Override
2659         public void accept(Visitor v) { v.visitIdent(this); }
2660 
2661         @DefinedBy(Api.COMPILER_TREE)
2662         public Kind getKind() { return Kind.IDENTIFIER; }
2663         @DefinedBy(Api.COMPILER_TREE)
2664         public Name getName() { return name; }
2665         @Override @DefinedBy(Api.COMPILER_TREE)
2666         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2667             return v.visitIdentifier(this, d);
2668         }
2669         @Override
2670         public Tag getTag() {
2671             return IDENT;
2672         }
2673     }
2674 
2675     /**
2676      * A constant value given literally.
2677      */
2678     public static class JCLiteral extends JCExpression implements LiteralTree {
2679         public TypeTag typetag;
2680         /** value representation */
2681         public Object value;
2682         protected JCLiteral(TypeTag typetag, Object value) {
2683             this.typetag = typetag;
2684             this.value = value;
2685         }
2686         @Override
2687         public void accept(Visitor v) { v.visitLiteral(this); }
2688 
2689         @DefinedBy(Api.COMPILER_TREE)
2690         public Kind getKind() {
2691             return typetag.getKindLiteral();
2692         }
2693 
2694         @DefinedBy(Api.COMPILER_TREE)
2695         public Object getValue() {
2696             switch (typetag) {
2697                 case BOOLEAN:
2698                     int bi = (Integer) value;
2699                     return (bi != 0);
2700                 case CHAR:
2701                     int ci = (Integer) value;
2702                     char c = (char) ci;
2703                     if (c != ci)
2704                         throw new AssertionError("bad value for char literal");
2705                     return c;
2706                 default:
2707                     return value;
2708             }
2709         }
2710         @Override @DefinedBy(Api.COMPILER_TREE)
2711         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2712             return v.visitLiteral(this, d);
2713         }
2714         @Override
2715         public JCLiteral setType(Type type) {
2716             super.setType(type);
2717             return this;
2718         }
2719         @Override
2720         public Tag getTag() {
2721             return LITERAL;
2722         }
2723     }
2724 
2725     /**
2726      * Identifies a basic type.
2727      * @see TypeTag
2728      */
2729     public static class JCPrimitiveTypeTree extends JCExpression implements PrimitiveTypeTree {
2730         /** the basic type id */
2731         public TypeTag typetag;
2732         protected JCPrimitiveTypeTree(TypeTag typetag) {
2733             this.typetag = typetag;
2734         }
2735         @Override
2736         public void accept(Visitor v) { v.visitTypeIdent(this); }
2737 
2738         @DefinedBy(Api.COMPILER_TREE)
2739         public Kind getKind() { return Kind.PRIMITIVE_TYPE; }
2740         @DefinedBy(Api.COMPILER_TREE)
2741         public TypeKind getPrimitiveTypeKind() {
2742             return typetag.getPrimitiveTypeKind();
2743         }
2744 
2745         @Override @DefinedBy(Api.COMPILER_TREE)
2746         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2747             return v.visitPrimitiveType(this, d);
2748         }
2749         @Override
2750         public Tag getTag() {
2751             return TYPEIDENT;
2752         }
2753     }
2754 
2755     /**
2756      * An array type, A[]
2757      */
2758     public static class JCArrayTypeTree extends JCExpression implements ArrayTypeTree {
2759         public JCExpression elemtype;
2760         protected JCArrayTypeTree(JCExpression elemtype) {
2761             this.elemtype = elemtype;
2762         }
2763         @Override
2764         public void accept(Visitor v) { v.visitTypeArray(this); }
2765 
2766         @DefinedBy(Api.COMPILER_TREE)
2767         public Kind getKind() { return Kind.ARRAY_TYPE; }
2768         @DefinedBy(Api.COMPILER_TREE)
2769         public JCTree getType() { return elemtype; }
2770         @Override @DefinedBy(Api.COMPILER_TREE)
2771         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2772             return v.visitArrayType(this, d);
2773         }
2774         @Override
2775         public Tag getTag() {
2776             return TYPEARRAY;
2777         }
2778     }
2779 
2780     /**
2781      * A parameterized type, {@literal T<...>}
2782      */
2783     public static class JCTypeApply extends JCExpression implements ParameterizedTypeTree {
2784         public JCExpression clazz;
2785         public List<JCExpression> arguments;
2786         protected JCTypeApply(JCExpression clazz, List<JCExpression> arguments) {
2787             this.clazz = clazz;
2788             this.arguments = arguments;
2789         }
2790         @Override
2791         public void accept(Visitor v) { v.visitTypeApply(this); }
2792 
2793         @DefinedBy(Api.COMPILER_TREE)
2794         public Kind getKind() { return Kind.PARAMETERIZED_TYPE; }
2795         @DefinedBy(Api.COMPILER_TREE)
2796         public JCTree getType() { return clazz; }
2797         @DefinedBy(Api.COMPILER_TREE)
2798         public List<JCExpression> getTypeArguments() {
2799             return arguments;
2800         }
2801         @Override @DefinedBy(Api.COMPILER_TREE)
2802         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2803             return v.visitParameterizedType(this, d);
2804         }
2805         @Override
2806         public Tag getTag() {
2807             return TYPEAPPLY;
2808         }
2809     }
2810 
2811     /**
2812      * A union type, T1 | T2 | ... Tn (used in multicatch statements)
2813      */
2814     public static class JCTypeUnion extends JCExpression implements UnionTypeTree {
2815 
2816         public List<JCExpression> alternatives;
2817 
2818         protected JCTypeUnion(List<JCExpression> components) {
2819             this.alternatives = components;
2820         }
2821         @Override
2822         public void accept(Visitor v) { v.visitTypeUnion(this); }
2823 
2824         @DefinedBy(Api.COMPILER_TREE)
2825         public Kind getKind() { return Kind.UNION_TYPE; }
2826 
2827         @DefinedBy(Api.COMPILER_TREE)
2828         public List<JCExpression> getTypeAlternatives() {
2829             return alternatives;
2830         }
2831         @Override @DefinedBy(Api.COMPILER_TREE)
2832         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2833             return v.visitUnionType(this, d);
2834         }
2835         @Override
2836         public Tag getTag() {
2837             return TYPEUNION;
2838         }
2839     }
2840 
2841     /**
2842      * An intersection type, {@code T1 & T2 & ... Tn} (used in cast expressions)
2843      */
2844     public static class JCTypeIntersection extends JCExpression implements IntersectionTypeTree {
2845 
2846         public List<JCExpression> bounds;
2847 
2848         protected JCTypeIntersection(List<JCExpression> bounds) {
2849             this.bounds = bounds;
2850         }
2851         @Override
2852         public void accept(Visitor v) { v.visitTypeIntersection(this); }
2853 
2854         @DefinedBy(Api.COMPILER_TREE)
2855         public Kind getKind() { return Kind.INTERSECTION_TYPE; }
2856 
2857         @DefinedBy(Api.COMPILER_TREE)
2858         public List<JCExpression> getBounds() {
2859             return bounds;
2860         }
2861         @Override @DefinedBy(Api.COMPILER_TREE)
2862         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2863             return v.visitIntersectionType(this, d);
2864         }
2865         @Override
2866         public Tag getTag() {
2867             return TYPEINTERSECTION;
2868         }
2869     }
2870 
2871     /**
2872      * A formal class parameter.
2873      */
2874     public static class JCTypeParameter extends JCTree implements TypeParameterTree {
2875         /** name */
2876         public Name name;
2877         /** bounds */
2878         public List<JCExpression> bounds;
2879         /** type annotations on type parameter */
2880         public List<JCAnnotation> annotations;
2881         protected JCTypeParameter(Name name, List<JCExpression> bounds, List<JCAnnotation> annotations) {
2882             this.name = name;
2883             this.bounds = bounds;
2884             this.annotations = annotations;
2885         }
2886         @Override
2887         public void accept(Visitor v) { v.visitTypeParameter(this); }
2888 
2889         @DefinedBy(Api.COMPILER_TREE)
2890         public Kind getKind() { return Kind.TYPE_PARAMETER; }
2891         @DefinedBy(Api.COMPILER_TREE)
2892         public Name getName() { return name; }
2893         @DefinedBy(Api.COMPILER_TREE)
2894         public List<JCExpression> getBounds() {
2895             return bounds;
2896         }
2897         @DefinedBy(Api.COMPILER_TREE)
2898         public List<JCAnnotation> getAnnotations() {
2899             return annotations;
2900         }
2901         @Override @DefinedBy(Api.COMPILER_TREE)
2902         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2903             return v.visitTypeParameter(this, d);
2904         }
2905         @Override
2906         public Tag getTag() {
2907             return TYPEPARAMETER;
2908         }
2909     }
2910 
2911     public static class JCWildcard extends JCExpression implements WildcardTree {
2912         public TypeBoundKind kind;
2913         public JCTree inner;
2914         protected JCWildcard(TypeBoundKind kind, JCTree inner) {
2915             this.kind = Assert.checkNonNull(kind);
2916             this.inner = inner;
2917         }
2918         @Override
2919         public void accept(Visitor v) { v.visitWildcard(this); }
2920 
2921         @DefinedBy(Api.COMPILER_TREE)
2922         public Kind getKind() {
2923             switch (kind.kind) {
2924             case UNBOUND:
2925                 return Kind.UNBOUNDED_WILDCARD;
2926             case EXTENDS:
2927                 return Kind.EXTENDS_WILDCARD;
2928             case SUPER:
2929                 return Kind.SUPER_WILDCARD;
2930             default:
2931                 throw new AssertionError("Unknown wildcard bound " + kind);
2932             }
2933         }
2934         @DefinedBy(Api.COMPILER_TREE)
2935         public JCTree getBound() { return inner; }
2936         @Override @DefinedBy(Api.COMPILER_TREE)
2937         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2938             return v.visitWildcard(this, d);
2939         }
2940         @Override
2941         public Tag getTag() {
2942             return Tag.WILDCARD;
2943         }
2944     }
2945 
2946     public static class TypeBoundKind extends JCTree {
2947         public BoundKind kind;
2948         protected TypeBoundKind(BoundKind kind) {
2949             this.kind = kind;
2950         }
2951         @Override
2952         public void accept(Visitor v) { v.visitTypeBoundKind(this); }
2953 
2954         @DefinedBy(Api.COMPILER_TREE)
2955         public Kind getKind() {
2956             throw new AssertionError("TypeBoundKind is not part of a public API");
2957         }
2958         @Override @DefinedBy(Api.COMPILER_TREE)
2959         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2960             throw new AssertionError("TypeBoundKind is not part of a public API");
2961         }
2962         @Override
2963         public Tag getTag() {
2964             return TYPEBOUNDKIND;
2965         }
2966     }
2967 
2968     public static class JCAnnotation extends JCExpression implements AnnotationTree {
2969         // Either Tag.ANNOTATION or Tag.TYPE_ANNOTATION
2970         private Tag tag;
2971 
2972         public JCTree annotationType;
2973         public List<JCExpression> args;
2974         public Attribute.Compound attribute;
2975 
2976         protected JCAnnotation(Tag tag, JCTree annotationType, List<JCExpression> args) {
2977             this.tag = tag;
2978             this.annotationType = annotationType;
2979             this.args = args;
2980         }
2981 
2982         @Override
2983         public void accept(Visitor v) { v.visitAnnotation(this); }
2984 
2985         @DefinedBy(Api.COMPILER_TREE)
2986         public Kind getKind() { return TreeInfo.tagToKind(getTag()); }
2987 
2988         @DefinedBy(Api.COMPILER_TREE)
2989         public JCTree getAnnotationType() { return annotationType; }
2990         @DefinedBy(Api.COMPILER_TREE)
2991         public List<JCExpression> getArguments() {
2992             return args;
2993         }
2994         @Override @DefinedBy(Api.COMPILER_TREE)
2995         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2996             return v.visitAnnotation(this, d);
2997         }
2998         @Override
2999         public Tag getTag() {
3000             return tag;
3001         }
3002     }
3003 
3004     public static class JCModifiers extends JCTree implements com.sun.source.tree.ModifiersTree {
3005         public long flags;
3006         public List<JCAnnotation> annotations;
3007         protected JCModifiers(long flags, List<JCAnnotation> annotations) {
3008             this.flags = flags;
3009             this.annotations = annotations;
3010         }
3011         @Override
3012         public void accept(Visitor v) { v.visitModifiers(this); }
3013 
3014         @DefinedBy(Api.COMPILER_TREE)
3015         public Kind getKind() { return Kind.MODIFIERS; }
3016         @DefinedBy(Api.COMPILER_TREE)
3017         public Set<Modifier> getFlags() {
3018             return Flags.asModifierSet(flags);
3019         }
3020         @DefinedBy(Api.COMPILER_TREE)
3021         public List<JCAnnotation> getAnnotations() {
3022             return annotations;
3023         }
3024         @Override @DefinedBy(Api.COMPILER_TREE)
3025         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
3026             return v.visitModifiers(this, d);
3027         }
3028         @Override
3029         public Tag getTag() {
3030             return MODIFIERS;
3031         }
3032     }
3033 
3034     public static class JCAnnotatedType extends JCExpression implements com.sun.source.tree.AnnotatedTypeTree {
3035         // type annotations
3036         public List<JCAnnotation> annotations;
3037         public JCExpression underlyingType;
3038 
3039         protected JCAnnotatedType(List<JCAnnotation> annotations, JCExpression underlyingType) {
3040             Assert.check(annotations != null && annotations.nonEmpty());
3041             this.annotations = annotations;
3042             this.underlyingType = underlyingType;
3043         }
3044         @Override
3045         public void accept(Visitor v) { v.visitAnnotatedType(this); }
3046 
3047         @DefinedBy(Api.COMPILER_TREE)
3048         public Kind getKind() { return Kind.ANNOTATED_TYPE; }
3049         @DefinedBy(Api.COMPILER_TREE)
3050         public List<JCAnnotation> getAnnotations() {
3051             return annotations;
3052         }
3053         @DefinedBy(Api.COMPILER_TREE)
3054         public JCExpression getUnderlyingType() {
3055             return underlyingType;
3056         }
3057         @Override @DefinedBy(Api.COMPILER_TREE)
3058         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
3059             return v.visitAnnotatedType(this, d);
3060         }
3061         @Override
3062         public Tag getTag() {
3063             return ANNOTATED_TYPE;
3064         }
3065     }
3066 
3067     public abstract static class JCDirective extends JCTree
3068         implements DirectiveTree {
3069     }
3070 
3071     public static class JCModuleDecl extends JCTree implements ModuleTree {
3072         public JCModifiers mods;
3073         public ModuleType type;
3074         private final ModuleKind kind;
3075         public JCExpression qualId;
3076         public List<JCDirective> directives;
3077         public ModuleSymbol sym;
3078 
3079         protected JCModuleDecl(JCModifiers mods, ModuleKind kind,
3080                 JCExpression qualId, List<JCDirective> directives) {
3081             this.mods = mods;
3082             this.kind = kind;
3083             this.qualId = qualId;
3084             this.directives = directives;
3085         }
3086 
3087         @Override
3088         public void accept(Visitor v) { v.visitModuleDef(this); }
3089 
3090         @Override @DefinedBy(Api.COMPILER_TREE)
3091         public Kind getKind() {
3092             return Kind.MODULE;
3093         }
3094 
3095         @Override @DefinedBy(Api.COMPILER_TREE)
3096         public List<? extends AnnotationTree> getAnnotations() {
3097             return mods.annotations;
3098         }
3099 
3100         @Override @DefinedBy(Api.COMPILER_TREE)
3101         public ModuleKind getModuleType() {
3102             return kind;
3103         }
3104 
3105         @Override @DefinedBy(Api.COMPILER_TREE)
3106         public JCExpression getName() {
3107             return qualId;
3108         }
3109 
3110         @Override @DefinedBy(Api.COMPILER_TREE)
3111         public List<JCDirective> getDirectives() {
3112             return directives;
3113         }
3114 
3115         @Override @DefinedBy(Api.COMPILER_TREE)
3116         public <R, D> R accept(TreeVisitor<R, D> v, D d) {
3117             return v.visitModule(this, d);
3118         }
3119 
3120         @Override
3121         public Tag getTag() {
3122             return MODULEDEF;
3123         }
3124     }
3125 
3126     public static class JCExports extends JCDirective
3127             implements ExportsTree {
3128         public JCExpression qualid;
3129         public List<JCExpression> moduleNames;
3130         public ExportsDirective directive;
3131 
3132         protected JCExports(JCExpression qualId, List<JCExpression> moduleNames) {
3133             this.qualid = qualId;
3134             this.moduleNames = moduleNames;
3135         }
3136 
3137         @Override
3138         public void accept(Visitor v) { v.visitExports(this); }
3139 
3140         @Override @DefinedBy(Api.COMPILER_TREE)
3141         public Kind getKind() {
3142             return Kind.EXPORTS;
3143         }
3144 
3145         @Override @DefinedBy(Api.COMPILER_TREE)
3146         public JCExpression getPackageName() {
3147             return qualid;
3148         }
3149 
3150         @Override @DefinedBy(Api.COMPILER_TREE)
3151         public List<JCExpression> getModuleNames() {
3152             return moduleNames;
3153         }
3154 
3155         @Override @DefinedBy(Api.COMPILER_TREE)
3156         public <R, D> R accept(TreeVisitor<R, D> v, D d) {
3157             return v.visitExports(this, d);
3158         }
3159 
3160         @Override
3161         public Tag getTag() {
3162             return Tag.EXPORTS;
3163         }
3164     }
3165 
3166     public static class JCOpens extends JCDirective
3167             implements OpensTree {
3168         public JCExpression qualid;
3169         public List<JCExpression> moduleNames;
3170         public OpensDirective directive;
3171 
3172         protected JCOpens(JCExpression qualId, List<JCExpression> moduleNames) {
3173             this.qualid = qualId;
3174             this.moduleNames = moduleNames;
3175         }
3176 
3177         @Override
3178         public void accept(Visitor v) { v.visitOpens(this); }
3179 
3180         @Override @DefinedBy(Api.COMPILER_TREE)
3181         public Kind getKind() {
3182             return Kind.OPENS;
3183         }
3184 
3185         @Override @DefinedBy(Api.COMPILER_TREE)
3186         public JCExpression getPackageName() {
3187             return qualid;
3188         }
3189 
3190         @Override @DefinedBy(Api.COMPILER_TREE)
3191         public List<JCExpression> getModuleNames() {
3192             return moduleNames;
3193         }
3194 
3195         @Override @DefinedBy(Api.COMPILER_TREE)
3196         public <R, D> R accept(TreeVisitor<R, D> v, D d) {
3197             return v.visitOpens(this, d);
3198         }
3199 
3200         @Override
3201         public Tag getTag() {
3202             return Tag.OPENS;
3203         }
3204     }
3205 
3206     public static class JCProvides extends JCDirective
3207             implements ProvidesTree {
3208         public JCExpression serviceName;
3209         public List<JCExpression> implNames;
3210 
3211         protected JCProvides(JCExpression serviceName, List<JCExpression> implNames) {
3212             this.serviceName = serviceName;
3213             this.implNames = implNames;
3214         }
3215 
3216         @Override
3217         public void accept(Visitor v) { v.visitProvides(this); }
3218 
3219         @Override @DefinedBy(Api.COMPILER_TREE)
3220         public Kind getKind() {
3221             return Kind.PROVIDES;
3222         }
3223 
3224         @Override @DefinedBy(Api.COMPILER_TREE)
3225         public <R, D> R accept(TreeVisitor<R, D> v, D d) {
3226             return v.visitProvides(this, d);
3227         }
3228 
3229         @Override @DefinedBy(Api.COMPILER_TREE)
3230         public JCExpression getServiceName() {
3231             return serviceName;
3232         }
3233 
3234         @Override @DefinedBy(Api.COMPILER_TREE)
3235         public List<JCExpression> getImplementationNames() {
3236             return implNames;
3237         }
3238 
3239         @Override
3240         public Tag getTag() {
3241             return PROVIDES;
3242         }
3243     }
3244 
3245     public static class JCRequires extends JCDirective
3246             implements RequiresTree {
3247         public boolean isTransitive;
3248         public boolean isStaticPhase;
3249         public JCExpression moduleName;
3250         public RequiresDirective directive;
3251 
3252         protected JCRequires(boolean isTransitive, boolean isStaticPhase, JCExpression moduleName) {
3253             this.isTransitive = isTransitive;
3254             this.isStaticPhase = isStaticPhase;
3255             this.moduleName = moduleName;
3256         }
3257 
3258         @Override
3259         public void accept(Visitor v) { v.visitRequires(this); }
3260 
3261         @Override @DefinedBy(Api.COMPILER_TREE)
3262         public Kind getKind() {
3263             return Kind.REQUIRES;
3264         }
3265 
3266         @Override @DefinedBy(Api.COMPILER_TREE)
3267         public <R, D> R accept(TreeVisitor<R, D> v, D d) {
3268             return v.visitRequires(this, d);
3269         }
3270 
3271         @Override @DefinedBy(Api.COMPILER_TREE)
3272         public boolean isTransitive() {
3273             return isTransitive;
3274         }
3275 
3276         @Override @DefinedBy(Api.COMPILER_TREE)
3277         public boolean isStatic() {
3278             return isStaticPhase;
3279         }
3280 
3281         @Override @DefinedBy(Api.COMPILER_TREE)
3282         public JCExpression getModuleName() {
3283             return moduleName;
3284         }
3285 
3286         @Override
3287         public Tag getTag() {
3288             return REQUIRES;
3289         }
3290     }
3291 
3292     public static class JCUses extends JCDirective
3293             implements UsesTree {
3294         public JCExpression qualid;
3295 
3296         protected JCUses(JCExpression qualId) {
3297             this.qualid = qualId;
3298         }
3299 
3300         @Override
3301         public void accept(Visitor v) { v.visitUses(this); }
3302 
3303         @Override @DefinedBy(Api.COMPILER_TREE)
3304         public Kind getKind() {
3305             return Kind.USES;
3306         }
3307 
3308         @Override @DefinedBy(Api.COMPILER_TREE)
3309         public JCExpression getServiceName() {
3310             return qualid;
3311         }
3312 
3313         @Override @DefinedBy(Api.COMPILER_TREE)
3314         public <R, D> R accept(TreeVisitor<R, D> v, D d) {
3315             return v.visitUses(this, d);
3316         }
3317 
3318         @Override
3319         public Tag getTag() {
3320             return USES;
3321         }
3322     }
3323 
3324     public static class JCErroneous extends JCExpression
3325             implements ErroneousTree {
3326         public List<? extends JCTree> errs;
3327         protected JCErroneous(List<? extends JCTree> errs) {
3328             this.errs = errs;
3329         }
3330         @Override
3331         public void accept(Visitor v) { v.visitErroneous(this); }
3332 
3333         @DefinedBy(Api.COMPILER_TREE)
3334         public Kind getKind() { return Kind.ERRONEOUS; }
3335 
3336         @DefinedBy(Api.COMPILER_TREE)
3337         public List<? extends JCTree> getErrorTrees() {
3338             return errs;
3339         }
3340 
3341         @Override @DefinedBy(Api.COMPILER_TREE)
3342         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
3343             return v.visitErroneous(this, d);
3344         }
3345         @Override
3346         public Tag getTag() {
3347             return ERRONEOUS;
3348         }
3349     }
3350 
3351     /** (let int x = 3; in x+2) */
3352     public static class LetExpr extends JCExpression {
3353         public List<JCStatement> defs;
3354         public JCExpression expr;
3355         /**true if a expr should be run through Gen.genCond:*/
3356         public boolean needsCond;
3357         protected LetExpr(List<JCStatement> defs, JCExpression expr) {
3358             this.defs = defs;
3359             this.expr = expr;
3360         }
3361         @Override
3362         public void accept(Visitor v) { v.visitLetExpr(this); }
3363 
3364         @DefinedBy(Api.COMPILER_TREE)
3365         public Kind getKind() {
3366             throw new AssertionError("LetExpr is not part of a public API");
3367         }
3368         @Override @DefinedBy(Api.COMPILER_TREE)
3369         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
3370             throw new AssertionError("LetExpr is not part of a public API");
3371         }
3372         @Override
3373         public Tag getTag() {
3374             return LETEXPR;
3375         }
3376     }
3377 
3378     /** An interface for tree factories
3379      */
3380     public interface Factory {
3381         JCCompilationUnit TopLevel(List<JCTree> defs);
3382         JCPackageDecl PackageDecl(List<JCAnnotation> annotations,
3383                                   JCExpression pid);
3384         JCImport Import(JCFieldAccess qualid, boolean staticImport);
3385         JCClassDecl ClassDef(JCModifiers mods,
3386                           Name name,
3387                           List<JCTypeParameter> typarams,
3388                           JCExpression extending,
3389                           List<JCExpression> implementing,
3390                           List<JCTree> defs);
3391         JCMethodDecl MethodDef(JCModifiers mods,
3392                             Name name,
3393                             JCExpression restype,
3394                             List<JCTypeParameter> typarams,
3395                             JCVariableDecl recvparam,
3396                             List<JCVariableDecl> params,
3397                             List<JCExpression> thrown,
3398                             JCBlock body,
3399                             JCExpression defaultValue);
3400         JCVariableDecl VarDef(JCModifiers mods,
3401                       Name name,
3402                       JCExpression vartype,
3403                       JCExpression init);
3404         JCSkip Skip();
3405         JCBlock Block(long flags, List<JCStatement> stats);
3406         JCDoWhileLoop DoLoop(JCStatement body, JCExpression cond);
3407         JCWhileLoop WhileLoop(JCExpression cond, JCStatement body);
3408         JCForLoop ForLoop(List<JCStatement> init,
3409                         JCExpression cond,
3410                         List<JCExpressionStatement> step,
3411                         JCStatement body);
3412         JCEnhancedForLoop ForeachLoop(JCVariableDecl var, JCExpression expr, JCStatement body);
3413         JCLabeledStatement Labelled(Name label, JCStatement body);
3414         JCSwitch Switch(JCExpression selector, List<JCCase> cases);
3415         JCSwitchExpression SwitchExpression(JCExpression selector, List<JCCase> cases);
3416         JCCase Case(CaseTree.CaseKind caseKind, List<JCCaseLabel> labels, JCExpression guard,
3417                     List<JCStatement> stats, JCTree body);
3418         JCSynchronized Synchronized(JCExpression lock, JCBlock body);
3419         JCTry Try(JCBlock body, List<JCCatch> catchers, JCBlock finalizer);
3420         JCTry Try(List<JCTree> resources,
3421                   JCBlock body,
3422                   List<JCCatch> catchers,
3423                   JCBlock finalizer);
3424         JCCatch Catch(JCVariableDecl param, JCBlock body);
3425         JCConditional Conditional(JCExpression cond,
3426                                 JCExpression thenpart,
3427                                 JCExpression elsepart);
3428         JCIf If(JCExpression cond, JCStatement thenpart, JCStatement elsepart);
3429         JCExpressionStatement Exec(JCExpression expr);
3430         JCBreak Break(Name label);
3431         JCYield Yield(JCExpression value);
3432         JCContinue Continue(Name label);
3433         JCReturn Return(JCExpression expr);
3434         JCThrow Throw(JCExpression expr);
3435         JCAssert Assert(JCExpression cond, JCExpression detail);
3436         JCMethodInvocation Apply(List<JCExpression> typeargs,
3437                     JCExpression fn,
3438                     List<JCExpression> args);
3439         JCNewClass NewClass(JCExpression encl,
3440                           List<JCExpression> typeargs,
3441                           JCExpression clazz,
3442                           List<JCExpression> args,
3443                           JCClassDecl def);
3444         JCNewArray NewArray(JCExpression elemtype,
3445                           List<JCExpression> dims,
3446                           List<JCExpression> elems);
3447         JCParens Parens(JCExpression expr);
3448         JCAssign Assign(JCExpression lhs, JCExpression rhs);
3449         JCAssignOp Assignop(Tag opcode, JCTree lhs, JCTree rhs);
3450         JCUnary Unary(Tag opcode, JCExpression arg);
3451         JCBinary Binary(Tag opcode, JCExpression lhs, JCExpression rhs);
3452         JCTypeCast TypeCast(JCTree expr, JCExpression type);
3453         JCInstanceOf TypeTest(JCExpression expr, JCTree clazz);
3454         JCBindingPattern BindingPattern(JCVariableDecl var);
3455         JCArrayAccess Indexed(JCExpression indexed, JCExpression index);
3456         JCFieldAccess Select(JCExpression selected, Name selector);
3457         JCIdent Ident(Name idname);
3458         JCLiteral Literal(TypeTag tag, Object value);
3459         JCPrimitiveTypeTree TypeIdent(TypeTag typetag);
3460         JCArrayTypeTree TypeArray(JCExpression elemtype);
3461         JCTypeApply TypeApply(JCExpression clazz, List<JCExpression> arguments);
3462         JCTypeParameter TypeParameter(Name name, List<JCExpression> bounds);
3463         JCWildcard Wildcard(TypeBoundKind kind, JCTree type);
3464         TypeBoundKind TypeBoundKind(BoundKind kind);
3465         JCAnnotation Annotation(JCTree annotationType, List<JCExpression> args);
3466         JCModifiers Modifiers(long flags, List<JCAnnotation> annotations);
3467         JCErroneous Erroneous(List<? extends JCTree> errs);
3468         JCModuleDecl ModuleDef(JCModifiers mods, ModuleKind kind, JCExpression qualId, List<JCDirective> directives);
3469         JCExports Exports(JCExpression qualId, List<JCExpression> moduleNames);
3470         JCOpens Opens(JCExpression qualId, List<JCExpression> moduleNames);
3471         JCProvides Provides(JCExpression serviceName, List<JCExpression> implNames);
3472         JCRequires Requires(boolean isTransitive, boolean isStaticPhase, JCExpression qualId);
3473         JCUses Uses(JCExpression qualId);
3474         LetExpr LetExpr(List<JCStatement> defs, JCExpression expr);
3475     }
3476 
3477     /** A generic visitor class for trees.
3478      */
3479     public abstract static class Visitor {
3480         public void visitTopLevel(JCCompilationUnit that)    { visitTree(that); }
3481         public void visitPackageDef(JCPackageDecl that)      { visitTree(that); }
3482         public void visitImport(JCImport that)               { visitTree(that); }
3483         public void visitClassDef(JCClassDecl that)          { visitTree(that); }
3484         public void visitMethodDef(JCMethodDecl that)        { visitTree(that); }
3485         public void visitVarDef(JCVariableDecl that)         { visitTree(that); }
3486         public void visitSkip(JCSkip that)                   { visitTree(that); }
3487         public void visitBlock(JCBlock that)                 { visitTree(that); }
3488         public void visitDoLoop(JCDoWhileLoop that)          { visitTree(that); }
3489         public void visitWhileLoop(JCWhileLoop that)         { visitTree(that); }
3490         public void visitForLoop(JCForLoop that)             { visitTree(that); }
3491         public void visitForeachLoop(JCEnhancedForLoop that) { visitTree(that); }
3492         public void visitLabelled(JCLabeledStatement that)   { visitTree(that); }
3493         public void visitSwitch(JCSwitch that)               { visitTree(that); }
3494         public void visitCase(JCCase that)                   { visitTree(that); }
3495         public void visitSwitchExpression(JCSwitchExpression that)               { visitTree(that); }
3496         public void visitSynchronized(JCSynchronized that)   { visitTree(that); }
3497         public void visitTry(JCTry that)                     { visitTree(that); }
3498         public void visitCatch(JCCatch that)                 { visitTree(that); }
3499         public void visitConditional(JCConditional that)     { visitTree(that); }
3500         public void visitIf(JCIf that)                       { visitTree(that); }
3501         public void visitExec(JCExpressionStatement that)    { visitTree(that); }
3502         public void visitBreak(JCBreak that)                 { visitTree(that); }
3503         public void visitYield(JCYield that)                 { visitTree(that); }
3504         public void visitContinue(JCContinue that)           { visitTree(that); }
3505         public void visitReturn(JCReturn that)               { visitTree(that); }
3506         public void visitThrow(JCThrow that)                 { visitTree(that); }
3507         public void visitAssert(JCAssert that)               { visitTree(that); }
3508         public void visitApply(JCMethodInvocation that)      { visitTree(that); }
3509         public void visitNewClass(JCNewClass that)           { visitTree(that); }
3510         public void visitNewArray(JCNewArray that)           { visitTree(that); }
3511         public void visitLambda(JCLambda that)               { visitTree(that); }
3512         public void visitParens(JCParens that)               { visitTree(that); }
3513         public void visitAssign(JCAssign that)               { visitTree(that); }
3514         public void visitAssignop(JCAssignOp that)           { visitTree(that); }
3515         public void visitUnary(JCUnary that)                 { visitTree(that); }
3516         public void visitBinary(JCBinary that)               { visitTree(that); }
3517         public void visitTypeCast(JCTypeCast that)           { visitTree(that); }
3518         public void visitTypeTest(JCInstanceOf that)         { visitTree(that); }
3519         public void visitAnyPattern(JCAnyPattern that)       { visitTree(that); }
3520         public void visitBindingPattern(JCBindingPattern that) { visitTree(that); }
3521         public void visitDefaultCaseLabel(JCDefaultCaseLabel that) { visitTree(that); }
3522         public void visitConstantCaseLabel(JCConstantCaseLabel that) { visitTree(that); }
3523         public void visitPatternCaseLabel(JCPatternCaseLabel that) { visitTree(that); }
3524         public void visitRecordPattern(JCRecordPattern that) { visitTree(that); }
3525         public void visitIndexed(JCArrayAccess that)         { visitTree(that); }
3526         public void visitSelect(JCFieldAccess that)          { visitTree(that); }
3527         public void visitReference(JCMemberReference that)   { visitTree(that); }
3528         public void visitIdent(JCIdent that)                 { visitTree(that); }
3529         public void visitLiteral(JCLiteral that)             { visitTree(that); }
3530         public void visitTypeIdent(JCPrimitiveTypeTree that) { visitTree(that); }
3531         public void visitTypeArray(JCArrayTypeTree that)     { visitTree(that); }
3532         public void visitTypeApply(JCTypeApply that)         { visitTree(that); }
3533         public void visitTypeUnion(JCTypeUnion that)         { visitTree(that); }
3534         public void visitTypeIntersection(JCTypeIntersection that)  { visitTree(that); }
3535         public void visitTypeParameter(JCTypeParameter that) { visitTree(that); }
3536         public void visitWildcard(JCWildcard that)           { visitTree(that); }
3537         public void visitTypeBoundKind(TypeBoundKind that)   { visitTree(that); }
3538         public void visitAnnotation(JCAnnotation that)       { visitTree(that); }
3539         public void visitModifiers(JCModifiers that)         { visitTree(that); }
3540         public void visitAnnotatedType(JCAnnotatedType that) { visitTree(that); }
3541         public void visitErroneous(JCErroneous that)         { visitTree(that); }
3542         public void visitModuleDef(JCModuleDecl that)        { visitTree(that); }
3543         public void visitExports(JCExports that)             { visitTree(that); }
3544         public void visitOpens(JCOpens that)                 { visitTree(that); }
3545         public void visitProvides(JCProvides that)           { visitTree(that); }
3546         public void visitRequires(JCRequires that)           { visitTree(that); }
3547         public void visitUses(JCUses that)                   { visitTree(that); }
3548         public void visitLetExpr(LetExpr that)               { visitTree(that); }
3549 
3550         public void visitTree(JCTree that)                   { Assert.error(); }
3551     }
3552 
3553 }