jdk/src/share/classes/sun/tools/java/ClassDeclaration.java
author ntoda
Thu, 31 Jul 2014 17:01:24 -0700
changeset 25799 1afc4675dc75
parent 23010 6dadb192ad81
permissions -rw-r--r--
8044867: Fix raw and unchecked lint warnings in sun.tools.* Reviewed-by: darcy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
23010
6dadb192ad81 8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents: 18293
diff changeset
     2
 * Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package sun.tools.java;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * This class represents an Java class declaration. It refers
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * to either a binary or source definition.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * ClassDefinitions are loaded on demand, this means that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * class declarations are late bound. The definition of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * class is obtained in stages. The status field describes
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * the state of the class definition:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * CS_UNDEFINED - the definition is not yet loaded
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * CS_UNDECIDED - a binary definition is loaded, but it is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 *                still unclear if the source definition need to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 *                be loaded
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * CS_BINARY    - the binary class is loaded
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * CS_PARSED    - the class is loaded from the source file, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 *                type information is available, but the class has
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 *                not yet been compiled.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * CS_CHECKED   - the class is loaded from the source file and has
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 *                been type-checked.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * CS_COMPILED  - the class has been type checked, compiled,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 *                and written out.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * CS_NOTFOUND  - no class definition could be found
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * WARNING: The contents of this source file are not part of any
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * supported API.  Code that depends on them does so at its own risk:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * they are subject to change or removal without notice.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
public final
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
class ClassDeclaration implements Constants {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    int status;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    Type type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    ClassDefinition definition;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * Constructor
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    public ClassDeclaration(Identifier name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        this.type = Type.tClass(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * Get the status of the class
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    public int getStatus() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        return status;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * Get the name of the class
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    public Identifier getName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
       return type.getClassName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * Get the type of the class
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    public Type getType() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        return type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * Check if the class is defined
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    public boolean isDefined() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        switch (status) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
          case CS_BINARY:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
          case CS_PARSED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
          case CS_CHECKED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
          case CS_COMPILED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
            return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * Get the definition of this class. Returns null if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * the class is not yet defined.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    public ClassDefinition getClassDefinition() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        return definition;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * This is a flag for use by getClassDefinition(env).  It is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * used to mark that a class has been successfully looked up
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * by that method before.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    private boolean found = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * Get the definition of this class, if the class is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * yet defined, load the definition. Loading a class may
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * throw various exceptions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    public ClassDefinition getClassDefinition(Environment env)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    throws ClassNotFound {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        if (tracing) env.dtEvent("getClassDefinition: " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
                                 getName() + ", status " + getStatus());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        // The majority of calls to getClassDefinition() are duplicates.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        // This check makes them fast.  It also allows us to avoid
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        // duplicate, useless calls to basicCheck().  In the future it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        // would be good to add an additional status value, CS_BASICCHECKED.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        if (found) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
            return definition;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        for(;;) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
            switch (status) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
                case CS_UNDEFINED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
                case CS_UNDECIDED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
                case CS_SOURCE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
                    env.loadDefinition(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
                case CS_BINARY:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
                case CS_PARSED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
                    //+FIX FOR BUGID 4056065
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
                    //definition.basicCheck(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
                    if (!definition.isInsideLocal()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
                        // Classes inside a block, including anonymous classes,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
                        // are checked when their surrounding member is checked.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
                        definition.basicCheck(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
                    //-FIX FOR BUGID 4056065
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
                    found = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
                    return definition;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
                case CS_CHECKED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
                case CS_COMPILED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
                    found = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
                    return definition;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
                default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
                    throw new ClassNotFound(getName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * Get the definition of this class, if the class is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * yet defined, load the definition. Loading a class may
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     * throw various exceptions.  Perform no basicCheck() on this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    public ClassDefinition getClassDefinitionNoCheck(Environment env) throws ClassNotFound {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        if (tracing) env.dtEvent("getClassDefinition: " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
                                 getName() + ", status " + getStatus());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        for(;;) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
            switch (status) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
                case CS_UNDEFINED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
                case CS_UNDECIDED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
                case CS_SOURCE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
                    env.loadDefinition(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
                case CS_BINARY:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
                case CS_PARSED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
                case CS_CHECKED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
                case CS_COMPILED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
                    return definition;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
                default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
                    throw new ClassNotFound(getName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     * Set the class definition
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    public void setDefinition(ClassDefinition definition, int status) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        // Sanity checks.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        // The name of the definition should match that of the declaration.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        if ((definition != null) && !getName().equals(definition.getName())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
            throw new CompilerError("setDefinition: name mismatch: " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
                                    this + ", " + definition);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        // The status states can be considered ordered in the same
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        // manner as their numerical values. We expect classes to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        // progress through a sequence of monotonically increasing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        // states. NOTE: There are currently exceptions to this rule
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        // which are believed to be legitimate.  In particular, a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        // class may be checked more than once, though we believe that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        // this is unnecessary and may be avoided.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        /*-----------------*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        if (status <= this.status) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
            System.out.println("STATUS REGRESSION: " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
                               this + " FROM " + this.status + " TO " + status);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        *------------------*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        this.definition = definition;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        this.status = status;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     * Equality
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    public boolean equals(Object obj) {
18293
5d768c1bf246 8016698: Cleanup overrides warning in sun/tools/ClassDeclaration.java
khazra
parents: 5506
diff changeset
   233
        if (obj instanceof ClassDeclaration) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
            return type.equals(((ClassDeclaration)obj).type);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
18293
5d768c1bf246 8016698: Cleanup overrides warning in sun/tools/ClassDeclaration.java
khazra
parents: 5506
diff changeset
   239
    @Override
5d768c1bf246 8016698: Cleanup overrides warning in sun/tools/ClassDeclaration.java
khazra
parents: 5506
diff changeset
   240
    public int hashCode() {
5d768c1bf246 8016698: Cleanup overrides warning in sun/tools/ClassDeclaration.java
khazra
parents: 5506
diff changeset
   241
        return type.hashCode();
5d768c1bf246 8016698: Cleanup overrides warning in sun/tools/ClassDeclaration.java
khazra
parents: 5506
diff changeset
   242
    }
5d768c1bf246 8016698: Cleanup overrides warning in sun/tools/ClassDeclaration.java
khazra
parents: 5506
diff changeset
   243
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     * toString
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        String name = getName().toString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        String type = "type ";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        String nested = getName().isInner() ? "nested " : "";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        if (getClassDefinition() != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
            if (getClassDefinition().isInterface()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
                type = "interface ";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
                type = "class ";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
            if (!getClassDefinition().isTopLevel()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
                nested = "inner ";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
                if (getClassDefinition().isLocal()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
                    nested = "local ";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
                    if (!getClassDefinition().isAnonymous()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
                        name = getClassDefinition().getLocalName() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
                            " (" + name + ")";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
        return nested + type + name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
}