author | erikj |
Thu, 14 Apr 2016 15:13:42 +0200 | |
changeset 37299 | db3b0d4c3bda |
parent 35061 | be6025ebffea |
child 38083 | 2ffb46735fec |
permissions | -rw-r--r-- |
29682
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
1 |
/* |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
2 |
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
4 |
* |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
8 |
* |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
13 |
* accompanied this code). |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
14 |
* |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
18 |
* |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
21 |
* questions. |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
22 |
*/ |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
23 |
|
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
24 |
/* |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
25 |
* @test TestDisableExplicitGC |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
26 |
* @requires vm.opt.DisableExplicitGC == null |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
27 |
* @summary Verify GC behavior with DisableExplicitGC flag. |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
28 |
* @library /testlibrary |
35061 | 29 |
* @run main/othervm -Xlog:gc=debug TestDisableExplicitGC |
30 |
* @run main/othervm/fail -XX:+DisableExplicitGC -Xlog:gc=debug TestDisableExplicitGC |
|
31 |
* @run main/othervm -XX:-DisableExplicitGC -Xlog:gc=debug TestDisableExplicitGC |
|
29682
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
32 |
*/ |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
33 |
import java.lang.management.GarbageCollectorMXBean; |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
34 |
import java.util.List; |
30604
b8d532cb6420
8067013: Rename the com.oracle.java.testlibary package
ykantser
parents:
29682
diff
changeset
|
35 |
import static jdk.test.lib.Asserts.*; |
29682
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
36 |
|
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
37 |
public class TestDisableExplicitGC { |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
38 |
|
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
39 |
public static void main(String[] args) throws InterruptedException { |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
40 |
List<GarbageCollectorMXBean> list = java.lang.management.ManagementFactory.getGarbageCollectorMXBeans(); |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
41 |
long collectionCountBefore = getCollectionCount(list); |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
42 |
System.gc(); |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
43 |
long collectionCountAfter = getCollectionCount(list); |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
44 |
assertLT(collectionCountBefore, collectionCountAfter); |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
45 |
} |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
46 |
|
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
47 |
private static long getCollectionCount(List<GarbageCollectorMXBean> list) { |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
48 |
int collectionCount = 0; |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
49 |
for (GarbageCollectorMXBean gcMXBean : list) { |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
50 |
collectionCount += gcMXBean.getCollectionCount(); |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
51 |
} |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
52 |
return collectionCount; |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
53 |
} |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
54 |
} |