APIdia Launch Partner
Top Description Inners Fields Constructors Methods
com.sun.tools.javac.tree

public abstract Class JCTree

extends Object
implements Tree, Cloneable, DiagnosticPosition
Class Inheritance
All Implemented Interfaces
com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition, java.lang.Cloneable, com.sun.source.tree.Tree
Known Direct Subclasses
com.sun.tools.javac.tree.JCTree.JCCompilationUnit, com.sun.tools.javac.tree.JCTree.JCPackageDecl, com.sun.tools.javac.tree.JCTree.JCImportBase, com.sun.tools.javac.tree.JCTree.JCStatement, com.sun.tools.javac.tree.JCTree.JCCaseLabel, com.sun.tools.javac.tree.JCTree.JCExpression, com.sun.tools.javac.tree.JCTree.JCMethodDecl, com.sun.tools.javac.tree.JCTree.JCCatch, com.sun.tools.javac.tree.JCTree.JCPattern, com.sun.tools.javac.tree.JCTree.JCTypeParameter, com.sun.tools.javac.tree.JCTree.TypeBoundKind, com.sun.tools.javac.tree.JCTree.JCModifiers, com.sun.tools.javac.tree.JCTree.JCDirective, com.sun.tools.javac.tree.JCTree.JCModuleDecl
Imports
java.io.IOException, .StringWriter, java.util.*, javax.lang.model.element.Modifier, javax.lang.model.type.TypeKind, javax.tools.JavaFileObject, .JavaFileManager.Location, com.sun.source.tree.*, .ModuleTree.ModuleKind, com.sun.tools.javac.code.*, .Directive.RequiresDirective, com.sun.tools.javac.code.Scope.*, com.sun.tools.javac.code.Symbol.*, .Directive.ExportsDirective, .Directive.OpensDirective, .Type.ModuleType, com.sun.tools.javac.util.*, .DefinedBy.Api, .JCDiagnostic.DiagnosticPosition, .List

Root class for abstract syntax tree nodes. It provides definitions for specific tree nodes as subclasses nested inside.

Each subclass is highly standardized. It generally contains only tree fields for the syntactic subcomponents of the node. Some classes that represent identifier uses or definitions also define a Symbol field that denotes the represented identifier. Classes for non-local jumps also carry the jump target as a field. The root class Tree itself defines fields for the tree's type and position. No other fields are kept in a tree node; instead parameters are passed to methods accessing the node.

Except for the methods defined by com.sun.source, the only method defined in subclasses is `visit' which applies a given visitor to the tree. The actual tree processing is done by visitor classes in other packages. The abstract class Visitor, as well as an Factory interface for trees, are defined as inner classes in Tree.

To avoid ambiguities with the Tree API in com.sun.source all sub classes should, by convention, start with JC (javac).

This is NOT part of any supported API. If you write code that depends on this, you do so at your own risk. This code and its internal interfaces are subject to change or deletion without notice.

See Also
TreeMaker, TreeInfo, TreeTranslator, Pretty

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
JCTree.Factory

An interface for tree factories

public static class
public static class
public static class
public static class
JCTree.JCArrayAccess

An array selection

public static class
JCTree.JCArrayTypeTree

An array type, A[]

public static class
JCTree.JCAssert

An assert statement.

public static class
JCTree.JCAssign

A assignment with "=".

public static class
JCTree.JCAssignOp

An assignment with "+=", "|=" ...

public static class
JCTree.JCBinary

A binary operation.

public static class
public static class
JCTree.JCBlock

A statement block.

public static class
JCTree.JCBreak

A break from a loop or switch.

public static class
JCTree.JCCase

A "case :" of a switch.

public abstract static class
public static class
JCTree.JCCatch

A catch block.

public static class
JCTree.JCClassDecl

A class definition.

public static class
JCTree.JCCompilationUnit

Everything in one source file is kept in a JCCompilationUnit structure.

public static class
public static class
public static class
JCTree.JCContinue

A continue of a loop.

public static class
public abstract static class
public static class
public static class
JCTree.JCEnhancedForLoop

The enhanced for loop.

public static class
public static class
public abstract static class
public static class
JCTree.JCExpressionStatement

an expression statement

public static class
JCTree.JCFieldAccess

Selects through packages and classes

public static class
JCTree.JCForLoop

A for loop.

public abstract static class
JCTree.JCFunctionalExpression

Common supertype for all functional expression trees (lambda and method references)

public static class
JCTree.JCIdent

An identifier

public static class
JCTree.JCIf

An "if ( ) { } else { }" block

public static class
JCTree.JCImport

An import clause.

public abstract static class
public static class
JCTree.JCInstanceOf

A type test.

public static class
JCTree.JCLabeledStatement

A labelled expression or statement.

public static class
JCTree.JCLambda

A lambda expression.

public static class
JCTree.JCLiteral

A constant value given literally.

public static class
JCTree.JCMemberReference

Selects a member expression.

public static class
JCTree.JCMethodDecl

A method definition.

public static class
JCTree.JCMethodInvocation

A method invocation

public static class
public static class
public static class
JCTree.JCModuleImport

A module import clause.

public static class
JCTree.JCNewArray

A new[...] operation.

public static class
JCTree.JCNewClass

A new(...) operation.

public static class
public abstract static class
public static class
JCTree.JCPackageDecl

Package definition.

public static class
JCTree.JCParens

A parenthesized subexpression ( ...

public abstract static class
JCTree.JCPattern

Pattern matching forms.

public static class
public abstract static class
JCTree.JCPolyExpression

Common supertype for all poly expression trees (lambda, method references, conditionals, method and constructor calls)

public static class
JCTree.JCPrimitiveTypeTree

Identifies a basic type.

public static class
public static class
public static class
public static class
JCTree.JCReturn

A return statement.

public static class
JCTree.JCSkip

A no-op statement ";".

public abstract static class
public static class
JCTree.JCSwitch

A "switch ( ) { }" construction.

public static class
JCTree.JCSwitchExpression

A "switch ( ) { }" construction.

public static class
JCTree.JCSynchronized

A synchronized block.

public static class
JCTree.JCThrow

A throw statement.

public static class
JCTree.JCTry

A "try { } catch ( ) { } finally { }" block.

public static class
JCTree.JCTypeApply

A parameterized type, T<...

public static class
JCTree.JCTypeCast

A type cast.

public static class
JCTree.JCTypeIntersection

An intersection type, T1 & T2 & ...

public static class
JCTree.JCTypeParameter

A formal class parameter.

public static class
JCTree.JCTypeUnion

A union type, T1 | T2 | ...

public static class
JCTree.JCUnary

A unary operation.

public static class
public static class
JCTree.JCVariableDecl

A variable definition.

public static class
public static class
JCTree.JCWhileLoop

A while loop

public static class
public static class
JCTree.JCYield

A break-with from a switch expression.

public static class
JCTree.LetExpr

(let int x = 3; in x+2)

public static enum
public static class
public abstract static class
JCTree.Visitor

A generic visitor class for trees.

Field Summary

Modifier and TypeField and Description
public int
public int
public Type

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public abstract void
accept(JCTree.Visitor v)

Visit this tree with a given visitor.

public abstract <R, D> R
accept(TreeVisitor<R, D> v, D d)

Redeclares com.sun.source.tree.Tree.accept.

Accept method used to implement the visitor pattern.

public Object
clone()

Overrides java.lang.Object.clone.

Return a shallow copy of this tree.

public int
getEndPosition()

Implements com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition.getEndPosition.

If there is a tree node, get the end position of the tree node.

public int
getPreferredPosition()

Implements com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition.getPreferredPosition.

Get the position within the file that most accurately defines the location for the diagnostic.

public int
getStartPosition()

Implements com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition.getStartPosition.

If there is a tree node, get the start position of the tree node.

public abstract JCTree.Tag
public JCTree
getTree()

Implements com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition.getTree.

Gets the tree node, if any, to which the diagnostic applies.

public boolean
private int
noNoPos(int position)

public JCDiagnostic.DiagnosticPosition
pos()

Get a default position for this tree node.

public JCTree
setPos(int pos)

Set position field and return this tree.

public JCTree
setType(Type type)

Set type field and return this tree.

public String
toString()

Overrides java.lang.Object.toString.

Convert a tree to a pretty-printed string.

Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait