Mon, 17 Oct 2016 21:20:17 -0700
8168115: Remove and retag jdk8u122-b03 in 8u repo
Reviewed-by: coffeys
1 /*
2 * Copyright (c) 2012, 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 */
24 /*
25 * @test
26 * @bug 7142672
27 * @summary Problems with the value passed to the 'classes' param of JavaCompiler.CompilationTask.getTask(...)
28 * @author holmlund
29 * @compile AnnoProcessor.java Bug.java Test3.java
30 * @run main Bug Test2.java
31 * @run main Bug Test2.foo
32 * @run main Bug Test3.java
33 */
34 import java.io.*;
35 import java.util.*;
36 import javax.tools.*;
38 // Each run should output the 'could not find class file' message, and not throw an AssertError.
39 public class Bug {
40 public static void main(String... arg) throws Throwable {
41 String name = arg[0];
42 final String expectedMsg = "error: Could not find class file for '" + name + "'.";
43 JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
44 JavaCompiler.CompilationTask task2;
45 StringWriter sw = new StringWriter();
46 final PrintWriter pw = new PrintWriter(sw);
49 DiagnosticListener<? super javax.tools.JavaFileObject> dl =
50 new DiagnosticListener<javax.tools.JavaFileObject>() {
51 public void report(Diagnostic message) {
52 pw.print("Diagnostic:\n"+ message.toString()+"\n");
53 if (!message.toString().equals(expectedMsg)){
54 System.err.println("Diagnostic:\n"+ message.toString()+"\n");
55 System.err.println("--Failed: Unexpected diagnostic");
56 System.exit(1);
57 }
58 }
59 };
61 StandardJavaFileManager sjfm = javac.getStandardFileManager(dl,null,null);
63 List<String> opts = new ArrayList<String>();
64 opts.add("-proc:only");
65 opts.add("-processor");
66 opts.add("AnnoProcessor");
68 boolean xxx;
70 System.err.println("\n-- " + name);
71 task2 = javac.getTask(pw, sjfm, dl, opts, Arrays.asList(name), null);
72 xxx = task2.call();
74 String out = sw.toString();
75 System.err.println(out);
76 if (out.contains("Assert")) {
77 System.err.println("--Failed: Assertion failure");
78 System.exit(1);
79 }
80 if (!out.contains(expectedMsg)) {
81 System.err.println("--Failed: Expected diagnostic not found");
82 System.exit(1);
83 }
84 }
85 }