## Uses of Interface
com.sun.source.tree.Tree

- Packages that use Tree
  Package | Description
  --- | ---
  com.sun.source.tree | Provides interfaces to represent source code as abstract syntax trees (AST).
  com.sun.source.util | Provides utilities for operations on abstract syntax trees (AST).

- - ### Uses of Tree in com.sun.source.tree

    Subinterfaces of Tree in com.sun.source.tree
    Modifier and Type | Interface | Description
    --- | --- | ---
    `interface` | `AnnotatedTypeTree` A tree node for an annotated type For example:
    `interface` | `AnnotationTree` A tree node for an annotation.
    `interface` | `ArrayAccessTree` A tree node for an array access expression.
    `interface` | `ArrayTypeTree` A tree node for an array type.
    `interface` | `AssertTree` A tree node for an 'assert' statement.
    `interface` | `AssignmentTree` A tree node for an assignment expression.
    `interface` | `BinaryTree` A tree node for a binary expression.
    `interface` | `BlockTree` A tree node for a statement block.
    `interface` | `BreakTree` A tree node for a 'break' statement.
    `interface` | `CaseTree` A tree node for a 'case' in a 'switch' statement.
    `interface` | `CatchTree` A tree node for a 'catch' block in a 'try' statement.
    `interface` | `ClassTree` A tree node for a class, interface, enum, or annotation type declaration.
    `interface` | `CompilationUnitTree` Represents the abstract syntax tree for compilation units (source files) and package declarations (package-info.java).
    `interface` | `CompoundAssignmentTree` A tree node for compound assignment operator.
    `interface` | `ConditionalExpressionTree` A tree node for the conditional operator ? :.
    `interface` | `ContinueTree` A tree node for a 'continue' statement.
    `interface` | `DoWhileLoopTree` A tree node for a 'do' statement.
    `interface` | `EmptyStatementTree` A tree node for an empty (skip) statement.
    `interface` | `EnhancedForLoopTree` A tree node for an "enhanced" 'for' loop statement.
    `interface` | `ErroneousTree` A tree node to stand in for a malformed expression.
    `interface` | `ExpressionStatementTree` A tree node for an expression statement.
    `interface` | `ExpressionTree` A tree node used as the base class for the different types of expressions.
    `interface` | `ForLoopTree` A tree node for a basic 'for' loop statement.
    `interface` | `IdentifierTree` A tree node for an identifier expression.
    `interface` | `IfTree` A tree node for an 'if' statement.
    `interface` | `ImportTree` A tree node for an import statement.
    `interface` | `InstanceOfTree` A tree node for an 'instanceof' expression.
    `interface` | `IntersectionTypeTree` A tree node for an intersection type in a cast expression.
    `interface` | `LabeledStatementTree` A tree node for a labeled statement.
    `interface` | `LambdaExpressionTree` A tree node for a lambda expression.
    `interface` | `LiteralTree` A tree node for a literal expression.
    `interface` | `MemberReferenceTree` A tree node for a member reference expression.
    `interface` | `MemberSelectTree` A tree node for a member access expression.
    `interface` | `MethodInvocationTree` A tree node for a method invocation expression.
    `interface` | `MethodTree` A tree node for a method or annotation type element declaration.
    `interface` | `ModifiersTree` A tree node for the modifiers, including annotations, for a declaration.
    `interface` | `NewArrayTree` A tree node for an expression to create a new instance of an array.
    `interface` | `NewClassTree` A tree node to declare a new instance of a class.
    `interface` | `ParameterizedTypeTree` A tree node for a type expression involving type parameters.
    `interface` | `ParenthesizedTree` A tree node for a parenthesized expression.
    `interface` | `PrimitiveTypeTree` A tree node for a primitive type.
    `interface` | `ReturnTree` A tree node for a 'return' statement.
    `interface` | `StatementTree` A tree node used as the base class for the different kinds of statements.
    `interface` | `SwitchTree` A tree node for a 'switch' statement.
    `interface` | `SynchronizedTree` A tree node for a 'synchronized' statement.
    `interface` | `ThrowTree` A tree node for a 'throw' statement.
    `interface` | `TryTree` A tree node for a 'try' statement.
    `interface` | `TypeCastTree` A tree node for a type cast expression.
    `interface` | `TypeParameterTree` A tree node for a type parameter.
    `interface` | `UnaryTree` A tree node for postfix and unary expressions.
    `interface` | `UnionTypeTree` A tree node for a union type expression in a multicatch var declaration.
    `interface` | `VariableTree` A tree node for a variable declaration.
    `interface` | `WhileLoopTree` A tree node for a 'while' loop statement.
    `interface` | `WildcardTree` A tree node for a wildcard type argument.

    Methods in com.sun.source.tree that return Tree
    Modifier and Type | Method | Description
    --- | --- | ---
    `Tree` | AnnotationTree.`getAnnotationType()`
    `Tree` | LambdaExpressionTree.`getBody()`
    `Tree` | WildcardTree.`getBound()`
    `Tree` | MethodTree.`getDefaultValue()`
    `Tree` | ClassTree.`getExtendsClause()`
    `Tree` | ImportTree.`getQualifiedIdentifier()`
    `Tree` | MethodTree.`getReturnType()`
    `Tree` | VariableTree.`getType()`
    `Tree` | InstanceOfTree.`getType()`
    `Tree` | TypeCastTree.`getType()`
    `Tree` | ArrayTypeTree.`getType()`
    `Tree` | ParameterizedTypeTree.`getType()`
    `Tree` | NewArrayTree.`getType()`

    Methods in com.sun.source.tree that return types with arguments of type Tree
    Modifier and Type | Method | Description
    --- | --- | ---
    `Class<? extends Tree>` | Tree.Kind.`asInterface()`
    `List<? extends Tree>` | TypeParameterTree.`getBounds()`
    `List<? extends Tree>` | IntersectionTypeTree.`getBounds()`
    `List<? extends Tree>` | ErroneousTree.`getErrorTrees()`
    `List<? extends Tree>` | ClassTree.`getImplementsClause()`
    `List<? extends Tree>` | ClassTree.`getMembers()`
    `List<? extends Tree>` | TryTree.`getResources()`
    `List<? extends Tree>` | UnionTypeTree.`getTypeAlternatives()`
    `List<? extends Tree>` | ParameterizedTypeTree.`getTypeArguments()`
    `List<? extends Tree>` | NewClassTree.`getTypeArguments()`
    `List<? extends Tree>` | MethodInvocationTree.`getTypeArguments()`
    `List<? extends Tree>` | CompilationUnitTree.`getTypeDecls()`

    Methods in com.sun.source.tree with parameters of type Tree
    Modifier and Type | Method | Description
    --- | --- | ---
    `R` | TreeVisitor.`visitOther(Tree node, P p)`

  - ### Uses of Tree in com.sun.source.util

    Methods in com.sun.source.util that return Tree
    Modifier and Type | Method | Description
    --- | --- | ---
    `Tree` | TreePath.`getLeaf()` Get the leaf node for this path.
    `abstract Tree` | Trees.`getTree(Element element)` Gets the Tree node for a given Element.
    `abstract Tree` | Trees.`getTree(Element e, AnnotationMirror a)` Gets the Tree node for an AnnotationMirror on a given Element.
    `abstract Tree` | Trees.`getTree(Element e, AnnotationMirror a, AnnotationValue v)` Gets the Tree node for an AnnotationValue for an AnnotationMirror on a given Element.

    Methods in com.sun.source.util that return types with arguments of type Tree
    Modifier and Type | Method | Description
    --- | --- | ---
    `Iterator<Tree>` | TreePath.`iterator()` Iterates from leaves to root.

    Methods in com.sun.source.util with parameters of type Tree
    Modifier and Type | Method | Description
    --- | --- | ---
    `protected R` | SimpleTreeVisitor.`defaultAction(Tree node, P p)`
    `long` | SourcePositions.`getEndPosition(CompilationUnitTree file, Tree tree)` Gets the ending position of tree within file.
    `static TreePath` | TreePath.`getPath(CompilationUnitTree unit, Tree target)` Gets a tree path for a tree node within a compilation unit.
    `abstract TreePath` | Trees.`getPath(CompilationUnitTree unit, Tree node)` Gets the path to tree node within the specified compilation unit.
    `static TreePath` | TreePath.`getPath(TreePath path, Tree target)` Gets a tree path for a tree node within a subtree identified by a TreePath object.
    `long` | SourcePositions.`getStartPosition(CompilationUnitTree file, Tree tree)` Gets the starting position of tree within file.
    `abstract void` | Trees.`printMessage(Diagnostic.Kind kind, CharSequence msg, Tree t, CompilationUnitTree root)` Prints a message of the specified kind at the location of the tree within the provided compilation unit
    `R` | TreeScanner.`scan(Tree node, P p)` Scan a single node.
    `R` | TreePathScanner.`scan(Tree tree, P p)` Scan a single node.
    `R` | SimpleTreeVisitor.`visit(Tree node, P p)`
    `R` | SimpleTreeVisitor.`visitOther(Tree node, P p)`
    `R` | TreeScanner.`visitOther(Tree node, P p)`

    Method parameters in com.sun.source.util with type arguments of type Tree
    Modifier and Type | Method | Description
    --- | --- | ---
    `abstract TypeMirror` | JavacTask.`getTypeMirror(Iterable<? extends Tree> path)` Get a type mirror of the tree node determined by the specified path.
    `R` | TreeScanner.`scan(Iterable<? extends Tree> nodes, P p)` Scan a list of nodes.
    `R` | SimpleTreeVisitor.`visit(Iterable<? extends Tree> nodes, P p)`

    Constructors in com.sun.source.util with parameters of type Tree
    Constructor | Description
    --- | ---
    `TreePath(TreePath p, Tree t)` Creates a TreePath for a child node.

Copyright © 2005, 2026, Oracle and/or its affiliates. All rights reserved.