src/share/classes/sun/rmi/rmic/iiop/NCClassType.java

Mon, 26 Mar 2012 14:01:40 +0100

author
coffeys
date
Mon, 26 Mar 2012 14:01:40 +0100
changeset 370
5222b7d658d4
parent 158
91006f157c46
child 748
6845b95cba6b
permissions
-rw-r--r--

7143851: Improve IIOP stub and tie generation in RMIC
7149048: Changes to corba rmic stubGenerator class are not used during jdk build process
Reviewed-by: mschoene, robm

duke@1 1 /*
ohair@158 2 * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved.
duke@1 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@1 4 *
duke@1 5 * This code is free software; you can redistribute it and/or modify it
duke@1 6 * under the terms of the GNU General Public License version 2 only, as
ohair@158 7 * published by the Free Software Foundation. Oracle designates this
duke@1 8 * particular file as subject to the "Classpath" exception as provided
ohair@158 9 * by Oracle in the LICENSE file that accompanied this code.
duke@1 10 *
duke@1 11 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@1 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@1 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@1 14 * version 2 for more details (a copy is included in the LICENSE file that
duke@1 15 * accompanied this code).
duke@1 16 *
duke@1 17 * You should have received a copy of the GNU General Public License version
duke@1 18 * 2 along with this work; if not, write to the Free Software Foundation,
duke@1 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@1 20 *
ohair@158 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohair@158 22 * or visit www.oracle.com if you need additional information or have any
ohair@158 23 * questions.
duke@1 24 */
duke@1 25
duke@1 26 /*
duke@1 27 * Licensed Materials - Property of IBM
duke@1 28 * RMI-IIOP v1.0
duke@1 29 * Copyright IBM Corp. 1998 1999 All Rights Reserved
duke@1 30 *
duke@1 31 */
duke@1 32
duke@1 33 package sun.rmi.rmic.iiop;
duke@1 34
duke@1 35 import java.util.Vector;
duke@1 36 import sun.tools.java.CompilerError;
duke@1 37 import sun.tools.java.ClassNotFound;
duke@1 38 import sun.tools.java.ClassDefinition;
duke@1 39
duke@1 40 /**
duke@1 41 * NCClassType represents any non-special class which does not
duke@1 42 * extends one or more interfaces which inherit from java.rmi.Remote.
duke@1 43 * <p>
duke@1 44 * The static forImplementation(...) method must be used to obtain an instance,
duke@1 45 * and will return null if the ClassDefinition is non-conforming.
duke@1 46 *
duke@1 47 * @author Bryan Atsatt
duke@1 48 */
duke@1 49 public class NCClassType extends ClassType {
duke@1 50
duke@1 51 //_____________________________________________________________________
duke@1 52 // Public Interfaces
duke@1 53 //_____________________________________________________________________
duke@1 54
duke@1 55 /**
duke@1 56 * Create an NCClassType for the given class.
duke@1 57 *
duke@1 58 * If the class is not a properly formed or if some other error occurs, the
duke@1 59 * return value will be null, and errors will have been reported to the
duke@1 60 * supplied BatchEnvironment.
duke@1 61 */
duke@1 62 public static NCClassType forNCClass(ClassDefinition classDef,
duke@1 63 ContextStack stack) {
duke@1 64
duke@1 65 if (stack.anyErrors()) return null;
duke@1 66
duke@1 67 boolean doPop = false;
duke@1 68 try {
duke@1 69 // Do we already have it?
duke@1 70
duke@1 71 sun.tools.java.Type theType = classDef.getType();
duke@1 72 Type existing = getType(theType,stack);
duke@1 73
duke@1 74 if (existing != null) {
duke@1 75
duke@1 76 if (!(existing instanceof NCClassType)) return null; // False hit.
duke@1 77
duke@1 78 // Yep, so return it...
duke@1 79
duke@1 80 return (NCClassType) existing;
duke@1 81
duke@1 82 }
duke@1 83
duke@1 84 NCClassType it = new NCClassType(stack, classDef);
duke@1 85 putType(theType,it,stack);
duke@1 86 stack.push(it);
duke@1 87 doPop = true;
duke@1 88
duke@1 89 if (it.initialize(stack)) {
duke@1 90 stack.pop(true);
duke@1 91 return it;
duke@1 92 } else {
duke@1 93 removeType(theType,stack);
duke@1 94 stack.pop(false);
duke@1 95 return null;
duke@1 96 }
duke@1 97 } catch (CompilerError e) {
duke@1 98 if (doPop) stack.pop(false);
duke@1 99 return null;
duke@1 100 }
duke@1 101 }
duke@1 102
duke@1 103 /**
duke@1 104 * Return a string describing this type.
duke@1 105 */
duke@1 106 public String getTypeDescription () {
duke@1 107 return addExceptionDescription("Non-conforming class");
duke@1 108 }
duke@1 109
duke@1 110 //_____________________________________________________________________
duke@1 111 // Internal/Subclass Interfaces
duke@1 112 //_____________________________________________________________________
duke@1 113
duke@1 114 /**
duke@1 115 * Create a NCClassType instance for the given class. The resulting
duke@1 116 * object is not yet completely initialized.
duke@1 117 */
duke@1 118 private NCClassType(ContextStack stack, ClassDefinition classDef) {
duke@1 119 super(stack,classDef,TYPE_NC_CLASS | TM_CLASS | TM_COMPOUND);
duke@1 120 }
duke@1 121
duke@1 122 //_____________________________________________________________________
duke@1 123 // Internal Interfaces
duke@1 124 //_____________________________________________________________________
duke@1 125
duke@1 126 /**
duke@1 127 * Initialize this instance.
duke@1 128 */
duke@1 129 private boolean initialize (ContextStack stack) {
duke@1 130 if (!initParents(stack)) {
duke@1 131 return false;
duke@1 132 }
duke@1 133
duke@1 134 if (stack.getEnv().getParseNonConforming()) {
duke@1 135
duke@1 136 Vector directInterfaces = new Vector();
duke@1 137 Vector directMethods = new Vector();
duke@1 138 Vector directMembers = new Vector();
duke@1 139
duke@1 140 try {
duke@1 141
duke@1 142 // Get methods...
duke@1 143
duke@1 144 if (addAllMethods(getClassDefinition(),directMethods,false,false,stack) != null) {
duke@1 145
duke@1 146 // Update parent class methods...
duke@1 147
duke@1 148 if (updateParentClassMethods(getClassDefinition(),directMethods,false,stack) != null) {
duke@1 149
duke@1 150 // Get conforming constants...
duke@1 151
duke@1 152 if (addConformingConstants(directMembers,false,stack)) {
duke@1 153
duke@1 154 // We're ok, so pass 'em up...
duke@1 155
duke@1 156 if (!initialize(directInterfaces,directMethods,directMembers,stack,false)) {
duke@1 157 return false;
duke@1 158 }
duke@1 159 }
duke@1 160 }
duke@1 161 }
duke@1 162 return true;
duke@1 163
duke@1 164 } catch (ClassNotFound e) {
duke@1 165 classNotFound(stack,e);
duke@1 166 }
duke@1 167 return false;
duke@1 168 } else {
duke@1 169 return initialize(null,null,null,stack,false);
duke@1 170 }
duke@1 171 }
duke@1 172 }

mercurial