/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4405807
* @summary Verify that references from ResourceBundle cache don't prevent
* class loader reclamation.
*/
/**
* This test relies on the current behavior of the garbage collector and is
* therefore no clear indicator of whether the fix for 4405807 works.
* If the test fails, it might indicate a regression, or it might just mean
* that a less aggressive garbage collector is used.
*/
public class ReferencesTest {
// These two parallel arrays have references to the same class loaders.
// The weakLoaders array lets us track whether class loaders are being
// reclaimed after the references in the loaders array are nulled out.
}
// fill the ResourceBundle cache with entries for half the class loaders
report("After loading resource bundles for first half of class loaders: ");
// release the first half of the class loaders
}
report("After releasing first half of class loaders: ");
// fill the ResourceBundle cache with entries for second half the class loaders
report("After loading resource bundles for second half of class loaders: ");
// release the second half of the class loaders
}
report("After releasing second half of class loaders: ");
// The garbage collector in Tiger actually has reclaimed all class
// loaders at this point, but in order not to become too dependent
// on the current behavior, we only require that the first half
// has been reclaimed.
throw new RuntimeException("Too many class loaders not reclaimed yet.");
}
}
cacheList.setAccessible(true);
}
// There's no resource bundle for NonExistantBundle - this
// let's us test the case where a resource bundle is not found,
// which in the past created a SoftReference on the value side
// of the cache.
try {
} catch (MissingResourceException e) {
}
// There's a base resource bundle for ReferencesTestBundle - the
// normal case.
}
}
int count = 0;
count++;
}
}
return count;
}
}