test/tools/javac/quid/QuotedIdent2.java

changeset 759
1bf969e9792f
parent 674
584365f256a7
equal deleted inserted replaced
750:d53cf2e9ad6c 759:1bf969e9792f
1 /*
2 * Copyright (c) 2008, 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 */
23
24 /*
25 * @test
26 * @bug 6746458
27 * @summary Verify correct separate compilation of classes with extended identifiers.
28 * @author jrose
29 * @ignore 6877225 test fails on Windows:
30 * QuotedIdent.java:81: error while writing QuotedIdent.*86: PATH\QuotedIdent$*86.class
31 * (The filename, directory name, or volume label syntax is incorrect)
32 *
33 * @library ..
34 * @compile -source 7 -target 7 -XDinvokedynamic QuotedIdent.java
35 * @run main quid.QuotedIdent2
36 */
37 /*
38 * Standalone testing:
39 * <code>
40 * $ cd $MY_REPO_DIR/langtools
41 * $ (cd make; make)
42 * $ ./dist/bootstrap/bin/javac -d dist test/tools/javac/quid/QuotedIdent.java
43 * $ ./dist/bootstrap/bin/javac -d dist -cp dist test/tools/javac/quid/QuotedIdent2.java
44 * $ java -version # should print 1.6 or later
45 * $ java -cp dist QuotedIdent2
46 * </code>
47 */
48
49 package quid;
50
51 import quid.QuotedIdent.*;
52 import quid.QuotedIdent.#"*86";
53 import static quid.QuotedIdent.#"MAKE-*86";
54
55 public class QuotedIdent2 {
56 static void check(int testid, String have, String expect)
57 throws RuntimeException {
58 QuotedIdent.check(testid, have, expect);
59 }
60
61 public static void main(String[] args) throws Exception {
62 String s;
63
64 s = #"int".valueOf(123).toString();
65 check(22, s, "123");
66
67 s = #"MAKE-*86"().#"555-1212"();
68 check(23, s, "[*86.555-1212]");
69
70 s = #"Yog-Shoggoth".#"(nameless ululation)";
71 check(25, s, "Tekeli-li!");
72
73 s = QuotedIdent.#"int".class.getName();
74 check(31, s, QuotedIdent.class.getName()+"$int");
75
76 Class<?> x86 = Class.forName(QuotedIdent.class.getName()+"$*86");
77 if (x86 != #"*86".class)
78 check(32, "reflected "+x86, "static "+#"*86".class);
79
80 s = (String) x86.getDeclaredMethod("555-1212").invoke(QuotedIdent.#"MAKE-*86"());
81 check(31, s, "[*86.555-1212]");
82
83 System.out.println("OK");
84 }
85 }

mercurial