langtools/test/tools/javac/TryWithResources/TwrTests.java

Print this page

        

*** 88,98 **** Resource r1 = createResource(1, createFailureId, bitMap, closedList)) { throw new AssertionError("Entire resource creation succeeded"); } catch (Resource.CreateFailException e) { creationFailuresDetected++; checkCreateFailureId(e.resourceId(), createFailureId); ! checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap); } catch (Resource.CloseFailException e) { throw new AssertionError("Secondary exception suppression failed"); } checkForSingleCreationFailure(creationFailuresDetected); checkClosedList(closedList, createFailureId); --- 88,98 ---- Resource r1 = createResource(1, createFailureId, bitMap, closedList)) { throw new AssertionError("Entire resource creation succeeded"); } catch (Resource.CreateFailException e) { creationFailuresDetected++; checkCreateFailureId(e.resourceId(), createFailureId); ! checkSuppressedExceptions(e.getSuppressed(), bitMap); } catch (Resource.CloseFailException e) { throw new AssertionError("Secondary exception suppression failed"); } checkForSingleCreationFailure(creationFailuresDetected); checkClosedList(closedList, createFailureId);
*** 110,120 **** throw new AssertionError("Entire resource creation succeeded"); } } catch (Resource.CreateFailException e) { creationFailuresDetected++; checkCreateFailureId(e.resourceId(), createFailureId); ! checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap); } catch (Resource.CloseFailException e) { throw new AssertionError("Secondary exception suppression failed"); } checkForSingleCreationFailure(creationFailuresDetected); checkClosedList(closedList, createFailureId); --- 110,120 ---- throw new AssertionError("Entire resource creation succeeded"); } } catch (Resource.CreateFailException e) { creationFailuresDetected++; checkCreateFailureId(e.resourceId(), createFailureId); ! checkSuppressedExceptions(e.getSuppressed(), bitMap); } catch (Resource.CloseFailException e) { throw new AssertionError("Secondary exception suppression failed"); } checkForSingleCreationFailure(creationFailuresDetected); checkClosedList(closedList, createFailureId);
*** 132,142 **** Resource r2 = createResource(2, createFailureId, bitMap, closedList)) { throw new AssertionError("Entire resource creation succeeded"); } catch (Resource.CreateFailException e) { creationFailuresDetected++; checkCreateFailureId(e.resourceId(), createFailureId); ! checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap); } catch (Resource.CloseFailException e) { throw new AssertionError("Secondary exception suppression failed:" + e); } checkForSingleCreationFailure(creationFailuresDetected); checkClosedList(closedList, createFailureId); --- 132,142 ---- Resource r2 = createResource(2, createFailureId, bitMap, closedList)) { throw new AssertionError("Entire resource creation succeeded"); } catch (Resource.CreateFailException e) { creationFailuresDetected++; checkCreateFailureId(e.resourceId(), createFailureId); ! checkSuppressedExceptions(e.getSuppressed(), bitMap); } catch (Resource.CloseFailException e) { throw new AssertionError("Secondary exception suppression failed:" + e); } checkForSingleCreationFailure(creationFailuresDetected); checkClosedList(closedList, createFailureId);
*** 156,166 **** } } } catch (Resource.CreateFailException e) { creationFailuresDetected++; checkCreateFailureId(e.resourceId(), createFailureId); ! checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap); } catch (Resource.CloseFailException e) { throw new AssertionError("Secondary exception suppression failed:" + e); } checkForSingleCreationFailure(creationFailuresDetected); checkClosedList(closedList, createFailureId); --- 156,166 ---- } } } catch (Resource.CreateFailException e) { creationFailuresDetected++; checkCreateFailureId(e.resourceId(), createFailureId); ! checkSuppressedExceptions(e.getSuppressed(), bitMap); } catch (Resource.CloseFailException e) { throw new AssertionError("Secondary exception suppression failed:" + e); } checkForSingleCreationFailure(creationFailuresDetected); checkClosedList(closedList, createFailureId);
*** 179,189 **** Resource r3 = createResource(3, createFailureId, bitMap, closedList)) { throw new AssertionError("Entire resource creation succeeded"); } catch (Resource.CreateFailException e) { creationFailuresDetected++; checkCreateFailureId(e.resourceId(), createFailureId); ! checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap); } catch (Resource.CloseFailException e) { throw new AssertionError("Secondary exception suppression failed:" + e); } checkForSingleCreationFailure(creationFailuresDetected); checkClosedList(closedList, createFailureId); --- 179,189 ---- Resource r3 = createResource(3, createFailureId, bitMap, closedList)) { throw new AssertionError("Entire resource creation succeeded"); } catch (Resource.CreateFailException e) { creationFailuresDetected++; checkCreateFailureId(e.resourceId(), createFailureId); ! checkSuppressedExceptions(e.getSuppressed(), bitMap); } catch (Resource.CloseFailException e) { throw new AssertionError("Secondary exception suppression failed:" + e); } checkForSingleCreationFailure(creationFailuresDetected); checkClosedList(closedList, createFailureId);
*** 205,215 **** } } } catch (Resource.CreateFailException e) { creationFailuresDetected++; checkCreateFailureId(e.resourceId(), createFailureId); ! checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap); } catch (Resource.CloseFailException e) { throw new AssertionError("Secondary exception suppression failed:" + e); } checkForSingleCreationFailure(creationFailuresDetected); checkClosedList(closedList, createFailureId); --- 205,215 ---- } } } catch (Resource.CreateFailException e) { creationFailuresDetected++; checkCreateFailureId(e.resourceId(), createFailureId); ! checkSuppressedExceptions(e.getSuppressed(), bitMap); } catch (Resource.CloseFailException e) { throw new AssertionError("Secondary exception suppression failed:" + e); } checkForSingleCreationFailure(creationFailuresDetected); checkClosedList(closedList, createFailureId);
*** 229,239 **** Resource r4 = createResource(4, createFailureId, bitMap, closedList)) { throw new AssertionError("Entire resource creation succeeded"); } catch (Resource.CreateFailException e) { creationFailuresDetected++; checkCreateFailureId(e.resourceId(), createFailureId); ! checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap); } catch (Resource.CloseFailException e) { throw new AssertionError("Secondary exception suppression failed:" + e); } checkForSingleCreationFailure(creationFailuresDetected); checkClosedList(closedList, createFailureId); --- 229,239 ---- Resource r4 = createResource(4, createFailureId, bitMap, closedList)) { throw new AssertionError("Entire resource creation succeeded"); } catch (Resource.CreateFailException e) { creationFailuresDetected++; checkCreateFailureId(e.resourceId(), createFailureId); ! checkSuppressedExceptions(e.getSuppressed(), bitMap); } catch (Resource.CloseFailException e) { throw new AssertionError("Secondary exception suppression failed:" + e); } checkForSingleCreationFailure(creationFailuresDetected); checkClosedList(closedList, createFailureId);
*** 257,267 **** } } } catch (Resource.CreateFailException e) { creationFailuresDetected++; checkCreateFailureId(e.resourceId(), createFailureId); ! checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap); } catch (Resource.CloseFailException e) { throw new AssertionError("Secondary exception suppression failed:" + e); } checkForSingleCreationFailure(creationFailuresDetected); checkClosedList(closedList, createFailureId); --- 257,267 ---- } } } catch (Resource.CreateFailException e) { creationFailuresDetected++; checkCreateFailureId(e.resourceId(), createFailureId); ! checkSuppressedExceptions(e.getSuppressed(), bitMap); } catch (Resource.CloseFailException e) { throw new AssertionError("Secondary exception suppression failed:" + e); } checkForSingleCreationFailure(creationFailuresDetected); checkClosedList(closedList, createFailureId);
*** 308,318 **** /** * Check for proper suppressed exceptions in proper order. * * @param suppressedExceptions the suppressed exceptions array returned by ! * getSuppressedExceptions() * @bitmap a bitmap indicating which suppressed exceptions are expected. * Bit i is set iff id should throw a CloseFailException. */ private static void checkSuppressedExceptions(Throwable[] suppressedExceptions, int bitMap) { if (suppressedExceptions.length != Integer.bitCount(bitMap)) --- 308,318 ---- /** * Check for proper suppressed exceptions in proper order. * * @param suppressedExceptions the suppressed exceptions array returned by ! * getSuppressed() * @bitmap a bitmap indicating which suppressed exceptions are expected. * Bit i is set iff id should throw a CloseFailException. */ private static void checkSuppressedExceptions(Throwable[] suppressedExceptions, int bitMap) { if (suppressedExceptions.length != Integer.bitCount(bitMap))
*** 374,384 **** throw new AssertionError( "Resource creation failed: " + e.resourceId()); } catch (MyKindOfException e) { if (failure == 0) throw new AssertionError("Unexpected MyKindOfException"); ! checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap); } catch (Resource.CloseFailException e) { if (failure == 1) throw new AssertionError("Secondary exception suppression failed"); int id = e.resourceId(); if (bitMap == 0) --- 374,384 ---- throw new AssertionError( "Resource creation failed: " + e.resourceId()); } catch (MyKindOfException e) { if (failure == 0) throw new AssertionError("Unexpected MyKindOfException"); ! checkSuppressedExceptions(e.getSuppressed(), bitMap); } catch (Resource.CloseFailException e) { if (failure == 1) throw new AssertionError("Secondary exception suppression failed"); int id = e.resourceId(); if (bitMap == 0)
*** 386,396 **** int highestCloseFailBit = Integer.highestOneBit(bitMap); if (1 << id != highestCloseFailBit) { throw new AssertionError("CloseFailException: got id " + id + ", expected lg(" + highestCloseFailBit +")"); } ! checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap & ~highestCloseFailBit); } checkClosedList(closedList, 1); } } } --- 386,396 ---- int highestCloseFailBit = Integer.highestOneBit(bitMap); if (1 << id != highestCloseFailBit) { throw new AssertionError("CloseFailException: got id " + id + ", expected lg(" + highestCloseFailBit +")"); } ! checkSuppressedExceptions(e.getSuppressed(), bitMap & ~highestCloseFailBit); } checkClosedList(closedList, 1); } } }
*** 407,417 **** throw new AssertionError( "Resource creation failed: " + e.resourceId()); } catch (MyKindOfException e) { if (failure == 0) throw new AssertionError("Unexpected MyKindOfException"); ! checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap); } catch (Resource.CloseFailException e) { if (failure == 1) throw new AssertionError("Secondary exception suppression failed"); int id = e.resourceId(); if (bitMap == 0) --- 407,417 ---- throw new AssertionError( "Resource creation failed: " + e.resourceId()); } catch (MyKindOfException e) { if (failure == 0) throw new AssertionError("Unexpected MyKindOfException"); ! checkSuppressedExceptions(e.getSuppressed(), bitMap); } catch (Resource.CloseFailException e) { if (failure == 1) throw new AssertionError("Secondary exception suppression failed"); int id = e.resourceId(); if (bitMap == 0)
*** 419,429 **** int highestCloseFailBit = Integer.highestOneBit(bitMap); if (1 << id != highestCloseFailBit) { throw new AssertionError("CloseFailException: got id " + id + ", expected lg(" + highestCloseFailBit +")"); } ! checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap & ~highestCloseFailBit); } checkClosedList(closedList, 2); } } } --- 419,429 ---- int highestCloseFailBit = Integer.highestOneBit(bitMap); if (1 << id != highestCloseFailBit) { throw new AssertionError("CloseFailException: got id " + id + ", expected lg(" + highestCloseFailBit +")"); } ! checkSuppressedExceptions(e.getSuppressed(), bitMap & ~highestCloseFailBit); } checkClosedList(closedList, 2); } } }
*** 441,451 **** throw new AssertionError( "Resource creation failed: " + e.resourceId()); } catch (MyKindOfException e) { if (failure == 0) throw new AssertionError("Unexpected MyKindOfException"); ! checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap); } catch (Resource.CloseFailException e) { if (failure == 1) throw new AssertionError("Secondary exception suppression failed"); int id = e.resourceId(); if (bitMap == 0) --- 441,451 ---- throw new AssertionError( "Resource creation failed: " + e.resourceId()); } catch (MyKindOfException e) { if (failure == 0) throw new AssertionError("Unexpected MyKindOfException"); ! checkSuppressedExceptions(e.getSuppressed(), bitMap); } catch (Resource.CloseFailException e) { if (failure == 1) throw new AssertionError("Secondary exception suppression failed"); int id = e.resourceId(); if (bitMap == 0)
*** 453,463 **** int highestCloseFailBit = Integer.highestOneBit(bitMap); if (1 << id != highestCloseFailBit) { throw new AssertionError("CloseFailException: got id " + id + ", expected lg(" + highestCloseFailBit +")"); } ! checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap & ~highestCloseFailBit); } checkClosedList(closedList, 2); } } } --- 453,463 ---- int highestCloseFailBit = Integer.highestOneBit(bitMap); if (1 << id != highestCloseFailBit) { throw new AssertionError("CloseFailException: got id " + id + ", expected lg(" + highestCloseFailBit +")"); } ! checkSuppressedExceptions(e.getSuppressed(), bitMap & ~highestCloseFailBit); } checkClosedList(closedList, 2); } } }
*** 475,485 **** throw new AssertionError( "Resource creation failed: " + e.resourceId()); } catch (MyKindOfException e) { if (failure == 0) throw new AssertionError("Unexpected MyKindOfException"); ! checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap); } catch (Resource.CloseFailException e) { if (failure == 1) throw new AssertionError("Secondary exception suppression failed"); int id = e.resourceId(); if (bitMap == 0) --- 475,485 ---- throw new AssertionError( "Resource creation failed: " + e.resourceId()); } catch (MyKindOfException e) { if (failure == 0) throw new AssertionError("Unexpected MyKindOfException"); ! checkSuppressedExceptions(e.getSuppressed(), bitMap); } catch (Resource.CloseFailException e) { if (failure == 1) throw new AssertionError("Secondary exception suppression failed"); int id = e.resourceId(); if (bitMap == 0)
*** 487,497 **** int highestCloseFailBit = Integer.highestOneBit(bitMap); if (1 << id != highestCloseFailBit) { throw new AssertionError("CloseFailException: got id " + id + ", expected lg(" + highestCloseFailBit +")"); } ! checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap & ~highestCloseFailBit); } checkClosedList(closedList, 3); } } } --- 487,497 ---- int highestCloseFailBit = Integer.highestOneBit(bitMap); if (1 << id != highestCloseFailBit) { throw new AssertionError("CloseFailException: got id " + id + ", expected lg(" + highestCloseFailBit +")"); } ! checkSuppressedExceptions(e.getSuppressed(), bitMap & ~highestCloseFailBit); } checkClosedList(closedList, 3); } } }
*** 511,521 **** throw new AssertionError( "Resource creation failed: " + e.resourceId()); } catch (MyKindOfException e) { if (failure == 0) throw new AssertionError("Unexpected MyKindOfException"); ! checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap); } catch (Resource.CloseFailException e) { if (failure == 1) throw new AssertionError("Secondary exception suppression failed"); int id = e.resourceId(); if (bitMap == 0) --- 511,521 ---- throw new AssertionError( "Resource creation failed: " + e.resourceId()); } catch (MyKindOfException e) { if (failure == 0) throw new AssertionError("Unexpected MyKindOfException"); ! checkSuppressedExceptions(e.getSuppressed(), bitMap); } catch (Resource.CloseFailException e) { if (failure == 1) throw new AssertionError("Secondary exception suppression failed"); int id = e.resourceId(); if (bitMap == 0)
*** 523,533 **** int highestCloseFailBit = Integer.highestOneBit(bitMap); if (1 << id != highestCloseFailBit) { throw new AssertionError("CloseFailException: got id " + id + ", expected lg(" + highestCloseFailBit +")"); } ! checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap & ~highestCloseFailBit); } checkClosedList(closedList, 3); } } } --- 523,533 ---- int highestCloseFailBit = Integer.highestOneBit(bitMap); if (1 << id != highestCloseFailBit) { throw new AssertionError("CloseFailException: got id " + id + ", expected lg(" + highestCloseFailBit +")"); } ! checkSuppressedExceptions(e.getSuppressed(), bitMap & ~highestCloseFailBit); } checkClosedList(closedList, 3); } } }
*** 546,556 **** throw new AssertionError( "Resource creation failed: " + e.resourceId()); } catch (MyKindOfException e) { if (failure == 0) throw new AssertionError("Unexpected MyKindOfException"); ! checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap); } catch (Resource.CloseFailException e) { if (failure == 1) throw new AssertionError("Secondary exception suppression failed"); int id = e.resourceId(); if (bitMap == 0) --- 546,556 ---- throw new AssertionError( "Resource creation failed: " + e.resourceId()); } catch (MyKindOfException e) { if (failure == 0) throw new AssertionError("Unexpected MyKindOfException"); ! checkSuppressedExceptions(e.getSuppressed(), bitMap); } catch (Resource.CloseFailException e) { if (failure == 1) throw new AssertionError("Secondary exception suppression failed"); int id = e.resourceId(); if (bitMap == 0)
*** 558,568 **** int highestCloseFailBit = Integer.highestOneBit(bitMap); if (1 << id != highestCloseFailBit) { throw new AssertionError("CloseFailException: got id " + id + ", expected lg(" + highestCloseFailBit +")"); } ! checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap & ~highestCloseFailBit); } checkClosedList(closedList, 4); } } } --- 558,568 ---- int highestCloseFailBit = Integer.highestOneBit(bitMap); if (1 << id != highestCloseFailBit) { throw new AssertionError("CloseFailException: got id " + id + ", expected lg(" + highestCloseFailBit +")"); } ! checkSuppressedExceptions(e.getSuppressed(), bitMap & ~highestCloseFailBit); } checkClosedList(closedList, 4); } } }
*** 584,594 **** throw new AssertionError( "Resource creation failed: " + e.resourceId()); } catch (MyKindOfException e) { if (failure == 0) throw new AssertionError("Unexpected MyKindOfException"); ! checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap); } catch (Resource.CloseFailException e) { if (failure == 1) throw new AssertionError("Secondary exception suppression failed"); int id = e.resourceId(); if (bitMap == 0) --- 584,594 ---- throw new AssertionError( "Resource creation failed: " + e.resourceId()); } catch (MyKindOfException e) { if (failure == 0) throw new AssertionError("Unexpected MyKindOfException"); ! checkSuppressedExceptions(e.getSuppressed(), bitMap); } catch (Resource.CloseFailException e) { if (failure == 1) throw new AssertionError("Secondary exception suppression failed"); int id = e.resourceId(); if (bitMap == 0)
*** 596,606 **** int highestCloseFailBit = Integer.highestOneBit(bitMap); if (1 << id != highestCloseFailBit) { throw new AssertionError("CloseFailException: got id " + id + ", expected lg(" + highestCloseFailBit +")"); } ! checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap & ~highestCloseFailBit); } checkClosedList(closedList, 4); } } } --- 596,606 ---- int highestCloseFailBit = Integer.highestOneBit(bitMap); if (1 << id != highestCloseFailBit) { throw new AssertionError("CloseFailException: got id " + id + ", expected lg(" + highestCloseFailBit +")"); } ! checkSuppressedExceptions(e.getSuppressed(), bitMap & ~highestCloseFailBit); } checkClosedList(closedList, 4); } } }
*** 619,629 **** } catch (Resource.CreateFailException e) { throw new AssertionError("Resource creation failed: " + e.resourceId()); } catch (MyKindOfException e) { if (failure == 0) throw new AssertionError("Unexpected MyKindOfException"); ! checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap); } catch (Resource.CloseFailException e) { if (failure == 1) throw new AssertionError("Secondary exception suppression failed"); int id = e.resourceId(); if (bitMap == 0) --- 619,629 ---- } catch (Resource.CreateFailException e) { throw new AssertionError("Resource creation failed: " + e.resourceId()); } catch (MyKindOfException e) { if (failure == 0) throw new AssertionError("Unexpected MyKindOfException"); ! checkSuppressedExceptions(e.getSuppressed(), bitMap); } catch (Resource.CloseFailException e) { if (failure == 1) throw new AssertionError("Secondary exception suppression failed"); int id = e.resourceId(); if (bitMap == 0)
*** 631,641 **** int highestCloseFailBit = Integer.highestOneBit(bitMap); if (1 << id != highestCloseFailBit) { throw new AssertionError("CloseFailException: got id " + id + ", expected lg(" + highestCloseFailBit +")"); } ! checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap & ~highestCloseFailBit); } checkClosedList(closedList, 5); } } } --- 631,641 ---- int highestCloseFailBit = Integer.highestOneBit(bitMap); if (1 << id != highestCloseFailBit) { throw new AssertionError("CloseFailException: got id " + id + ", expected lg(" + highestCloseFailBit +")"); } ! checkSuppressedExceptions(e.getSuppressed(), bitMap & ~highestCloseFailBit); } checkClosedList(closedList, 5); } } }
*** 658,668 **** } catch (Resource.CreateFailException e) { throw new AssertionError("Resource creation failed: " + e.resourceId()); } catch (MyKindOfException e) { if (failure == 0) throw new AssertionError("Unexpected MyKindOfException"); ! checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap); } catch (Resource.CloseFailException e) { if (failure == 1) throw new AssertionError("Secondary exception suppression failed"); int id = e.resourceId(); if (bitMap == 0) --- 658,668 ---- } catch (Resource.CreateFailException e) { throw new AssertionError("Resource creation failed: " + e.resourceId()); } catch (MyKindOfException e) { if (failure == 0) throw new AssertionError("Unexpected MyKindOfException"); ! checkSuppressedExceptions(e.getSuppressed(), bitMap); } catch (Resource.CloseFailException e) { if (failure == 1) throw new AssertionError("Secondary exception suppression failed"); int id = e.resourceId(); if (bitMap == 0)
*** 670,680 **** int highestCloseFailBit = Integer.highestOneBit(bitMap); if (1 << id != highestCloseFailBit) { throw new AssertionError("CloseFailException: got id " + id + ", expected lg(" + highestCloseFailBit +")"); } ! checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap & ~highestCloseFailBit); } checkClosedList(closedList, 5); } } } --- 670,680 ---- int highestCloseFailBit = Integer.highestOneBit(bitMap); if (1 << id != highestCloseFailBit) { throw new AssertionError("CloseFailException: got id " + id + ", expected lg(" + highestCloseFailBit +")"); } ! checkSuppressedExceptions(e.getSuppressed(), bitMap & ~highestCloseFailBit); } checkClosedList(closedList, 5); } } }