langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/MethodDocImpl.java
author jjg
Mon, 09 May 2016 16:52:15 -0700
changeset 37938 42baa89d2156
parent 32800 langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/MethodDocImpl.java@8457813125e3
child 38617 d93a7f64e231
permissions -rw-r--r--
8075703: jdk.javadoc module exports com.sun.tools.javadoc package which contains a lot of internal API. Reviewed-by: ksrini
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
25443
9187d77f2c64 8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents: 17275
diff changeset
     2
 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
06bc494ca11e Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
 *
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    23
 * questions.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
37938
42baa89d2156 8075703: jdk.javadoc module exports com.sun.tools.javadoc package which contains a lot of internal API.
jjg
parents: 32800
diff changeset
    26
package com.sun.tools.javadoc.main;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
14258
8d2148961366 8000663: clean up langtools imports
jjg
parents: 5520
diff changeset
    28
import java.lang.reflect.Modifier;
8d2148961366 8000663: clean up langtools imports
jjg
parents: 5520
diff changeset
    29
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
import com.sun.javadoc.*;
14802
969e90f68ac5 8004828: refactor init of *DocImpl classes
jjg
parents: 14359
diff changeset
    31
import com.sun.source.util.TreePath;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
import com.sun.tools.javac.code.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
import com.sun.tools.javac.code.Symbol.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
import com.sun.tools.javac.code.Type;
14359
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14260
diff changeset
    35
import static com.sun.tools.javac.code.TypeTag.CLASS;
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14260
diff changeset
    36
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
 * Represents a method of a java class.
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
 *
14260
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14258
diff changeset
    40
 *  <p><b>This is NOT part of any supported API.
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14258
diff changeset
    41
 *  If you write code that depends on this, you do so at your own risk.
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14258
diff changeset
    42
 *  This code and its internal interfaces are subject to change or
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14258
diff changeset
    43
 *  deletion without notice.</b>
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14258
diff changeset
    44
 *
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
 * @since 1.2
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
 * @author Robert Field
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
 * @author Neal Gafter (rewrite)
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
public class MethodDocImpl
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
        extends ExecutableMemberDocImpl implements MethodDoc {
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
     * constructor.
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
    public MethodDocImpl(DocEnv env, MethodSymbol sym) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
        super(env, sym);
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
     * constructor.
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
     */
14802
969e90f68ac5 8004828: refactor init of *DocImpl classes
jjg
parents: 14359
diff changeset
    63
    public MethodDocImpl(DocEnv env, MethodSymbol sym, TreePath treePath) {
969e90f68ac5 8004828: refactor init of *DocImpl classes
jjg
parents: 14359
diff changeset
    64
        super(env, sym, treePath);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
     * Return true if it is a method, which it is.
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
     * Note: constructors are not methods.
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
     * This method is overridden by AnnotationTypeElementDocImpl.
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
     * @return true
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
    public boolean isMethod() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
        return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
    /**
14951
8d9ea42e4aba 8004814: javadoc should be able to detect default methods
vromero
parents: 14802
diff changeset
    79
     * Return true if this method is default
8d9ea42e4aba 8004814: javadoc should be able to detect default methods
vromero
parents: 14802
diff changeset
    80
     */
8d9ea42e4aba 8004814: javadoc should be able to detect default methods
vromero
parents: 14802
diff changeset
    81
    public boolean isDefault() {
8d9ea42e4aba 8004814: javadoc should be able to detect default methods
vromero
parents: 14802
diff changeset
    82
        return (sym.flags() & Flags.DEFAULT) != 0;
8d9ea42e4aba 8004814: javadoc should be able to detect default methods
vromero
parents: 14802
diff changeset
    83
    }
8d9ea42e4aba 8004814: javadoc should be able to detect default methods
vromero
parents: 14802
diff changeset
    84
8d9ea42e4aba 8004814: javadoc should be able to detect default methods
vromero
parents: 14802
diff changeset
    85
    /**
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
     * Return true if this method is abstract
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
    public boolean isAbstract() {
15034
b7c791bc4526 8004891: Check for abstract method in javadoc does not conform to the language model
bpatel
parents: 14951
diff changeset
    89
        return (Modifier.isAbstract(getModifiers()) && !isDefault());
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
     * Get return type.
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
     * @return the return type of this method, null if it
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
     * is a constructor.
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
    public com.sun.javadoc.Type returnType() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
        return TypeMaker.getType(env, sym.type.getReturnType(), false);
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
     * Return the class that originally defined the method that
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
     * is overridden by the current definition, or null if no
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
     * such class exists.
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
     * @return a ClassDocImpl representing the superclass that
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
     * originally defined this method, null if this method does
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
     * not override a definition in a superclass.
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
    public ClassDoc overriddenClass() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
        com.sun.javadoc.Type t = overriddenType();
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
        return (t != null) ? t.asClassDoc() : null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
     * Return the type containing the method that this method overrides.
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
     * It may be a <code>ClassDoc</code> or a <code>ParameterizedType</code>.
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
    public com.sun.javadoc.Type overriddenType() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
        if ((sym.flags() & Flags.STATIC) != 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
            return null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
        ClassSymbol origin = (ClassSymbol)sym.owner;
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
        for (Type t = env.types.supertype(origin.type);
14359
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14260
diff changeset
   128
             t.hasTag(CLASS);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
             t = env.types.supertype(t)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
            ClassSymbol c = (ClassSymbol)t.tsym;
32800
8457813125e3 8135307: CompletionFailure thrown when calling FieldDoc.type, if the field's type is missing
jlahoda
parents: 25874
diff changeset
   131
            for (Symbol sym2 : membersOf(c).getSymbolsByName(sym.name)) {
25443
9187d77f2c64 8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents: 17275
diff changeset
   132
                if (sym.overrides(sym2, origin, env.types, true)) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
                    return TypeMaker.getType(env, t);
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
        return null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
     * Return the method that this method overrides.
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
     * @return a MethodDoc representing a method definition
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
     * in a superclass this method overrides, null if
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
     * this method does not override.
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
    public MethodDoc overriddenMethod() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
        // Real overriding only.  Static members are simply hidden.
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
        // Likewise for constructors, but the MethodSymbol.overrides
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
        // method takes this into account.
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
        if ((sym.flags() & Flags.STATIC) != 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
            return null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
        // Derived from  com.sun.tools.javac.comp.Check.checkOverride .
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
        ClassSymbol origin = (ClassSymbol)sym.owner;
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
        for (Type t = env.types.supertype(origin.type);
14359
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14260
diff changeset
   160
             t.hasTag(CLASS);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
             t = env.types.supertype(t)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
            ClassSymbol c = (ClassSymbol)t.tsym;
32800
8457813125e3 8135307: CompletionFailure thrown when calling FieldDoc.type, if the field's type is missing
jlahoda
parents: 25874
diff changeset
   163
            for (Symbol sym2 : membersOf(c).getSymbolsByName(sym.name)) {
25443
9187d77f2c64 8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents: 17275
diff changeset
   164
                if (sym.overrides(sym2, origin, env.types, true)) {
9187d77f2c64 8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents: 17275
diff changeset
   165
                    return env.getMethodDoc((MethodSymbol)sym2);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
        return null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
32800
8457813125e3 8135307: CompletionFailure thrown when calling FieldDoc.type, if the field's type is missing
jlahoda
parents: 25874
diff changeset
   172
    /**Retrieve members of c, ignoring any CompletionFailures that occur. */
8457813125e3 8135307: CompletionFailure thrown when calling FieldDoc.type, if the field's type is missing
jlahoda
parents: 25874
diff changeset
   173
    private Scope membersOf(ClassSymbol c) {
8457813125e3 8135307: CompletionFailure thrown when calling FieldDoc.type, if the field's type is missing
jlahoda
parents: 25874
diff changeset
   174
        try {
8457813125e3 8135307: CompletionFailure thrown when calling FieldDoc.type, if the field's type is missing
jlahoda
parents: 25874
diff changeset
   175
            return c.members();
8457813125e3 8135307: CompletionFailure thrown when calling FieldDoc.type, if the field's type is missing
jlahoda
parents: 25874
diff changeset
   176
        } catch (CompletionFailure cf) {
8457813125e3 8135307: CompletionFailure thrown when calling FieldDoc.type, if the field's type is missing
jlahoda
parents: 25874
diff changeset
   177
            /* Quietly ignore completion failures and try again - the type
8457813125e3 8135307: CompletionFailure thrown when calling FieldDoc.type, if the field's type is missing
jlahoda
parents: 25874
diff changeset
   178
             * for which the CompletionFailure was thrown shouldn't be completed
8457813125e3 8135307: CompletionFailure thrown when calling FieldDoc.type, if the field's type is missing
jlahoda
parents: 25874
diff changeset
   179
             * again by the completer that threw the CompletionFailure.
8457813125e3 8135307: CompletionFailure thrown when calling FieldDoc.type, if the field's type is missing
jlahoda
parents: 25874
diff changeset
   180
             */
8457813125e3 8135307: CompletionFailure thrown when calling FieldDoc.type, if the field's type is missing
jlahoda
parents: 25874
diff changeset
   181
            return membersOf(c);
8457813125e3 8135307: CompletionFailure thrown when calling FieldDoc.type, if the field's type is missing
jlahoda
parents: 25874
diff changeset
   182
        }
8457813125e3 8135307: CompletionFailure thrown when calling FieldDoc.type, if the field's type is missing
jlahoda
parents: 25874
diff changeset
   183
    }
8457813125e3 8135307: CompletionFailure thrown when calling FieldDoc.type, if the field's type is missing
jlahoda
parents: 25874
diff changeset
   184
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   185
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
     * Tests whether this method overrides another.
06bc494ca11e Initial load
duke
parents:
diff changeset
   187
     * The overridden method may be one declared in a superclass or
06bc494ca11e Initial load
duke
parents:
diff changeset
   188
     * a superinterface (unlike {@link #overriddenMethod()}).
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   190
     * <p> When a non-abstract method overrides an abstract one, it is
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
     * also said to <i>implement</i> the other.
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   193
     * @param meth  the other method to examine
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
     * @return <tt>true</tt> if this method overrides the other
06bc494ca11e Initial load
duke
parents:
diff changeset
   195
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   196
    public boolean overrides(MethodDoc meth) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   197
        MethodSymbol overridee = ((MethodDocImpl) meth).sym;
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
        ClassSymbol origin = (ClassSymbol) sym.owner;
06bc494ca11e Initial load
duke
parents:
diff changeset
   199
06bc494ca11e Initial load
duke
parents:
diff changeset
   200
        return sym.name == overridee.name &&
06bc494ca11e Initial load
duke
parents:
diff changeset
   201
06bc494ca11e Initial load
duke
parents:
diff changeset
   202
               // not reflexive as per JLS
06bc494ca11e Initial load
duke
parents:
diff changeset
   203
               sym != overridee &&
06bc494ca11e Initial load
duke
parents:
diff changeset
   204
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
               // we don't care if overridee is static, though that wouldn't
06bc494ca11e Initial load
duke
parents:
diff changeset
   206
               // compile
06bc494ca11e Initial load
duke
parents:
diff changeset
   207
               !sym.isStatic() &&
06bc494ca11e Initial load
duke
parents:
diff changeset
   208
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
               // sym, whose declaring type is the origin, must be
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
               // in a subtype of overridee's type
06bc494ca11e Initial load
duke
parents:
diff changeset
   211
               env.types.asSuper(origin.type, overridee.owner) != null &&
06bc494ca11e Initial load
duke
parents:
diff changeset
   212
06bc494ca11e Initial load
duke
parents:
diff changeset
   213
               // check access and signatures; don't check return types
06bc494ca11e Initial load
duke
parents:
diff changeset
   214
               sym.overrides(overridee, origin, env.types, false);
06bc494ca11e Initial load
duke
parents:
diff changeset
   215
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   216
06bc494ca11e Initial load
duke
parents:
diff changeset
   217
06bc494ca11e Initial load
duke
parents:
diff changeset
   218
    public String name() {
17275
bcaa1940863a 8012656: cache frequently used name strings for DocImpl classes
jjg
parents: 15034
diff changeset
   219
        if (name == null) {
bcaa1940863a 8012656: cache frequently used name strings for DocImpl classes
jjg
parents: 15034
diff changeset
   220
            name = sym.name.toString();
bcaa1940863a 8012656: cache frequently used name strings for DocImpl classes
jjg
parents: 15034
diff changeset
   221
        }
bcaa1940863a 8012656: cache frequently used name strings for DocImpl classes
jjg
parents: 15034
diff changeset
   222
        return name;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   223
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   224
17275
bcaa1940863a 8012656: cache frequently used name strings for DocImpl classes
jjg
parents: 15034
diff changeset
   225
    private String name;
bcaa1940863a 8012656: cache frequently used name strings for DocImpl classes
jjg
parents: 15034
diff changeset
   226
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   227
    public String qualifiedName() {
17275
bcaa1940863a 8012656: cache frequently used name strings for DocImpl classes
jjg
parents: 15034
diff changeset
   228
        if (qualifiedName == null) {
bcaa1940863a 8012656: cache frequently used name strings for DocImpl classes
jjg
parents: 15034
diff changeset
   229
            qualifiedName =  sym.enclClass().getQualifiedName() + "." + sym.name;
bcaa1940863a 8012656: cache frequently used name strings for DocImpl classes
jjg
parents: 15034
diff changeset
   230
        }
bcaa1940863a 8012656: cache frequently used name strings for DocImpl classes
jjg
parents: 15034
diff changeset
   231
        return qualifiedName;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   232
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   233
17275
bcaa1940863a 8012656: cache frequently used name strings for DocImpl classes
jjg
parents: 15034
diff changeset
   234
    private String qualifiedName;
bcaa1940863a 8012656: cache frequently used name strings for DocImpl classes
jjg
parents: 15034
diff changeset
   235
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   236
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   237
     * Returns a string representation of this method.  Includes the
06bc494ca11e Initial load
duke
parents:
diff changeset
   238
     * qualified signature, the qualified method name, and any type
06bc494ca11e Initial load
duke
parents:
diff changeset
   239
     * parameters.  Type parameters follow the class name, as they do
06bc494ca11e Initial load
duke
parents:
diff changeset
   240
     * in the syntax for invoking methods with explicit type parameters.
06bc494ca11e Initial load
duke
parents:
diff changeset
   241
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   242
    public String toString() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   243
        return sym.enclClass().getQualifiedName() +
06bc494ca11e Initial load
duke
parents:
diff changeset
   244
                "." + typeParametersString() + name() + signature();
06bc494ca11e Initial load
duke
parents:
diff changeset
   245
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   246
}