727N/A/*
727N/A * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
727N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
727N/A *
727N/A * This code is free software; you can redistribute it and/or modify it
727N/A * under the terms of the GNU General Public License version 2 only, as
727N/A * published by the Free Software Foundation.
727N/A *
727N/A * This code is distributed in the hope that it will be useful, but WITHOUT
727N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
727N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
727N/A * version 2 for more details (a copy is included in the LICENSE file that
727N/A * accompanied this code).
727N/A *
727N/A * You should have received a copy of the GNU General Public License version
727N/A * 2 along with this work; if not, write to the Free Software Foundation,
727N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
727N/A *
727N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
727N/A * or visit www.oracle.com if you need additional information or have any
727N/A * questions.
727N/A */
727N/A
727N/A/*
727N/A * @test
727N/A * @bug 6994608
727N/A * @summary javah no longer accepts parameter files as input
727N/A */
727N/A
727N/Aimport java.io.*;
727N/Aimport java.util.*;
727N/A
727N/Apublic class T6994608 {
727N/A public static void main(String... args) throws Exception {
727N/A new T6994608().run();
727N/A }
727N/A
727N/A void run() throws Exception {
727N/A Locale prev = Locale.getDefault();
727N/A Locale.setDefault(Locale.ENGLISH);
727N/A try {
727N/A File f = writeFile(new File("classList"), "java.lang.Object");
727N/A test(Arrays.asList("@" + f.getPath()), 0, null);
727N/A test(Arrays.asList("@badfile"), 1, "Can't find file badfile");
727N/A if (errors > 0)
727N/A throw new Exception(errors + " errors occurred");
727N/A } finally {
727N/A Locale.setDefault(prev);
727N/A }
727N/A }
727N/A
727N/A void test(List<String> args, int expectRC, String expectOut) {
727N/A System.err.println("Test: " + args
727N/A + " rc:" + expectRC
727N/A + ((expectOut != null) ? " out:" + expectOut : ""));
727N/A
727N/A StringWriter sw = new StringWriter();
727N/A PrintWriter pw = new PrintWriter(sw);
727N/A int rc = com.sun.tools.javah.Main.run(args.toArray(new String[args.size()]), pw);
727N/A pw.close();
727N/A String out = sw.toString();
727N/A if (!out.isEmpty())
727N/A System.err.println(out);
727N/A
727N/A if (rc != expectRC)
727N/A error("Unexpected exit code: " + rc + "; expected: " + expectRC);
727N/A if (expectOut != null && !out.contains(expectOut))
727N/A error("Expected string not found: " + expectOut);
727N/A
727N/A System.err.println();
727N/A }
727N/A
727N/A File writeFile(File f, String s) throws IOException {
727N/A if (f.getParentFile() != null)
727N/A f.getParentFile().mkdirs();
727N/A try (FileWriter out = new FileWriter(f)) {
727N/A out.write(s);
727N/A }
727N/A return f;
727N/A }
727N/A
727N/A void error(String msg) {
727N/A System.err.println(msg);
727N/A errors++;
727N/A }
727N/A
727N/A int errors;
727N/A}
727N/A