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 26 * @key gc 27 * @bug 8049831 28 * @library /testlibrary /testlibrary/whitebox 29 * @build TestCMSClassUnloadingEnabledHWM 30 * @run main ClassFileInstaller sun.hotspot.WhiteBox 31 * sun.hotspot.WhiteBox$WhiteBoxPermission 32 * @run driver TestCMSClassUnloadingEnabledHWM 33 * @summary Test that -XX:-CMSClassUnloadingEnabled will trigger a Full GC when more than MetaspaceSize metadata is allocated. 34 */ 35 36 import com.oracle.java.testlibrary.OutputAnalyzer; 37 import com.oracle.java.testlibrary.ProcessTools; 38 import java.lang.management.GarbageCollectorMXBean; 39 import java.lang.management.ManagementFactory; 40 import java.util.ArrayList; 41 import java.util.Arrays; 42 import sun.hotspot.WhiteBox; 43 44 public class TestCMSClassUnloadingEnabledHWM { 45 private static long MetaspaceSize = 32 * 1024 * 1024; 46 private static long YoungGenSize = 32 * 1024 * 1024; 47 48 private static OutputAnalyzer run(boolean enableUnloading) throws Exception { 49 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( 50 "-Xbootclasspath/a:.", 51 "-XX:+UnlockDiagnosticVMOptions", 52 "-XX:+WhiteBoxAPI", 53 "-Xmx128m", 54 "-XX:CMSMaxAbortablePrecleanTime=1", 55 "-XX:CMSWaitDuration=50", 56 "-XX:MetaspaceSize=" + MetaspaceSize, 57 "-Xmn" + YoungGenSize, 58 "-XX:+UseConcMarkSweepGC", 59 "-XX:" + (enableUnloading ? "+" : "-") + "CMSClassUnloadingEnabled", 60 "-XX:+PrintHeapAtGC", 61 "-XX:+PrintGCDetails", 62 "-XX:+PrintGCTimeStamps", | 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 26 * @key gc 27 * @bug 8049831 28 * @library /testlibrary /../../test/lib 29 * @build TestCMSClassUnloadingEnabledHWM 30 * @run main ClassFileInstaller jdk.testlib.WhiteBox 31 * jdk.testlib.WhiteBox$WhiteBoxPermission 32 * @run driver TestCMSClassUnloadingEnabledHWM 33 * @summary Test that -XX:-CMSClassUnloadingEnabled will trigger a Full GC when more than MetaspaceSize metadata is allocated. 34 */ 35 36 import com.oracle.java.testlibrary.OutputAnalyzer; 37 import com.oracle.java.testlibrary.ProcessTools; 38 import java.lang.management.GarbageCollectorMXBean; 39 import java.lang.management.ManagementFactory; 40 import java.util.ArrayList; 41 import java.util.Arrays; 42 import jdk.testlib.WhiteBox; 43 44 public class TestCMSClassUnloadingEnabledHWM { 45 private static long MetaspaceSize = 32 * 1024 * 1024; 46 private static long YoungGenSize = 32 * 1024 * 1024; 47 48 private static OutputAnalyzer run(boolean enableUnloading) throws Exception { 49 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( 50 "-Xbootclasspath/a:.", 51 "-XX:+UnlockDiagnosticVMOptions", 52 "-XX:+WhiteBoxAPI", 53 "-Xmx128m", 54 "-XX:CMSMaxAbortablePrecleanTime=1", 55 "-XX:CMSWaitDuration=50", 56 "-XX:MetaspaceSize=" + MetaspaceSize, 57 "-Xmn" + YoungGenSize, 58 "-XX:+UseConcMarkSweepGC", 59 "-XX:" + (enableUnloading ? "+" : "-") + "CMSClassUnloadingEnabled", 60 "-XX:+PrintHeapAtGC", 61 "-XX:+PrintGCDetails", 62 "-XX:+PrintGCTimeStamps", |