Petr Nejedl? discovered that surrounding variable definition with { } does not guarantee it to be removed from stack
authorJaroslav Tulach <jtulach@netbeans.org>
Wed, 29 Oct 2008 17:41:37 +0100
changeset 2880f2e5a6ddbe5
parent 287 e1186601a720
child 289 6f81ee6b914e
Petr Nejedl? discovered that surrounding variable definition with { } does not guarantee it to be removed from stack
samples/gc/test/org/apidesign/gc/CompilerSurprisesTest.java
     1.1 --- a/samples/gc/test/org/apidesign/gc/CompilerSurprisesTest.java	Fri Oct 24 21:15:50 2008 +0200
     1.2 +++ b/samples/gc/test/org/apidesign/gc/CompilerSurprisesTest.java	Wed Oct 29 17:41:37 2008 +0100
     1.3 @@ -85,6 +85,14 @@
     1.4      }
     1.5  // END: compiler.surprises.fix.final
     1.6  
     1.7 +// BEGIN: compiler.surprises.scope
     1.8 +    @Test public void canItBeHeldByNoLongerExistingScopeSurprisingly() {
     1.9 +        {
    1.10 +            Object val = factory();
    1.11 +        }
    1.12 +        assertNotGC("Surprisingly this variable cannot be GCed, even val is out of scope!!!!", cache);
    1.13 +    }
    1.14 +// END: compiler.surprises.scope
    1.15  
    1.16      private static void assertGC(String msg, Reference<?> ref) {
    1.17          NbTestCase.assertGC(msg, ref);