Tue, 10 Apr 2012 08:15:25 -0700
7074397: Build infrastructure changes (makefile re-write)
Summary: New makefiles transition, old and new living side by side for now.
Reviewed-by: ohair, jjg, dholmes, ohrstrom, erikj, ihse, tgranat, ykantser
Contributed-by: ohrstrom <fredrik.ohrstrom@oracle.com>, erikj <erik.joelsson@oracle.com>, ihse <magnus.ihse.bursie@oracle.com>, tgranat <torbjorn.granat@oracle.com>, ykantser <yekaterina.kantserova@oracle.com>
1 /*
2 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
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 */
25 /* @test
26 * @bug 6917288
27 * @summary Unnamed nested class is not generated
28 */
30 import java.io.*;
31 import java.util.*;
33 public class GraphicalInstallerTest {
34 public static void main(String... args) throws Exception {
35 new GraphicalInstallerTest().run();
36 }
38 void run() throws Exception {
39 File testSrc = new File(System.getProperty("test.src"));
40 File classes = new File("classes");
41 classes.mkdirs();
42 List<String> opts = Arrays.asList("-d", classes.getPath());
43 int rc = compile(opts, new File(testSrc, "GraphicalInstaller.java"));
44 if (rc != 0) {
45 error("compilation failed: rc=" + rc);
46 return;
47 }
49 check(classes,
50 "GraphicalInstaller$1.class",
51 "GraphicalInstaller$1X$1.class",
52 "GraphicalInstaller$1X.class",
53 "GraphicalInstaller$BackgroundInstaller.class",
54 "GraphicalInstaller.class");
56 if (errors > 0)
57 throw new Exception(errors + " errors occurred");
58 }
60 /**
61 * Compile files with given options.
62 * Display any output from compiler, and return javac return code.
63 */
64 int compile(List<String> opts, File... files) {
65 List<String> args = new ArrayList<String>();
66 args.addAll(opts);
67 for (File f: files)
68 args.add(f.getPath());
69 StringWriter sw = new StringWriter();
70 PrintWriter pw = new PrintWriter(sw);
71 int rc = com.sun.tools.javac.Main.compile(args.toArray(new String[args.size()]), pw);
72 pw.close();
73 String out = sw.toString();
74 if (out.length() > 0)
75 System.err.println(out);
76 return rc;
77 }
79 /**
80 * Check that a directory contains the expected files.
81 */
82 void check(File dir, String... paths) {
83 Set<String> found = new TreeSet<String>(Arrays.asList(dir.list()));
84 Set<String> expect = new TreeSet<String>(Arrays.asList(paths));
85 if (found.equals(expect))
86 return;
87 for (String f: found) {
88 if (!expect.contains(f))
89 error("Unexpected file found: " + f);
90 }
91 for (String e: expect) {
92 if (!found.contains(e))
93 error("Expected file not found: " + e);
94 }
95 }
97 /**
98 * Record an error message.
99 */
100 void error(String msg) {
101 System.err.println(msg);
102 errors++;
103 }
105 int errors;
106 }