4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 import jdk.test.lib.Asserts;
25 import jdk.test.lib.Utils;
26 import java.lang.management.ManagementFactory;
27 import java.lang.management.MemoryNotificationInfo;
28 import java.lang.management.MemoryPoolMXBean;
29 import java.util.HashMap;
30 import java.util.Map;
31 import java.util.concurrent.atomic.AtomicInteger;
32 import javax.management.ListenerNotFoundException;
33 import javax.management.Notification;
34 import javax.management.NotificationEmitter;
35 import javax.management.NotificationListener;
36 import sun.hotspot.code.BlobType;
37
38 /*
39 * @test PoolsIndependenceTest
40 * @modules java.base/jdk.internal.misc
41 * java.management
42 * @library /testlibrary /test/lib
43 * @build PoolsIndependenceTest
44 * @run main ClassFileInstaller sun.hotspot.WhiteBox
45 * sun.hotspot.WhiteBox$WhiteBoxPermission
46 * @run main/othervm -Xbootclasspath/a:. -XX:-UseCodeCacheFlushing
47 * -XX:-MethodFlushing -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
48 * -XX:+SegmentedCodeCache PoolsIndependenceTest
49 * @summary testing of getUsageThreshold()
50 */
51 public class PoolsIndependenceTest implements NotificationListener {
52
53 private final Map<String, AtomicInteger> counters;
54 private final BlobType btype;
55 private volatile long lastEventTimestamp;
56
57 public PoolsIndependenceTest(BlobType btype) {
58 counters = new HashMap<>();
59 for (BlobType bt : BlobType.getAvailable()) {
60 counters.put(bt.getMemoryPool().getName(), new AtomicInteger(0));
61 }
62 this.btype = btype;
63 lastEventTimestamp = 0;
64 CodeCacheUtils.disableCollectionUsageThresholds();
65 }
66
67 public static void main(String[] args) {
68 for (BlobType bt : BlobType.getAvailable()) {
69 new PoolsIndependenceTest(bt).runTest();
70 }
|
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test PoolsIndependenceTest
26 * @summary testing of getUsageThreshold()
27 * @modules java.base/jdk.internal.misc
28 * java.management
29 * @library /testlibrary /test/lib /
30 *
31 * @build compiler.codecache.jmx.PoolsIndependenceTest
32 * @run driver ClassFileInstaller sun.hotspot.WhiteBox
33 * sun.hotspot.WhiteBox$WhiteBoxPermission
34 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
35 * -XX:+WhiteBoxAPI -XX:-UseCodeCacheFlushing -XX:-MethodFlushing
36 * -XX:+SegmentedCodeCache
37 * compiler.codecache.jmx.PoolsIndependenceTest
38 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
39 * -XX:+WhiteBoxAPI -XX:-UseCodeCacheFlushing -XX:-MethodFlushing
40 * -XX:-SegmentedCodeCache
41 * compiler.codecache.jmx.PoolsIndependenceTest
42 */
43
44 package compiler.codecache.jmx;
45
46 import jdk.test.lib.Asserts;
47 import jdk.test.lib.Utils;
48 import sun.hotspot.code.BlobType;
49
50 import javax.management.ListenerNotFoundException;
51 import javax.management.Notification;
52 import javax.management.NotificationEmitter;
53 import javax.management.NotificationListener;
54 import java.lang.management.ManagementFactory;
55 import java.lang.management.MemoryNotificationInfo;
56 import java.lang.management.MemoryPoolMXBean;
57 import java.util.HashMap;
58 import java.util.Map;
59 import java.util.concurrent.atomic.AtomicInteger;
60
61 public class PoolsIndependenceTest implements NotificationListener {
62
63 private final Map<String, AtomicInteger> counters;
64 private final BlobType btype;
65 private volatile long lastEventTimestamp;
66
67 public PoolsIndependenceTest(BlobType btype) {
68 counters = new HashMap<>();
69 for (BlobType bt : BlobType.getAvailable()) {
70 counters.put(bt.getMemoryPool().getName(), new AtomicInteger(0));
71 }
72 this.btype = btype;
73 lastEventTimestamp = 0;
74 CodeCacheUtils.disableCollectionUsageThresholds();
75 }
76
77 public static void main(String[] args) {
78 for (BlobType bt : BlobType.getAvailable()) {
79 new PoolsIndependenceTest(bt).runTest();
80 }
|