hotspot/test/runtime/CommandLine/ObsoleteFlagErrorMessage.java
author coleenp
Fri, 14 Nov 2014 13:09:53 -0500
changeset 27659 82af5d5e777b
child 29678 dd2f3932c21e
permissions -rw-r--r--
8060449: Obsolete command line flags accept arbitrary appendix Summary: Proper error messages for newly obsolete command line flags. Reviewed-by: lfoltan, dcubed, coleenp Contributed-by: max.ockner@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
27659
82af5d5e777b 8060449: Obsolete command line flags accept arbitrary appendix
coleenp
parents:
diff changeset
     1
/*
82af5d5e777b 8060449: Obsolete command line flags accept arbitrary appendix
coleenp
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
82af5d5e777b 8060449: Obsolete command line flags accept arbitrary appendix
coleenp
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
82af5d5e777b 8060449: Obsolete command line flags accept arbitrary appendix
coleenp
parents:
diff changeset
     4
 *
82af5d5e777b 8060449: Obsolete command line flags accept arbitrary appendix
coleenp
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
82af5d5e777b 8060449: Obsolete command line flags accept arbitrary appendix
coleenp
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
82af5d5e777b 8060449: Obsolete command line flags accept arbitrary appendix
coleenp
parents:
diff changeset
     7
 * published by the Free Software Foundation.
82af5d5e777b 8060449: Obsolete command line flags accept arbitrary appendix
coleenp
parents:
diff changeset
     8
 *
82af5d5e777b 8060449: Obsolete command line flags accept arbitrary appendix
coleenp
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
82af5d5e777b 8060449: Obsolete command line flags accept arbitrary appendix
coleenp
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
82af5d5e777b 8060449: Obsolete command line flags accept arbitrary appendix
coleenp
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
82af5d5e777b 8060449: Obsolete command line flags accept arbitrary appendix
coleenp
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
82af5d5e777b 8060449: Obsolete command line flags accept arbitrary appendix
coleenp
parents:
diff changeset
    13
 * accompanied this code).
82af5d5e777b 8060449: Obsolete command line flags accept arbitrary appendix
coleenp
parents:
diff changeset
    14
 *
82af5d5e777b 8060449: Obsolete command line flags accept arbitrary appendix
coleenp
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
82af5d5e777b 8060449: Obsolete command line flags accept arbitrary appendix
coleenp
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
82af5d5e777b 8060449: Obsolete command line flags accept arbitrary appendix
coleenp
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
82af5d5e777b 8060449: Obsolete command line flags accept arbitrary appendix
coleenp
parents:
diff changeset
    18
 *
82af5d5e777b 8060449: Obsolete command line flags accept arbitrary appendix
coleenp
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
82af5d5e777b 8060449: Obsolete command line flags accept arbitrary appendix
coleenp
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
82af5d5e777b 8060449: Obsolete command line flags accept arbitrary appendix
coleenp
parents:
diff changeset
    21
 * questions.
82af5d5e777b 8060449: Obsolete command line flags accept arbitrary appendix
coleenp
parents:
diff changeset
    22
 */
82af5d5e777b 8060449: Obsolete command line flags accept arbitrary appendix
coleenp
parents:
diff changeset
    23
82af5d5e777b 8060449: Obsolete command line flags accept arbitrary appendix
coleenp
parents:
diff changeset
    24
/*
82af5d5e777b 8060449: Obsolete command line flags accept arbitrary appendix
coleenp
parents:
diff changeset
    25
 * @test
82af5d5e777b 8060449: Obsolete command line flags accept arbitrary appendix
coleenp
parents:
diff changeset
    26
 * @bug 8060449
82af5d5e777b 8060449: Obsolete command line flags accept arbitrary appendix
coleenp
parents:
diff changeset
    27
 * @summary Newly obsolete command line options should still give useful error messages when used improperly.
82af5d5e777b 8060449: Obsolete command line flags accept arbitrary appendix
coleenp
parents:
diff changeset
    28
 * @library /testlibrary
82af5d5e777b 8060449: Obsolete command line flags accept arbitrary appendix
coleenp
parents:
diff changeset
    29
 */
82af5d5e777b 8060449: Obsolete command line flags accept arbitrary appendix
coleenp
parents:
diff changeset
    30
82af5d5e777b 8060449: Obsolete command line flags accept arbitrary appendix
coleenp
parents:
diff changeset
    31
import com.oracle.java.testlibrary.*;
82af5d5e777b 8060449: Obsolete command line flags accept arbitrary appendix
coleenp
parents:
diff changeset
    32
82af5d5e777b 8060449: Obsolete command line flags accept arbitrary appendix
coleenp
parents:
diff changeset
    33
public class ObsoleteFlagErrorMessage {
82af5d5e777b 8060449: Obsolete command line flags accept arbitrary appendix
coleenp
parents:
diff changeset
    34
  public static void main(String[] args) throws Exception {
82af5d5e777b 8060449: Obsolete command line flags accept arbitrary appendix
coleenp
parents:
diff changeset
    35
    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
82af5d5e777b 8060449: Obsolete command line flags accept arbitrary appendix
coleenp
parents:
diff changeset
    36
        "-XX:UseBoundThreadsPlusJunk", "-version");
82af5d5e777b 8060449: Obsolete command line flags accept arbitrary appendix
coleenp
parents:
diff changeset
    37
82af5d5e777b 8060449: Obsolete command line flags accept arbitrary appendix
coleenp
parents:
diff changeset
    38
    OutputAnalyzer output = new OutputAnalyzer(pb.start());
82af5d5e777b 8060449: Obsolete command line flags accept arbitrary appendix
coleenp
parents:
diff changeset
    39
    output.shouldContain("Unrecognized VM option 'UseBoundThreadsPlusJunk'"); // Must identify bad option.
82af5d5e777b 8060449: Obsolete command line flags accept arbitrary appendix
coleenp
parents:
diff changeset
    40
    output.shouldContain("UseBoundThreads"); // Should apply fuzzy matching to find correct option.
82af5d5e777b 8060449: Obsolete command line flags accept arbitrary appendix
coleenp
parents:
diff changeset
    41
    output.shouldContain("support").shouldContain("removed"); // Should warn user that the option they are trying to use is no longer supported.
82af5d5e777b 8060449: Obsolete command line flags accept arbitrary appendix
coleenp
parents:
diff changeset
    42
    output.shouldHaveExitValue(1);
82af5d5e777b 8060449: Obsolete command line flags accept arbitrary appendix
coleenp
parents:
diff changeset
    43
  }
82af5d5e777b 8060449: Obsolete command line flags accept arbitrary appendix
coleenp
parents:
diff changeset
    44
}