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

Fri, 14 Jun 2013 16:31:55 +0100

author
msheppar
date
Fri, 14 Jun 2013 16:31:55 +0100
changeset 512
81d694b1ab2f
parent 158
91006f157c46
child 748
6845b95cba6b
permissions
-rw-r--r--

8011157: Improve CORBA portablility
Summary: fix also reviewed by Alexander Fomin
Reviewed-by: alanb, coffeys, skoivu

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

mercurial