AST
node type TryWithResources

General Info

Production
TryWithResources : TryStmt ::= Resource:ResourceDeclaration* Block CatchClause* [Finally:Block];
Type Hierarchy:
java.lang.Object
  extended by beaver.Symbol
      extended by AST.ASTNode<ASTNode>
          extended by AST.Stmt
              extended by AST.TryStmt
                  extended by AST.TryWithResources
All Implemented Interfaces:
FinallyHost, VariableScope, java.lang.Cloneable, java.lang.Iterable<ASTNode>

Description

The JSR 334 try with resources statement.
Source
Declared in Java7Frontend/TryWithResources.ast at line 4

Member Filters

API level:

Aspect:

Constructors

Attributes

syn boolean catchHandlesException(TypeDecl exceptionType)
This attribute computes whether or not the TWR statement has a catch clause which handles the exception.
Source
Declared in Java7Frontend/TryWithResources.jrag at line 60
Aspect
TryWithResources
syn boolean twrHandlesException(TypeDecl exceptionType)
Returns true if exceptions of type exceptionType are handled in the try-with-resources statement or any containing statement within the directly enclosing method or initializer block.
Source
Declared in Java7Frontend/TryWithResources.jrag at line 72
Aspect
TryWithResources
Lookup the close method declaration for the resource which is being used.
Source
Declared in Java7Frontend/TryWithResources.jrag at line 95
Aspect
TryWithResources
syn SimpleSet localLookup(java.lang.String name)
Source
Declared in Java7Frontend/TryWithResources.jrag at line 128
Aspect
TryWithResources
syn VariableDeclaration localVariableDeclaration(java.lang.String name)
Source
Declared in Java7Frontend/TryWithResources.jrag at line 133
Aspect
TryWithResources
syn boolean isDAafter(Variable v)
Overrides:isDAafter in class TryStmt
Source
Declared in Java7Frontend/TryWithResources.jrag at line 167
Aspect
TryWithResources
syn boolean resourceClosingException(TypeDecl catchType)
True if the automatic closing of resources in this try-with-resources statement may throw an exception of type catchType.
Source
Declared in Java7Frontend/TryWithResources.jrag at line 204
Aspect
TryWithResources
syn boolean resourceInitializationException(TypeDecl catchType)
True if the resource initialization of this try-with-resources statement may throw an exception of type catchType.
Source
Declared in Java7Frontend/TryWithResources.jrag at line 221
Aspect
TryWithResources
syn boolean catchableException(TypeDecl type)
Description copied from class: TryStmt
The block of the try statement can throw an exception of a type assignable to the given type.
Overrides:catchableException in class TryStmt
See Also:
TryStmt.catchableException(TypeDecl)
Source
Declared in Java7Frontend/TryWithResources.jrag at line 232
Aspect
TryWithResources
An NTA which is used for code generation. This NTA will handle the recursive nature of code generation for try-with-resources statements.
Source
Declared in Java7Backend/TryWithResources.jrag at line 17
Aspect
TryWithResources
inh boolean handlesException(TypeDecl exceptionType)
Inherit the handlesException attribute from methoddecl.
Overrides:handlesException in class TryStmt
Source
Declared in Java7Frontend/TryWithResources.jrag at line 83
Aspect
TryWithResources
Overrides:typeError in class TryStmt
Source
Declared in Java7Frontend/TryWithResources.jrag at line 110
Aspect
TryWithResources
Overrides:typeRuntimeException in class TryStmt
Source
Declared in Java7Frontend/TryWithResources.jrag at line 111
Aspect
TryWithResources
inh SimpleSet lookupVariable(java.lang.String name)
Specified by:lookupVariable in interface VariableScopeOverrides:lookupVariable in class Stmt
Source
Declared in Java7Frontend/TryWithResources.jrag at line 141
Aspect
TryWithResources
inh boolean resourcePreviouslyDeclared(java.lang.String name)
Source
Declared in Java7Frontend/TryWithResources.jrag at line 145
Aspect
TryWithResources

Methods

public void flushCache()
Overrides:flushCache in class TryStmt
public void flushCollectionCache()
Overrides:flushCollectionCache in class TryStmt
public TryWithResources clone()
                       throws java.lang.CloneNotSupportedException
Overrides:clone in class TryStmt
Throws:
java.lang.CloneNotSupportedException
Overrides:copy in class TryStmt
Create a deep copy of the AST subtree at this node. The copy is dangling, i.e. has no parent.
Overrides:fullCopy in class TryStmt
Returns:
dangling copy of the subtree at this node
public void exceptionHandling()
Exception error checks.
Overrides:exceptionHandling in class ASTNode<ASTNode>
Source
Declared in Java7Frontend/TryWithResources.jrag at line 40
Aspect
TryWithResources
protected boolean reachedException(TypeDecl catchType)
Returns true if the try-with-resources statement can throw an exception of type (or a subtype of) catchType.
Overrides:reachedException in class TryStmt
Source
Declared in Java7Frontend/TryWithResources.jrag at line 181
Aspect
TryWithResources
public void toString(java.lang.StringBuffer sb)
Pretty printing of try-with-resources
Overrides:toString in class TryStmt
Source
Declared in Java7Frontend/TryWithResources.jrag at line 244
Aspect
PrettyPrint
public void createBCode(CodeGeneration gen)
Code generation for the try-with-resources statement.
Overrides:createBCode in class TryStmt
Source
Declared in Java7Backend/TryWithResources.jrag at line 60
Aspect
TryWithResources
public void init$Children()
Initializes the child array to the correct size. Initializes List and Opt nta children.
Overrides:init$Children in class TryStmt
protected int numChildren()
Overrides:numChildren in class TryStmt
public boolean mayHaveRewrite()
Overrides:mayHaveRewrite in class TryStmt
Replaces the Resource list.
Parameters:
list - The new list node to be used as the Resource list.
public int getNumResource()
Retrieves the number of children in the Resource list.
Returns:
Number of children in the Resource list.
Retrieves the number of children in the Resource list. Calling this method will not trigger rewrites..
Returns:
Number of children in the Resource list.
Retrieves the element at index i in the Resource list..
Parameters:
i - Index of the element to return.
Returns:
The element at position i in the Resource list.
public void addResource(ResourceDeclaration node)
Append an element to the Resource list.
Parameters:
node - The element to append to the Resource list.
public void setResource(ResourceDeclaration node,
                        int i)
Replaces the Resource list element at index i with the new node node.
Parameters:
node - The new node to replace the old list element.
i - The list index of the node to be replaced.
Retrieves the Resource list.
Returns:
The node representing the Resource list.
Retrieves the Resource list.

This method does not invoke AST transformations.

Returns:
The node representing the Resource list.
Retrieves the Resource list.
Returns:
The node representing the Resource list.
Retrieves the Resource list.

This method does not invoke AST transformations.

Returns:
The node representing the Resource list.
public void setBlock(Block node)
Replaces the Block child.
Overrides:setBlock in class TryStmt
Parameters:
node - The new node to replace the Block child.
public Block getBlock()
Retrieves the Block child.
Overrides:getBlock in class TryStmt
Returns:
The current node used as the Block child.
Retrieves the Block child.

This method does not invoke AST transformations.

Overrides:getBlockNoTransform in class TryStmt
Returns:
The current node used as the Block child.
public void setCatchClauseList(List<CatchClause> list)
Replaces the CatchClause list.
Overrides:setCatchClauseList in class TryStmt
Parameters:
list - The new list node to be used as the CatchClause list.
public int getNumCatchClause()
Retrieves the number of children in the CatchClause list.
Overrides:getNumCatchClause in class TryStmt
Returns:
Number of children in the CatchClause list.
Retrieves the number of children in the CatchClause list. Calling this method will not trigger rewrites..
Overrides:getNumCatchClauseNoTransform in class TryStmt
Returns:
Number of children in the CatchClause list.
Retrieves the element at index i in the CatchClause list..
Overrides:getCatchClause in class TryStmt
Parameters:
i - Index of the element to return.
Returns:
The element at position i in the CatchClause list.
public void addCatchClause(CatchClause node)
Append an element to the CatchClause list.
Overrides:addCatchClause in class TryStmt
Parameters:
node - The element to append to the CatchClause list.
public void setCatchClause(CatchClause node,
                           int i)
Replaces the CatchClause list element at index i with the new node node.
Overrides:setCatchClause in class TryStmt
Parameters:
node - The new node to replace the old list element.
i - The list index of the node to be replaced.
Retrieves the CatchClause list.
Overrides:getCatchClauses in class TryStmt
Returns:
The node representing the CatchClause list.
Retrieves the CatchClause list.

This method does not invoke AST transformations.

Overrides:getCatchClausesNoTransform in class TryStmt
Returns:
The node representing the CatchClause list.
Retrieves the CatchClause list.
Overrides:getCatchClauseList in class TryStmt
Returns:
The node representing the CatchClause list.
Retrieves the CatchClause list.

This method does not invoke AST transformations.

Overrides:getCatchClauseListNoTransform in class TryStmt
Returns:
The node representing the CatchClause list.
public void setFinallyOpt(Opt<Block> opt)
Replaces the optional node for the Finally child. This is the Opt node containing the child Finally, not the actual child!
Overrides:setFinallyOpt in class TryStmt
Parameters:
opt - The new node to be used as the optional node for the Finally child.
public boolean hasFinally()
Check whether the optional Finally child exists.
Overrides:hasFinally in class TryStmt
Returns:
true if the optional Finally child exists, false if it does not.
public Block getFinally()
Retrieves the (optional) Finally child.
Overrides:getFinally in class TryStmt
Returns:
The Finally child, if it exists. Returns null otherwise.
public void setFinally(Block node)
Replaces the (optional) Finally child.
Overrides:setFinally in class TryStmt
Parameters:
node - The new node to be used as the Finally child.
Overrides:getFinallyOpt in class TryStmt
Retrieves the optional node for child Finally. This is the Opt node containing the child Finally, not the actual child!

This method does not invoke AST transformations.

Overrides:getFinallyOptNoTransform in class TryStmt
Returns:
The optional node for child Finally.
public boolean Define_boolean_handlesException(ASTNode caller,
                                               ASTNode child,
                                               TypeDecl exceptionType)
Overrides:Define_boolean_handlesException in class TryStmt
Source
Declared in Java7Frontend/TryWithResources.jrag at line 88
public boolean Define_boolean_reachableCatchClause(ASTNode caller,
                                                   ASTNode child,
                                                   TypeDecl exceptionType)
Overrides:Define_boolean_reachableCatchClause in class TryStmt
Source
Declared in Java7Frontend/TryWithResources.jrag at line 113
public SimpleSet Define_SimpleSet_lookupVariable(ASTNode caller,
                                                 ASTNode child,
                                                 java.lang.String name)
Overrides:Define_SimpleSet_lookupVariable in class ASTNode<ASTNode>
Source
Declared in Java7Frontend/TryWithResources.jrag at line 127
Overrides:Define_VariableScope_outerScope in class ASTNode<ASTNode>
Source
Declared in Java7Frontend/TryWithResources.jrag at line 142
public boolean Define_boolean_resourcePreviouslyDeclared(ASTNode caller,
                                                         ASTNode child,
                                                         java.lang.String name)
Overrides:Define_boolean_resourcePreviouslyDeclared in class ASTNode<ASTNode>
Source
Declared in Java7Frontend/TryWithResources.jrag at line 146
public boolean Define_boolean_isDAbefore(ASTNode caller,
                                         ASTNode child,
                                         Variable v)
Overrides:Define_boolean_isDAbefore in class TryStmt
Source
Declared in Java7Frontend/TryWithResources.jrag at line 173
public int Define_int_localNum(ASTNode caller,
                               ASTNode child)
Overrides:Define_int_localNum in class TryStmt
Source
Declared in Java7Backend/TryWithResources.jrag at line 286
Overrides:rewriteTo in class TryStmt

Fields

protected java.util.Map localLookup_String_values
protected java.util.Map isDAafter_Variable_values
protected java.util.Map catchableException_TypeDecl_values
protected boolean getTransformed_computed
protected java.util.Map handlesException_TypeDecl_values
protected boolean typeError_computed
protected java.util.Map lookupVariable_String_values

Inherited Members

Attributes inherited from AST.TryStmt

Attributes inherited from AST.Stmt

Attributes inherited from AST.ASTNode

Methods inherited from class AST.TryStmt

Methods inherited from class AST.Stmt

Methods inherited from class AST.ASTNode

Methods inherited from class beaver.Symbol

getColumn
getEnd
getId
getLine
getStart
makePosition

Methods inherited from class java.lang.Object

equals
finalize
getClass
hashCode
notify
notifyAll
wait
wait
wait

Methods inherited from interface AST.VariableScope

Methods inherited from interface AST.FinallyHost

Fields inherited from AST.TryStmt

Fields inherited from AST.Stmt

Fields inherited from AST.ASTNode

Fields inherited from beaver.Symbol

end
id
start
value