langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Pool.java
author mcimadamore
Mon, 24 Aug 2015 13:15:12 +0100
changeset 32334 fd65e32e16b3
parent 27224 228abfa87080
child 32336 9e9acf7f26a4
permissions -rw-r--r--
8129547: Excess entries in BootstrapMethods with the same (bsm, bsmKind, bsmStaticArgs), but different dynamicArgs Summary: Pool.DynamicMethod implementation for hash/equals leads to duplicate BSM entries. Reviewed-by: jlahoda Contributed-by: aleksey.shipilev@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
15564
6d8db91563a7 8005075: Pool.Method, and Pool.Variable redundant Symbol field should be removed
vromero
parents: 14949
diff changeset
     2
 * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
06bc494ca11e Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1264
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1264
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
 *
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1264
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1264
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1264
diff changeset
    23
 * questions.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
06bc494ca11e Initial load
duke
parents:
diff changeset
    26
package com.sun.tools.javac.jvm;
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
14046
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
    28
import com.sun.tools.javac.code.Symbol;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
import com.sun.tools.javac.code.Symbol.*;
24605
265027386d51 8015927: Class reference duplicates in constant pool
pgovereau
parents: 24396
diff changeset
    30
import com.sun.tools.javac.code.TypeTag;
14949
45f43822bbde 8000518: Javac generates duplicate name_and_type constant pool entry for class BinaryOpValueExp.java
vromero
parents: 14547
diff changeset
    31
import com.sun.tools.javac.code.Type;
45f43822bbde 8000518: Javac generates duplicate name_and_type constant pool entry for class BinaryOpValueExp.java
vromero
parents: 14547
diff changeset
    32
import com.sun.tools.javac.code.Types;
45f43822bbde 8000518: Javac generates duplicate name_and_type constant pool entry for class BinaryOpValueExp.java
vromero
parents: 14547
diff changeset
    33
import com.sun.tools.javac.code.Types.UniqueType;
14052
8b839ae9074b 8000233: Fix issues in recent push
mcimadamore
parents: 14049
diff changeset
    34
14053
99e71e40b111 8000241: langtools doesn't build
mcimadamore
parents: 14052
diff changeset
    35
import com.sun.tools.javac.util.ArrayUtils;
14046
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
    36
import com.sun.tools.javac.util.Assert;
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
    37
import com.sun.tools.javac.util.Filter;
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
    38
import com.sun.tools.javac.util.Name;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
14052
8b839ae9074b 8000233: Fix issues in recent push
mcimadamore
parents: 14049
diff changeset
    40
import java.util.*;
8b839ae9074b 8000233: Fix issues in recent push
mcimadamore
parents: 14049
diff changeset
    41
26266
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents: 25874
diff changeset
    42
import com.sun.tools.javac.util.DefinedBy;
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents: 25874
diff changeset
    43
import com.sun.tools.javac.util.DefinedBy.Api;
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents: 25874
diff changeset
    44
27224
228abfa87080 8054457: Refactor Symbol kinds from small ints to an enum
emc
parents: 26266
diff changeset
    45
import static com.sun.tools.javac.code.Kinds.*;
228abfa87080 8054457: Refactor Symbol kinds from small ints to an enum
emc
parents: 26266
diff changeset
    46
import static com.sun.tools.javac.code.Kinds.Kind.*;
228abfa87080 8054457: Refactor Symbol kinds from small ints to an enum
emc
parents: 26266
diff changeset
    47
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
/** An internal structure that corresponds to the constant pool of a classfile.
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
 *
5847
1908176fd6e3 6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents: 5520
diff changeset
    50
 *  <p><b>This is NOT part of any supported API.
1908176fd6e3 6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents: 5520
diff changeset
    51
 *  If you write code that depends on this, you do so at your own risk.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
 *  This code and its internal interfaces are subject to change or
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
 *  deletion without notice.</b>
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
public class Pool {
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
    public static final int MAX_ENTRIES = 0xFFFF;
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
    public static final int MAX_STRING_LENGTH = 0xFFFF;
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
    /** Index of next constant to be entered.
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
    int pp;
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
    /** The initial pool buffer.
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
    Object[] pool;
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
    /** A hashtable containing all constants in the pool.
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
    Map<Object,Integer> indices;
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
14949
45f43822bbde 8000518: Javac generates duplicate name_and_type constant pool entry for class BinaryOpValueExp.java
vromero
parents: 14547
diff changeset
    72
    Types types;
45f43822bbde 8000518: Javac generates duplicate name_and_type constant pool entry for class BinaryOpValueExp.java
vromero
parents: 14547
diff changeset
    73
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
    /** Construct a pool with given number of elements and element array.
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
     */
14949
45f43822bbde 8000518: Javac generates duplicate name_and_type constant pool entry for class BinaryOpValueExp.java
vromero
parents: 14547
diff changeset
    76
    public Pool(int pp, Object[] pool, Types types) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
        this.pp = pp;
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
        this.pool = pool;
14949
45f43822bbde 8000518: Javac generates duplicate name_and_type constant pool entry for class BinaryOpValueExp.java
vromero
parents: 14547
diff changeset
    79
        this.types = types;
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 21014
diff changeset
    80
        this.indices = new HashMap<>(pool.length);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
        for (int i = 1; i < pp; i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
            if (pool[i] != null) indices.put(pool[i], i);
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
    /** Construct an empty pool.
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
     */
14949
45f43822bbde 8000518: Javac generates duplicate name_and_type constant pool entry for class BinaryOpValueExp.java
vromero
parents: 14547
diff changeset
    88
    public Pool(Types types) {
45f43822bbde 8000518: Javac generates duplicate name_and_type constant pool entry for class BinaryOpValueExp.java
vromero
parents: 14547
diff changeset
    89
        this(1, new Object[64], types);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
    /** Return the number of entries in the constant pool.
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
    public int numEntries() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
        return pp;
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
    /** Remove everything from this pool.
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
    public void reset() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
        pp = 1;
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
        indices.clear();
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
    /** Place an object in the pool, unless it is already there.
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
     *  If object is a symbol also enter its owner unless the owner is a
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
     *  package.  Return the object's index in the pool.
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
    public int put(Object value) {
14547
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents: 14053
diff changeset
   110
        value = makePoolValue(value);
24396
3c36c6afcbca 8040327: Eliminate AnnotatedType
emc
parents: 22163
diff changeset
   111
        Assert.check(!(value instanceof Type.TypeVar));
3c36c6afcbca 8040327: Eliminate AnnotatedType
emc
parents: 22163
diff changeset
   112
        Assert.check(!(value instanceof Types.UniqueType &&
3c36c6afcbca 8040327: Eliminate AnnotatedType
emc
parents: 22163
diff changeset
   113
                       ((UniqueType) value).type instanceof Type.TypeVar));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
        Integer index = indices.get(value);
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
        if (index == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
            index = pp;
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
            indices.put(value, index);
14049
3207422a0f9b 7193657: provide internal ArrayUtils class to simplify common usage of arrays in javac
jjg
parents: 14046
diff changeset
   118
            pool = ArrayUtils.ensureCapacity(pool, pp);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
            pool[pp++] = value;
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
            if (value instanceof Long || value instanceof Double) {
14049
3207422a0f9b 7193657: provide internal ArrayUtils class to simplify common usage of arrays in javac
jjg
parents: 14046
diff changeset
   121
                pool = ArrayUtils.ensureCapacity(pool, pp);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
                pool[pp++] = null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
        return index.intValue();
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
14547
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents: 14053
diff changeset
   128
    Object makePoolValue(Object o) {
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents: 14053
diff changeset
   129
        if (o instanceof DynamicMethodSymbol) {
14949
45f43822bbde 8000518: Javac generates duplicate name_and_type constant pool entry for class BinaryOpValueExp.java
vromero
parents: 14547
diff changeset
   130
            return new DynamicMethod((DynamicMethodSymbol)o, types);
14547
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents: 14053
diff changeset
   131
        } else if (o instanceof MethodSymbol) {
14949
45f43822bbde 8000518: Javac generates duplicate name_and_type constant pool entry for class BinaryOpValueExp.java
vromero
parents: 14547
diff changeset
   132
            return new Method((MethodSymbol)o, types);
14547
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents: 14053
diff changeset
   133
        } else if (o instanceof VarSymbol) {
14949
45f43822bbde 8000518: Javac generates duplicate name_and_type constant pool entry for class BinaryOpValueExp.java
vromero
parents: 14547
diff changeset
   134
            return new Variable((VarSymbol)o, types);
45f43822bbde 8000518: Javac generates duplicate name_and_type constant pool entry for class BinaryOpValueExp.java
vromero
parents: 14547
diff changeset
   135
        } else if (o instanceof Type) {
24605
265027386d51 8015927: Class reference duplicates in constant pool
pgovereau
parents: 24396
diff changeset
   136
            Type t = (Type)o;
265027386d51 8015927: Class reference duplicates in constant pool
pgovereau
parents: 24396
diff changeset
   137
            // ClassRefs can come from ClassSymbols or from Types.
265027386d51 8015927: Class reference duplicates in constant pool
pgovereau
parents: 24396
diff changeset
   138
            // Return the symbol for these types to avoid duplicates
265027386d51 8015927: Class reference duplicates in constant pool
pgovereau
parents: 24396
diff changeset
   139
            // in the constant pool
265027386d51 8015927: Class reference duplicates in constant pool
pgovereau
parents: 24396
diff changeset
   140
            if (t.hasTag(TypeTag.CLASS))
265027386d51 8015927: Class reference duplicates in constant pool
pgovereau
parents: 24396
diff changeset
   141
                return t.tsym;
265027386d51 8015927: Class reference duplicates in constant pool
pgovereau
parents: 24396
diff changeset
   142
            else
265027386d51 8015927: Class reference duplicates in constant pool
pgovereau
parents: 24396
diff changeset
   143
                return new UniqueType(t, types);
14547
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents: 14053
diff changeset
   144
        } else {
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents: 14053
diff changeset
   145
            return o;
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents: 14053
diff changeset
   146
        }
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents: 14053
diff changeset
   147
    }
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents: 14053
diff changeset
   148
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
    /** Return the given object's index in the pool,
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
     *  or -1 if object is not in there.
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
    public int get(Object o) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
        Integer n = indices.get(o);
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
        return n == null ? -1 : n.intValue();
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
15564
6d8db91563a7 8005075: Pool.Method, and Pool.Variable redundant Symbol field should be removed
vromero
parents: 14949
diff changeset
   157
    static class Method extends DelegatedSymbol<MethodSymbol> {
14949
45f43822bbde 8000518: Javac generates duplicate name_and_type constant pool entry for class BinaryOpValueExp.java
vromero
parents: 14547
diff changeset
   158
        UniqueType uniqueType;
45f43822bbde 8000518: Javac generates duplicate name_and_type constant pool entry for class BinaryOpValueExp.java
vromero
parents: 14547
diff changeset
   159
        Method(MethodSymbol m, Types types) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
            super(m);
14949
45f43822bbde 8000518: Javac generates duplicate name_and_type constant pool entry for class BinaryOpValueExp.java
vromero
parents: 14547
diff changeset
   161
            this.uniqueType = new UniqueType(m.type, types);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
        }
26266
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents: 25874
diff changeset
   163
        @DefinedBy(Api.LANGUAGE_MODEL)
15564
6d8db91563a7 8005075: Pool.Method, and Pool.Variable redundant Symbol field should be removed
vromero
parents: 14949
diff changeset
   164
        public boolean equals(Object any) {
6d8db91563a7 8005075: Pool.Method, and Pool.Variable redundant Symbol field should be removed
vromero
parents: 14949
diff changeset
   165
            if (!(any instanceof Method)) return false;
6d8db91563a7 8005075: Pool.Method, and Pool.Variable redundant Symbol field should be removed
vromero
parents: 14949
diff changeset
   166
            MethodSymbol o = ((Method)any).other;
6d8db91563a7 8005075: Pool.Method, and Pool.Variable redundant Symbol field should be removed
vromero
parents: 14949
diff changeset
   167
            MethodSymbol m = this.other;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
            return
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
                o.name == m.name &&
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
                o.owner == m.owner &&
15564
6d8db91563a7 8005075: Pool.Method, and Pool.Variable redundant Symbol field should be removed
vromero
parents: 14949
diff changeset
   171
                ((Method)any).uniqueType.equals(uniqueType);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
        }
26266
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents: 25874
diff changeset
   173
        @DefinedBy(Api.LANGUAGE_MODEL)
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
        public int hashCode() {
15564
6d8db91563a7 8005075: Pool.Method, and Pool.Variable redundant Symbol field should be removed
vromero
parents: 14949
diff changeset
   175
            MethodSymbol m = this.other;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   176
            return
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
                m.name.hashCode() * 33 +
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
                m.owner.hashCode() * 9 +
14949
45f43822bbde 8000518: Javac generates duplicate name_and_type constant pool entry for class BinaryOpValueExp.java
vromero
parents: 14547
diff changeset
   179
                uniqueType.hashCode();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
14547
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents: 14053
diff changeset
   183
    static class DynamicMethod extends Method {
14949
45f43822bbde 8000518: Javac generates duplicate name_and_type constant pool entry for class BinaryOpValueExp.java
vromero
parents: 14547
diff changeset
   184
        public Object[] uniqueStaticArgs;
14547
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents: 14053
diff changeset
   185
14949
45f43822bbde 8000518: Javac generates duplicate name_and_type constant pool entry for class BinaryOpValueExp.java
vromero
parents: 14547
diff changeset
   186
        DynamicMethod(DynamicMethodSymbol m, Types types) {
45f43822bbde 8000518: Javac generates duplicate name_and_type constant pool entry for class BinaryOpValueExp.java
vromero
parents: 14547
diff changeset
   187
            super(m, types);
45f43822bbde 8000518: Javac generates duplicate name_and_type constant pool entry for class BinaryOpValueExp.java
vromero
parents: 14547
diff changeset
   188
            uniqueStaticArgs = getUniqueTypeArray(m.staticArgs, types);
14547
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents: 14053
diff changeset
   189
        }
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents: 14053
diff changeset
   190
26266
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents: 25874
diff changeset
   191
        @Override @DefinedBy(Api.LANGUAGE_MODEL)
15564
6d8db91563a7 8005075: Pool.Method, and Pool.Variable redundant Symbol field should be removed
vromero
parents: 14949
diff changeset
   192
        public boolean equals(Object any) {
32334
fd65e32e16b3 8129547: Excess entries in BootstrapMethods with the same (bsm, bsmKind, bsmStaticArgs), but different dynamicArgs
mcimadamore
parents: 27224
diff changeset
   193
            return equalsImpl(any, true);
fd65e32e16b3 8129547: Excess entries in BootstrapMethods with the same (bsm, bsmKind, bsmStaticArgs), but different dynamicArgs
mcimadamore
parents: 27224
diff changeset
   194
        }
fd65e32e16b3 8129547: Excess entries in BootstrapMethods with the same (bsm, bsmKind, bsmStaticArgs), but different dynamicArgs
mcimadamore
parents: 27224
diff changeset
   195
fd65e32e16b3 8129547: Excess entries in BootstrapMethods with the same (bsm, bsmKind, bsmStaticArgs), but different dynamicArgs
mcimadamore
parents: 27224
diff changeset
   196
        protected boolean equalsImpl(Object any, boolean includeDynamicArgs) {
fd65e32e16b3 8129547: Excess entries in BootstrapMethods with the same (bsm, bsmKind, bsmStaticArgs), but different dynamicArgs
mcimadamore
parents: 27224
diff changeset
   197
            if (includeDynamicArgs && !super.equals(any)) return false;
15564
6d8db91563a7 8005075: Pool.Method, and Pool.Variable redundant Symbol field should be removed
vromero
parents: 14949
diff changeset
   198
            if (!(any instanceof DynamicMethod)) return false;
6d8db91563a7 8005075: Pool.Method, and Pool.Variable redundant Symbol field should be removed
vromero
parents: 14949
diff changeset
   199
            DynamicMethodSymbol dm1 = (DynamicMethodSymbol)other;
6d8db91563a7 8005075: Pool.Method, and Pool.Variable redundant Symbol field should be removed
vromero
parents: 14949
diff changeset
   200
            DynamicMethodSymbol dm2 = (DynamicMethodSymbol)((DynamicMethod)any).other;
14547
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents: 14053
diff changeset
   201
            return dm1.bsm == dm2.bsm &&
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents: 14053
diff changeset
   202
                        dm1.bsmKind == dm2.bsmKind &&
14949
45f43822bbde 8000518: Javac generates duplicate name_and_type constant pool entry for class BinaryOpValueExp.java
vromero
parents: 14547
diff changeset
   203
                        Arrays.equals(uniqueStaticArgs,
15564
6d8db91563a7 8005075: Pool.Method, and Pool.Variable redundant Symbol field should be removed
vromero
parents: 14949
diff changeset
   204
                            ((DynamicMethod)any).uniqueStaticArgs);
14547
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents: 14053
diff changeset
   205
        }
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents: 14053
diff changeset
   206
26266
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents: 25874
diff changeset
   207
        @Override @DefinedBy(Api.LANGUAGE_MODEL)
14547
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents: 14053
diff changeset
   208
        public int hashCode() {
32334
fd65e32e16b3 8129547: Excess entries in BootstrapMethods with the same (bsm, bsmKind, bsmStaticArgs), but different dynamicArgs
mcimadamore
parents: 27224
diff changeset
   209
            return hashCodeImpl(true);
fd65e32e16b3 8129547: Excess entries in BootstrapMethods with the same (bsm, bsmKind, bsmStaticArgs), but different dynamicArgs
mcimadamore
parents: 27224
diff changeset
   210
        }
fd65e32e16b3 8129547: Excess entries in BootstrapMethods with the same (bsm, bsmKind, bsmStaticArgs), but different dynamicArgs
mcimadamore
parents: 27224
diff changeset
   211
fd65e32e16b3 8129547: Excess entries in BootstrapMethods with the same (bsm, bsmKind, bsmStaticArgs), but different dynamicArgs
mcimadamore
parents: 27224
diff changeset
   212
        protected int hashCodeImpl(boolean includeDynamicArgs) {
fd65e32e16b3 8129547: Excess entries in BootstrapMethods with the same (bsm, bsmKind, bsmStaticArgs), but different dynamicArgs
mcimadamore
parents: 27224
diff changeset
   213
            int hash = includeDynamicArgs ? super.hashCode() : 0;
15564
6d8db91563a7 8005075: Pool.Method, and Pool.Variable redundant Symbol field should be removed
vromero
parents: 14949
diff changeset
   214
            DynamicMethodSymbol dm = (DynamicMethodSymbol)other;
14547
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents: 14053
diff changeset
   215
            hash += dm.bsmKind * 7 +
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents: 14053
diff changeset
   216
                    dm.bsm.hashCode() * 11;
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents: 14053
diff changeset
   217
            for (int i = 0; i < dm.staticArgs.length; i++) {
14949
45f43822bbde 8000518: Javac generates duplicate name_and_type constant pool entry for class BinaryOpValueExp.java
vromero
parents: 14547
diff changeset
   218
                hash += (uniqueStaticArgs[i].hashCode() * 23);
14547
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents: 14053
diff changeset
   219
            }
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents: 14053
diff changeset
   220
            return hash;
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents: 14053
diff changeset
   221
        }
14949
45f43822bbde 8000518: Javac generates duplicate name_and_type constant pool entry for class BinaryOpValueExp.java
vromero
parents: 14547
diff changeset
   222
45f43822bbde 8000518: Javac generates duplicate name_and_type constant pool entry for class BinaryOpValueExp.java
vromero
parents: 14547
diff changeset
   223
        private Object[] getUniqueTypeArray(Object[] objects, Types types) {
45f43822bbde 8000518: Javac generates duplicate name_and_type constant pool entry for class BinaryOpValueExp.java
vromero
parents: 14547
diff changeset
   224
            Object[] result = new Object[objects.length];
45f43822bbde 8000518: Javac generates duplicate name_and_type constant pool entry for class BinaryOpValueExp.java
vromero
parents: 14547
diff changeset
   225
            for (int i = 0; i < objects.length; i++) {
45f43822bbde 8000518: Javac generates duplicate name_and_type constant pool entry for class BinaryOpValueExp.java
vromero
parents: 14547
diff changeset
   226
                if (objects[i] instanceof Type) {
45f43822bbde 8000518: Javac generates duplicate name_and_type constant pool entry for class BinaryOpValueExp.java
vromero
parents: 14547
diff changeset
   227
                    result[i] = new UniqueType((Type)objects[i], types);
45f43822bbde 8000518: Javac generates duplicate name_and_type constant pool entry for class BinaryOpValueExp.java
vromero
parents: 14547
diff changeset
   228
                } else {
45f43822bbde 8000518: Javac generates duplicate name_and_type constant pool entry for class BinaryOpValueExp.java
vromero
parents: 14547
diff changeset
   229
                    result[i] = objects[i];
45f43822bbde 8000518: Javac generates duplicate name_and_type constant pool entry for class BinaryOpValueExp.java
vromero
parents: 14547
diff changeset
   230
                }
45f43822bbde 8000518: Javac generates duplicate name_and_type constant pool entry for class BinaryOpValueExp.java
vromero
parents: 14547
diff changeset
   231
            }
45f43822bbde 8000518: Javac generates duplicate name_and_type constant pool entry for class BinaryOpValueExp.java
vromero
parents: 14547
diff changeset
   232
            return result;
45f43822bbde 8000518: Javac generates duplicate name_and_type constant pool entry for class BinaryOpValueExp.java
vromero
parents: 14547
diff changeset
   233
        }
32334
fd65e32e16b3 8129547: Excess entries in BootstrapMethods with the same (bsm, bsmKind, bsmStaticArgs), but different dynamicArgs
mcimadamore
parents: 27224
diff changeset
   234
fd65e32e16b3 8129547: Excess entries in BootstrapMethods with the same (bsm, bsmKind, bsmStaticArgs), but different dynamicArgs
mcimadamore
parents: 27224
diff changeset
   235
        static class BootstrapMethodsKey extends DynamicMethod {
fd65e32e16b3 8129547: Excess entries in BootstrapMethods with the same (bsm, bsmKind, bsmStaticArgs), but different dynamicArgs
mcimadamore
parents: 27224
diff changeset
   236
            BootstrapMethodsKey(DynamicMethodSymbol m, Types types) {
fd65e32e16b3 8129547: Excess entries in BootstrapMethods with the same (bsm, bsmKind, bsmStaticArgs), but different dynamicArgs
mcimadamore
parents: 27224
diff changeset
   237
                super(m, types);
fd65e32e16b3 8129547: Excess entries in BootstrapMethods with the same (bsm, bsmKind, bsmStaticArgs), but different dynamicArgs
mcimadamore
parents: 27224
diff changeset
   238
            }
fd65e32e16b3 8129547: Excess entries in BootstrapMethods with the same (bsm, bsmKind, bsmStaticArgs), but different dynamicArgs
mcimadamore
parents: 27224
diff changeset
   239
fd65e32e16b3 8129547: Excess entries in BootstrapMethods with the same (bsm, bsmKind, bsmStaticArgs), but different dynamicArgs
mcimadamore
parents: 27224
diff changeset
   240
            @Override @DefinedBy(Api.LANGUAGE_MODEL)
fd65e32e16b3 8129547: Excess entries in BootstrapMethods with the same (bsm, bsmKind, bsmStaticArgs), but different dynamicArgs
mcimadamore
parents: 27224
diff changeset
   241
            public boolean equals(Object any) {
fd65e32e16b3 8129547: Excess entries in BootstrapMethods with the same (bsm, bsmKind, bsmStaticArgs), but different dynamicArgs
mcimadamore
parents: 27224
diff changeset
   242
                return equalsImpl(any, false);
fd65e32e16b3 8129547: Excess entries in BootstrapMethods with the same (bsm, bsmKind, bsmStaticArgs), but different dynamicArgs
mcimadamore
parents: 27224
diff changeset
   243
            }
fd65e32e16b3 8129547: Excess entries in BootstrapMethods with the same (bsm, bsmKind, bsmStaticArgs), but different dynamicArgs
mcimadamore
parents: 27224
diff changeset
   244
fd65e32e16b3 8129547: Excess entries in BootstrapMethods with the same (bsm, bsmKind, bsmStaticArgs), but different dynamicArgs
mcimadamore
parents: 27224
diff changeset
   245
            @Override @DefinedBy(Api.LANGUAGE_MODEL)
fd65e32e16b3 8129547: Excess entries in BootstrapMethods with the same (bsm, bsmKind, bsmStaticArgs), but different dynamicArgs
mcimadamore
parents: 27224
diff changeset
   246
            public int hashCode() {
fd65e32e16b3 8129547: Excess entries in BootstrapMethods with the same (bsm, bsmKind, bsmStaticArgs), but different dynamicArgs
mcimadamore
parents: 27224
diff changeset
   247
                return hashCodeImpl(false);
fd65e32e16b3 8129547: Excess entries in BootstrapMethods with the same (bsm, bsmKind, bsmStaticArgs), but different dynamicArgs
mcimadamore
parents: 27224
diff changeset
   248
            }
fd65e32e16b3 8129547: Excess entries in BootstrapMethods with the same (bsm, bsmKind, bsmStaticArgs), but different dynamicArgs
mcimadamore
parents: 27224
diff changeset
   249
fd65e32e16b3 8129547: Excess entries in BootstrapMethods with the same (bsm, bsmKind, bsmStaticArgs), but different dynamicArgs
mcimadamore
parents: 27224
diff changeset
   250
            Object[] getUniqueArgs() {
fd65e32e16b3 8129547: Excess entries in BootstrapMethods with the same (bsm, bsmKind, bsmStaticArgs), but different dynamicArgs
mcimadamore
parents: 27224
diff changeset
   251
                return uniqueStaticArgs;
fd65e32e16b3 8129547: Excess entries in BootstrapMethods with the same (bsm, bsmKind, bsmStaticArgs), but different dynamicArgs
mcimadamore
parents: 27224
diff changeset
   252
            }
fd65e32e16b3 8129547: Excess entries in BootstrapMethods with the same (bsm, bsmKind, bsmStaticArgs), but different dynamicArgs
mcimadamore
parents: 27224
diff changeset
   253
        }
14547
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents: 14053
diff changeset
   254
    }
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents: 14053
diff changeset
   255
15564
6d8db91563a7 8005075: Pool.Method, and Pool.Variable redundant Symbol field should be removed
vromero
parents: 14949
diff changeset
   256
    static class Variable extends DelegatedSymbol<VarSymbol> {
14949
45f43822bbde 8000518: Javac generates duplicate name_and_type constant pool entry for class BinaryOpValueExp.java
vromero
parents: 14547
diff changeset
   257
        UniqueType uniqueType;
45f43822bbde 8000518: Javac generates duplicate name_and_type constant pool entry for class BinaryOpValueExp.java
vromero
parents: 14547
diff changeset
   258
        Variable(VarSymbol v, Types types) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   259
            super(v);
14949
45f43822bbde 8000518: Javac generates duplicate name_and_type constant pool entry for class BinaryOpValueExp.java
vromero
parents: 14547
diff changeset
   260
            this.uniqueType = new UniqueType(v.type, types);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   261
        }
26266
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents: 25874
diff changeset
   262
        @DefinedBy(Api.LANGUAGE_MODEL)
15564
6d8db91563a7 8005075: Pool.Method, and Pool.Variable redundant Symbol field should be removed
vromero
parents: 14949
diff changeset
   263
        public boolean equals(Object any) {
6d8db91563a7 8005075: Pool.Method, and Pool.Variable redundant Symbol field should be removed
vromero
parents: 14949
diff changeset
   264
            if (!(any instanceof Variable)) return false;
6d8db91563a7 8005075: Pool.Method, and Pool.Variable redundant Symbol field should be removed
vromero
parents: 14949
diff changeset
   265
            VarSymbol o = ((Variable)any).other;
6d8db91563a7 8005075: Pool.Method, and Pool.Variable redundant Symbol field should be removed
vromero
parents: 14949
diff changeset
   266
            VarSymbol v = other;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   267
            return
06bc494ca11e Initial load
duke
parents:
diff changeset
   268
                o.name == v.name &&
06bc494ca11e Initial load
duke
parents:
diff changeset
   269
                o.owner == v.owner &&
15564
6d8db91563a7 8005075: Pool.Method, and Pool.Variable redundant Symbol field should be removed
vromero
parents: 14949
diff changeset
   270
                ((Variable)any).uniqueType.equals(uniqueType);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   271
        }
26266
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents: 25874
diff changeset
   272
        @DefinedBy(Api.LANGUAGE_MODEL)
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   273
        public int hashCode() {
15564
6d8db91563a7 8005075: Pool.Method, and Pool.Variable redundant Symbol field should be removed
vromero
parents: 14949
diff changeset
   274
            VarSymbol v = other;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   275
            return
06bc494ca11e Initial load
duke
parents:
diff changeset
   276
                v.name.hashCode() * 33 +
06bc494ca11e Initial load
duke
parents:
diff changeset
   277
                v.owner.hashCode() * 9 +
14949
45f43822bbde 8000518: Javac generates duplicate name_and_type constant pool entry for class BinaryOpValueExp.java
vromero
parents: 14547
diff changeset
   278
                uniqueType.hashCode();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   279
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   280
    }
14046
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   281
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   282
    public static class MethodHandle {
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   283
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   284
        /** Reference kind - see ClassFile */
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   285
        int refKind;
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   286
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   287
        /** Reference symbol */
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   288
        Symbol refSym;
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   289
14949
45f43822bbde 8000518: Javac generates duplicate name_and_type constant pool entry for class BinaryOpValueExp.java
vromero
parents: 14547
diff changeset
   290
        UniqueType uniqueType;
45f43822bbde 8000518: Javac generates duplicate name_and_type constant pool entry for class BinaryOpValueExp.java
vromero
parents: 14547
diff changeset
   291
45f43822bbde 8000518: Javac generates duplicate name_and_type constant pool entry for class BinaryOpValueExp.java
vromero
parents: 14547
diff changeset
   292
        public MethodHandle(int refKind, Symbol refSym, Types types) {
14046
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   293
            this.refKind = refKind;
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   294
            this.refSym = refSym;
14949
45f43822bbde 8000518: Javac generates duplicate name_and_type constant pool entry for class BinaryOpValueExp.java
vromero
parents: 14547
diff changeset
   295
            this.uniqueType = new UniqueType(this.refSym.type, types);
14046
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   296
            checkConsistent();
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   297
        }
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   298
        public boolean equals(Object other) {
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   299
            if (!(other instanceof MethodHandle)) return false;
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   300
            MethodHandle mr = (MethodHandle) other;
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   301
            if (mr.refKind != refKind)  return false;
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   302
            Symbol o = mr.refSym;
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   303
            return
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   304
                o.name == refSym.name &&
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   305
                o.owner == refSym.owner &&
14949
45f43822bbde 8000518: Javac generates duplicate name_and_type constant pool entry for class BinaryOpValueExp.java
vromero
parents: 14547
diff changeset
   306
                ((MethodHandle)other).uniqueType.equals(uniqueType);
14046
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   307
        }
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   308
        public int hashCode() {
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   309
            return
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   310
                refKind * 65 +
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   311
                refSym.name.hashCode() * 33 +
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   312
                refSym.owner.hashCode() * 9 +
14949
45f43822bbde 8000518: Javac generates duplicate name_and_type constant pool entry for class BinaryOpValueExp.java
vromero
parents: 14547
diff changeset
   313
                uniqueType.hashCode();
14046
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   314
        }
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   315
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   316
        /**
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   317
         * Check consistency of reference kind and symbol (see JVMS 4.4.8)
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   318
         */
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   319
        @SuppressWarnings("fallthrough")
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   320
        private void checkConsistent() {
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   321
            boolean staticOk = false;
27224
228abfa87080 8054457: Refactor Symbol kinds from small ints to an enum
emc
parents: 26266
diff changeset
   322
            Kind expectedKind = null;
14046
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   323
            Filter<Name> nameFilter = nonInitFilter;
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   324
            boolean interfaceOwner = false;
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   325
            switch (refKind) {
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   326
                case ClassFile.REF_getStatic:
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   327
                case ClassFile.REF_putStatic:
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   328
                    staticOk = true;
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   329
                case ClassFile.REF_getField:
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   330
                case ClassFile.REF_putField:
27224
228abfa87080 8054457: Refactor Symbol kinds from small ints to an enum
emc
parents: 26266
diff changeset
   331
                    expectedKind = VAR;
14046
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   332
                    break;
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   333
                case ClassFile.REF_newInvokeSpecial:
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   334
                    nameFilter = initFilter;
27224
228abfa87080 8054457: Refactor Symbol kinds from small ints to an enum
emc
parents: 26266
diff changeset
   335
                    expectedKind = MTH;
14046
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   336
                    break;
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   337
                case ClassFile.REF_invokeInterface:
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   338
                    interfaceOwner = true;
27224
228abfa87080 8054457: Refactor Symbol kinds from small ints to an enum
emc
parents: 26266
diff changeset
   339
                    expectedKind = MTH;
14046
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   340
                    break;
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   341
                case ClassFile.REF_invokeStatic:
16330
66e277848a69 8009299: Javac crashes when compiling method reference to static interface method
mcimadamore
parents: 15564
diff changeset
   342
                    interfaceOwner = true;
14046
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   343
                    staticOk = true;
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   344
                case ClassFile.REF_invokeVirtual:
27224
228abfa87080 8054457: Refactor Symbol kinds from small ints to an enum
emc
parents: 26266
diff changeset
   345
                    expectedKind = MTH;
21014
57913337d634 8012557: Implement lambda methods on interfaces as private
rfield
parents: 16330
diff changeset
   346
                    break;
14046
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   347
                case ClassFile.REF_invokeSpecial:
21014
57913337d634 8012557: Implement lambda methods on interfaces as private
rfield
parents: 16330
diff changeset
   348
                    interfaceOwner = true;
27224
228abfa87080 8054457: Refactor Symbol kinds from small ints to an enum
emc
parents: 26266
diff changeset
   349
                    expectedKind = MTH;
14046
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   350
                    break;
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   351
            }
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   352
            Assert.check(!refSym.isStatic() || staticOk);
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   353
            Assert.check(refSym.kind == expectedKind);
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   354
            Assert.check(nameFilter.accepts(refSym.name));
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   355
            Assert.check(!refSym.owner.isInterface() || interfaceOwner);
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   356
        }
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   357
        //where
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   358
                Filter<Name> nonInitFilter = new Filter<Name>() {
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   359
                    public boolean accepts(Name n) {
14052
8b839ae9074b 8000233: Fix issues in recent push
mcimadamore
parents: 14049
diff changeset
   360
                        return n != n.table.names.init && n != n.table.names.clinit;
14046
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   361
                    }
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   362
                };
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   363
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   364
                Filter<Name> initFilter = new Filter<Name>() {
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   365
                    public boolean accepts(Name n) {
14052
8b839ae9074b 8000233: Fix issues in recent push
mcimadamore
parents: 14049
diff changeset
   366
                        return n == n.table.names.init;
14046
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   367
                    }
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   368
                };
8ef5d5b19998 7194586: Add back-end support for invokedynamic
mcimadamore
parents: 5847
diff changeset
   369
    }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   370
}