1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/classes/sun/rmi/rmic/iiop/NCClassType.java Sat Dec 01 00:00:00 2007 +0000 1.3 @@ -0,0 +1,172 @@ 1.4 +/* 1.5 + * Portions Copyright 1998-2007 Sun Microsystems, Inc. All Rights Reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. Sun designates this 1.11 + * particular file as subject to the "Classpath" exception as provided 1.12 + * by Sun in the LICENSE file that accompanied this code. 1.13 + * 1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.17 + * version 2 for more details (a copy is included in the LICENSE file that 1.18 + * accompanied this code). 1.19 + * 1.20 + * You should have received a copy of the GNU General Public License version 1.21 + * 2 along with this work; if not, write to the Free Software Foundation, 1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.23 + * 1.24 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 1.25 + * CA 95054 USA or visit www.sun.com if you need additional information or 1.26 + * have any questions. 1.27 + */ 1.28 + 1.29 +/* 1.30 + * Licensed Materials - Property of IBM 1.31 + * RMI-IIOP v1.0 1.32 + * Copyright IBM Corp. 1998 1999 All Rights Reserved 1.33 + * 1.34 + */ 1.35 + 1.36 +package sun.rmi.rmic.iiop; 1.37 + 1.38 +import java.util.Vector; 1.39 +import sun.tools.java.CompilerError; 1.40 +import sun.tools.java.ClassNotFound; 1.41 +import sun.tools.java.ClassDefinition; 1.42 + 1.43 +/** 1.44 + * NCClassType represents any non-special class which does not 1.45 + * extends one or more interfaces which inherit from java.rmi.Remote. 1.46 + * <p> 1.47 + * The static forImplementation(...) method must be used to obtain an instance, 1.48 + * and will return null if the ClassDefinition is non-conforming. 1.49 + * 1.50 + * @author Bryan Atsatt 1.51 + */ 1.52 +public class NCClassType extends ClassType { 1.53 + 1.54 + //_____________________________________________________________________ 1.55 + // Public Interfaces 1.56 + //_____________________________________________________________________ 1.57 + 1.58 + /** 1.59 + * Create an NCClassType for the given class. 1.60 + * 1.61 + * If the class is not a properly formed or if some other error occurs, the 1.62 + * return value will be null, and errors will have been reported to the 1.63 + * supplied BatchEnvironment. 1.64 + */ 1.65 + public static NCClassType forNCClass(ClassDefinition classDef, 1.66 + ContextStack stack) { 1.67 + 1.68 + if (stack.anyErrors()) return null; 1.69 + 1.70 + boolean doPop = false; 1.71 + try { 1.72 + // Do we already have it? 1.73 + 1.74 + sun.tools.java.Type theType = classDef.getType(); 1.75 + Type existing = getType(theType,stack); 1.76 + 1.77 + if (existing != null) { 1.78 + 1.79 + if (!(existing instanceof NCClassType)) return null; // False hit. 1.80 + 1.81 + // Yep, so return it... 1.82 + 1.83 + return (NCClassType) existing; 1.84 + 1.85 + } 1.86 + 1.87 + NCClassType it = new NCClassType(stack, classDef); 1.88 + putType(theType,it,stack); 1.89 + stack.push(it); 1.90 + doPop = true; 1.91 + 1.92 + if (it.initialize(stack)) { 1.93 + stack.pop(true); 1.94 + return it; 1.95 + } else { 1.96 + removeType(theType,stack); 1.97 + stack.pop(false); 1.98 + return null; 1.99 + } 1.100 + } catch (CompilerError e) { 1.101 + if (doPop) stack.pop(false); 1.102 + return null; 1.103 + } 1.104 + } 1.105 + 1.106 + /** 1.107 + * Return a string describing this type. 1.108 + */ 1.109 + public String getTypeDescription () { 1.110 + return addExceptionDescription("Non-conforming class"); 1.111 + } 1.112 + 1.113 + //_____________________________________________________________________ 1.114 + // Internal/Subclass Interfaces 1.115 + //_____________________________________________________________________ 1.116 + 1.117 + /** 1.118 + * Create a NCClassType instance for the given class. The resulting 1.119 + * object is not yet completely initialized. 1.120 + */ 1.121 + private NCClassType(ContextStack stack, ClassDefinition classDef) { 1.122 + super(stack,classDef,TYPE_NC_CLASS | TM_CLASS | TM_COMPOUND); 1.123 + } 1.124 + 1.125 + //_____________________________________________________________________ 1.126 + // Internal Interfaces 1.127 + //_____________________________________________________________________ 1.128 + 1.129 + /** 1.130 + * Initialize this instance. 1.131 + */ 1.132 + private boolean initialize (ContextStack stack) { 1.133 + if (!initParents(stack)) { 1.134 + return false; 1.135 + } 1.136 + 1.137 + if (stack.getEnv().getParseNonConforming()) { 1.138 + 1.139 + Vector directInterfaces = new Vector(); 1.140 + Vector directMethods = new Vector(); 1.141 + Vector directMembers = new Vector(); 1.142 + 1.143 + try { 1.144 + 1.145 + // Get methods... 1.146 + 1.147 + if (addAllMethods(getClassDefinition(),directMethods,false,false,stack) != null) { 1.148 + 1.149 + // Update parent class methods... 1.150 + 1.151 + if (updateParentClassMethods(getClassDefinition(),directMethods,false,stack) != null) { 1.152 + 1.153 + // Get conforming constants... 1.154 + 1.155 + if (addConformingConstants(directMembers,false,stack)) { 1.156 + 1.157 + // We're ok, so pass 'em up... 1.158 + 1.159 + if (!initialize(directInterfaces,directMethods,directMembers,stack,false)) { 1.160 + return false; 1.161 + } 1.162 + } 1.163 + } 1.164 + } 1.165 + return true; 1.166 + 1.167 + } catch (ClassNotFound e) { 1.168 + classNotFound(stack,e); 1.169 + } 1.170 + return false; 1.171 + } else { 1.172 + return initialize(null,null,null,stack,false); 1.173 + } 1.174 + } 1.175 +}