History

My first initial commit with all of mine experimental changes.

Dmitry Kabak (userdima committed 13 years ago

Commit d37b88d1 parent 3f5b46618352 files · +2598093 −-8690Browse files

Showing the changes to java/pkg/sun/rmi/rmic/Names.java (1 of 18352 files). Show all

Unified · Split

java/pkg/sun/rmi/rmic/Names.java+88−0
@@ -0,0 +1,88 @@
1/*
2 * Copyright (c) 1996, 2003, 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. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26package sun.rmi.rmic;
27
28import sun.tools.java.Identifier;
29
30/**
31 * Names provides static utility methods used by other rmic classes
32 * for dealing with identifiers.
33 *
34 * WARNING: The contents of this source file are not part of any
35 * supported API. Code that depends on them does so at its own risk:
36 * they are subject to change or removal without notice.
37 */
38public class Names {
39
40 /**
41 * Return stub class name for impl class name.
42 */
43 static final public Identifier stubFor(Identifier name) {
44 return Identifier.lookup(name + "_Stub");
45 }
46
47 /**
48 * Return skeleton class name for impl class name.
49 */
50 static final public Identifier skeletonFor(Identifier name) {
51 return Identifier.lookup(name + "_Skel");
52 }
53
54 /**
55 * If necessary, convert a class name to its mangled form, i.e. the
56 * non-inner class name used in the binary representation of
57 * inner classes. This is necessary to be able to name inner
58 * classes in the generated source code in places where the language
59 * does not permit it, such as when synthetically defining an inner
60 * class outside of its outer class, and for generating file names
61 * corresponding to inner classes.
62 *
63 * Currently this mangling involves modifying the internal names of
64 * inner classes by converting occurrences of ". " into "$".
65 *
66 * This code is taken from the "mangleInnerType" method of
67 * the "sun.tools.java.Type" class; this method cannot be accessed
68 * itself because it is package protected.
69 */
70 static final public Identifier mangleClass(Identifier className) {
71 if (!className.isInner())
72 return className;
73
74 /*
75 * Get '.' qualified inner class name (with outer class
76 * qualification and no package qualification) and replace
77 * each '.' with '$'.
78 */
79 Identifier mangled = Identifier.lookup(
80 className.getFlatName().toString()
81 .replace('.', sun.tools.java.Constants.SIGC_INNERCLASS));
82 if (mangled.isInner())
83 throw new Error("failed to mangle inner class name");
84
85 // prepend package qualifier back for returned identifier
86 return Identifier.lookup(className.getQualifier(), mangled);
87 }
88}