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