jdk/src/share/classes/sun/tools/java/BinaryMember.java
author ntoda
Thu, 31 Jul 2014 17:01:24 -0700
changeset 25799 1afc4675dc75
parent 5506 202f599c92aa
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
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 1994, 2003, 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
import sun.tools.tree.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.util.Vector;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.util.Hashtable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.io.DataInputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.io.ByteArrayInputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * This class represents a binary member
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * WARNING: The contents of this source file are not part of any
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * supported API.  Code that depends on them does so at its own risk:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * they are subject to change or removal without notice.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
public final
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
class BinaryMember extends MemberDefinition {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    Expression value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    BinaryAttribute atts;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
     * Constructor
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    public BinaryMember(ClassDefinition clazz, int modifiers, Type type,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
                       Identifier name, BinaryAttribute atts) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
        super(0, clazz, modifiers, type, name, null, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
        this.atts = atts;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
        // Was it compiled as deprecated?
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
        if (getAttribute(idDeprecated) != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
            this.modifiers |= M_DEPRECATED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
        // Was it synthesized by the compiler?
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
        if (getAttribute(idSynthetic) != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
            this.modifiers |= M_SYNTHETIC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     * Constructor for an inner class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    public BinaryMember(ClassDefinition innerClass) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        super(innerClass);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * Inline allowed (currently only allowed for the constructor of Object).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    public boolean isInlineable(Environment env, boolean fromFinal) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        // It is possible for 'getSuperClass()' to return null due to error
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        // recovery from cyclic inheritace.  Can this cause a problem here?
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        return isConstructor() && (getClassDefinition().getSuperClass() == null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * Get arguments
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     */
25799
1afc4675dc75 8044867: Fix raw and unchecked lint warnings in sun.tools.*
ntoda
parents: 5506
diff changeset
    85
    public Vector<MemberDefinition> getArguments() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        if (isConstructor() && (getClassDefinition().getSuperClass() == null)) {
25799
1afc4675dc75 8044867: Fix raw and unchecked lint warnings in sun.tools.*
ntoda
parents: 5506
diff changeset
    87
            Vector<MemberDefinition> v = new Vector<>();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
            v.addElement(new LocalMember(0, getClassDefinition(), 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
                                        getClassDefinition().getType(), idThis));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
            return v;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * Get exceptions
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    public ClassDeclaration[] getExceptions(Environment env) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        if ((!isMethod()) || (exp != null)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
            return exp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        byte data[] = getAttribute(idExceptions);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        if (data == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
            return new ClassDeclaration[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
            BinaryConstantPool cpool = ((BinaryClass)getClassDefinition()).getConstants();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
            DataInputStream in = new DataInputStream(new ByteArrayInputStream(data));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
            // JVM 4.7.5 Exceptions_attribute.number_of_exceptions
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
            int n = in.readUnsignedShort();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
            exp = new ClassDeclaration[n];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
            for (int i = 0 ; i < n ; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
                // JVM 4.7.5 Exceptions_attribute.exception_index_table[]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
                exp[i] = cpool.getDeclaration(env, in.readUnsignedShort());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
            return exp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        } catch (IOException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
            throw new CompilerError(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * Get documentation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    public String getDocumentation() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        if (documentation != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
            return documentation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        byte data[] = getAttribute(idDocumentation);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        if (data == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
            return documentation = new DataInputStream(new ByteArrayInputStream(data)).readUTF();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        } catch (IOException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
            throw new CompilerError(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     * Check if constant:  Will it inline away to a constant?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * This override is needed to solve bug 4128266.  It is also
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * integral to the solution of 4119776.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    private boolean isConstantCache = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    private boolean isConstantCached = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    public boolean isConstant() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        if (!isConstantCached) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
            isConstantCache = isFinal()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
                              && isVariable()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
                              && getAttribute(idConstantValue) != null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
            isConstantCached = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        return isConstantCache;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * Get the value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    public Node getValue(Environment env) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        if (isMethod()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        if (!isFinal()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        if (getValue() != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
            return (Expression)getValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        byte data[] = getAttribute(idConstantValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        if (data == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
            BinaryConstantPool cpool = ((BinaryClass)getClassDefinition()).getConstants();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
            // JVM 4.7.3 ConstantValue.constantvalue_index
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
            Object obj = cpool.getValue(new DataInputStream(new ByteArrayInputStream(data)).readUnsignedShort());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
            switch (getType().getTypeCode()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
              case TC_BOOLEAN:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
                setValue(new BooleanExpression(0, ((Number)obj).intValue() != 0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
              case TC_BYTE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
              case TC_SHORT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
              case TC_CHAR:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
              case TC_INT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
                setValue(new IntExpression(0, ((Number)obj).intValue()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
              case TC_LONG:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
                setValue(new LongExpression(0, ((Number)obj).longValue()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
              case TC_FLOAT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                setValue(new FloatExpression(0, ((Number)obj).floatValue()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
              case TC_DOUBLE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
                setValue(new DoubleExpression(0, ((Number)obj).doubleValue()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
              case TC_CLASS:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
                setValue(new StringExpression(0, (String)cpool.getValue(((Number)obj).intValue())));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
            return (Expression)getValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        } catch (IOException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
            throw new CompilerError(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * Get a field attribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    public byte[] getAttribute(Identifier name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        for (BinaryAttribute att = atts ; att != null ; att = att.next) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
            if (att.name.equals(name)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
                return att.data;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    public boolean deleteAttribute(Identifier name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        BinaryAttribute walker = null, next = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        boolean succeed = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        while (atts.name.equals(name)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
            atts = atts.next;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
            succeed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        for (walker = atts; walker != null; walker = next) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
            next = walker.next;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
            if (next != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
                if (next.name.equals(name)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
                    walker.next = next.next;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
                    next = next.next;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
                    succeed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        for (walker = atts; walker != null; walker = walker.next) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
            if (walker.name.equals(name)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
                throw new InternalError("Found attribute " + name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        return succeed;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     * Add an attribute to a field
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
    public void addAttribute(Identifier name, byte data[], Environment env) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        this.atts = new BinaryAttribute(name, data, this.atts);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        // Make sure that the new attribute is in the constant pool
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        ((BinaryClass)(this.clazz)).cpool.indexString(name.toString(), env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
}