< prev index next > test/hotspot/jtreg/gc/TestSoftReferencesBehaviorOnOOME.java
8217332: JTREG: Clean up, use generics instead of raw types
* Test that all SoftReferences has been cleared at time of OOM.
*/
void softReferencesOom(long minSize, long maxSize) {
System.out.format( "minSize = %d, maxSize = %d%n", minSize, maxSize );
- LinkedList<SoftReference> arrSoftRefs = new LinkedList();
+ LinkedList<SoftReference<byte[]>> arrSoftRefs = new LinkedList<>();
staticRef = arrSoftRefs;
- LinkedList arrObjects = new LinkedList();
+ LinkedList<byte[]> arrObjects = new LinkedList<>();
staticRef = arrObjects;
long multiplier = maxSize - minSize;
long numberOfNotNulledObjects = 0;
System.out.println("num Soft: " + numSofts);
while (numSofts-- > 0) {
int allocationSize = ((int) (RND_GENERATOR.nextDouble() * multiplier))
+ (int)minSize;
- arrSoftRefs.add(new SoftReference(new byte[allocationSize]));
+ arrSoftRefs.add(new SoftReference<byte[]>(new byte[allocationSize]));
}
System.out.println("free: " + Runtime.getRuntime().freeMemory());
// provoke OOME.
// Clear allocated ballast, so we don't get another OOM.
staticRef = null;
arrObjects = null;
long oomSoftArraySize = arrSoftRefs.size();
- for (SoftReference sr : arrSoftRefs) {
+ for (SoftReference<byte[]> sr : arrSoftRefs) {
Object o = sr.get();
if (o != null) {
numberOfNotNulledObjects++;
}
< prev index next >