src/jdk.jdeps/share/classes/com/sun/tools/classfile/ReferenceFinder.java
author psandoz
Fri, 08 Sep 2017 10:46:46 -0700
changeset 48826 c4d9d1b08e2e
parent 47216 71c04702a3d5
permissions -rw-r--r--
8186209: Tool support for ConstantDynamic 8186046: Minimal ConstantDynamic support 8190972: Ensure that AOT/Graal filters out class files containing CONSTANT_Dynamic ahead of full AOT support Reviewed-by: acorn, coleenp, kvn Contributed-by: lois.foltan@oracle.com, john.r.rose@oracle.com, paul.sandoz@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
17284
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
     1
/*
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
     2
 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
     4
 *
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    10
 *
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    15
 * accompanied this code).
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    16
 *
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    20
 *
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    23
 * questions.
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    24
 */
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    25
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    26
package com.sun.tools.classfile;
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    27
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    28
import java.util.ArrayList;
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    29
import java.util.HashSet;
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    30
import java.util.List;
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    31
import java.util.Objects;
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    32
import java.util.Set;
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    33
import com.sun.tools.classfile.Instruction.TypeKind;
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    34
import static com.sun.tools.classfile.ConstantPool.*;
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    35
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    36
/**
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    37
 * A utility class to find where in a ClassFile references
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    38
 * a {@link CONSTANT_Methodref_info method},
31751
ec251536a004 8080880: some docs cleanup for langtools
avstepan
parents: 30846
diff changeset
    39
 * a {@link CONSTANT_InterfaceMethodref_info interface method},
17284
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    40
 * or a {@link CONSTANT_Fieldref_info field}.
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    41
 */
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    42
public final class ReferenceFinder {
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    43
    /**
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    44
     * Filter for ReferenceFinder of what constant pool entries for reference lookup.
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    45
     */
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    46
    public interface Filter {
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    47
        /**
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    48
         * Decides if the given CPRefInfo entry should be accepted or filtered.
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    49
         *
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    50
         * @param cpool  ConstantPool of the ClassFile being parsed
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    51
         * @param cpref  constant pool entry representing a reference to
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    52
         *               a fields method, and interface method.
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    53
         * @return {@code true} if accepted; otherwise {@code false}
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    54
         */
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    55
        boolean accept(ConstantPool cpool, CPRefInfo cpref);
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    56
    }
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    57
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    58
    /**
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    59
     * Visitor of individual method of a ClassFile that references the
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    60
     * accepted field, method, or interface method references.
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    61
     */
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    62
    public interface Visitor {
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    63
        /**
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    64
         * Invoked for a method containing one or more accepted CPRefInfo entries
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    65
         *
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    66
         * @param cf      ClassFile
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    67
         * @param method  Method that does the references the accepted references
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    68
         * @param refs    Accepted constant pool method/field reference
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    69
         */
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    70
        void visit(ClassFile cf, Method method, List<CPRefInfo> refConstantPool);
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    71
    }
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    72
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    73
    private final Filter filter;
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    74
    private final Visitor visitor;
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    75
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    76
    /**
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    77
     * Constructor.
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    78
     */
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    79
    public ReferenceFinder(Filter filter, Visitor visitor) {
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    80
        this.filter = Objects.requireNonNull(filter);
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    81
        this.visitor = Objects.requireNonNull(visitor);
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    82
    }
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    83
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    84
    /**
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    85
     * Parses a given ClassFile and invoke the visitor if there is any reference
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    86
     * to the constant pool entries referencing field, method, or
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    87
     * interface method that are accepted. This method will return
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    88
     * {@code true} if there is one or more accepted constant pool entries
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    89
     * to lookup; otherwise, it will return {@code false}.
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    90
     *
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    91
     * @param  cf  ClassFile
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    92
     * @return {@code true} if the given class file is processed to lookup
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    93
     *         references
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    94
     * @throws ConstantPoolException if an error of the constant pool
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    95
     */
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    96
    public boolean parse(ClassFile cf) throws ConstantPoolException {
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 17284
diff changeset
    97
        List<Integer> cprefs = new ArrayList<>();
17284
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    98
        int index = 1;
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
    99
        for (ConstantPool.CPInfo cpInfo : cf.constant_pool.entries()) {
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   100
            if (cpInfo.accept(cpVisitor, cf.constant_pool)) {
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   101
                cprefs.add(index);
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   102
            }
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   103
            index += cpInfo.size();
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   104
        }
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   105
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   106
        if (cprefs.isEmpty()) {
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   107
            return false;
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   108
        }
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   109
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   110
        for (Method m : cf.methods) {
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 17284
diff changeset
   111
            Set<Integer> ids = new HashSet<>();
17284
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   112
            Code_attribute c_attr = (Code_attribute) m.attributes.get(Attribute.Code);
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   113
            if (c_attr != null) {
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   114
                for (Instruction instr : c_attr.getInstructions()) {
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   115
                    int idx = instr.accept(codeVisitor, cprefs);
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   116
                    if (idx > 0) {
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   117
                        ids.add(idx);
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   118
                    }
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   119
                }
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   120
            }
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   121
            if (ids.size() > 0) {
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 17284
diff changeset
   122
                List<CPRefInfo> refInfos = new ArrayList<>(ids.size());
17284
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   123
                for (int id : ids) {
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   124
                    refInfos.add(CPRefInfo.class.cast(cf.constant_pool.get(id)));
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   125
                }
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   126
                visitor.visit(cf, m, refInfos);
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   127
            }
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   128
        }
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   129
        return true;
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   130
    }
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   131
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   132
    private ConstantPool.Visitor<Boolean,ConstantPool> cpVisitor =
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   133
            new ConstantPool.Visitor<Boolean,ConstantPool>()
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   134
    {
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   135
        public Boolean visitClass(CONSTANT_Class_info info, ConstantPool cpool) {
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   136
            return false;
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   137
        }
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   138
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   139
        public Boolean visitFieldref(CONSTANT_Fieldref_info info, ConstantPool cpool) {
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   140
            return filter.accept(cpool, info);
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   141
        }
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   142
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   143
        public Boolean visitDouble(CONSTANT_Double_info info, ConstantPool cpool) {
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   144
            return false;
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   145
        }
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   146
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   147
        public Boolean visitFloat(CONSTANT_Float_info info, ConstantPool cpool) {
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   148
            return false;
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   149
        }
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   150
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   151
        public Boolean visitInteger(CONSTANT_Integer_info info, ConstantPool cpool) {
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   152
            return false;
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   153
        }
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   154
42822
a84956e7ee4d 8170987: Module system implementation refresh (12/2016)
alanb
parents: 31751
diff changeset
   155
        public Boolean visitInterfaceMethodref(CONSTANT_InterfaceMethodref_info info, ConstantPool cpool) {
a84956e7ee4d 8170987: Module system implementation refresh (12/2016)
alanb
parents: 31751
diff changeset
   156
            return filter.accept(cpool, info);
a84956e7ee4d 8170987: Module system implementation refresh (12/2016)
alanb
parents: 31751
diff changeset
   157
        }
a84956e7ee4d 8170987: Module system implementation refresh (12/2016)
alanb
parents: 31751
diff changeset
   158
17284
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   159
        public Boolean visitInvokeDynamic(CONSTANT_InvokeDynamic_info info, ConstantPool cpool) {
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   160
            return false;
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   161
        }
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   162
48826
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47216
diff changeset
   163
        @Override
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47216
diff changeset
   164
        public Boolean visitDynamicConstant(CONSTANT_Dynamic_info info, ConstantPool constantPool) {
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47216
diff changeset
   165
            return false;
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47216
diff changeset
   166
        }
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47216
diff changeset
   167
17284
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   168
        public Boolean visitLong(CONSTANT_Long_info info, ConstantPool cpool) {
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   169
            return false;
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   170
        }
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   171
42822
a84956e7ee4d 8170987: Module system implementation refresh (12/2016)
alanb
parents: 31751
diff changeset
   172
        public Boolean visitMethodHandle(CONSTANT_MethodHandle_info info, ConstantPool cpool) {
a84956e7ee4d 8170987: Module system implementation refresh (12/2016)
alanb
parents: 31751
diff changeset
   173
            return false;
a84956e7ee4d 8170987: Module system implementation refresh (12/2016)
alanb
parents: 31751
diff changeset
   174
        }
a84956e7ee4d 8170987: Module system implementation refresh (12/2016)
alanb
parents: 31751
diff changeset
   175
a84956e7ee4d 8170987: Module system implementation refresh (12/2016)
alanb
parents: 31751
diff changeset
   176
        public Boolean visitMethodref(CONSTANT_Methodref_info info, ConstantPool cpool) {
a84956e7ee4d 8170987: Module system implementation refresh (12/2016)
alanb
parents: 31751
diff changeset
   177
            return filter.accept(cpool, info);
a84956e7ee4d 8170987: Module system implementation refresh (12/2016)
alanb
parents: 31751
diff changeset
   178
        }
a84956e7ee4d 8170987: Module system implementation refresh (12/2016)
alanb
parents: 31751
diff changeset
   179
a84956e7ee4d 8170987: Module system implementation refresh (12/2016)
alanb
parents: 31751
diff changeset
   180
        public Boolean visitMethodType(CONSTANT_MethodType_info info, ConstantPool cpool) {
a84956e7ee4d 8170987: Module system implementation refresh (12/2016)
alanb
parents: 31751
diff changeset
   181
            return false;
a84956e7ee4d 8170987: Module system implementation refresh (12/2016)
alanb
parents: 31751
diff changeset
   182
        }
a84956e7ee4d 8170987: Module system implementation refresh (12/2016)
alanb
parents: 31751
diff changeset
   183
a84956e7ee4d 8170987: Module system implementation refresh (12/2016)
alanb
parents: 31751
diff changeset
   184
        public Boolean visitModule(CONSTANT_Module_info info, ConstantPool cpool) {
a84956e7ee4d 8170987: Module system implementation refresh (12/2016)
alanb
parents: 31751
diff changeset
   185
            return false;
a84956e7ee4d 8170987: Module system implementation refresh (12/2016)
alanb
parents: 31751
diff changeset
   186
        }
a84956e7ee4d 8170987: Module system implementation refresh (12/2016)
alanb
parents: 31751
diff changeset
   187
17284
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   188
        public Boolean visitNameAndType(CONSTANT_NameAndType_info info, ConstantPool cpool) {
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   189
            return false;
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   190
        }
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   191
42822
a84956e7ee4d 8170987: Module system implementation refresh (12/2016)
alanb
parents: 31751
diff changeset
   192
        public Boolean visitPackage(CONSTANT_Package_info info, ConstantPool cpool) {
17284
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   193
            return false;
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   194
        }
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   195
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   196
        public Boolean visitString(CONSTANT_String_info info, ConstantPool cpool) {
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   197
            return false;
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   198
        }
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   199
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   200
        public Boolean visitUtf8(CONSTANT_Utf8_info info, ConstantPool cpool) {
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   201
            return false;
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   202
        }
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   203
    };
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   204
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   205
    private Instruction.KindVisitor<Integer, List<Integer>> codeVisitor =
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   206
            new Instruction.KindVisitor<Integer, List<Integer>>()
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   207
    {
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   208
        public Integer visitNoOperands(Instruction instr, List<Integer> p) {
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   209
            return 0;
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   210
        }
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   211
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   212
        public Integer visitArrayType(Instruction instr, TypeKind kind, List<Integer> p) {
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   213
            return 0;
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   214
        }
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   215
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   216
        public Integer visitBranch(Instruction instr, int offset, List<Integer> p) {
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   217
            return 0;
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   218
        }
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   219
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   220
        public Integer visitConstantPoolRef(Instruction instr, int index, List<Integer> p) {
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   221
            return p.contains(index) ? index : 0;
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   222
        }
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   223
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   224
        public Integer visitConstantPoolRefAndValue(Instruction instr, int index, int value, List<Integer> p) {
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   225
            return p.contains(index) ? index : 0;
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   226
        }
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   227
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   228
        public Integer visitLocal(Instruction instr, int index, List<Integer> p) {
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   229
            return 0;
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   230
        }
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   231
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   232
        public Integer visitLocalAndValue(Instruction instr, int index, int value, List<Integer> p) {
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   233
            return 0;
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   234
        }
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   235
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   236
        public Integer visitLookupSwitch(Instruction instr, int default_, int npairs, int[] matches, int[] offsets, List<Integer> p) {
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   237
            return 0;
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   238
        }
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   239
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   240
        public Integer visitTableSwitch(Instruction instr, int default_, int low, int high, int[] offsets, List<Integer> p) {
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   241
            return 0;
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   242
        }
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   243
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   244
        public Integer visitValue(Instruction instr, int value, List<Integer> p) {
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   245
            return 0;
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   246
        }
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   247
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   248
        public Integer visitUnknown(Instruction instr, List<Integer> p) {
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   249
            return 0;
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   250
        }
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   251
    };
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   252
}
7cae365bf8d5 8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff changeset
   253