30 * @run main ClassFileInstaller sun.hotspot.WhiteBox
31 * sun.hotspot.WhiteBox$WhiteBoxPermission
32 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI TestCapacityUntilGCWrapAround
33 */
34
35 import sun.hotspot.WhiteBox;
36
37 import com.oracle.java.testlibrary.Asserts;
38 import com.oracle.java.testlibrary.Platform;
39
40 public class TestCapacityUntilGCWrapAround {
41 private static long MB = 1024 * 1024;
42 private static long GB = 1024 * MB;
43 private static long MAX_UINT = 4 * GB - 1; // On 32-bit platforms
44
45 public static void main(String[] args) {
46 if (Platform.is32bit()) {
47 WhiteBox wb = WhiteBox.getWhiteBox();
48
49 long before = wb.metaspaceCapacityUntilGC();
50 long after = wb.incMetaspaceCapacityUntilGC(MAX_UINT);
51
52 Asserts.assertGTE(after, before,
53 "Increasing with MAX_UINT should not cause wrap around: " + after + " < " + before);
54 Asserts.assertLTE(after, MAX_UINT,
55 "Increasing with MAX_UINT should not cause value larger than MAX_UINT:" + after);
56 }
57 }
58 }
|
30 * @run main ClassFileInstaller sun.hotspot.WhiteBox
31 * sun.hotspot.WhiteBox$WhiteBoxPermission
32 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI TestCapacityUntilGCWrapAround
33 */
34
35 import sun.hotspot.WhiteBox;
36
37 import com.oracle.java.testlibrary.Asserts;
38 import com.oracle.java.testlibrary.Platform;
39
40 public class TestCapacityUntilGCWrapAround {
41 private static long MB = 1024 * 1024;
42 private static long GB = 1024 * MB;
43 private static long MAX_UINT = 4 * GB - 1; // On 32-bit platforms
44
45 public static void main(String[] args) {
46 if (Platform.is32bit()) {
47 WhiteBox wb = WhiteBox.getWhiteBox();
48
49 long before = wb.metaspaceCapacityUntilGC();
50 // Now force possible overflow of capacity_until_GC.
51 long after = wb.incMetaspaceCapacityUntilGC(MAX_UINT);
52
53 Asserts.assertGTE(after, before,
54 "Increasing with MAX_UINT should not cause wrap around: " + after + " < " + before);
55 Asserts.assertLTE(after, MAX_UINT,
56 "Increasing with MAX_UINT should not cause value larger than MAX_UINT:" + after);
57 }
58 }
59 }
|