Wed, 25 Aug 2010 11:40:25 -0700
6960424: new option -Xpkginfo for better control of when package-info.class is generated
Reviewed-by: mcimadamore
1 /*
2 * Copyright (c) 2006, 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 6437999
27 * @summary Unit test for encoding argument to standard file manager
28 * @author Peter von der Ah\u00e9
29 * @library ../lib
30 * @compile T6437999.java
31 * @run main T6437999
32 */
34 import java.io.File;
35 import java.nio.charset.Charset;
36 import java.util.Collections;
37 import javax.tools.*;
39 public class T6437999 extends ToolTester {
40 static class MyDiagnosticListener implements DiagnosticListener<JavaFileObject> {
41 boolean error = false;
42 public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
43 error |= diagnostic.getKind() == Diagnostic.Kind.ERROR;
44 System.out.println(diagnostic);
45 }
46 }
48 void test(String... args) {
49 Iterable<String> sourceLevel = Collections.singleton("6");
50 MyDiagnosticListener dl = new MyDiagnosticListener();
51 StandardJavaFileManager fm;
52 Iterable<? extends JavaFileObject> files;
54 dl.error = false;
55 fm = getFileManager(tool, dl, Charset.forName("ASCII"));
56 fm.handleOption("-source", sourceLevel.iterator());
57 files = fm.getJavaFileObjects(new File(test_src, "Utf8.java"));
58 tool.getTask(null, fm, null, null, null, files).call();
59 if (!dl.error)
60 throw new AssertionError("No error in ASCII mode");
62 dl.error = false;
63 fm = getFileManager(tool, dl, Charset.forName("UTF-8"));
64 fm.handleOption("-source", sourceLevel.iterator());
65 files = fm.getJavaFileObjects(new File(test_src, "Utf8.java"));
66 task = tool.getTask(null, fm, null, null, null, files);
67 if (dl.error)
68 throw new AssertionError("Error in UTF-8 mode");
69 }
70 public static void main(String... args) {
71 new T6437999().test(args);
72 }
73 }