jaxp/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FieldGen.java
author joehw
Sun, 13 Aug 2017 21:10:40 -0700
changeset 46174 5611d2529b49
parent 45853 bfa06be36a17
permissions -rw-r--r--
8163121: BCEL: update to the latest 6.0 release Reviewed-by: dfuchs, lancea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6
7f561c08de6b Initial load
duke
parents:
diff changeset
     1
/*
45853
bfa06be36a17 8181154: Fix lint warnings in JAXP repo: deprecation
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
 */
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    20
package com.sun.org.apache.bcel.internal.generic;
7f561c08de6b Initial load
duke
parents:
diff changeset
    21
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    22
import java.util.ArrayList;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    23
import java.util.List;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    24
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    25
import com.sun.org.apache.bcel.internal.Const;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    26
import com.sun.org.apache.bcel.internal.classfile.AnnotationEntry;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    27
import com.sun.org.apache.bcel.internal.classfile.Annotations;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    28
import com.sun.org.apache.bcel.internal.classfile.Attribute;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    29
import com.sun.org.apache.bcel.internal.classfile.Constant;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    30
import com.sun.org.apache.bcel.internal.classfile.ConstantObject;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    31
import com.sun.org.apache.bcel.internal.classfile.ConstantPool;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    32
import com.sun.org.apache.bcel.internal.classfile.ConstantValue;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    33
import com.sun.org.apache.bcel.internal.classfile.Field;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    34
import com.sun.org.apache.bcel.internal.classfile.Utility;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    35
import com.sun.org.apache.bcel.internal.util.BCELComparator;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    36
7f561c08de6b Initial load
duke
parents:
diff changeset
    37
/**
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    38
 * Template class for building up a field. The only extraordinary thing one can
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    39
 * do is to add a constant value attribute to a field (which must of course be
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    40
 * compatible with to the declared type).
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    41
 *
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    42
 * @version $Id: FieldGen.java 1749603 2016-06-21 20:50:19Z ggregory $
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    43
 * @see Field
7f561c08de6b Initial load
duke
parents:
diff changeset
    44
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
    45
public class FieldGen extends FieldGenOrMethodGen {
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    46
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    47
    private Object value = null;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    48
    private static BCELComparator bcelComparator = new BCELComparator() {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    49
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    50
        @Override
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    51
        public boolean equals(final Object o1, final Object o2) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    52
            final FieldGen THIS = (FieldGen) o1;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    53
            final FieldGen THAT = (FieldGen) o2;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    54
            return THIS.getName().equals(THAT.getName())
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    55
                    && THIS.getSignature().equals(THAT.getSignature());
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    56
        }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    57
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    58
        @Override
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    59
        public int hashCode(final Object o) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    60
            final FieldGen THIS = (FieldGen) o;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    61
            return THIS.getSignature().hashCode() ^ THIS.getName().hashCode();
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    62
        }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    63
    };
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    64
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    65
    /**
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    66
     * Declare a field. If it is static (isStatic() == true) and has a basic
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    67
     * type like int or String it may have an initial value associated with it
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    68
     * as defined by setInitValue().
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    69
     *
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    70
     * @param access_flags access qualifiers
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    71
     * @param type field type
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    72
     * @param name field name
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    73
     * @param cp constant pool
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    74
     */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    75
    public FieldGen(final int access_flags, final Type type, final String name, final ConstantPoolGen cp) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    76
        super(access_flags);
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    77
        setType(type);
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    78
        setName(name);
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    79
        setConstantPool(cp);
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    80
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
    81
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    82
    /**
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    83
     * Instantiate from existing field.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    84
     *
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    85
     * @param field Field object
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    86
     * @param cp constant pool (must contain the same entries as the field's
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    87
     * constant pool)
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    88
     */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    89
    public FieldGen(final Field field, final ConstantPoolGen cp) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    90
        this(field.getAccessFlags(), Type.getType(field.getSignature()), field.getName(), cp);
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    91
        final Attribute[] attrs = field.getAttributes();
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    92
        for (final Attribute attr : attrs) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    93
            if (attr instanceof ConstantValue) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    94
                setValue(((ConstantValue) attr).getConstantValueIndex());
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    95
            } else if (attr instanceof Annotations) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    96
                final Annotations runtimeAnnotations = (Annotations) attr;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    97
                final AnnotationEntry[] annotationEntries = runtimeAnnotations.getAnnotationEntries();
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    98
                for (final AnnotationEntry element : annotationEntries) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    99
                    addAnnotationEntry(new AnnotationEntryGen(element, cp, false));
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   100
                }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   101
            } else {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   102
                addAttribute(attr);
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   103
            }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   104
        }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   105
    }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   106
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   107
    private void setValue(final int index) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   108
        final ConstantPool cp = super.getConstantPool().getConstantPool();
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   109
        final Constant c = cp.getConstant(index);
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   110
        value = ((ConstantObject) c).getConstantValue(cp);
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   111
    }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   112
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   113
    /**
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   114
     * Set (optional) initial value of field, otherwise it will be set to
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   115
     * null/0/false by the JVM automatically.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   116
     */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   117
    public void setInitValue(final String str) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   118
        checkType(ObjectType.getInstance("java.lang.String"));
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   119
        if (str != null) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   120
            value = str;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   121
        }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   122
    }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   123
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   124
    public void setInitValue(final long l) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   125
        checkType(Type.LONG);
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   126
        if (l != 0L) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   127
            value = l;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   128
        }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   129
    }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   130
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   131
    public void setInitValue(final int i) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   132
        checkType(Type.INT);
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   133
        if (i != 0) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   134
            value = i;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   135
        }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   136
    }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   137
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   138
    public void setInitValue(final short s) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   139
        checkType(Type.SHORT);
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   140
        if (s != 0) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   141
            value = (int) s;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   142
        }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   143
    }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   144
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   145
    public void setInitValue(final char c) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   146
        checkType(Type.CHAR);
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   147
        if (c != 0) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   148
            value = (int) c;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   149
        }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   150
    }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   151
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   152
    public void setInitValue(final byte b) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   153
        checkType(Type.BYTE);
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   154
        if (b != 0) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   155
            value = (int) b;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   156
        }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   157
    }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   158
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   159
    public void setInitValue(final boolean b) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   160
        checkType(Type.BOOLEAN);
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   161
        if (b) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   162
            value = 1;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   163
        }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   164
    }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   165
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   166
    public void setInitValue(final float f) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   167
        checkType(Type.FLOAT);
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   168
        if (f != 0.0) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   169
            value = f;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   170
        }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   171
    }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   172
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   173
    public void setInitValue(final double d) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   174
        checkType(Type.DOUBLE);
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   175
        if (d != 0.0) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   176
            value = d;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   177
        }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   178
    }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   179
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   180
    /**
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   181
     * Remove any initial value.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   182
     */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   183
    public void cancelInitValue() {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   184
        value = null;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   185
    }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   186
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   187
    private void checkType(final Type atype) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   188
        final Type superType = super.getType();
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   189
        if (superType == null) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   190
            throw new ClassGenException("You haven't defined the type of the field yet");
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   191
        }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   192
        if (!isFinal()) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   193
            throw new ClassGenException("Only final fields may have an initial value!");
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   194
        }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   195
        if (!superType.equals(atype)) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   196
            throw new ClassGenException("Types are not compatible: " + superType + " vs. " + atype);
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   197
        }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   198
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   199
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   200
    /**
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   201
     * Get field object after having set up all necessary values.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   202
     */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   203
    public Field getField() {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   204
        final String signature = getSignature();
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   205
        final int name_index = super.getConstantPool().addUtf8(super.getName());
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   206
        final int signature_index = super.getConstantPool().addUtf8(signature);
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   207
        if (value != null) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   208
            checkType(super.getType());
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   209
            final int index = addConstant();
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   210
            addAttribute(new ConstantValue(super.getConstantPool().addUtf8("ConstantValue"), 2, index,
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   211
                    super.getConstantPool().getConstantPool())); // sic
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   212
        }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   213
        addAnnotationsAsAttribute(super.getConstantPool());
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   214
        return new Field(super.getAccessFlags(), name_index, signature_index, getAttributes(),
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   215
                super.getConstantPool().getConstantPool()); // sic
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   216
    }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   217
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   218
    private void addAnnotationsAsAttribute(final ConstantPoolGen cp) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   219
        final Attribute[] attrs = AnnotationEntryGen.getAnnotationAttributes(cp, super.getAnnotationEntries());
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   220
        for (final Attribute attr : attrs) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   221
            addAttribute(attr);
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   222
        }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   223
    }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   224
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   225
    private int addConstant() {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   226
        switch (super.getType().getType()) { // sic
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   227
            case Const.T_INT:
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   228
            case Const.T_CHAR:
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   229
            case Const.T_BYTE:
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   230
            case Const.T_BOOLEAN:
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   231
            case Const.T_SHORT:
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   232
                return super.getConstantPool().addInteger(((Integer) value));
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   233
            case Const.T_FLOAT:
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   234
                return super.getConstantPool().addFloat(((Float) value));
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   235
            case Const.T_DOUBLE:
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   236
                return super.getConstantPool().addDouble(((Double) value));
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   237
            case Const.T_LONG:
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   238
                return super.getConstantPool().addLong(((Long) value));
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   239
            case Const.T_REFERENCE:
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   240
                return super.getConstantPool().addString((String) value);
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   241
            default:
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   242
                throw new RuntimeException("Oops: Unhandled : " + super.getType().getType()); // sic
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   243
        }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   244
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   245
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   246
    @Override
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   247
    public String getSignature() {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   248
        return super.getType().getSignature();
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   249
    }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   250
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   251
    private List<FieldObserver> observers;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   252
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   253
    /**
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   254
     * Add observer for this object.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   255
     */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   256
    public void addObserver(final FieldObserver o) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   257
        if (observers == null) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   258
            observers = new ArrayList<>();
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   259
        }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   260
        observers.add(o);
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   261
    }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   262
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   263
    /**
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   264
     * Remove observer for this object.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   265
     */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   266
    public void removeObserver(final FieldObserver o) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   267
        if (observers != null) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   268
            observers.remove(o);
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   269
        }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   270
    }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   271
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   272
    /**
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   273
     * Call notify() method on all observers. This method is not called
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   274
     * automatically whenever the state has changed, but has to be called by the
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   275
     * user after he has finished editing the object.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   276
     */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   277
    public void update() {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   278
        if (observers != null) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   279
            for (final FieldObserver observer : observers) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   280
                observer.notify(this);
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   281
            }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   282
        }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   283
    }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   284
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   285
    public String getInitValue() {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   286
        if (value != null) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   287
            return value.toString();
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   288
        }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   289
        return null;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   290
    }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   291
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   292
    /**
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   293
     * Return string representation close to declaration format, `public static
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   294
     * final short MAX = 100', e.g..
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   295
     *
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   296
     * @return String representation of field
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   297
     */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   298
    @Override
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   299
    public final String toString() {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   300
        String name;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   301
        String signature;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   302
        String access; // Short cuts to constant pool
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   303
        access = Utility.accessToString(super.getAccessFlags());
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   304
        access = access.isEmpty() ? "" : (access + " ");
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   305
        signature = super.getType().toString();
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   306
        name = getName();
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   307
        final StringBuilder buf = new StringBuilder(32); // CHECKSTYLE IGNORE MagicNumber
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   308
        buf.append(access).append(signature).append(" ").append(name);
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   309
        final String value = getInitValue();
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   310
        if (value != null) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   311
            buf.append(" = ").append(value);
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   312
        }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   313
        return buf.toString();
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   314
    }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   315
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   316
    /**
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   317
     * @return deep copy of this field
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   318
     */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   319
    public FieldGen copy(final ConstantPoolGen cp) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   320
        final FieldGen fg = (FieldGen) clone();
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   321
        fg.setConstantPool(cp);
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   322
        return fg;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   323
    }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   324
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   325
    /**
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   326
     * @return Comparison strategy object
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   327
     */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   328
    public static BCELComparator getComparator() {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   329
        return bcelComparator;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   330
    }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   331
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   332
    /**
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   333
     * @param comparator Comparison strategy object
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   334
     */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   335
    public static void setComparator(final BCELComparator comparator) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   336
        bcelComparator = comparator;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   337
    }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   338
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   339
    /**
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   340
     * Return value as defined by given BCELComparator strategy. By default two
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   341
     * FieldGen objects are said to be equal when their names and signatures are
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   342
     * equal.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   343
     *
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   344
     * @see java.lang.Object#equals(java.lang.Object)
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   345
     */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   346
    @Override
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   347
    public boolean equals(final Object obj) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   348
        return bcelComparator.equals(this, obj);
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   349
    }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   350
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   351
    /**
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   352
     * Return value as defined by given BCELComparator strategy. By default
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   353
     * return the hashcode of the field's name XOR signature.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   354
     *
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   355
     * @see java.lang.Object#hashCode()
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   356
     */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   357
    @Override
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   358
    public int hashCode() {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   359
        return bcelComparator.hashCode(this);
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   360
    }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   361
}