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 * @modules java.base/jdk.internal.misc 30 * java.management 31 * @build TestG1ClassUnloadingHWM 32 * @run main ClassFileInstaller sun.hotspot.WhiteBox 33 * sun.hotspot.WhiteBox$WhiteBoxPermission 34 * @run driver TestG1ClassUnloadingHWM 35 * @summary Test that -XX:-ClassUnloadingWithConcurrentMark will trigger a Full GC when more than MetaspaceSize metadata is allocated. 36 */ 37 38 import jdk.test.lib.OutputAnalyzer; 39 import jdk.test.lib.ProcessTools; 40 import java.util.ArrayList; 41 import java.util.Arrays; 42 import sun.hotspot.WhiteBox; 43 44 public class TestG1ClassUnloadingHWM { 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 "-XX:MetaspaceSize=" + MetaspaceSize, 54 "-Xmn" + YoungGenSize, 55 "-XX:+UseG1GC", 56 "-XX:" + (enableUnloading ? "+" : "-") + "ClassUnloadingWithConcurrentMark", 57 "-Xlog:gc", 58 TestG1ClassUnloadingHWM.AllocateBeyondMetaspaceSize.class.getName(), 59 "" + MetaspaceSize, | 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 /test/lib 29 * @modules java.base/jdk.internal.misc 30 * java.management 31 * @build sun.hotspot.WhiteBox 32 * @run main ClassFileInstaller sun.hotspot.WhiteBox 33 * sun.hotspot.WhiteBox$WhiteBoxPermission 34 * @run driver TestG1ClassUnloadingHWM 35 * @summary Test that -XX:-ClassUnloadingWithConcurrentMark will trigger a Full GC when more than MetaspaceSize metadata is allocated. 36 */ 37 38 import jdk.test.lib.process.OutputAnalyzer; 39 import jdk.test.lib.process.ProcessTools; 40 import java.util.ArrayList; 41 import java.util.Arrays; 42 import sun.hotspot.WhiteBox; 43 44 public class TestG1ClassUnloadingHWM { 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 "-XX:MetaspaceSize=" + MetaspaceSize, 54 "-Xmn" + YoungGenSize, 55 "-XX:+UseG1GC", 56 "-XX:" + (enableUnloading ? "+" : "-") + "ClassUnloadingWithConcurrentMark", 57 "-Xlog:gc", 58 TestG1ClassUnloadingHWM.AllocateBeyondMetaspaceSize.class.getName(), 59 "" + MetaspaceSize, |