Package soot.JastAddJ

Class TryWithResources

    • Field Detail

      • localLookup_String_values

        protected Map localLookup_String_values
      • localVariableDeclaration_String_values

        protected Map localVariableDeclaration_String_values
      • isDAafter_Variable_values

        protected Map isDAafter_Variable_values
      • catchableException_TypeDecl_values

        protected Map catchableException_TypeDecl_values
      • handlesException_TypeDecl_values

        protected Map handlesException_TypeDecl_values
      • typeError_computed

        protected boolean typeError_computed
      • typeError_value

        protected TypeDecl typeError_value
      • typeRuntimeException_computed

        protected boolean typeRuntimeException_computed
      • typeRuntimeException_value

        protected TypeDecl typeRuntimeException_value
      • lookupVariable_String_values

        protected Map lookupVariable_String_values
    • Method Detail

      • fullCopy

        public TryWithResources fullCopy()
        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
      • reachedException

        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
      • init$Children

        public void init$Children()
        Initializes the child array to the correct size. Initializes List and Opt nta children.
        Overrides:
        init$Children in class TryStmt
      • setResourceList

        public void setResourceList​(List<ResourceDeclaration> list)
        Replaces the Resource list.
        Parameters:
        list - The new list node to be used as the Resource list.
      • getNumResource

        public int getNumResource()
        Retrieves the number of children in the Resource list.
        Returns:
        Number of children in the Resource list.
      • getNumResourceNoTransform

        public int getNumResourceNoTransform()
        Retrieves the number of children in the Resource list. Calling this method will not trigger rewrites..
        Returns:
        Number of children in the Resource list.
      • getResource

        public ResourceDeclaration getResource​(int i)
        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.
      • addResource

        public void addResource​(ResourceDeclaration node)
        Append an element to the Resource list.
        Parameters:
        node - The element to append to the Resource list.
      • setResource

        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.
      • getResources

        public List<ResourceDeclaration> getResources()
        Retrieves the Resource list.
        Returns:
        The node representing the Resource list.
      • getResourcesNoTransform

        public List<ResourceDeclaration> getResourcesNoTransform()
        Retrieves the Resource list.

        This method does not invoke AST transformations.

        Returns:
        The node representing the Resource list.
      • getResourceList

        public List<ResourceDeclaration> getResourceList()
        Retrieves the Resource list.
        Returns:
        The node representing the Resource list.
      • getResourceListNoTransform

        public List<ResourceDeclaration> getResourceListNoTransform()
        Retrieves the Resource list.

        This method does not invoke AST transformations.

        Returns:
        The node representing the Resource list.
      • setBlock

        public void setBlock​(Block node)
        Replaces the Block child.
        Overrides:
        setBlock in class TryStmt
        Parameters:
        node - The new node to replace the Block child.
      • getBlock

        public Block getBlock()
        Retrieves the Block child.
        Overrides:
        getBlock in class TryStmt
        Returns:
        The current node used as the Block child.
      • getBlockNoTransform

        public Block getBlockNoTransform()
        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.
      • setCatchClauseList

        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.
      • getNumCatchClause

        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.
      • getNumCatchClauseNoTransform

        public int getNumCatchClauseNoTransform()
        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.
      • getCatchClause

        public CatchClause getCatchClause​(int i)
        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.
      • addCatchClause

        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.
      • setCatchClause

        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.
      • getCatchClauses

        public List<CatchClause> getCatchClauses()
        Retrieves the CatchClause list.
        Overrides:
        getCatchClauses in class TryStmt
        Returns:
        The node representing the CatchClause list.
      • getCatchClausesNoTransform

        public List<CatchClause> getCatchClausesNoTransform()
        Retrieves the CatchClause list.

        This method does not invoke AST transformations.

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

        public List<CatchClause> getCatchClauseList()
        Retrieves the CatchClause list.
        Overrides:
        getCatchClauseList in class TryStmt
        Returns:
        The node representing the CatchClause list.
      • getCatchClauseListNoTransform

        public List<CatchClause> getCatchClauseListNoTransform()
        Retrieves the CatchClause list.

        This method does not invoke AST transformations.

        Overrides:
        getCatchClauseListNoTransform in class TryStmt
        Returns:
        The node representing the CatchClause list.
      • setFinallyOpt

        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.
      • hasFinally

        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.
      • getFinally

        public Block getFinally()
        Retrieves the (optional) Finally child.
        Overrides:
        getFinally in class TryStmt
        Returns:
        The Finally child, if it exists. Returns null otherwise.
      • setFinally

        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.
      • getFinallyOptNoTransform

        public Opt<Block> getFinallyOptNoTransform()
        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.
      • catchHandlesException

        public boolean catchHandlesException​(TypeDecl exceptionType)
        This attribute computes whether or not the TWR statement has a catch clause which handles the exception.
      • twrHandlesException

        public 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.
      • lookupClose

        public MethodDecl lookupClose​(ResourceDeclaration resource)
        Lookup the close method declaration for the resource which is being used.
      • resourceClosingException

        public boolean resourceClosingException​(TypeDecl catchType)
        True if the automatic closing of resources in this try-with-resources statement may throw an exception of type catchType.
      • resourceInitializationException

        public boolean resourceInitializationException​(TypeDecl catchType)
        True if the resource initialization of this try-with-resources statement may throw an exception of type catchType.
      • catchableException

        public 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)
      • handlesException

        public boolean handlesException​(TypeDecl exceptionType)
        Inherit the handlesException attribute from methoddecl.
        Overrides:
        handlesException in class TryStmt
      • resourcePreviouslyDeclared

        public boolean resourcePreviouslyDeclared​(String name)