Path: blob/master/test/jdk/tools/launcher/ChangeDataModel.java
41145 views
/*1* Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/**24* @test25* @bug 4894330 4810347 6277269 8029388 816964626* @compile -XDignore.symbol.file ChangeDataModel.java27* @run main ChangeDataModel28* @summary Verify -d32, -d64 and -J prefixed data-model options are rejected on all platforms29* @author Joseph D. Darcy, ksrini30*/3132import java.util.Arrays;3334public class ChangeDataModel extends TestHelper {3536public static void main(String... args) throws Exception {37new ChangeDataModel().run(args);38}3940@Test41public void check32bitRejection() throws Exception {42checkRejection("-d32");43}4445@Test46public void check64bitRejection() throws Exception {47checkRejection("-d64");48}4950void checkRejection(String dmodel) throws Exception {51String expect = "Unrecognized option: " + dmodel;52String[] cmds1 = {53javaCmd,54dmodel,55"-version"56};57checkRejection(expect, cmds1);5859String[] cmds2 = {60javacCmd,61"-J" + dmodel,62"-version"63};64checkRejection(expect, cmds2);65}666768void checkRejection(String expect, String... cmds) throws Exception {69TestResult tr = doExec(cmds);70tr.checkNegative();71if (!tr.contains(expect)) {72System.out.println(tr);73String error = "did not get " + "\'" + expect + "\'" +74"with options " + Arrays.asList(cmds);75throw new Exception(error);76}77}78}798081