/*
* 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 4530538
* @summary Basic unit test of MemoryMXBean.getMemoryPools() and
* MemoryMXBean.getMemoryManager().
* @author Mandy Chung
*
* @run main MemoryTest 2
*/
/*
* NOTE: This expected result is hardcoded in this test and this test
* will be affected if the heap memory layout is changed in
* the future implementation.
*/
public class MemoryTest {
private static boolean testFailed = false;
// WARNING: if the number of pools changes in the future,
// this test needs to be modified to handle different version of VMs.
// Hotspot VM 1.5 expected to have
// heap memory pools = 3 (Eden, Survivor spaces, Old gen)
// non-heap memory pools = 2 (Perm gen, Code cache)
// or 4 if Class Sharing is enabled.
// Number of memory managers = 3
// (or equivalent for other collectors)
// Number of GC memory managers = 2
if (testFailed)
throw new RuntimeException("TEST FAILED.");
}
}
}
}
// Check the number of Memory pools
for (int i = 0; i < NUM_TYPES; i++) {
if (numPools[i] < expectedMinNumPools[i] ||
numPools[i] > expectedMaxNumPools[i]) {
throw new RuntimeException("TEST FAILED: " +
" but expected <= " + expectedMaxNumPools[i] +
" and >= " + expectedMinNumPools[i]);
}
}
}
int numGCMgr = 0;
// Check the number of Memory Managers
throw new RuntimeException("TEST FAILED: " +
"Expected to have one or more pools for " +
}
if (mgr instanceof GarbageCollectorMXBean) {
numGCMgr++;
} else {
}
}
}
throw new RuntimeException("TEST FAILED: " +
" but expected = " + expectedNumMgrs);
}
if (numGCMgr != expectedNumGCMgrs) {
throw new RuntimeException("TEST FAILED: " +
}
}
throws Exception {
throw new RuntimeException("TEST FAILED: " +
} else {
return;
}
}
}
throw new RuntimeException("TEST FAILED: " +
" not found");
}
}