src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ReferenceType.java
author joehw
Wed, 26 Jun 2019 05:49:59 +0000
changeset 55496 8e0ae3830fca
parent 47216 71c04702a3d5
permissions -rw-r--r--
8224157: BCEL: update to version 6.3.1 Reviewed-by: dfuchs, lancea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6
7f561c08de6b Initial load
duke
parents:
diff changeset
     1
/*
45490
dc68478b53b9 8181153: Fix lint warnings in JAXP repo: dep-ann
joehw
parents: 44797
diff changeset
     2
 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
6
7f561c08de6b Initial load
duke
parents:
diff changeset
     3
 */
44797
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
     4
/*
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
     5
 * Licensed to the Apache Software Foundation (ASF) under one or more
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
     6
 * contributor license agreements.  See the NOTICE file distributed with
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
     7
 * this work for additional information regarding copyright ownership.
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
     8
 * The ASF licenses this file to You under the Apache License, Version 2.0
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
     9
 * (the "License"); you may not use this file except in compliance with
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    10
 * the License.  You may obtain a copy of the License at
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    11
 *
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    12
 *      http://www.apache.org/licenses/LICENSE-2.0
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    13
 *
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    14
 * Unless required by applicable law or agreed to in writing, software
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    15
 * distributed under the License is distributed on an "AS IS" BASIS,
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    16
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    17
 * See the License for the specific language governing permissions and
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    18
 * limitations under the License.
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    19
 */
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    20
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    21
package com.sun.org.apache.bcel.internal.generic;
7f561c08de6b Initial load
duke
parents:
diff changeset
    22
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    23
import com.sun.org.apache.bcel.internal.Const;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    24
import com.sun.org.apache.bcel.internal.Repository;
7f561c08de6b Initial load
duke
parents:
diff changeset
    25
import com.sun.org.apache.bcel.internal.classfile.JavaClass;
7f561c08de6b Initial load
duke
parents:
diff changeset
    26
7f561c08de6b Initial load
duke
parents:
diff changeset
    27
/**
7f561c08de6b Initial load
duke
parents:
diff changeset
    28
 * Super class for object and array types.
7f561c08de6b Initial load
duke
parents:
diff changeset
    29
 *
55496
8e0ae3830fca 8224157: BCEL: update to version 6.3.1
joehw
parents: 47216
diff changeset
    30
 * @version $Id$
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    31
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
    32
public abstract class ReferenceType extends Type {
7f561c08de6b Initial load
duke
parents:
diff changeset
    33
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    34
    protected ReferenceType(final byte t, final String s) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    35
        super(t, s);
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    36
    }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    37
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    38
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    39
    /** Class is non-abstract but not instantiable from the outside
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    40
     */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    41
    ReferenceType() {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    42
        super(Const.T_OBJECT, "<null object>");
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    43
    }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    44
7f561c08de6b Initial load
duke
parents:
diff changeset
    45
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    46
    /**
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    47
     * Return true iff this type is castable to another type t as defined in
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    48
     * the JVM specification.  The case where this is Type.NULL is not
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    49
     * defined (see the CHECKCAST definition in the JVM specification).
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    50
     * However, because e.g. CHECKCAST doesn't throw a
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    51
     * ClassCastException when casting a null reference to any Object,
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    52
     * true is returned in this case.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    53
     *
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    54
     * @throws ClassNotFoundException if any classes or interfaces required
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    55
     *  to determine assignment compatibility can't be found
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    56
     */
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    57
    public boolean isCastableTo( final Type t ) throws ClassNotFoundException {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    58
        if (this.equals(Type.NULL)) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    59
            return t instanceof ReferenceType; // If this is ever changed in isAssignmentCompatible()
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    60
        }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    61
        return isAssignmentCompatibleWith(t);
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    62
        /* Yes, it's true: It's the same definition.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    63
         * See vmspec2 AASTORE / CHECKCAST definitions.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    64
         */
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    65
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
    66
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    67
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    68
    /**
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    69
     * Return true iff this is assignment compatible with another type t
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    70
     * as defined in the JVM specification; see the AASTORE definition
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    71
     * there.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    72
     * @throws ClassNotFoundException if any classes or interfaces required
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    73
     *  to determine assignment compatibility can't be found
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    74
     */
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    75
    public boolean isAssignmentCompatibleWith( final Type t ) throws ClassNotFoundException {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    76
        if (!(t instanceof ReferenceType)) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    77
            return false;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    78
        }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    79
        final ReferenceType T = (ReferenceType) t;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    80
        if (this.equals(Type.NULL)) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    81
            return true; // This is not explicitely stated, but clear. Isn't it?
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    82
        }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    83
        /* If this is a class type then
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    84
         */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    85
        if ((this instanceof ObjectType) && (((ObjectType) this).referencesClassExact())) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    86
            /* If T is a class type, then this must be the same class as T,
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    87
             or this must be a subclass of T;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    88
             */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    89
            if ((T instanceof ObjectType) && (((ObjectType) T).referencesClassExact())) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    90
                if (this.equals(T)) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    91
                    return true;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    92
                }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    93
                if (Repository.instanceOf(((ObjectType) this).getClassName(), ((ObjectType) T)
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    94
                        .getClassName())) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    95
                    return true;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    96
                }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    97
            }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    98
            /* If T is an interface type, this must implement interface T.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
    99
             */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   100
            if ((T instanceof ObjectType) && (((ObjectType) T).referencesInterfaceExact())) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   101
                if (Repository.implementationOf(((ObjectType) this).getClassName(),
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   102
                        ((ObjectType) T).getClassName())) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   103
                    return true;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   104
                }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   105
            }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   106
        }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   107
        /* If this is an interface type, then:
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   108
         */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   109
        if ((this instanceof ObjectType) && (((ObjectType) this).referencesInterfaceExact())) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   110
            /* If T is a class type, then T must be Object (2.4.7).
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   111
             */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   112
            if ((T instanceof ObjectType) && (((ObjectType) T).referencesClassExact())) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   113
                if (T.equals(Type.OBJECT)) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   114
                    return true;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   115
                }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   116
            }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   117
            /* If T is an interface type, then T must be the same interface
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   118
             * as this or a superinterface of this (2.13.2).
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   119
             */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   120
            if ((T instanceof ObjectType) && (((ObjectType) T).referencesInterfaceExact())) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   121
                if (this.equals(T)) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   122
                    return true;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   123
                }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   124
                if (Repository.implementationOf(((ObjectType) this).getClassName(),
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   125
                        ((ObjectType) T).getClassName())) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   126
                    return true;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   127
                }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   128
            }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   129
        }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   130
        /* If this is an array type, namely, the type SC[], that is, an
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   131
         * array of components of type SC, then:
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   132
         */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   133
        if (this instanceof ArrayType) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   134
            /* If T is a class type, then T must be Object (2.4.7).
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   135
             */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   136
            if ((T instanceof ObjectType) && (((ObjectType) T).referencesClassExact())) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   137
                if (T.equals(Type.OBJECT)) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   138
                    return true;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   139
                }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   140
            }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   141
            /* If T is an array type TC[], that is, an array of components
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   142
             * of type TC, then one of the following must be true:
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   143
             */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   144
            if (T instanceof ArrayType) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   145
                /* TC and SC are the same primitive type (2.4.1).
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   146
                 */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   147
                final Type sc = ((ArrayType) this).getElementType();
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   148
                final Type tc = ((ArrayType) T).getElementType();
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   149
                if (sc instanceof BasicType && tc instanceof BasicType && sc.equals(tc)) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   150
                    return true;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   151
                }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   152
                /* TC and SC are reference types (2.4.6), and type SC is
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   153
                 * assignable to TC by these runtime rules.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   154
                 */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   155
                if (tc instanceof ReferenceType && sc instanceof ReferenceType
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   156
                        && ((ReferenceType) sc).isAssignmentCompatibleWith(tc)) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   157
                    return true;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   158
                }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   159
            }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   160
            /* If T is an interface type, T must be one of the interfaces implemented by arrays (2.15). */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   161
            // TODO: Check if this is still valid or find a way to dynamically find out which
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   162
            // interfaces arrays implement. However, as of the JVM specification edition 2, there
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   163
            // are at least two different pages where assignment compatibility is defined and
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   164
            // on one of them "interfaces implemented by arrays" is exchanged with "'Cloneable' or
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   165
            // 'java.io.Serializable'"
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   166
            if ((T instanceof ObjectType) && (((ObjectType) T).referencesInterfaceExact())) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   167
                for (final String element : Const.getInterfacesImplementedByArrays()) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   168
                    if (T.equals(ObjectType.getInstance(element))) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   169
                        return true;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   170
                    }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   171
                }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   172
            }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   173
        }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   174
        return false; // default.
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   175
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   176
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   177
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   178
    /**
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   179
     * This commutative operation returns the first common superclass (narrowest ReferenceType
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   180
     * referencing a class, not an interface).
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   181
     * If one of the types is a superclass of the other, the former is returned.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   182
     * If "this" is Type.NULL, then t is returned.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   183
     * If t is Type.NULL, then "this" is returned.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   184
     * If "this" equals t ['this.equals(t)'] "this" is returned.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   185
     * If "this" or t is an ArrayType, then Type.OBJECT is returned;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   186
     * unless their dimensions match. Then an ArrayType of the same
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   187
     * number of dimensions is returned, with its basic type being the
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   188
     * first common super class of the basic types of "this" and t.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   189
     * If "this" or t is a ReferenceType referencing an interface, then Type.OBJECT is returned.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   190
     * If not all of the two classes' superclasses cannot be found, "null" is returned.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   191
     * See the JVM specification edition 2, "4.9.2 The Bytecode Verifier".
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   192
     *
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   193
     * @throws ClassNotFoundException on failure to find superclasses of this
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   194
     *  type, or the type passed as a parameter
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   195
     */
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   196
    public ReferenceType getFirstCommonSuperclass( final ReferenceType t ) throws ClassNotFoundException {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   197
        if (this.equals(Type.NULL)) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   198
            return t;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   199
        }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   200
        if (t.equals(Type.NULL)) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   201
            return this;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   202
        }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   203
        if (this.equals(t)) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   204
            return this;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   205
            /*
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   206
             * TODO: Above sounds a little arbitrary. On the other hand, there is
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   207
             * no object referenced by Type.NULL so we can also say all the objects
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   208
             * referenced by Type.NULL were derived from java.lang.Object.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   209
             * However, the Java Language's "instanceof" operator proves us wrong:
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   210
             * "null" is not referring to an instance of java.lang.Object :)
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   211
             */
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   212
        }
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   213
        /* This code is from a bug report by Konstantin Shagin <konst@cs.technion.ac.il> */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   214
        if ((this instanceof ArrayType) && (t instanceof ArrayType)) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   215
            final ArrayType arrType1 = (ArrayType) this;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   216
            final ArrayType arrType2 = (ArrayType) t;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   217
            if ((arrType1.getDimensions() == arrType2.getDimensions())
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   218
                    && arrType1.getBasicType() instanceof ObjectType
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   219
                    && arrType2.getBasicType() instanceof ObjectType) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   220
                return new ArrayType(((ObjectType) arrType1.getBasicType())
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   221
                        .getFirstCommonSuperclass((ObjectType) arrType2.getBasicType()), arrType1
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   222
                        .getDimensions());
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   223
            }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   224
        }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   225
        if ((this instanceof ArrayType) || (t instanceof ArrayType)) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   226
            return Type.OBJECT;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   227
            // TODO: Is there a proof of OBJECT being the direct ancestor of every ArrayType?
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   228
        }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   229
        if (((this instanceof ObjectType) && ((ObjectType) this).referencesInterfaceExact())
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   230
                || ((t instanceof ObjectType) && ((ObjectType) t).referencesInterfaceExact())) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   231
            return Type.OBJECT;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   232
            // TODO: The above line is correct comparing to the vmspec2. But one could
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   233
            // make class file verification a bit stronger here by using the notion of
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   234
            // superinterfaces or even castability or assignment compatibility.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   235
        }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   236
        // this and t are ObjectTypes, see above.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   237
        final ObjectType thiz = (ObjectType) this;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   238
        final ObjectType other = (ObjectType) t;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   239
        final JavaClass[] thiz_sups = Repository.getSuperClasses(thiz.getClassName());
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   240
        final JavaClass[] other_sups = Repository.getSuperClasses(other.getClassName());
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   241
        if ((thiz_sups == null) || (other_sups == null)) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   242
            return null;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   243
        }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   244
        // Waaahh...
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   245
        final JavaClass[] this_sups = new JavaClass[thiz_sups.length + 1];
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   246
        final JavaClass[] t_sups = new JavaClass[other_sups.length + 1];
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   247
        System.arraycopy(thiz_sups, 0, this_sups, 1, thiz_sups.length);
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   248
        System.arraycopy(other_sups, 0, t_sups, 1, other_sups.length);
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   249
        this_sups[0] = Repository.lookupClass(thiz.getClassName());
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   250
        t_sups[0] = Repository.lookupClass(other.getClassName());
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   251
        for (final JavaClass t_sup : t_sups) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   252
            for (final JavaClass this_sup : this_sups) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   253
                if (this_sup.equals(t_sup)) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   254
                    return ObjectType.getInstance(this_sup.getClassName());
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   255
                }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   256
            }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   257
        }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   258
        // Huh? Did you ask for Type.OBJECT's superclass??
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   259
        return null;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   260
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   261
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   262
    /**
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   263
     * This commutative operation returns the first common superclass (narrowest ReferenceType
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   264
     * referencing a class, not an interface).
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   265
     * If one of the types is a superclass of the other, the former is returned.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   266
     * If "this" is Type.NULL, then t is returned.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   267
     * If t is Type.NULL, then "this" is returned.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   268
     * If "this" equals t ['this.equals(t)'] "this" is returned.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   269
     * If "this" or t is an ArrayType, then Type.OBJECT is returned.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   270
     * If "this" or t is a ReferenceType referencing an interface, then Type.OBJECT is returned.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   271
     * If not all of the two classes' superclasses cannot be found, "null" is returned.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   272
     * See the JVM specification edition 2, "4.9.2 The Bytecode Verifier".
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   273
     *
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   274
     * @deprecated use getFirstCommonSuperclass(ReferenceType t) which has
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   275
     *             slightly changed semantics.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   276
     * @throws ClassNotFoundException on failure to find superclasses of this
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   277
     *  type, or the type passed as a parameter
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   278
     */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   279
    @Deprecated
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   280
    public ReferenceType firstCommonSuperclass( final ReferenceType t ) throws ClassNotFoundException {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   281
        if (this.equals(Type.NULL)) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   282
            return t;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   283
        }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   284
        if (t.equals(Type.NULL)) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   285
            return this;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   286
        }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   287
        if (this.equals(t)) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   288
            return this;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   289
            /*
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   290
             * TODO: Above sounds a little arbitrary. On the other hand, there is
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   291
             * no object referenced by Type.NULL so we can also say all the objects
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   292
             * referenced by Type.NULL were derived from java.lang.Object.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   293
             * However, the Java Language's "instanceof" operator proves us wrong:
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   294
             * "null" is not referring to an instance of java.lang.Object :)
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   295
             */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   296
        }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   297
        if ((this instanceof ArrayType) || (t instanceof ArrayType)) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   298
            return Type.OBJECT;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   299
            // TODO: Is there a proof of OBJECT being the direct ancestor of every ArrayType?
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   300
        }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   301
        if (((this instanceof ObjectType) && ((ObjectType) this).referencesInterface())
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   302
                || ((t instanceof ObjectType) && ((ObjectType) t).referencesInterface())) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   303
            return Type.OBJECT;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   304
            // TODO: The above line is correct comparing to the vmspec2. But one could
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   305
            // make class file verification a bit stronger here by using the notion of
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   306
            // superinterfaces or even castability or assignment compatibility.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   307
        }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   308
        // this and t are ObjectTypes, see above.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   309
        final ObjectType thiz = (ObjectType) this;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   310
        final ObjectType other = (ObjectType) t;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   311
        final JavaClass[] thiz_sups = Repository.getSuperClasses(thiz.getClassName());
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   312
        final JavaClass[] other_sups = Repository.getSuperClasses(other.getClassName());
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   313
        if ((thiz_sups == null) || (other_sups == null)) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   314
            return null;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   315
        }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   316
        // Waaahh...
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   317
        final JavaClass[] this_sups = new JavaClass[thiz_sups.length + 1];
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   318
        final JavaClass[] t_sups = new JavaClass[other_sups.length + 1];
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   319
        System.arraycopy(thiz_sups, 0, this_sups, 1, thiz_sups.length);
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   320
        System.arraycopy(other_sups, 0, t_sups, 1, other_sups.length);
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   321
        this_sups[0] = Repository.lookupClass(thiz.getClassName());
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   322
        t_sups[0] = Repository.lookupClass(other.getClassName());
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   323
        for (final JavaClass t_sup : t_sups) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   324
            for (final JavaClass this_sup : this_sups) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   325
                if (this_sup.equals(t_sup)) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   326
                    return ObjectType.getInstance(this_sup.getClassName());
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   327
                }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   328
            }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   329
        }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   330
        // Huh? Did you ask for Type.OBJECT's superclass??
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45490
diff changeset
   331
        return null;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   332
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   333
}