corba/src/share/classes/sun/rmi/rmic/iiop/ImplementationType.java
author ohair
Tue, 25 May 2010 15:52:11 -0700
changeset 5555 b2b5ed3f0d0d
parent 4 02bb8761fcce
permissions -rw-r--r--
6943119: Rebrand source copyright notices Reviewed-by: darcy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4
02bb8761fcce Initial load
duke
parents:
diff changeset
     1
/*
5555
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
     2
 * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved.
4
02bb8761fcce Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
02bb8761fcce Initial load
duke
parents:
diff changeset
     4
 *
02bb8761fcce Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
02bb8761fcce Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5555
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
4
02bb8761fcce Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5555
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
4
02bb8761fcce Initial load
duke
parents:
diff changeset
    10
 *
02bb8761fcce Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
02bb8761fcce Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
02bb8761fcce Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
02bb8761fcce Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
02bb8761fcce Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
02bb8761fcce Initial load
duke
parents:
diff changeset
    16
 *
02bb8761fcce Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
02bb8761fcce Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
02bb8761fcce Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
02bb8761fcce Initial load
duke
parents:
diff changeset
    20
 *
5555
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
    23
 * questions.
4
02bb8761fcce Initial load
duke
parents:
diff changeset
    24
 */
02bb8761fcce Initial load
duke
parents:
diff changeset
    25
02bb8761fcce Initial load
duke
parents:
diff changeset
    26
/*
02bb8761fcce Initial load
duke
parents:
diff changeset
    27
 * Licensed Materials - Property of IBM
02bb8761fcce Initial load
duke
parents:
diff changeset
    28
 * RMI-IIOP v1.0
02bb8761fcce Initial load
duke
parents:
diff changeset
    29
 * Copyright IBM Corp. 1998 1999  All Rights Reserved
02bb8761fcce Initial load
duke
parents:
diff changeset
    30
 *
02bb8761fcce Initial load
duke
parents:
diff changeset
    31
 */
02bb8761fcce Initial load
duke
parents:
diff changeset
    32
02bb8761fcce Initial load
duke
parents:
diff changeset
    33
package sun.rmi.rmic.iiop;
02bb8761fcce Initial load
duke
parents:
diff changeset
    34
02bb8761fcce Initial load
duke
parents:
diff changeset
    35
import java.util.Vector;
02bb8761fcce Initial load
duke
parents:
diff changeset
    36
import sun.tools.java.CompilerError;
02bb8761fcce Initial load
duke
parents:
diff changeset
    37
import sun.tools.java.ClassNotFound;
02bb8761fcce Initial load
duke
parents:
diff changeset
    38
import sun.tools.java.ClassDefinition;
02bb8761fcce Initial load
duke
parents:
diff changeset
    39
import sun.tools.java.MemberDefinition;
02bb8761fcce Initial load
duke
parents:
diff changeset
    40
02bb8761fcce Initial load
duke
parents:
diff changeset
    41
/**
02bb8761fcce Initial load
duke
parents:
diff changeset
    42
 * ImplementationType represents any non-special class which implements
02bb8761fcce Initial load
duke
parents:
diff changeset
    43
 * one or more interfaces which inherit from java.rmi.Remote.
02bb8761fcce Initial load
duke
parents:
diff changeset
    44
 * <p>
02bb8761fcce Initial load
duke
parents:
diff changeset
    45
 * The static forImplementation(...) method must be used to obtain an instance,
02bb8761fcce Initial load
duke
parents:
diff changeset
    46
 * and will return null if the ClassDefinition is non-conforming.
02bb8761fcce Initial load
duke
parents:
diff changeset
    47
 *
02bb8761fcce Initial load
duke
parents:
diff changeset
    48
 * @author      Bryan Atsatt
02bb8761fcce Initial load
duke
parents:
diff changeset
    49
 */
02bb8761fcce Initial load
duke
parents:
diff changeset
    50
public class ImplementationType extends ClassType {
02bb8761fcce Initial load
duke
parents:
diff changeset
    51
02bb8761fcce Initial load
duke
parents:
diff changeset
    52
    //_____________________________________________________________________
02bb8761fcce Initial load
duke
parents:
diff changeset
    53
    // Public Interfaces
02bb8761fcce Initial load
duke
parents:
diff changeset
    54
    //_____________________________________________________________________
02bb8761fcce Initial load
duke
parents:
diff changeset
    55
02bb8761fcce Initial load
duke
parents:
diff changeset
    56
    /**
02bb8761fcce Initial load
duke
parents:
diff changeset
    57
     * Create an ImplementationType for the given class.
02bb8761fcce Initial load
duke
parents:
diff changeset
    58
     *
02bb8761fcce Initial load
duke
parents:
diff changeset
    59
     * If the class is not a properly formed or if some other error occurs, the
02bb8761fcce Initial load
duke
parents:
diff changeset
    60
     * return value will be null, and errors will have been reported to the
02bb8761fcce Initial load
duke
parents:
diff changeset
    61
     * supplied BatchEnvironment.
02bb8761fcce Initial load
duke
parents:
diff changeset
    62
     */
02bb8761fcce Initial load
duke
parents:
diff changeset
    63
    public static ImplementationType forImplementation(ClassDefinition classDef,
02bb8761fcce Initial load
duke
parents:
diff changeset
    64
                                                       ContextStack stack,
02bb8761fcce Initial load
duke
parents:
diff changeset
    65
                                                       boolean quiet) {
02bb8761fcce Initial load
duke
parents:
diff changeset
    66
        if (stack.anyErrors()) return null;
02bb8761fcce Initial load
duke
parents:
diff changeset
    67
02bb8761fcce Initial load
duke
parents:
diff changeset
    68
        boolean doPop = false;
02bb8761fcce Initial load
duke
parents:
diff changeset
    69
        ImplementationType result = null;
02bb8761fcce Initial load
duke
parents:
diff changeset
    70
02bb8761fcce Initial load
duke
parents:
diff changeset
    71
        try {
02bb8761fcce Initial load
duke
parents:
diff changeset
    72
            // Do we already have it?
02bb8761fcce Initial load
duke
parents:
diff changeset
    73
02bb8761fcce Initial load
duke
parents:
diff changeset
    74
            sun.tools.java.Type theType = classDef.getType();
02bb8761fcce Initial load
duke
parents:
diff changeset
    75
            Type existing = getType(theType,stack);
02bb8761fcce Initial load
duke
parents:
diff changeset
    76
02bb8761fcce Initial load
duke
parents:
diff changeset
    77
            if (existing != null) {
02bb8761fcce Initial load
duke
parents:
diff changeset
    78
02bb8761fcce Initial load
duke
parents:
diff changeset
    79
                if (!(existing instanceof ImplementationType)) return null; // False hit.
02bb8761fcce Initial load
duke
parents:
diff changeset
    80
02bb8761fcce Initial load
duke
parents:
diff changeset
    81
                                // Yep, so return it...
02bb8761fcce Initial load
duke
parents:
diff changeset
    82
02bb8761fcce Initial load
duke
parents:
diff changeset
    83
                return (ImplementationType) existing;
02bb8761fcce Initial load
duke
parents:
diff changeset
    84
02bb8761fcce Initial load
duke
parents:
diff changeset
    85
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
    86
02bb8761fcce Initial load
duke
parents:
diff changeset
    87
            // Could this be an implementation?
02bb8761fcce Initial load
duke
parents:
diff changeset
    88
02bb8761fcce Initial load
duke
parents:
diff changeset
    89
            if (couldBeImplementation(quiet,stack,classDef)) {
02bb8761fcce Initial load
duke
parents:
diff changeset
    90
02bb8761fcce Initial load
duke
parents:
diff changeset
    91
                // Yes, so check it...
02bb8761fcce Initial load
duke
parents:
diff changeset
    92
02bb8761fcce Initial load
duke
parents:
diff changeset
    93
                ImplementationType it = new ImplementationType(stack, classDef);
02bb8761fcce Initial load
duke
parents:
diff changeset
    94
                putType(theType,it,stack);
02bb8761fcce Initial load
duke
parents:
diff changeset
    95
                stack.push(it);
02bb8761fcce Initial load
duke
parents:
diff changeset
    96
                doPop = true;
02bb8761fcce Initial load
duke
parents:
diff changeset
    97
02bb8761fcce Initial load
duke
parents:
diff changeset
    98
                if (it.initialize(stack,quiet)) {
02bb8761fcce Initial load
duke
parents:
diff changeset
    99
                    stack.pop(true);
02bb8761fcce Initial load
duke
parents:
diff changeset
   100
                    result = it;
02bb8761fcce Initial load
duke
parents:
diff changeset
   101
                } else {
02bb8761fcce Initial load
duke
parents:
diff changeset
   102
                    removeType(theType,stack);
02bb8761fcce Initial load
duke
parents:
diff changeset
   103
                    stack.pop(false);
02bb8761fcce Initial load
duke
parents:
diff changeset
   104
                }
02bb8761fcce Initial load
duke
parents:
diff changeset
   105
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   106
        } catch (CompilerError e) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   107
            if (doPop) stack.pop(false);
02bb8761fcce Initial load
duke
parents:
diff changeset
   108
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   109
02bb8761fcce Initial load
duke
parents:
diff changeset
   110
        return result;
02bb8761fcce Initial load
duke
parents:
diff changeset
   111
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   112
02bb8761fcce Initial load
duke
parents:
diff changeset
   113
    /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   114
     * Return a string describing this type.
02bb8761fcce Initial load
duke
parents:
diff changeset
   115
     */
02bb8761fcce Initial load
duke
parents:
diff changeset
   116
    public String getTypeDescription () {
02bb8761fcce Initial load
duke
parents:
diff changeset
   117
        return "Implementation";
02bb8761fcce Initial load
duke
parents:
diff changeset
   118
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   119
02bb8761fcce Initial load
duke
parents:
diff changeset
   120
02bb8761fcce Initial load
duke
parents:
diff changeset
   121
    //_____________________________________________________________________
02bb8761fcce Initial load
duke
parents:
diff changeset
   122
    // Internal Interfaces
02bb8761fcce Initial load
duke
parents:
diff changeset
   123
    //_____________________________________________________________________
02bb8761fcce Initial load
duke
parents:
diff changeset
   124
02bb8761fcce Initial load
duke
parents:
diff changeset
   125
    /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   126
     * Create a ImplementationType instance for the given class.  The resulting
02bb8761fcce Initial load
duke
parents:
diff changeset
   127
     * object is not yet completely initialized.
02bb8761fcce Initial load
duke
parents:
diff changeset
   128
     */
02bb8761fcce Initial load
duke
parents:
diff changeset
   129
    private ImplementationType(ContextStack stack, ClassDefinition classDef) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   130
        super(TYPE_IMPLEMENTATION | TM_CLASS | TM_COMPOUND,classDef,stack); // Use special constructor.
02bb8761fcce Initial load
duke
parents:
diff changeset
   131
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   132
02bb8761fcce Initial load
duke
parents:
diff changeset
   133
02bb8761fcce Initial load
duke
parents:
diff changeset
   134
    private static boolean couldBeImplementation(boolean quiet, ContextStack stack,
02bb8761fcce Initial load
duke
parents:
diff changeset
   135
                                                 ClassDefinition classDef) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   136
        boolean result = false;
02bb8761fcce Initial load
duke
parents:
diff changeset
   137
        BatchEnvironment env = stack.getEnv();
02bb8761fcce Initial load
duke
parents:
diff changeset
   138
02bb8761fcce Initial load
duke
parents:
diff changeset
   139
        try {
02bb8761fcce Initial load
duke
parents:
diff changeset
   140
            if (!classDef.isClass()) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   141
                failedConstraint(17,quiet,stack,classDef.getName());
02bb8761fcce Initial load
duke
parents:
diff changeset
   142
            } else {
02bb8761fcce Initial load
duke
parents:
diff changeset
   143
                result = env.defRemote.implementedBy(env, classDef.getClassDeclaration());
02bb8761fcce Initial load
duke
parents:
diff changeset
   144
                if (!result) failedConstraint(8,quiet,stack,classDef.getName());
02bb8761fcce Initial load
duke
parents:
diff changeset
   145
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   146
        } catch (ClassNotFound e) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   147
            classNotFound(stack,e);
02bb8761fcce Initial load
duke
parents:
diff changeset
   148
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   149
02bb8761fcce Initial load
duke
parents:
diff changeset
   150
        return result;
02bb8761fcce Initial load
duke
parents:
diff changeset
   151
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   152
02bb8761fcce Initial load
duke
parents:
diff changeset
   153
02bb8761fcce Initial load
duke
parents:
diff changeset
   154
    /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   155
     * Initialize this instance.
02bb8761fcce Initial load
duke
parents:
diff changeset
   156
     */
02bb8761fcce Initial load
duke
parents:
diff changeset
   157
    private boolean initialize (ContextStack stack, boolean quiet) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   158
02bb8761fcce Initial load
duke
parents:
diff changeset
   159
        boolean result = false;
02bb8761fcce Initial load
duke
parents:
diff changeset
   160
        ClassDefinition theClass = getClassDefinition();
02bb8761fcce Initial load
duke
parents:
diff changeset
   161
02bb8761fcce Initial load
duke
parents:
diff changeset
   162
        if (initParents(stack)) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   163
02bb8761fcce Initial load
duke
parents:
diff changeset
   164
            // Make up our collections...
02bb8761fcce Initial load
duke
parents:
diff changeset
   165
02bb8761fcce Initial load
duke
parents:
diff changeset
   166
            Vector directInterfaces = new Vector();
02bb8761fcce Initial load
duke
parents:
diff changeset
   167
            Vector directMethods = new Vector();
02bb8761fcce Initial load
duke
parents:
diff changeset
   168
02bb8761fcce Initial load
duke
parents:
diff changeset
   169
            // Check interfaces...
02bb8761fcce Initial load
duke
parents:
diff changeset
   170
02bb8761fcce Initial load
duke
parents:
diff changeset
   171
            try {
02bb8761fcce Initial load
duke
parents:
diff changeset
   172
                if (addRemoteInterfaces(directInterfaces,true,stack) != null) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   173
02bb8761fcce Initial load
duke
parents:
diff changeset
   174
                    boolean haveRemote = false;
02bb8761fcce Initial load
duke
parents:
diff changeset
   175
02bb8761fcce Initial load
duke
parents:
diff changeset
   176
                    // Get methods from all interfaces...
02bb8761fcce Initial load
duke
parents:
diff changeset
   177
02bb8761fcce Initial load
duke
parents:
diff changeset
   178
                    for (int i = 0; i < directInterfaces.size(); i++) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   179
                        InterfaceType theInt = (InterfaceType) directInterfaces.elementAt(i);
02bb8761fcce Initial load
duke
parents:
diff changeset
   180
                        if (theInt.isType(TYPE_REMOTE) ||
02bb8761fcce Initial load
duke
parents:
diff changeset
   181
                            theInt.isType(TYPE_JAVA_RMI_REMOTE)) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   182
                            haveRemote = true;
02bb8761fcce Initial load
duke
parents:
diff changeset
   183
                        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   184
02bb8761fcce Initial load
duke
parents:
diff changeset
   185
                        copyRemoteMethods(theInt,directMethods);
02bb8761fcce Initial load
duke
parents:
diff changeset
   186
                    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   187
02bb8761fcce Initial load
duke
parents:
diff changeset
   188
                    // Make sure we have at least one remote interface...
02bb8761fcce Initial load
duke
parents:
diff changeset
   189
02bb8761fcce Initial load
duke
parents:
diff changeset
   190
                    if (!haveRemote) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   191
                        failedConstraint(8,quiet,stack,getQualifiedName());
02bb8761fcce Initial load
duke
parents:
diff changeset
   192
                        return false;
02bb8761fcce Initial load
duke
parents:
diff changeset
   193
                    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   194
02bb8761fcce Initial load
duke
parents:
diff changeset
   195
                    // Now check the methods to ensure we have the
02bb8761fcce Initial load
duke
parents:
diff changeset
   196
                    // correct throws clauses...
02bb8761fcce Initial load
duke
parents:
diff changeset
   197
02bb8761fcce Initial load
duke
parents:
diff changeset
   198
                    if (checkMethods(theClass,directMethods,stack,quiet)) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   199
02bb8761fcce Initial load
duke
parents:
diff changeset
   200
                        // We're ok, so pass 'em up...
02bb8761fcce Initial load
duke
parents:
diff changeset
   201
02bb8761fcce Initial load
duke
parents:
diff changeset
   202
                        result = initialize(directInterfaces,directMethods,null,stack,quiet);
02bb8761fcce Initial load
duke
parents:
diff changeset
   203
                    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   204
                }
02bb8761fcce Initial load
duke
parents:
diff changeset
   205
            } catch (ClassNotFound e) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   206
                classNotFound(stack,e);
02bb8761fcce Initial load
duke
parents:
diff changeset
   207
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   208
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   209
02bb8761fcce Initial load
duke
parents:
diff changeset
   210
        return result;
02bb8761fcce Initial load
duke
parents:
diff changeset
   211
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   212
02bb8761fcce Initial load
duke
parents:
diff changeset
   213
    private static void copyRemoteMethods(InterfaceType type, Vector list) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   214
02bb8761fcce Initial load
duke
parents:
diff changeset
   215
        if (type.isType(TYPE_REMOTE)) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   216
02bb8761fcce Initial load
duke
parents:
diff changeset
   217
            // Copy all the unique methods from type...
02bb8761fcce Initial load
duke
parents:
diff changeset
   218
02bb8761fcce Initial load
duke
parents:
diff changeset
   219
            Method[] allMethods = type.getMethods();
02bb8761fcce Initial load
duke
parents:
diff changeset
   220
02bb8761fcce Initial load
duke
parents:
diff changeset
   221
            for (int i = 0; i < allMethods.length; i++) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   222
                Method theMethod = allMethods[i];
02bb8761fcce Initial load
duke
parents:
diff changeset
   223
02bb8761fcce Initial load
duke
parents:
diff changeset
   224
                if (!list.contains(theMethod)) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   225
                    list.addElement(theMethod);
02bb8761fcce Initial load
duke
parents:
diff changeset
   226
                }
02bb8761fcce Initial load
duke
parents:
diff changeset
   227
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   228
02bb8761fcce Initial load
duke
parents:
diff changeset
   229
            // Now recurse thru all inherited interfaces...
02bb8761fcce Initial load
duke
parents:
diff changeset
   230
02bb8761fcce Initial load
duke
parents:
diff changeset
   231
            InterfaceType[] allInterfaces = type.getInterfaces();
02bb8761fcce Initial load
duke
parents:
diff changeset
   232
02bb8761fcce Initial load
duke
parents:
diff changeset
   233
            for (int i = 0; i < allInterfaces.length; i++) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   234
                copyRemoteMethods(allInterfaces[i],list);
02bb8761fcce Initial load
duke
parents:
diff changeset
   235
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   236
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   237
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   238
02bb8761fcce Initial load
duke
parents:
diff changeset
   239
    // Walk all methods of the class, and for each that is already in
02bb8761fcce Initial load
duke
parents:
diff changeset
   240
    // the list, call setImplExceptions()...
02bb8761fcce Initial load
duke
parents:
diff changeset
   241
02bb8761fcce Initial load
duke
parents:
diff changeset
   242
    private boolean checkMethods(ClassDefinition theClass, Vector list,
02bb8761fcce Initial load
duke
parents:
diff changeset
   243
                                 ContextStack stack, boolean quiet) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   244
02bb8761fcce Initial load
duke
parents:
diff changeset
   245
        // Convert vector to array...
02bb8761fcce Initial load
duke
parents:
diff changeset
   246
02bb8761fcce Initial load
duke
parents:
diff changeset
   247
        Method[] methods = new Method[list.size()];
02bb8761fcce Initial load
duke
parents:
diff changeset
   248
        list.copyInto(methods);
02bb8761fcce Initial load
duke
parents:
diff changeset
   249
02bb8761fcce Initial load
duke
parents:
diff changeset
   250
        for (MemberDefinition member = theClass.getFirstMember();
02bb8761fcce Initial load
duke
parents:
diff changeset
   251
             member != null;
02bb8761fcce Initial load
duke
parents:
diff changeset
   252
             member = member.getNextMember()) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   253
02bb8761fcce Initial load
duke
parents:
diff changeset
   254
            if (member.isMethod() && !member.isConstructor()
02bb8761fcce Initial load
duke
parents:
diff changeset
   255
                && !member.isInitializer()) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   256
02bb8761fcce Initial load
duke
parents:
diff changeset
   257
                // It's a method...
02bb8761fcce Initial load
duke
parents:
diff changeset
   258
02bb8761fcce Initial load
duke
parents:
diff changeset
   259
                if (!updateExceptions(member,methods,stack,quiet)) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   260
                    return false;
02bb8761fcce Initial load
duke
parents:
diff changeset
   261
                }
02bb8761fcce Initial load
duke
parents:
diff changeset
   262
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   263
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   264
        return true;
02bb8761fcce Initial load
duke
parents:
diff changeset
   265
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   266
02bb8761fcce Initial load
duke
parents:
diff changeset
   267
    private boolean updateExceptions (MemberDefinition implMethod, Method[] list,
02bb8761fcce Initial load
duke
parents:
diff changeset
   268
                                      ContextStack stack, boolean quiet) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   269
        int length = list.length;
02bb8761fcce Initial load
duke
parents:
diff changeset
   270
        String implMethodSig = implMethod.toString();
02bb8761fcce Initial load
duke
parents:
diff changeset
   271
02bb8761fcce Initial load
duke
parents:
diff changeset
   272
        for (int i = 0; i < length; i++) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   273
            Method existingMethod = list[i];
02bb8761fcce Initial load
duke
parents:
diff changeset
   274
            MemberDefinition existing = existingMethod.getMemberDefinition();
02bb8761fcce Initial load
duke
parents:
diff changeset
   275
02bb8761fcce Initial load
duke
parents:
diff changeset
   276
            // Do we have a matching method?
02bb8761fcce Initial load
duke
parents:
diff changeset
   277
02bb8761fcce Initial load
duke
parents:
diff changeset
   278
            if (implMethodSig.equals(existing.toString())) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   279
02bb8761fcce Initial load
duke
parents:
diff changeset
   280
                // Yes, so create exception list...
02bb8761fcce Initial load
duke
parents:
diff changeset
   281
02bb8761fcce Initial load
duke
parents:
diff changeset
   282
                try {
02bb8761fcce Initial load
duke
parents:
diff changeset
   283
                    ValueType[] implExcept = getMethodExceptions(implMethod,quiet,stack);
02bb8761fcce Initial load
duke
parents:
diff changeset
   284
                    existingMethod.setImplExceptions(implExcept);
02bb8761fcce Initial load
duke
parents:
diff changeset
   285
                } catch (Exception e) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   286
                    return false;
02bb8761fcce Initial load
duke
parents:
diff changeset
   287
                }
02bb8761fcce Initial load
duke
parents:
diff changeset
   288
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   289
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   290
        return true;
02bb8761fcce Initial load
duke
parents:
diff changeset
   291
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   292
}