duke@1: /* ohair@158: * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. duke@1: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@1: * duke@1: * This code is free software; you can redistribute it and/or modify it duke@1: * under the terms of the GNU General Public License version 2 only, as ohair@158: * published by the Free Software Foundation. Oracle designates this duke@1: * particular file as subject to the "Classpath" exception as provided ohair@158: * by Oracle in the LICENSE file that accompanied this code. duke@1: * duke@1: * This code is distributed in the hope that it will be useful, but WITHOUT duke@1: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@1: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@1: * version 2 for more details (a copy is included in the LICENSE file that duke@1: * accompanied this code). duke@1: * duke@1: * You should have received a copy of the GNU General Public License version duke@1: * 2 along with this work; if not, write to the Free Software Foundation, duke@1: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@1: * ohair@158: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ohair@158: * or visit www.oracle.com if you need additional information or have any ohair@158: * questions. duke@1: */ duke@1: duke@1: /* duke@1: * Licensed Materials - Property of IBM duke@1: * RMI-IIOP v1.0 duke@1: * Copyright IBM Corp. 1998 1999 All Rights Reserved duke@1: * duke@1: */ duke@1: duke@1: package sun.rmi.rmic.iiop; duke@1: duke@1: import java.util.Vector; duke@1: import sun.tools.java.CompilerError; duke@1: import sun.tools.java.ClassNotFound; duke@1: import sun.tools.java.ClassDefinition; duke@1: duke@1: /** duke@1: * NCClassType represents any non-special class which does not duke@1: * extends one or more interfaces which inherit from java.rmi.Remote. duke@1: *

duke@1: * The static forImplementation(...) method must be used to obtain an instance, duke@1: * and will return null if the ClassDefinition is non-conforming. duke@1: * duke@1: * @author Bryan Atsatt duke@1: */ duke@1: public class NCClassType extends ClassType { duke@1: duke@1: //_____________________________________________________________________ duke@1: // Public Interfaces duke@1: //_____________________________________________________________________ duke@1: duke@1: /** duke@1: * Create an NCClassType for the given class. duke@1: * duke@1: * If the class is not a properly formed or if some other error occurs, the duke@1: * return value will be null, and errors will have been reported to the duke@1: * supplied BatchEnvironment. duke@1: */ duke@1: public static NCClassType forNCClass(ClassDefinition classDef, duke@1: ContextStack stack) { duke@1: duke@1: if (stack.anyErrors()) return null; duke@1: duke@1: boolean doPop = false; duke@1: try { duke@1: // Do we already have it? duke@1: duke@1: sun.tools.java.Type theType = classDef.getType(); duke@1: Type existing = getType(theType,stack); duke@1: duke@1: if (existing != null) { duke@1: duke@1: if (!(existing instanceof NCClassType)) return null; // False hit. duke@1: duke@1: // Yep, so return it... duke@1: duke@1: return (NCClassType) existing; duke@1: duke@1: } duke@1: duke@1: NCClassType it = new NCClassType(stack, classDef); duke@1: putType(theType,it,stack); duke@1: stack.push(it); duke@1: doPop = true; duke@1: duke@1: if (it.initialize(stack)) { duke@1: stack.pop(true); duke@1: return it; duke@1: } else { duke@1: removeType(theType,stack); duke@1: stack.pop(false); duke@1: return null; duke@1: } duke@1: } catch (CompilerError e) { duke@1: if (doPop) stack.pop(false); duke@1: return null; duke@1: } duke@1: } duke@1: duke@1: /** duke@1: * Return a string describing this type. duke@1: */ duke@1: public String getTypeDescription () { duke@1: return addExceptionDescription("Non-conforming class"); duke@1: } duke@1: duke@1: //_____________________________________________________________________ duke@1: // Internal/Subclass Interfaces duke@1: //_____________________________________________________________________ duke@1: duke@1: /** duke@1: * Create a NCClassType instance for the given class. The resulting duke@1: * object is not yet completely initialized. duke@1: */ duke@1: private NCClassType(ContextStack stack, ClassDefinition classDef) { duke@1: super(stack,classDef,TYPE_NC_CLASS | TM_CLASS | TM_COMPOUND); duke@1: } duke@1: duke@1: //_____________________________________________________________________ duke@1: // Internal Interfaces duke@1: //_____________________________________________________________________ duke@1: duke@1: /** duke@1: * Initialize this instance. duke@1: */ duke@1: private boolean initialize (ContextStack stack) { duke@1: if (!initParents(stack)) { duke@1: return false; duke@1: } duke@1: duke@1: if (stack.getEnv().getParseNonConforming()) { duke@1: duke@1: Vector directInterfaces = new Vector(); duke@1: Vector directMethods = new Vector(); duke@1: Vector directMembers = new Vector(); duke@1: duke@1: try { duke@1: duke@1: // Get methods... duke@1: duke@1: if (addAllMethods(getClassDefinition(),directMethods,false,false,stack) != null) { duke@1: duke@1: // Update parent class methods... duke@1: duke@1: if (updateParentClassMethods(getClassDefinition(),directMethods,false,stack) != null) { duke@1: duke@1: // Get conforming constants... duke@1: duke@1: if (addConformingConstants(directMembers,false,stack)) { duke@1: duke@1: // We're ok, so pass 'em up... duke@1: duke@1: if (!initialize(directInterfaces,directMethods,directMembers,stack,false)) { duke@1: return false; duke@1: } duke@1: } duke@1: } duke@1: } duke@1: return true; duke@1: duke@1: } catch (ClassNotFound e) { duke@1: classNotFound(stack,e); duke@1: } duke@1: return false; duke@1: } else { duke@1: return initialize(null,null,null,stack,false); duke@1: } duke@1: } duke@1: }