src/share/classes/sun/rmi/rmic/iiop/NCInterfaceType.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 * NCInterfaceType represents any non-special, non-conforming interface.
duke@1 42 * <p>
duke@1 43 * The static forNCInterface(...) method must be used to obtain an instance.
duke@1 44 * @author Bryan Atsatt
duke@1 45 */
duke@1 46 public class NCInterfaceType extends InterfaceType {
duke@1 47
duke@1 48 //_____________________________________________________________________
duke@1 49 // Public Interfaces
duke@1 50 //_____________________________________________________________________
duke@1 51
duke@1 52 /**
duke@1 53 * Create an NCInterfaceType for the given class.
duke@1 54 *
duke@1 55 * If the class is not a properly formed or if some other error occurs, the
duke@1 56 * return value will be null, and errors will have been reported to the
duke@1 57 * supplied BatchEnvironment.
duke@1 58 */
duke@1 59 public static NCInterfaceType forNCInterface( ClassDefinition classDef,
duke@1 60 ContextStack stack) {
duke@1 61 if (stack.anyErrors()) return null;
duke@1 62
duke@1 63 boolean doPop = false;
duke@1 64 try {
duke@1 65 // Do we already have it?
duke@1 66
duke@1 67 sun.tools.java.Type theType = classDef.getType();
duke@1 68 Type existing = getType(theType,stack);
duke@1 69
duke@1 70 if (existing != null) {
duke@1 71
duke@1 72 if (!(existing instanceof NCInterfaceType)) return null; // False hit.
duke@1 73
duke@1 74 // Yep, so return it...
duke@1 75
duke@1 76 return (NCInterfaceType) existing;
duke@1 77 }
duke@1 78
duke@1 79 NCInterfaceType it = new NCInterfaceType(stack, classDef);
duke@1 80 putType(theType,it,stack);
duke@1 81 stack.push(it);
duke@1 82 doPop = true;
duke@1 83
duke@1 84 if (it.initialize(stack)) {
duke@1 85 stack.pop(true);
duke@1 86 return it;
duke@1 87 } else {
duke@1 88 removeType(theType,stack);
duke@1 89 stack.pop(false);
duke@1 90 return null;
duke@1 91 }
duke@1 92 } catch (CompilerError e) {
duke@1 93 if (doPop) stack.pop(false);
duke@1 94 return null;
duke@1 95 }
duke@1 96 }
duke@1 97
duke@1 98 /**
duke@1 99 * Return a string describing this type.
duke@1 100 */
duke@1 101 public String getTypeDescription () {
duke@1 102 return "Non-conforming interface";
duke@1 103 }
duke@1 104
duke@1 105 //_____________________________________________________________________
duke@1 106 // Internal/Subclass Interfaces
duke@1 107 //_____________________________________________________________________
duke@1 108
duke@1 109 /**
duke@1 110 * Create a NCInterfaceType instance for the given class. The resulting
duke@1 111 * object is not yet completely initialized.
duke@1 112 */
duke@1 113 private NCInterfaceType(ContextStack stack, ClassDefinition classDef) {
duke@1 114 super(stack,classDef,TYPE_NC_INTERFACE | TM_INTERFACE | TM_COMPOUND);
duke@1 115 }
duke@1 116
duke@1 117 //_____________________________________________________________________
duke@1 118 // Internal Interfaces
duke@1 119 //_____________________________________________________________________
duke@1 120
duke@1 121 /**
duke@1 122 * Initialize this instance.
duke@1 123 */
duke@1 124 private boolean initialize (ContextStack stack) {
duke@1 125
duke@1 126 if (stack.getEnv().getParseNonConforming()) {
duke@1 127
duke@1 128 Vector directInterfaces = new Vector();
duke@1 129 Vector directMethods = new Vector();
duke@1 130 Vector directMembers = new Vector();
duke@1 131
duke@1 132 try {
duke@1 133
duke@1 134 // need to include parent interfaces in IDL generation...
duke@1 135 addNonRemoteInterfaces( directInterfaces,stack );
duke@1 136
duke@1 137 // Get methods...
duke@1 138
duke@1 139 if (addAllMethods(getClassDefinition(),directMethods,false,false,stack) != null) {
duke@1 140
duke@1 141 // Get conforming constants...
duke@1 142
duke@1 143 if (addConformingConstants(directMembers,false,stack)) {
duke@1 144
duke@1 145 // We're ok, so pass 'em up...
duke@1 146
duke@1 147 if (!initialize(directInterfaces,directMethods,directMembers,stack,false)) {
duke@1 148 return false;
duke@1 149 }
duke@1 150 }
duke@1 151 }
duke@1 152 return true;
duke@1 153
duke@1 154 } catch (ClassNotFound e) {
duke@1 155 classNotFound(stack,e);
duke@1 156 }
duke@1 157 return false;
duke@1 158 } else {
duke@1 159 return initialize(null,null,null,stack,false);
duke@1 160 }
duke@1 161 }
duke@1 162 }

mercurial