edu.rice.cs.javalanglevels
Class TryCatchBodyTypeChecker

java.lang.Object
  extended by edu.rice.cs.javalanglevels.tree.JExpressionIFDepthFirstVisitor<TypeData>
      extended by edu.rice.cs.javalanglevels.TypeChecker
          extended by edu.rice.cs.javalanglevels.SpecialTypeChecker
              extended by edu.rice.cs.javalanglevels.BodyTypeChecker
                  extended by edu.rice.cs.javalanglevels.TryCatchBodyTypeChecker
All Implemented Interfaces:
JExpressionIFVisitor<TypeData>

public class TryCatchBodyTypeChecker
extends BodyTypeChecker

Does TypeChecking for the context of a Try-Catch body. Common to all LanguageLevels.


Nested Class Summary
static class TryCatchBodyTypeChecker.TryCatchBodyTypeCheckerTest
          Test the methods declared in the above class.
 
Nested classes/interfaces inherited from class edu.rice.cs.javalanglevels.BodyTypeChecker
BodyTypeChecker.BodyTypeCheckerTest
 
Nested classes/interfaces inherited from class edu.rice.cs.javalanglevels.SpecialTypeChecker
SpecialTypeChecker.BobTest
 
Nested classes/interfaces inherited from class edu.rice.cs.javalanglevels.TypeChecker
TypeChecker.TypeCheckerTest
 
Field Summary
 
Fields inherited from class edu.rice.cs.javalanglevels.BodyTypeChecker
_bodyData
 
Fields inherited from class edu.rice.cs.javalanglevels.SpecialTypeChecker
_data, _thrown, _vars, thingsThatHaveBeenAssigned
 
Fields inherited from class edu.rice.cs.javalanglevels.TypeChecker
_abstractMav, _finalMav, _finalPublicMav, _log, _packageMav, _privateMav, _protectedMav, _publicAbstractMav, _publicMav, _publicStaticMav, NONE, NULL_LITERAL
 
Constructor Summary
TryCatchBodyTypeChecker(BodyData bodyData, java.io.File file, java.lang.String packageName, java.util.LinkedList<java.lang.String> importedFiles, java.util.LinkedList<java.lang.String> importedPackages, java.util.LinkedList<VariableData> vars, java.util.LinkedList<Pair<SymbolData,JExpression>> thrown)
           
 
Method Summary
protected  void compareThrownAndCaught(TryCatchStatement that, SymbolData[] caught_array, java.util.LinkedList<Pair<SymbolData,JExpression>> thrown)
          Make sure that every Exception in thrown is either in caught or in the list of what can be thrown from where we are.
protected  BodyTypeChecker createANewInstanceOfMe(BodyData bodyData, java.io.File file, java.lang.String pakage, java.util.LinkedList<java.lang.String> importedFiles, java.util.LinkedList<java.lang.String> importedPackages, java.util.LinkedList<VariableData> vars, java.util.LinkedList<Pair<SymbolData,JExpression>> thrown)
          Create a new instance of this class for visiting inner bodies.
 TypeData forBracedBody(BracedBody that)
          Overwritten here, becuase it is okay for there to be thrown exceptions in the middle of a try catch.
 
Methods inherited from class edu.rice.cs.javalanglevels.BodyTypeChecker
_getData, checkDuplicateExceptions, forBlock, forBodyOnly, forBracedBodyOnly, forCatchBlock, forCatchBlockOnly, forDefaultCase, forDoStatement, forDoStatementOnly, forForStatement, forForStatementOnly, forIfThenElseStatement, forIfThenElseStatementOnly, forIfThenStatement, forIfThenStatementOnly, forInstanceInitializer, forLabeledCase, forNormalTryCatchStatement, forNormalTryCatchStatementOnly, forSimpleSuperReferenceOnly, forSimpleThisReferenceOnly, forSwitchCase, forSwitchStatement, forSwitchStatementOnly, forTryCatchFinallyStatement, forTryCatchFinallyStatementOnly, forTypeOnly, forUnbracedBodyOnly, forUninitializedVariableDeclaratorOnly, forValueReturnStatement, forValueReturnStatementOnly, forVoidReturnStatementOnly, forWhileStatement, forWhileStatementOnly, getCommonSuperType, isException, isUncaughtCheckedException, makeSureCaughtStuffWasThrown, tryCatchLeastRestrictiveType
 
Methods inherited from class edu.rice.cs.javalanglevels.SpecialTypeChecker
canBeAssigned, findClassReference, forArrayInitializerHelper, forBody, forExpressionStatement, forFormalParameter, forInitializedVariableDeclarator, forInitializedVariableDeclaratorOnly, forInnerClassDef, forInnerInterfaceDef, forLabeledStatement, forStaticInitializer, forSynchronizedStatement, forThrowStatement, forThrowStatementOnly, forUnbracedBody, forUninitializedVariableDeclarator, forVariableDeclaration, getArgTypesForInvocation, handleMethodInvocation, handleUncheckedException, inStaticMethod, isCheckedException
 
Methods inherited from class edu.rice.cs.javalanglevels.TypeChecker
_addError, _checkAbstractMethods, _getMatchingMethods, _isAssignableFrom, _isAssignableFromWithoutAutoboxing, _lookupMethod, _lookupMethodHelper, _lookupMethodHelper, assertFound, assertInstanceType, checkAccess, checkAccess, checkAccess, checkForCyclicInheritance, cloneVariableDataList, defaultCase, defineTestCaseClass, forBlockOnly, forBreakStatementOnly, forCastExpression, forClassDef, forClassDefOnly, forClassImportStatement, forConcreteMethodDefOnly, forContinueStatementOnly, forExpressionStatementOnly, forInnerClassDefOnly, forInnerInterfaceDefOnly, forInstanceInitializerOnly, forInterfaceDef, forInterfaceDefOnly, forLabeledStatementOnly, forMethodDefOnly, forPackageStatement, forPrimitiveType, forReturnStatementOnly, forStaticInitializerOnly, forSwitchStatementOnly, forTryCatchStatementOnly, getCommonSuperTypeBaseCase, getFieldOrVariable, getFieldOrVariable, getFieldOrVariable, getFieldOrVariable, getQualifiedClassName, getSymbolData, getSymbolData, getSymbolData, getSymbolData, makeArrayOfRetType, notRightPackage
 
Methods inherited from class edu.rice.cs.javalanglevels.tree.JExpressionIFDepthFirstVisitor
forAbstractMethodDef, forAbstractMethodDefOnly, forAndExpression, forAndExpressionOnly, forAnonymousClassInstantiationOnly, forArrayAccess, forArrayAccessOnly, forArrayInitializer, forArrayInitializerOnly, forArrayInstantiationOnly, forArrayType, forArrayTypeOnly, forAssignmentExpressionOnly, forBinaryExpressionOnly, forBitwiseAndAssignmentExpression, forBitwiseAndAssignmentExpressionOnly, forBitwiseAndExpression, forBitwiseAndExpressionOnly, forBitwiseAssignmentExpressionOnly, forBitwiseBinaryExpressionOnly, forBitwiseNotExpression, forBitwiseNotExpressionOnly, forBitwiseOrAssignmentExpression, forBitwiseOrAssignmentExpressionOnly, forBitwiseOrExpression, forBitwiseOrExpressionOnly, forBitwiseXorAssignmentExpression, forBitwiseXorAssignmentExpressionOnly, forBitwiseXorExpression, forBitwiseXorExpressionOnly, forBlockOnly, forBooleanExpressionOnly, forBooleanLiteral, forBooleanLiteralOnly, forCastExpressionOnly, forCatchBlockOnly, forCharLiteral, forCharLiteralOnly, forClassImportStatementOnly, forClassInstantiationOnly, forClassLiteral, forClassLiteralOnly, forClassOrInterfaceType, forClassOrInterfaceTypeOnly, forComparisonExpressionOnly, forComplexAnonymousClassInstantiation, forComplexAnonymousClassInstantiationOnly, forComplexInitializedArrayInstantiation, forComplexInitializedArrayInstantiationOnly, forComplexMethodInvocation, forComplexMethodInvocationOnly, forComplexNamedClassInstantiation, forComplexNamedClassInstantiationOnly, forComplexNameReference, forComplexNameReferenceOnly, forComplexSuperConstructorInvocation, forComplexSuperConstructorInvocationOnly, forComplexSuperReference, forComplexSuperReferenceOnly, forComplexThisConstructorInvocation, forComplexThisConstructorInvocationOnly, forComplexThisReference, forComplexThisReferenceOnly, forComplexUninitializedArrayInstantiation, forComplexUninitializedArrayInstantiationOnly, forCompoundWord, forCompoundWordOnly, forConcreteMethodDef, forConcreteMethodDefOnly, forConditionalExpression, forConditionalExpressionOnly, forConstructorDef, forConstructorDefOnly, forDefaultCaseOnly, forDimensionExpressionList, forDimensionExpressionListOnly, forDivideAssignmentExpression, forDivideAssignmentExpressionOnly, forDivideExpression, forDivideExpressionOnly, forDoubleLiteral, forDoubleLiteralOnly, forEmptyExpression, forEmptyExpressionOnly, forEmptyForCondition, forEmptyForConditionOnly, forEmptyStatement, forEmptyStatementOnly, forEqualityExpressionOnly, forEqualsExpression, forEqualsExpressionOnly, forExpressionListOnly, forExpressionOnly, forFloatLiteral, forFloatLiteralOnly, forFormalParameterOnly, forFunctionInvocationOnly, forGreaterThanExpression, forGreaterThanExpressionOnly, forGreaterThanOrEqualExpression, forGreaterThanOrEqualExpressionOnly, forImportStatementOnly, forIncrementExpressionOnly, forInitializedArrayInstantiationOnly, forInitializerOnly, forInstanceofExpression, forInstanceofExpressionOnly, forInstantiationOnly, forIntegerLiteral, forIntegerLiteralOnly, forJExpressionOnly, forLabeledBreakStatement, forLabeledBreakStatementOnly, forLabeledCaseOnly, forLabeledContinueStatement, forLabeledContinueStatementOnly, forLabeledStatementOnly, forLeftShiftAssignmentExpression, forLeftShiftAssignmentExpressionOnly, forLeftShiftExpression, forLeftShiftExpressionOnly, forLessThanExpression, forLessThanExpressionOnly, forLessThanOrEqualExpression, forLessThanOrEqualExpressionOnly, forLexicalLiteralOnly, forLongLiteral, forLongLiteralOnly, forMemberType, forMemberTypeOnly, forMethodDefOnly, forMethodInvocationOnly, forMinusAssignmentExpression, forMinusAssignmentExpressionOnly, forMinusExpression, forMinusExpressionOnly, forModAssignmentExpression, forModAssignmentExpressionOnly, forModExpression, forModExpressionOnly, forModifiersAndVisibility, forModifiersAndVisibilityOnly, forMultiplyAssignmentExpression, forMultiplyAssignmentExpressionOnly, forMultiplyExpression, forMultiplyExpressionOnly, forNamedClassInstantiationOnly, forNameReferenceOnly, forNegativeExpression, forNegativeExpressionOnly, forNegativePostfixIncrementExpression, forNegativePostfixIncrementExpressionOnly, forNegativePrefixIncrementExpression, forNegativePrefixIncrementExpressionOnly, forNoOpExpression, forNoOpExpressionOnly, forNotEqualExpression, forNotEqualExpressionOnly, forNotExpression, forNotExpressionOnly, forNullLiteral, forNullLiteralOnly, forNumericAssignmentExpressionOnly, forNumericBinaryExpressionOnly, forNumericUnaryExpressionOnly, forOrExpression, forOrExpressionOnly, forPackageImportStatement, forPackageImportStatementOnly, forPackageStatementOnly, forParenthesized, forParenthesizedExpressionList, forParenthesizedExpressionListOnly, forParenthesizedOnly, forPlusAssignmentExpression, forPlusAssignmentExpressionOnly, forPlusExpression, forPlusExpressionOnly, forPositiveExpression, forPositiveExpressionOnly, forPositivePostfixIncrementExpression, forPositivePostfixIncrementExpressionOnly, forPositivePrefixIncrementExpression, forPositivePrefixIncrementExpressionOnly, forPostfixIncrementExpressionOnly, forPrefixIncrementExpressionOnly, forPrimaryOnly, forPrimitiveTypeOnly, forReferenceTypeOnly, forRightSignedShiftAssignmentExpression, forRightSignedShiftAssignmentExpressionOnly, forRightSignedShiftExpression, forRightSignedShiftExpressionOnly, forRightUnsignedShiftAssignmentExpression, forRightUnsignedShiftAssignmentExpressionOnly, forRightUnsignedShiftExpression, forRightUnsignedShiftExpressionOnly, forShiftAssignmentExpressionOnly, forShiftBinaryExpressionOnly, forSimpleAnonymousClassInstantiation, forSimpleAnonymousClassInstantiationOnly, forSimpleAssignmentExpression, forSimpleAssignmentExpressionOnly, forSimpleInitializedArrayInstantiation, forSimpleInitializedArrayInstantiationOnly, forSimpleMethodInvocation, forSimpleMethodInvocationOnly, forSimpleNamedClassInstantiation, forSimpleNamedClassInstantiationOnly, forSimpleNameReference, forSimpleNameReferenceOnly, forSimpleSuperConstructorInvocation, forSimpleSuperConstructorInvocationOnly, forSimpleSuperReference, forSimpleThisConstructorInvocation, forSimpleThisConstructorInvocationOnly, forSimpleThisReference, forSimpleUninitializedArrayInstantiation, forSimpleUninitializedArrayInstantiationOnly, forSourceFile, forSourceFileOnly, forStatementOnly, forStringLiteral, forStringLiteralOnly, forSuperConstructorInvocationOnly, forSuperReferenceOnly, forSwitchCaseOnly, forSynchronizedStatementOnly, forThisConstructorInvocationOnly, forThisReferenceOnly, forTypeDefBaseOnly, forTypeParameter, forTypeParameterOnly, forTypeVariable, forTypeVariableOnly, forUnaryExpressionOnly, forUninitializedArrayInstantiationOnly, forUnlabeledBreakStatement, forUnlabeledBreakStatementOnly, forUnlabeledContinueStatement, forUnlabeledContinueStatementOnly, forUnparenthesizedExpressionList, forUnparenthesizedExpressionListOnly, forVariableDeclarationOnly, forVariableDeclaratorOnly, forVariableReferenceOnly, forVoidReturn, forVoidReturnOnly, forVoidReturnStatement, forWord, forWordOnly
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface edu.rice.cs.javalanglevels.tree.JExpressionIFVisitor
forAbstractMethodDef, forAndExpression, forArrayAccess, forArrayInitializer, forArrayType, forBitwiseAndAssignmentExpression, forBitwiseAndExpression, forBitwiseNotExpression, forBitwiseOrAssignmentExpression, forBitwiseOrExpression, forBitwiseXorAssignmentExpression, forBitwiseXorExpression, forBooleanLiteral, forCharLiteral, forClassLiteral, forClassOrInterfaceType, forComplexAnonymousClassInstantiation, forComplexInitializedArrayInstantiation, forComplexMethodInvocation, forComplexNamedClassInstantiation, forComplexNameReference, forComplexSuperConstructorInvocation, forComplexSuperReference, forComplexThisConstructorInvocation, forComplexThisReference, forComplexUninitializedArrayInstantiation, forCompoundWord, forConcreteMethodDef, forConditionalExpression, forConstructorDef, forDimensionExpressionList, forDivideAssignmentExpression, forDivideExpression, forDoubleLiteral, forEmptyExpression, forEmptyForCondition, forEmptyStatement, forEqualsExpression, forFloatLiteral, forGreaterThanExpression, forGreaterThanOrEqualExpression, forInstanceofExpression, forIntegerLiteral, forLabeledBreakStatement, forLabeledContinueStatement, forLeftShiftAssignmentExpression, forLeftShiftExpression, forLessThanExpression, forLessThanOrEqualExpression, forLongLiteral, forMemberType, forMinusAssignmentExpression, forMinusExpression, forModAssignmentExpression, forModExpression, forModifiersAndVisibility, forMultiplyAssignmentExpression, forMultiplyExpression, forNegativeExpression, forNegativePostfixIncrementExpression, forNegativePrefixIncrementExpression, forNoOpExpression, forNotEqualExpression, forNotExpression, forNullLiteral, forOrExpression, forPackageImportStatement, forParenthesized, forParenthesizedExpressionList, forPlusAssignmentExpression, forPlusExpression, forPositiveExpression, forPositivePostfixIncrementExpression, forPositivePrefixIncrementExpression, forRightSignedShiftAssignmentExpression, forRightSignedShiftExpression, forRightUnsignedShiftAssignmentExpression, forRightUnsignedShiftExpression, forSimpleAnonymousClassInstantiation, forSimpleAssignmentExpression, forSimpleInitializedArrayInstantiation, forSimpleMethodInvocation, forSimpleNamedClassInstantiation, forSimpleNameReference, forSimpleSuperConstructorInvocation, forSimpleSuperReference, forSimpleThisConstructorInvocation, forSimpleThisReference, forSimpleUninitializedArrayInstantiation, forSourceFile, forStringLiteral, forTypeParameter, forTypeVariable, forUnlabeledBreakStatement, forUnlabeledContinueStatement, forUnparenthesizedExpressionList, forVoidReturn, forVoidReturnStatement, forWord
 

Constructor Detail

TryCatchBodyTypeChecker

public TryCatchBodyTypeChecker(BodyData bodyData,
                               java.io.File file,
                               java.lang.String packageName,
                               java.util.LinkedList<java.lang.String> importedFiles,
                               java.util.LinkedList<java.lang.String> importedPackages,
                               java.util.LinkedList<VariableData> vars,
                               java.util.LinkedList<Pair<SymbolData,JExpression>> thrown)
Method Detail

createANewInstanceOfMe

protected BodyTypeChecker createANewInstanceOfMe(BodyData bodyData,
                                                 java.io.File file,
                                                 java.lang.String pakage,
                                                 java.util.LinkedList<java.lang.String> importedFiles,
                                                 java.util.LinkedList<java.lang.String> importedPackages,
                                                 java.util.LinkedList<VariableData> vars,
                                                 java.util.LinkedList<Pair<SymbolData,JExpression>> thrown)
Create a new instance of this class for visiting inner bodies.

Overrides:
createANewInstanceOfMe in class BodyTypeChecker

forBracedBody

public TypeData forBracedBody(BracedBody that)
Overwritten here, becuase it is okay for there to be thrown exceptions in the middle of a try catch.

Specified by:
forBracedBody in interface JExpressionIFVisitor<TypeData>
Overrides:
forBracedBody in class SpecialTypeChecker

compareThrownAndCaught

protected void compareThrownAndCaught(TryCatchStatement that,
                                      SymbolData[] caught_array,
                                      java.util.LinkedList<Pair<SymbolData,JExpression>> thrown)
Make sure that every Exception in thrown is either in caught or in the list of what can be thrown from where we are. Also make sure that every Exception that is declared to be thrown or caught is actually thrown. Overrides the same method in BodyTypeChecker.

Overrides:
compareThrownAndCaught in class BodyTypeChecker
Parameters:
that - The TryCatchStatement we are currently working with
caught_array - The SymbolData[] of exceptions that are explicitely caught.
thrown - The LinkedList of SymbolData of exceptions that are thrown. This will be modified.