hotspot/test/gc/startup_warnings/TestCMSForegroundFlags.java
author brutisso
Mon, 28 Oct 2013 13:27:57 +0100
changeset 21196 538177a5209a
permissions -rw-r--r--
8027132: Print deprecation warning message for the flags controlling the CMS foreground collector Reviewed-by: stefank, ehelin, ysr, tschatzl
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
21196
538177a5209a 8027132: Print deprecation warning message for the flags controlling the CMS foreground collector
brutisso
parents:
diff changeset
     1
/*
538177a5209a 8027132: Print deprecation warning message for the flags controlling the CMS foreground collector
brutisso
parents:
diff changeset
     2
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
538177a5209a 8027132: Print deprecation warning message for the flags controlling the CMS foreground collector
brutisso
parents:
diff changeset
     3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
538177a5209a 8027132: Print deprecation warning message for the flags controlling the CMS foreground collector
brutisso
parents:
diff changeset
     4
*
538177a5209a 8027132: Print deprecation warning message for the flags controlling the CMS foreground collector
brutisso
parents:
diff changeset
     5
* This code is free software; you can redistribute it and/or modify it
538177a5209a 8027132: Print deprecation warning message for the flags controlling the CMS foreground collector
brutisso
parents:
diff changeset
     6
* under the terms of the GNU General Public License version 2 only, as
538177a5209a 8027132: Print deprecation warning message for the flags controlling the CMS foreground collector
brutisso
parents:
diff changeset
     7
* published by the Free Software Foundation.
538177a5209a 8027132: Print deprecation warning message for the flags controlling the CMS foreground collector
brutisso
parents:
diff changeset
     8
*
538177a5209a 8027132: Print deprecation warning message for the flags controlling the CMS foreground collector
brutisso
parents:
diff changeset
     9
* This code is distributed in the hope that it will be useful, but WITHOUT
538177a5209a 8027132: Print deprecation warning message for the flags controlling the CMS foreground collector
brutisso
parents:
diff changeset
    10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
538177a5209a 8027132: Print deprecation warning message for the flags controlling the CMS foreground collector
brutisso
parents:
diff changeset
    11
* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
538177a5209a 8027132: Print deprecation warning message for the flags controlling the CMS foreground collector
brutisso
parents:
diff changeset
    12
* version 2 for more details (a copy is included in the LICENSE file that
538177a5209a 8027132: Print deprecation warning message for the flags controlling the CMS foreground collector
brutisso
parents:
diff changeset
    13
* accompanied this code).
538177a5209a 8027132: Print deprecation warning message for the flags controlling the CMS foreground collector
brutisso
parents:
diff changeset
    14
*
538177a5209a 8027132: Print deprecation warning message for the flags controlling the CMS foreground collector
brutisso
parents:
diff changeset
    15
* You should have received a copy of the GNU General Public License version
538177a5209a 8027132: Print deprecation warning message for the flags controlling the CMS foreground collector
brutisso
parents:
diff changeset
    16
* 2 along with this work; if not, write to the Free Software Foundation,
538177a5209a 8027132: Print deprecation warning message for the flags controlling the CMS foreground collector
brutisso
parents:
diff changeset
    17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
538177a5209a 8027132: Print deprecation warning message for the flags controlling the CMS foreground collector
brutisso
parents:
diff changeset
    18
*
538177a5209a 8027132: Print deprecation warning message for the flags controlling the CMS foreground collector
brutisso
parents:
diff changeset
    19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
538177a5209a 8027132: Print deprecation warning message for the flags controlling the CMS foreground collector
brutisso
parents:
diff changeset
    20
* or visit www.oracle.com if you need additional information or have any
538177a5209a 8027132: Print deprecation warning message for the flags controlling the CMS foreground collector
brutisso
parents:
diff changeset
    21
* questions.
538177a5209a 8027132: Print deprecation warning message for the flags controlling the CMS foreground collector
brutisso
parents:
diff changeset
    22
*/
538177a5209a 8027132: Print deprecation warning message for the flags controlling the CMS foreground collector
brutisso
parents:
diff changeset
    23
538177a5209a 8027132: Print deprecation warning message for the flags controlling the CMS foreground collector
brutisso
parents:
diff changeset
    24
/*
538177a5209a 8027132: Print deprecation warning message for the flags controlling the CMS foreground collector
brutisso
parents:
diff changeset
    25
* @test TestCMSForegroundFlags
538177a5209a 8027132: Print deprecation warning message for the flags controlling the CMS foreground collector
brutisso
parents:
diff changeset
    26
* @key gc
538177a5209a 8027132: Print deprecation warning message for the flags controlling the CMS foreground collector
brutisso
parents:
diff changeset
    27
* @bug 8027132
538177a5209a 8027132: Print deprecation warning message for the flags controlling the CMS foreground collector
brutisso
parents:
diff changeset
    28
* @summary Test that the deprecated CMS foreground collector flags print warning messages
538177a5209a 8027132: Print deprecation warning message for the flags controlling the CMS foreground collector
brutisso
parents:
diff changeset
    29
* @library /testlibrary
538177a5209a 8027132: Print deprecation warning message for the flags controlling the CMS foreground collector
brutisso
parents:
diff changeset
    30
* @run main TestCMSForegroundFlags -XX:-UseCMSCompactAtFullCollection UseCMSCompactAtFullCollection
538177a5209a 8027132: Print deprecation warning message for the flags controlling the CMS foreground collector
brutisso
parents:
diff changeset
    31
* @run main TestCMSForegroundFlags -XX:CMSFullGCsBeforeCompaction=4 CMSFullGCsBeforeCompaction
538177a5209a 8027132: Print deprecation warning message for the flags controlling the CMS foreground collector
brutisso
parents:
diff changeset
    32
* @run main TestCMSForegroundFlags -XX:-UseCMSCollectionPassing UseCMSCollectionPassing
538177a5209a 8027132: Print deprecation warning message for the flags controlling the CMS foreground collector
brutisso
parents:
diff changeset
    33
*/
538177a5209a 8027132: Print deprecation warning message for the flags controlling the CMS foreground collector
brutisso
parents:
diff changeset
    34
538177a5209a 8027132: Print deprecation warning message for the flags controlling the CMS foreground collector
brutisso
parents:
diff changeset
    35
import com.oracle.java.testlibrary.OutputAnalyzer;
538177a5209a 8027132: Print deprecation warning message for the flags controlling the CMS foreground collector
brutisso
parents:
diff changeset
    36
import com.oracle.java.testlibrary.ProcessTools;
538177a5209a 8027132: Print deprecation warning message for the flags controlling the CMS foreground collector
brutisso
parents:
diff changeset
    37
538177a5209a 8027132: Print deprecation warning message for the flags controlling the CMS foreground collector
brutisso
parents:
diff changeset
    38
public class TestCMSForegroundFlags {
538177a5209a 8027132: Print deprecation warning message for the flags controlling the CMS foreground collector
brutisso
parents:
diff changeset
    39
  public static void main(String[] args) throws Exception {
538177a5209a 8027132: Print deprecation warning message for the flags controlling the CMS foreground collector
brutisso
parents:
diff changeset
    40
    if (args.length != 2) {
538177a5209a 8027132: Print deprecation warning message for the flags controlling the CMS foreground collector
brutisso
parents:
diff changeset
    41
      throw new Exception("Expected two arguments,flagValue and flagName");
538177a5209a 8027132: Print deprecation warning message for the flags controlling the CMS foreground collector
brutisso
parents:
diff changeset
    42
    }
538177a5209a 8027132: Print deprecation warning message for the flags controlling the CMS foreground collector
brutisso
parents:
diff changeset
    43
    String flagValue = args[0];
538177a5209a 8027132: Print deprecation warning message for the flags controlling the CMS foreground collector
brutisso
parents:
diff changeset
    44
    String flagName = args[1];
538177a5209a 8027132: Print deprecation warning message for the flags controlling the CMS foreground collector
brutisso
parents:
diff changeset
    45
538177a5209a 8027132: Print deprecation warning message for the flags controlling the CMS foreground collector
brutisso
parents:
diff changeset
    46
    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(flagValue, "-version");
538177a5209a 8027132: Print deprecation warning message for the flags controlling the CMS foreground collector
brutisso
parents:
diff changeset
    47
    OutputAnalyzer output = new OutputAnalyzer(pb.start());
538177a5209a 8027132: Print deprecation warning message for the flags controlling the CMS foreground collector
brutisso
parents:
diff changeset
    48
    output.shouldContain("warning: " + flagName + " is deprecated and will likely be removed in a future release.");
538177a5209a 8027132: Print deprecation warning message for the flags controlling the CMS foreground collector
brutisso
parents:
diff changeset
    49
    output.shouldNotContain("error");
538177a5209a 8027132: Print deprecation warning message for the flags controlling the CMS foreground collector
brutisso
parents:
diff changeset
    50
    output.shouldHaveExitValue(0);
538177a5209a 8027132: Print deprecation warning message for the flags controlling the CMS foreground collector
brutisso
parents:
diff changeset
    51
  }
538177a5209a 8027132: Print deprecation warning message for the flags controlling the CMS foreground collector
brutisso
parents:
diff changeset
    52
}