Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/sun/rmi/rmic/Names.java
38831 views
/*1* Copyright (c) 1996, 2003, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package sun.rmi.rmic;2627import sun.tools.java.Identifier;2829/**30* Names provides static utility methods used by other rmic classes31* for dealing with identifiers.32*33* WARNING: The contents of this source file are not part of any34* supported API. Code that depends on them does so at its own risk:35* they are subject to change or removal without notice.36*/37public class Names {3839/**40* Return stub class name for impl class name.41*/42static final public Identifier stubFor(Identifier name) {43return Identifier.lookup(name + "_Stub");44}4546/**47* Return skeleton class name for impl class name.48*/49static final public Identifier skeletonFor(Identifier name) {50return Identifier.lookup(name + "_Skel");51}5253/**54* If necessary, convert a class name to its mangled form, i.e. the55* non-inner class name used in the binary representation of56* inner classes. This is necessary to be able to name inner57* classes in the generated source code in places where the language58* does not permit it, such as when synthetically defining an inner59* class outside of its outer class, and for generating file names60* corresponding to inner classes.61*62* Currently this mangling involves modifying the internal names of63* inner classes by converting occurrences of ". " into "$".64*65* This code is taken from the "mangleInnerType" method of66* the "sun.tools.java.Type" class; this method cannot be accessed67* itself because it is package protected.68*/69static final public Identifier mangleClass(Identifier className) {70if (!className.isInner())71return className;7273/*74* Get '.' qualified inner class name (with outer class75* qualification and no package qualification) and replace76* each '.' with '$'.77*/78Identifier mangled = Identifier.lookup(79className.getFlatName().toString()80.replace('.', sun.tools.java.Constants.SIGC_INNERCLASS));81if (mangled.isInner())82throw new Error("failed to mangle inner class name");8384// prepend package qualifier back for returned identifier85return Identifier.lookup(className.getQualifier(), mangled);86}87}888990