# HG changeset patch # User Jaroslav Tulach # Date 1225298497 -3600 # Node ID 0f2e5a6ddbe5e7dfda81da6240fa8aa6261461da # Parent e1186601a720a34e2d202a099c55b0794363428e Petr Nejedl? discovered that surrounding variable definition with { } does not guarantee it to be removed from stack diff -r e1186601a720 -r 0f2e5a6ddbe5 samples/gc/test/org/apidesign/gc/CompilerSurprisesTest.java --- a/samples/gc/test/org/apidesign/gc/CompilerSurprisesTest.java Fri Oct 24 21:15:50 2008 +0200 +++ b/samples/gc/test/org/apidesign/gc/CompilerSurprisesTest.java Wed Oct 29 17:41:37 2008 +0100 @@ -85,6 +85,14 @@ } // END: compiler.surprises.fix.final +// BEGIN: compiler.surprises.scope + @Test public void canItBeHeldByNoLongerExistingScopeSurprisingly() { + { + Object val = factory(); + } + assertNotGC("Surprisingly this variable cannot be GCed, even val is out of scope!!!!", cache); + } +// END: compiler.surprises.scope private static void assertGC(String msg, Reference ref) { NbTestCase.assertGC(msg, ref);