< prev index next >

test/gc/arguments/TestUnrecognizedVMOptionsHandling.java

Print this page




  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 TestUnrecognizedVMOptionsHandling
  26  * @key gc
  27  * @bug 8017611
  28  * @summary Tests handling unrecognized VM options
  29  * @library /testlibrary
  30  * @modules java.base/sun.misc
  31  *          java.management
  32  * @run main/othervm TestUnrecognizedVMOptionsHandling
  33  */
  34 
  35 import com.oracle.java.testlibrary.*;
  36 
  37 public class TestUnrecognizedVMOptionsHandling {
  38 
  39   public static void main(String args[]) throws Exception {
  40     // The first two JAVA processes are expected to fail, but with a correct VM option suggestion
  41     ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
  42       "-XX:+PrintGc",
  43       "-version"
  44       );
  45     OutputAnalyzer outputWithError = new OutputAnalyzer(pb.start());
  46     outputWithError.shouldContain("Did you mean '(+/-)PrintGC'?");
  47     if (outputWithError.getExitValue() == 0) {
  48       throw new RuntimeException("Not expected to get exit value 0");
  49     }
  50 
  51     pb = ProcessTools.createJavaProcessBuilder(
  52       "-XX:MaxiumHeapSize=500m",
  53       "-version"
  54       );
  55     outputWithError = new OutputAnalyzer(pb.start());


  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 TestUnrecognizedVMOptionsHandling
  26  * @key gc
  27  * @bug 8017611
  28  * @summary Tests handling unrecognized VM options
  29  * @library /testlibrary
  30  * @modules java.base/sun.misc
  31  *          java.management
  32  * @run main/othervm TestUnrecognizedVMOptionsHandling
  33  */
  34 
  35 import jdk.test.lib.*;
  36 
  37 public class TestUnrecognizedVMOptionsHandling {
  38 
  39   public static void main(String args[]) throws Exception {
  40     // The first two JAVA processes are expected to fail, but with a correct VM option suggestion
  41     ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
  42       "-XX:+PrintGc",
  43       "-version"
  44       );
  45     OutputAnalyzer outputWithError = new OutputAnalyzer(pb.start());
  46     outputWithError.shouldContain("Did you mean '(+/-)PrintGC'?");
  47     if (outputWithError.getExitValue() == 0) {
  48       throw new RuntimeException("Not expected to get exit value 0");
  49     }
  50 
  51     pb = ProcessTools.createJavaProcessBuilder(
  52       "-XX:MaxiumHeapSize=500m",
  53       "-version"
  54       );
  55     outputWithError = new OutputAnalyzer(pb.start());
< prev index next >