langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/ConstantPool.java
author mikael
Tue, 22 Dec 2015 20:47:40 -0800
changeset 35023 ee10ca0129b2
parent 30846 2b3f379840f0
child 39104 61c5b5f8fd8c
permissions -rw-r--r--
8145828: JPRT hotspot push jobs should allow merge on push Reviewed-by: dholmes, iklam
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
727
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
     1
/*
8042
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
     2
 * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
727
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
     4
 *
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
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: 5010
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
727
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 5010
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
727
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    10
 *
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    15
 * accompanied this code).
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    16
 *
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    20
 *
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 5010
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 5010
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 5010
diff changeset
    23
 * questions.
727
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    24
 */
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    25
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    26
package com.sun.tools.classfile;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    27
3543
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
    28
import java.io.DataOutputStream;
727
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    29
import java.io.IOException;
3543
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
    30
import java.io.OutputStream;
2978
a72220103e31 6841419: classfile: add constant pool iterator
jjg
parents: 2977
diff changeset
    31
import java.util.Iterator;
727
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    32
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    33
/**
9303
eae35c201e19 7032975: API files in javax.annotation.processing need to be updated for references to JLS
jjh
parents: 8042
diff changeset
    34
 * See JVMS, section 4.5.
727
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    35
 *
5847
1908176fd6e3 6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents: 5520
diff changeset
    36
 *  <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
    37
 *  If you write code that depends on this, you do so at your own risk.
727
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    38
 *  This code and its internal interfaces are subject to change or
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    39
 *  deletion without notice.</b>
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    40
 */
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    41
public class ConstantPool {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    42
5010
c9fd6294653a 6931482: minor findbugs fixes
jjg
parents: 4071
diff changeset
    43
    public static class InvalidIndex extends ConstantPoolException {
1870
57a1138dffc8 6795903: fix latent build warnings in langtools repository
jjg
parents: 735
diff changeset
    44
        private static final long serialVersionUID = -4350294289300939730L;
727
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    45
        InvalidIndex(int index) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    46
            super(index);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    47
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    48
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    49
        @Override
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    50
        public String getMessage() {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    51
            // i18n
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    52
            return "invalid index #" + index;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    53
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    54
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    55
5010
c9fd6294653a 6931482: minor findbugs fixes
jjg
parents: 4071
diff changeset
    56
    public static class UnexpectedEntry extends ConstantPoolException {
1870
57a1138dffc8 6795903: fix latent build warnings in langtools repository
jjg
parents: 735
diff changeset
    57
        private static final long serialVersionUID = 6986335935377933211L;
727
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    58
        UnexpectedEntry(int index, int expected_tag, int found_tag) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    59
            super(index);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    60
            this.expected_tag = expected_tag;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    61
            this.found_tag = found_tag;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    62
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    63
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    64
        @Override
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    65
        public String getMessage() {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    66
            // i18n?
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    67
            return "unexpected entry at #" + index + " -- expected tag " + expected_tag + ", found " + found_tag;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    68
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    69
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    70
        public final int expected_tag;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    71
        public final int found_tag;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    72
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    73
5010
c9fd6294653a 6931482: minor findbugs fixes
jjg
parents: 4071
diff changeset
    74
    public static class InvalidEntry extends ConstantPoolException {
1870
57a1138dffc8 6795903: fix latent build warnings in langtools repository
jjg
parents: 735
diff changeset
    75
        private static final long serialVersionUID = 1000087545585204447L;
727
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    76
        InvalidEntry(int index, int tag) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    77
            super(index);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    78
            this.tag = tag;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    79
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    80
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    81
        @Override
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    82
        public String getMessage() {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    83
            // i18n?
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    84
            return "unexpected tag at #" + index + ": " + tag;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    85
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    86
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    87
        public final int tag;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    88
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    89
5010
c9fd6294653a 6931482: minor findbugs fixes
jjg
parents: 4071
diff changeset
    90
    public static class EntryNotFound extends ConstantPoolException {
1870
57a1138dffc8 6795903: fix latent build warnings in langtools repository
jjg
parents: 735
diff changeset
    91
        private static final long serialVersionUID = 2885537606468581850L;
727
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    92
        EntryNotFound(Object value) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    93
            super(-1);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    94
            this.value = value;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    95
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    96
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    97
        @Override
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    98
        public String getMessage() {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    99
            // i18n?
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   100
            return "value not found: " + value;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   101
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   102
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   103
        public final Object value;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   104
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   105
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   106
    public static final int CONSTANT_Utf8 = 1;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   107
    public static final int CONSTANT_Integer = 3;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   108
    public static final int CONSTANT_Float = 4;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   109
    public static final int CONSTANT_Long = 5;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   110
    public static final int CONSTANT_Double = 6;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   111
    public static final int CONSTANT_Class = 7;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   112
    public static final int CONSTANT_String = 8;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   113
    public static final int CONSTANT_Fieldref = 9;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   114
    public static final int CONSTANT_Methodref = 10;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   115
    public static final int CONSTANT_InterfaceMethodref = 11;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   116
    public static final int CONSTANT_NameAndType = 12;
8042
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   117
    public static final int CONSTANT_MethodHandle = 15;
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   118
    public static final int CONSTANT_MethodType = 16;
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   119
    public static final int CONSTANT_InvokeDynamic = 18;
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   120
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   121
    public static enum RefKind {
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   122
        REF_getField(1, "getfield"),
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   123
        REF_getStatic(2, "getstatic"),
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   124
        REF_putField(3, "putfield"),
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   125
        REF_putStatic(4, "putstatic"),
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   126
        REF_invokeVirtual(5, "invokevirtual"),
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   127
        REF_invokeStatic(6, "invokestatic"),
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   128
        REF_invokeSpecial(7, "invokespecial"),
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   129
        REF_newInvokeSpecial(8, "newinvokespecial"),
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   130
        REF_invokeInterface(9, "invokeinterface");
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   131
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   132
        public final int tag;
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   133
        public final String name;
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   134
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   135
        RefKind(int tag, String name) {
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   136
            this.tag = tag;
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   137
            this.name = name;
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   138
        }
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   139
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   140
        static RefKind getRefkind(int tag) {
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   141
            switch(tag) {
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   142
                case 1:
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   143
                    return REF_getField;
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   144
                case 2:
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   145
                    return REF_getStatic;
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   146
                case 3:
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   147
                    return REF_putField;
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   148
                case 4:
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   149
                    return REF_putStatic;
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   150
                case 5:
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   151
                    return REF_invokeVirtual;
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   152
                case 6:
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   153
                    return REF_invokeStatic;
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   154
                case 7:
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   155
                    return REF_invokeSpecial;
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   156
                case 8:
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   157
                    return REF_newInvokeSpecial;
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   158
                case 9:
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   159
                    return REF_invokeInterface;
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   160
                default:
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   161
                    return null;
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   162
            }
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   163
        }
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   164
    }
727
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   165
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   166
    ConstantPool(ClassReader cr) throws IOException, InvalidEntry {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   167
        int count = cr.readUnsignedShort();
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   168
        pool = new CPInfo[count];
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   169
        for (int i = 1; i < count; i++) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   170
            int tag = cr.readUnsignedByte();
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   171
            switch (tag) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   172
            case CONSTANT_Class:
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   173
                pool[i] = new CONSTANT_Class_info(this, cr);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   174
                break;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   175
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   176
            case CONSTANT_Double:
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   177
                pool[i] = new CONSTANT_Double_info(cr);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   178
                i++;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   179
                break;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   180
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   181
            case CONSTANT_Fieldref:
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   182
                pool[i] = new CONSTANT_Fieldref_info(this, cr);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   183
                break;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   184
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   185
            case CONSTANT_Float:
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   186
                pool[i] = new CONSTANT_Float_info(cr);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   187
                break;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   188
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   189
            case CONSTANT_Integer:
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   190
                pool[i] = new CONSTANT_Integer_info(cr);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   191
                break;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   192
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   193
            case CONSTANT_InterfaceMethodref:
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   194
                pool[i] = new CONSTANT_InterfaceMethodref_info(this, cr);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   195
                break;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   196
8042
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   197
            case CONSTANT_InvokeDynamic:
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   198
                pool[i] = new CONSTANT_InvokeDynamic_info(this, cr);
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   199
                break;
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   200
727
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   201
            case CONSTANT_Long:
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   202
                pool[i] = new CONSTANT_Long_info(cr);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   203
                i++;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   204
                break;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   205
8042
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   206
            case CONSTANT_MethodHandle:
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   207
                pool[i] = new CONSTANT_MethodHandle_info(this, cr);
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   208
                break;
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   209
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   210
            case CONSTANT_MethodType:
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   211
                pool[i] = new CONSTANT_MethodType_info(this, cr);
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   212
                break;
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   213
727
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   214
            case CONSTANT_Methodref:
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   215
                pool[i] = new CONSTANT_Methodref_info(this, cr);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   216
                break;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   217
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   218
            case CONSTANT_NameAndType:
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   219
                pool[i] = new CONSTANT_NameAndType_info(this, cr);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   220
                break;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   221
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   222
            case CONSTANT_String:
733
b76c4357c649 6715767: javap on java.lang.ClassLoader crashes
jjg
parents: 727
diff changeset
   223
                pool[i] = new CONSTANT_String_info(this, cr);
727
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   224
                break;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   225
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   226
            case CONSTANT_Utf8:
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   227
                pool[i] = new CONSTANT_Utf8_info(cr);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   228
                break;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   229
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   230
            default:
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   231
                throw new InvalidEntry(i, tag);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   232
            }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   233
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   234
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   235
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   236
    public ConstantPool(CPInfo[] pool) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   237
        this.pool = pool;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   238
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   239
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   240
    public int size() {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   241
        return pool.length;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   242
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   243
3543
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
   244
    public int byteLength() {
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
   245
        int length = 2;
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
   246
        for (int i = 1; i < size(); ) {
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
   247
            CPInfo cpInfo = pool[i];
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
   248
            length += cpInfo.byteLength();
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
   249
            i += cpInfo.size();
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
   250
        }
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
   251
        return length;
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
   252
    }
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
   253
727
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   254
    public CPInfo get(int index) throws InvalidIndex {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   255
        if (index <= 0 || index >= pool.length)
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   256
            throw new InvalidIndex(index);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   257
        CPInfo info = pool[index];
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   258
        if (info == null) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   259
            // this occurs for indices referencing the "second half" of an
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   260
            // 8 byte constant, such as CONSTANT_Double or CONSTANT_Long
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   261
            throw new InvalidIndex(index);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   262
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   263
        return pool[index];
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   264
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   265
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   266
    private CPInfo get(int index, int expected_type) throws InvalidIndex, UnexpectedEntry {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   267
        CPInfo info = get(index);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   268
        if (info.getTag() != expected_type)
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   269
            throw new UnexpectedEntry(index, expected_type, info.getTag());
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   270
        return info;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   271
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   272
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   273
    public CONSTANT_Utf8_info getUTF8Info(int index) throws InvalidIndex, UnexpectedEntry {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   274
        return ((CONSTANT_Utf8_info) get(index, CONSTANT_Utf8));
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   275
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   276
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   277
    public CONSTANT_Class_info getClassInfo(int index) throws InvalidIndex, UnexpectedEntry {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   278
        return ((CONSTANT_Class_info) get(index, CONSTANT_Class));
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   279
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   280
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   281
    public CONSTANT_NameAndType_info getNameAndTypeInfo(int index) throws InvalidIndex, UnexpectedEntry {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   282
        return ((CONSTANT_NameAndType_info) get(index, CONSTANT_NameAndType));
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   283
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   284
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   285
    public String getUTF8Value(int index) throws InvalidIndex, UnexpectedEntry {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   286
        return getUTF8Info(index).value;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   287
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   288
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   289
    public int getUTF8Index(String value) throws EntryNotFound {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   290
        for (int i = 1; i < pool.length; i++) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   291
            CPInfo info = pool[i];
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   292
            if (info instanceof CONSTANT_Utf8_info &&
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   293
                    ((CONSTANT_Utf8_info) info).value.equals(value))
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   294
                return i;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   295
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   296
        throw new EntryNotFound(value);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   297
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   298
2978
a72220103e31 6841419: classfile: add constant pool iterator
jjg
parents: 2977
diff changeset
   299
    public Iterable<CPInfo> entries() {
a72220103e31 6841419: classfile: add constant pool iterator
jjg
parents: 2977
diff changeset
   300
        return new Iterable<CPInfo>() {
a72220103e31 6841419: classfile: add constant pool iterator
jjg
parents: 2977
diff changeset
   301
            public Iterator<CPInfo> iterator() {
a72220103e31 6841419: classfile: add constant pool iterator
jjg
parents: 2977
diff changeset
   302
                return new Iterator<CPInfo>() {
a72220103e31 6841419: classfile: add constant pool iterator
jjg
parents: 2977
diff changeset
   303
a72220103e31 6841419: classfile: add constant pool iterator
jjg
parents: 2977
diff changeset
   304
                    public boolean hasNext() {
a72220103e31 6841419: classfile: add constant pool iterator
jjg
parents: 2977
diff changeset
   305
                        return next < pool.length;
a72220103e31 6841419: classfile: add constant pool iterator
jjg
parents: 2977
diff changeset
   306
                    }
a72220103e31 6841419: classfile: add constant pool iterator
jjg
parents: 2977
diff changeset
   307
a72220103e31 6841419: classfile: add constant pool iterator
jjg
parents: 2977
diff changeset
   308
                    public CPInfo next() {
a72220103e31 6841419: classfile: add constant pool iterator
jjg
parents: 2977
diff changeset
   309
                        current = pool[next];
a72220103e31 6841419: classfile: add constant pool iterator
jjg
parents: 2977
diff changeset
   310
                        switch (current.getTag()) {
a72220103e31 6841419: classfile: add constant pool iterator
jjg
parents: 2977
diff changeset
   311
                            case CONSTANT_Double:
a72220103e31 6841419: classfile: add constant pool iterator
jjg
parents: 2977
diff changeset
   312
                            case CONSTANT_Long:
a72220103e31 6841419: classfile: add constant pool iterator
jjg
parents: 2977
diff changeset
   313
                                next += 2;
a72220103e31 6841419: classfile: add constant pool iterator
jjg
parents: 2977
diff changeset
   314
                                break;
a72220103e31 6841419: classfile: add constant pool iterator
jjg
parents: 2977
diff changeset
   315
                            default:
a72220103e31 6841419: classfile: add constant pool iterator
jjg
parents: 2977
diff changeset
   316
                                next += 1;
a72220103e31 6841419: classfile: add constant pool iterator
jjg
parents: 2977
diff changeset
   317
                        }
a72220103e31 6841419: classfile: add constant pool iterator
jjg
parents: 2977
diff changeset
   318
                        return current;
a72220103e31 6841419: classfile: add constant pool iterator
jjg
parents: 2977
diff changeset
   319
                    }
a72220103e31 6841419: classfile: add constant pool iterator
jjg
parents: 2977
diff changeset
   320
a72220103e31 6841419: classfile: add constant pool iterator
jjg
parents: 2977
diff changeset
   321
                    public void remove() {
a72220103e31 6841419: classfile: add constant pool iterator
jjg
parents: 2977
diff changeset
   322
                        throw new UnsupportedOperationException();
a72220103e31 6841419: classfile: add constant pool iterator
jjg
parents: 2977
diff changeset
   323
                    }
a72220103e31 6841419: classfile: add constant pool iterator
jjg
parents: 2977
diff changeset
   324
a72220103e31 6841419: classfile: add constant pool iterator
jjg
parents: 2977
diff changeset
   325
                    private CPInfo current;
a72220103e31 6841419: classfile: add constant pool iterator
jjg
parents: 2977
diff changeset
   326
                    private int next = 1;
a72220103e31 6841419: classfile: add constant pool iterator
jjg
parents: 2977
diff changeset
   327
a72220103e31 6841419: classfile: add constant pool iterator
jjg
parents: 2977
diff changeset
   328
                };
a72220103e31 6841419: classfile: add constant pool iterator
jjg
parents: 2977
diff changeset
   329
            }
a72220103e31 6841419: classfile: add constant pool iterator
jjg
parents: 2977
diff changeset
   330
        };
a72220103e31 6841419: classfile: add constant pool iterator
jjg
parents: 2977
diff changeset
   331
    }
a72220103e31 6841419: classfile: add constant pool iterator
jjg
parents: 2977
diff changeset
   332
727
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   333
    private CPInfo[] pool;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   334
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   335
    public interface Visitor<R,P> {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   336
        R visitClass(CONSTANT_Class_info info, P p);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   337
        R visitDouble(CONSTANT_Double_info info, P p);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   338
        R visitFieldref(CONSTANT_Fieldref_info info, P p);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   339
        R visitFloat(CONSTANT_Float_info info, P p);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   340
        R visitInteger(CONSTANT_Integer_info info, P p);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   341
        R visitInterfaceMethodref(CONSTANT_InterfaceMethodref_info info, P p);
8042
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   342
        R visitInvokeDynamic(CONSTANT_InvokeDynamic_info info, P p);
727
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   343
        R visitLong(CONSTANT_Long_info info, P p);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   344
        R visitNameAndType(CONSTANT_NameAndType_info info, P p);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   345
        R visitMethodref(CONSTANT_Methodref_info info, P p);
8042
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   346
        R visitMethodHandle(CONSTANT_MethodHandle_info info, P p);
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   347
        R visitMethodType(CONSTANT_MethodType_info info, P p);
727
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   348
        R visitString(CONSTANT_String_info info, P p);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   349
        R visitUtf8(CONSTANT_Utf8_info info, P p);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   350
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   351
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   352
    public static abstract class CPInfo {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   353
        CPInfo() {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   354
            this.cp = null;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   355
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   356
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   357
        CPInfo(ConstantPool cp) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   358
            this.cp = cp;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   359
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   360
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   361
        public abstract int getTag();
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   362
2978
a72220103e31 6841419: classfile: add constant pool iterator
jjg
parents: 2977
diff changeset
   363
        /** The number of slots in the constant pool used by this entry.
a72220103e31 6841419: classfile: add constant pool iterator
jjg
parents: 2977
diff changeset
   364
         * 2 for CONSTANT_Double and CONSTANT_Long; 1 for everything else. */
a72220103e31 6841419: classfile: add constant pool iterator
jjg
parents: 2977
diff changeset
   365
        public int size() {
a72220103e31 6841419: classfile: add constant pool iterator
jjg
parents: 2977
diff changeset
   366
            return 1;
a72220103e31 6841419: classfile: add constant pool iterator
jjg
parents: 2977
diff changeset
   367
        }
a72220103e31 6841419: classfile: add constant pool iterator
jjg
parents: 2977
diff changeset
   368
3543
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
   369
        public abstract int byteLength();
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
   370
727
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   371
        public abstract <R,D> R accept(Visitor<R,D> visitor, D data);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   372
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   373
        protected final ConstantPool cp;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   374
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   375
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   376
    public static abstract class CPRefInfo extends CPInfo {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   377
        protected CPRefInfo(ConstantPool cp, ClassReader cr, int tag) throws IOException {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   378
            super(cp);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   379
            this.tag = tag;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   380
            class_index = cr.readUnsignedShort();
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   381
            name_and_type_index = cr.readUnsignedShort();
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   382
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   383
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   384
        protected CPRefInfo(ConstantPool cp, int tag, int class_index, int name_and_type_index) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   385
            super(cp);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   386
            this.tag = tag;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   387
            this.class_index = class_index;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   388
            this.name_and_type_index = name_and_type_index;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   389
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   390
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   391
        public int getTag() {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   392
            return tag;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   393
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   394
3543
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
   395
        public int byteLength() {
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
   396
            return 5;
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
   397
        }
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
   398
727
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   399
        public CONSTANT_Class_info getClassInfo() throws ConstantPoolException {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   400
            return cp.getClassInfo(class_index);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   401
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   402
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   403
        public String getClassName() throws ConstantPoolException {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   404
            return cp.getClassInfo(class_index).getName();
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   405
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   406
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   407
        public CONSTANT_NameAndType_info getNameAndTypeInfo() throws ConstantPoolException {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   408
            return cp.getNameAndTypeInfo(name_and_type_index);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   409
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   410
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   411
        public final int tag;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   412
        public final int class_index;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   413
        public final int name_and_type_index;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   414
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   415
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   416
    public static class CONSTANT_Class_info extends CPInfo {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   417
        CONSTANT_Class_info(ConstantPool cp, ClassReader cr) throws IOException {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   418
            super(cp);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   419
            name_index = cr.readUnsignedShort();
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   420
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   421
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   422
        public CONSTANT_Class_info(ConstantPool cp, int name_index) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   423
            super(cp);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   424
            this.name_index = name_index;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   425
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   426
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   427
        public int getTag() {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   428
            return CONSTANT_Class;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   429
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   430
3543
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
   431
        public int  byteLength() {
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
   432
            return 3;
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
   433
        }
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
   434
4071
10c876d2de66 6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents: 3543
diff changeset
   435
        /**
10c876d2de66 6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents: 3543
diff changeset
   436
         * Get the raw value of the class referenced by this constant pool entry.
10c876d2de66 6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents: 3543
diff changeset
   437
         * This will either be the name of the class, in internal form, or a
10c876d2de66 6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents: 3543
diff changeset
   438
         * descriptor for an array class.
10c876d2de66 6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents: 3543
diff changeset
   439
         * @return the raw value of the class
10c876d2de66 6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents: 3543
diff changeset
   440
         */
727
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   441
        public String getName() throws ConstantPoolException {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   442
            return cp.getUTF8Value(name_index);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   443
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   444
4071
10c876d2de66 6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents: 3543
diff changeset
   445
        /**
10c876d2de66 6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents: 3543
diff changeset
   446
         * If this constant pool entry identifies either a class or interface type,
10c876d2de66 6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents: 3543
diff changeset
   447
         * or a possibly multi-dimensional array of a class of interface type,
10c876d2de66 6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents: 3543
diff changeset
   448
         * return the name of the class or interface in internal form. Otherwise,
10c876d2de66 6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents: 3543
diff changeset
   449
         * (i.e. if this is a possibly multi-dimensional array of a primitive type),
10c876d2de66 6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents: 3543
diff changeset
   450
         * return null.
10c876d2de66 6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents: 3543
diff changeset
   451
         * @return the base class or interface name
10c876d2de66 6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents: 3543
diff changeset
   452
         */
2977
fdbc11409428 6841420: classfile: add new methods to ConstantClassInfo
jjg
parents: 2212
diff changeset
   453
        public String getBaseName() throws ConstantPoolException {
fdbc11409428 6841420: classfile: add new methods to ConstantClassInfo
jjg
parents: 2212
diff changeset
   454
            String name = getName();
4071
10c876d2de66 6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents: 3543
diff changeset
   455
            if (name.startsWith("[")) {
10c876d2de66 6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents: 3543
diff changeset
   456
                int index = name.indexOf("[L");
10c876d2de66 6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents: 3543
diff changeset
   457
                if (index == -1)
10c876d2de66 6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents: 3543
diff changeset
   458
                    return null;
10c876d2de66 6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents: 3543
diff changeset
   459
                return name.substring(index + 2, name.length() - 1);
10c876d2de66 6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents: 3543
diff changeset
   460
            } else
10c876d2de66 6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents: 3543
diff changeset
   461
                return name;
2977
fdbc11409428 6841420: classfile: add new methods to ConstantClassInfo
jjg
parents: 2212
diff changeset
   462
        }
fdbc11409428 6841420: classfile: add new methods to ConstantClassInfo
jjg
parents: 2212
diff changeset
   463
fdbc11409428 6841420: classfile: add new methods to ConstantClassInfo
jjg
parents: 2212
diff changeset
   464
        public int getDimensionCount() throws ConstantPoolException {
fdbc11409428 6841420: classfile: add new methods to ConstantClassInfo
jjg
parents: 2212
diff changeset
   465
            String name = getName();
fdbc11409428 6841420: classfile: add new methods to ConstantClassInfo
jjg
parents: 2212
diff changeset
   466
            int count = 0;
fdbc11409428 6841420: classfile: add new methods to ConstantClassInfo
jjg
parents: 2212
diff changeset
   467
            while (name.charAt(count) == '[')
fdbc11409428 6841420: classfile: add new methods to ConstantClassInfo
jjg
parents: 2212
diff changeset
   468
                count++;
fdbc11409428 6841420: classfile: add new methods to ConstantClassInfo
jjg
parents: 2212
diff changeset
   469
            return count;
fdbc11409428 6841420: classfile: add new methods to ConstantClassInfo
jjg
parents: 2212
diff changeset
   470
        }
fdbc11409428 6841420: classfile: add new methods to ConstantClassInfo
jjg
parents: 2212
diff changeset
   471
727
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   472
        @Override
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   473
        public String toString() {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   474
            return "CONSTANT_Class_info[name_index: " + name_index + "]";
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   475
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   476
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   477
        public <R, D> R accept(Visitor<R, D> visitor, D data) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   478
            return visitor.visitClass(this, data);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   479
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   480
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   481
        public final int name_index;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   482
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   483
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   484
    public static class CONSTANT_Double_info extends CPInfo {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   485
        CONSTANT_Double_info(ClassReader cr) throws IOException {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   486
            value = cr.readDouble();
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   487
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   488
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   489
        public CONSTANT_Double_info(double value) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   490
            this.value = value;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   491
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   492
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   493
        public int getTag() {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   494
            return CONSTANT_Double;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   495
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   496
3543
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
   497
        public int  byteLength() {
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
   498
            return 9;
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
   499
        }
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
   500
727
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   501
        @Override
2978
a72220103e31 6841419: classfile: add constant pool iterator
jjg
parents: 2977
diff changeset
   502
        public int size() {
a72220103e31 6841419: classfile: add constant pool iterator
jjg
parents: 2977
diff changeset
   503
            return 2;
a72220103e31 6841419: classfile: add constant pool iterator
jjg
parents: 2977
diff changeset
   504
        }
a72220103e31 6841419: classfile: add constant pool iterator
jjg
parents: 2977
diff changeset
   505
a72220103e31 6841419: classfile: add constant pool iterator
jjg
parents: 2977
diff changeset
   506
        @Override
727
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   507
        public String toString() {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   508
            return "CONSTANT_Double_info[value: " + value + "]";
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   509
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   510
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   511
        public <R, D> R accept(Visitor<R, D> visitor, D data) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   512
            return visitor.visitDouble(this, data);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   513
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   514
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   515
        public final double value;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   516
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   517
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   518
    public static class CONSTANT_Fieldref_info extends CPRefInfo {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   519
        CONSTANT_Fieldref_info(ConstantPool cp, ClassReader cr) throws IOException {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   520
            super(cp, cr, CONSTANT_Fieldref);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   521
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   522
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   523
        public CONSTANT_Fieldref_info(ConstantPool cp, int class_index, int name_and_type_index) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   524
            super(cp, CONSTANT_Fieldref, class_index, name_and_type_index);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   525
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   526
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   527
        @Override
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   528
        public String toString() {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   529
            return "CONSTANT_Fieldref_info[class_index: " + class_index + ", name_and_type_index: " + name_and_type_index + "]";
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   530
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   531
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   532
        public <R, D> R accept(Visitor<R, D> visitor, D data) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   533
            return visitor.visitFieldref(this, data);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   534
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   535
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   536
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   537
    public static class CONSTANT_Float_info extends CPInfo {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   538
        CONSTANT_Float_info(ClassReader cr) throws IOException {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   539
            value = cr.readFloat();
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   540
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   541
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   542
        public CONSTANT_Float_info(float value) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   543
            this.value = value;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   544
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   545
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   546
        public int getTag() {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   547
            return CONSTANT_Float;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   548
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   549
3543
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
   550
        public int byteLength() {
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
   551
            return 5;
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
   552
        }
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
   553
727
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   554
        @Override
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   555
        public String toString() {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   556
            return "CONSTANT_Float_info[value: " + value + "]";
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   557
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   558
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   559
        public <R, D> R accept(Visitor<R, D> visitor, D data) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   560
            return visitor.visitFloat(this, data);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   561
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   562
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   563
        public final float value;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   564
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   565
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   566
    public static class CONSTANT_Integer_info extends CPInfo {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   567
        CONSTANT_Integer_info(ClassReader cr) throws IOException {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   568
            value = cr.readInt();
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   569
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   570
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   571
        public CONSTANT_Integer_info(int value) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   572
            this.value = value;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   573
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   574
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   575
        public int getTag() {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   576
            return CONSTANT_Integer;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   577
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   578
3543
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
   579
        public int byteLength() {
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
   580
            return 5;
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
   581
        }
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
   582
727
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   583
        @Override
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   584
        public String toString() {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   585
            return "CONSTANT_Integer_info[value: " + value + "]";
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   586
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   587
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   588
        public <R, D> R accept(Visitor<R, D> visitor, D data) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   589
            return visitor.visitInteger(this, data);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   590
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   591
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   592
        public final int value;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   593
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   594
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   595
    public static class CONSTANT_InterfaceMethodref_info extends CPRefInfo {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   596
        CONSTANT_InterfaceMethodref_info(ConstantPool cp, ClassReader cr) throws IOException {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   597
            super(cp, cr, CONSTANT_InterfaceMethodref);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   598
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   599
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   600
        public CONSTANT_InterfaceMethodref_info(ConstantPool cp, int class_index, int name_and_type_index) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   601
            super(cp, CONSTANT_InterfaceMethodref, class_index, name_and_type_index);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   602
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   603
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   604
        @Override
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   605
        public String toString() {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   606
            return "CONSTANT_InterfaceMethodref_info[class_index: " + class_index + ", name_and_type_index: " + name_and_type_index + "]";
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   607
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   608
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   609
        public <R, D> R accept(Visitor<R, D> visitor, D data) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   610
            return visitor.visitInterfaceMethodref(this, data);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   611
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   612
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   613
8042
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   614
    public static class CONSTANT_InvokeDynamic_info extends CPInfo {
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   615
        CONSTANT_InvokeDynamic_info(ConstantPool cp, ClassReader cr) throws IOException {
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   616
            super(cp);
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   617
            bootstrap_method_attr_index = cr.readUnsignedShort();
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   618
            name_and_type_index = cr.readUnsignedShort();
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   619
        }
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   620
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   621
        public CONSTANT_InvokeDynamic_info(ConstantPool cp, int bootstrap_method_index, int name_and_type_index) {
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   622
            super(cp);
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   623
            this.bootstrap_method_attr_index = bootstrap_method_index;
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   624
            this.name_and_type_index = name_and_type_index;
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   625
        }
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   626
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   627
        public int getTag() {
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   628
            return CONSTANT_InvokeDynamic;
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   629
        }
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   630
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   631
        public int byteLength() {
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   632
            return 5;
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   633
        }
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   634
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   635
        @Override
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   636
        public String toString() {
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   637
            return "CONSTANT_InvokeDynamic_info[bootstrap_method_index: " + bootstrap_method_attr_index + ", name_and_type_index: " + name_and_type_index + "]";
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   638
        }
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   639
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   640
        public <R, D> R accept(Visitor<R, D> visitor, D data) {
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   641
            return visitor.visitInvokeDynamic(this, data);
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   642
        }
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   643
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   644
        public CONSTANT_NameAndType_info getNameAndTypeInfo() throws ConstantPoolException {
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   645
            return cp.getNameAndTypeInfo(name_and_type_index);
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   646
        }
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   647
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   648
        public final int bootstrap_method_attr_index;
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   649
        public final int name_and_type_index;
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   650
    }
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   651
727
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   652
    public static class CONSTANT_Long_info extends CPInfo {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   653
        CONSTANT_Long_info(ClassReader cr) throws IOException {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   654
            value = cr.readLong();
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   655
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   656
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   657
        public CONSTANT_Long_info(long value) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   658
            this.value = value;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   659
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   660
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   661
        public int getTag() {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   662
            return CONSTANT_Long;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   663
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   664
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   665
        @Override
2978
a72220103e31 6841419: classfile: add constant pool iterator
jjg
parents: 2977
diff changeset
   666
        public int size() {
a72220103e31 6841419: classfile: add constant pool iterator
jjg
parents: 2977
diff changeset
   667
            return 2;
a72220103e31 6841419: classfile: add constant pool iterator
jjg
parents: 2977
diff changeset
   668
        }
a72220103e31 6841419: classfile: add constant pool iterator
jjg
parents: 2977
diff changeset
   669
3543
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
   670
        public int byteLength() {
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
   671
            return 9;
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
   672
        }
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
   673
2978
a72220103e31 6841419: classfile: add constant pool iterator
jjg
parents: 2977
diff changeset
   674
        @Override
727
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   675
        public String toString() {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   676
            return "CONSTANT_Long_info[value: " + value + "]";
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   677
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   678
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   679
        public <R, D> R accept(Visitor<R, D> visitor, D data) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   680
            return visitor.visitLong(this, data);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   681
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   682
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   683
        public final long value;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   684
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   685
8042
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   686
    public static class CONSTANT_MethodHandle_info extends CPInfo {
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   687
        CONSTANT_MethodHandle_info(ConstantPool cp, ClassReader cr) throws IOException {
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   688
            super(cp);
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   689
            reference_kind =  RefKind.getRefkind(cr.readUnsignedByte());
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   690
            reference_index = cr.readUnsignedShort();
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   691
        }
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   692
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   693
        public CONSTANT_MethodHandle_info(ConstantPool cp, RefKind ref_kind, int member_index) {
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   694
            super(cp);
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   695
            this.reference_kind = ref_kind;
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   696
            this.reference_index = member_index;
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   697
        }
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   698
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   699
        public int getTag() {
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   700
            return CONSTANT_MethodHandle;
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   701
        }
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   702
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   703
        public int byteLength() {
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   704
            return 4;
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   705
        }
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   706
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   707
        @Override
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   708
        public String toString() {
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   709
            return "CONSTANT_MethodHandle_info[ref_kind: " + reference_kind + ", member_index: " + reference_index + "]";
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   710
        }
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   711
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   712
        public <R, D> R accept(Visitor<R, D> visitor, D data) {
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   713
            return visitor.visitMethodHandle(this, data);
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   714
        }
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   715
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   716
        public CPRefInfo getCPRefInfo() throws ConstantPoolException {
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   717
            int expected = CONSTANT_Methodref;
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   718
            int actual = cp.get(reference_index).getTag();
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   719
            // allow these tag types also:
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   720
            switch (actual) {
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   721
                case CONSTANT_Fieldref:
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   722
                case CONSTANT_InterfaceMethodref:
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   723
                    expected = actual;
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   724
            }
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   725
            return (CPRefInfo) cp.get(reference_index, expected);
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   726
        }
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   727
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   728
        public final RefKind reference_kind;
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   729
        public final int reference_index;
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   730
    }
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   731
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   732
    public static class CONSTANT_MethodType_info extends CPInfo {
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   733
        CONSTANT_MethodType_info(ConstantPool cp, ClassReader cr) throws IOException {
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   734
            super(cp);
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   735
            descriptor_index = cr.readUnsignedShort();
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   736
        }
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   737
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   738
        public CONSTANT_MethodType_info(ConstantPool cp, int signature_index) {
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   739
            super(cp);
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   740
            this.descriptor_index = signature_index;
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   741
        }
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   742
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   743
        public int getTag() {
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   744
            return CONSTANT_MethodType;
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   745
        }
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   746
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   747
        public int byteLength() {
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   748
            return 3;
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   749
        }
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   750
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   751
        @Override
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   752
        public String toString() {
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   753
            return "CONSTANT_MethodType_info[signature_index: " + descriptor_index + "]";
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   754
        }
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   755
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   756
        public <R, D> R accept(Visitor<R, D> visitor, D data) {
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   757
            return visitor.visitMethodType(this, data);
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   758
        }
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   759
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   760
        public String getType() throws ConstantPoolException {
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   761
            return cp.getUTF8Value(descriptor_index);
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   762
        }
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   763
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   764
        public final int descriptor_index;
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   765
    }
d534dd80da9f 6982999: tools must support -target 7 bytecodes
ksrini
parents: 5847
diff changeset
   766
727
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   767
    public static class CONSTANT_Methodref_info extends CPRefInfo {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   768
        CONSTANT_Methodref_info(ConstantPool cp, ClassReader cr) throws IOException {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   769
            super(cp, cr, CONSTANT_Methodref);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   770
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   771
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   772
        public CONSTANT_Methodref_info(ConstantPool cp, int class_index, int name_and_type_index) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   773
            super(cp, CONSTANT_Methodref, class_index, name_and_type_index);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   774
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   775
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   776
        @Override
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   777
        public String toString() {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   778
            return "CONSTANT_Methodref_info[class_index: " + class_index + ", name_and_type_index: " + name_and_type_index + "]";
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   779
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   780
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   781
        public <R, D> R accept(Visitor<R, D> visitor, D data) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   782
            return visitor.visitMethodref(this, data);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   783
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   784
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   785
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   786
    public static class CONSTANT_NameAndType_info extends CPInfo {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   787
        CONSTANT_NameAndType_info(ConstantPool cp, ClassReader cr) throws IOException {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   788
            super(cp);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   789
            name_index = cr.readUnsignedShort();
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   790
            type_index = cr.readUnsignedShort();
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   791
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   792
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   793
        public CONSTANT_NameAndType_info(ConstantPool cp, int name_index, int type_index) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   794
            super(cp);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   795
            this.name_index = name_index;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   796
            this.type_index = type_index;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   797
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   798
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   799
        public int getTag() {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   800
            return CONSTANT_NameAndType;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   801
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   802
3543
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
   803
        public int byteLength() {
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
   804
            return 5;
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
   805
        }
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
   806
727
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   807
        public String getName() throws ConstantPoolException {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   808
            return cp.getUTF8Value(name_index);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   809
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   810
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   811
        public String getType() throws ConstantPoolException {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   812
            return cp.getUTF8Value(type_index);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   813
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   814
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   815
        public <R, D> R accept(Visitor<R, D> visitor, D data) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   816
            return visitor.visitNameAndType(this, data);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   817
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   818
3141
79c119fae7fb 6852856: javap changes to facilitate subclassing javap for variants
jjg
parents: 2978
diff changeset
   819
        @Override
79c119fae7fb 6852856: javap changes to facilitate subclassing javap for variants
jjg
parents: 2978
diff changeset
   820
        public String toString() {
79c119fae7fb 6852856: javap changes to facilitate subclassing javap for variants
jjg
parents: 2978
diff changeset
   821
            return "CONSTANT_NameAndType_info[name_index: " + name_index + ", type_index: " + type_index + "]";
79c119fae7fb 6852856: javap changes to facilitate subclassing javap for variants
jjg
parents: 2978
diff changeset
   822
        }
79c119fae7fb 6852856: javap changes to facilitate subclassing javap for variants
jjg
parents: 2978
diff changeset
   823
727
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   824
        public final int name_index;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   825
        public final int type_index;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   826
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   827
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   828
    public static class CONSTANT_String_info extends CPInfo {
733
b76c4357c649 6715767: javap on java.lang.ClassLoader crashes
jjg
parents: 727
diff changeset
   829
        CONSTANT_String_info(ConstantPool cp, ClassReader cr) throws IOException {
b76c4357c649 6715767: javap on java.lang.ClassLoader crashes
jjg
parents: 727
diff changeset
   830
            super(cp);
727
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   831
            string_index = cr.readUnsignedShort();
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   832
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   833
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   834
        public CONSTANT_String_info(ConstantPool cp, int string_index) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   835
            super(cp);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   836
            this.string_index = string_index;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   837
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   838
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   839
        public int getTag() {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   840
            return CONSTANT_String;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   841
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   842
3543
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
   843
        public int byteLength() {
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
   844
            return 3;
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
   845
        }
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
   846
727
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   847
        public String getString() throws ConstantPoolException {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   848
            return cp.getUTF8Value(string_index);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   849
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   850
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   851
        public <R, D> R accept(Visitor<R, D> visitor, D data) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   852
            return visitor.visitString(this, data);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   853
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   854
3141
79c119fae7fb 6852856: javap changes to facilitate subclassing javap for variants
jjg
parents: 2978
diff changeset
   855
        @Override
79c119fae7fb 6852856: javap changes to facilitate subclassing javap for variants
jjg
parents: 2978
diff changeset
   856
        public String toString() {
79c119fae7fb 6852856: javap changes to facilitate subclassing javap for variants
jjg
parents: 2978
diff changeset
   857
            return "CONSTANT_String_info[class_index: " + string_index + "]";
79c119fae7fb 6852856: javap changes to facilitate subclassing javap for variants
jjg
parents: 2978
diff changeset
   858
        }
79c119fae7fb 6852856: javap changes to facilitate subclassing javap for variants
jjg
parents: 2978
diff changeset
   859
727
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   860
        public final int string_index;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   861
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   862
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   863
    public static class CONSTANT_Utf8_info extends CPInfo {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   864
        CONSTANT_Utf8_info(ClassReader cr) throws IOException {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   865
            value = cr.readUTF();
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   866
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   867
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   868
        public CONSTANT_Utf8_info(String value) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   869
            this.value = value;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   870
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   871
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   872
        public int getTag() {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   873
            return CONSTANT_Utf8;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   874
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   875
3543
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
   876
        public int byteLength() {
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
   877
            class SizeOutputStream extends OutputStream {
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
   878
                @Override
5010
c9fd6294653a 6931482: minor findbugs fixes
jjg
parents: 4071
diff changeset
   879
                public void write(int b) {
3543
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
   880
                    size++;
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
   881
                }
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
   882
                int size;
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
   883
            }
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
   884
            SizeOutputStream sizeOut = new SizeOutputStream();
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
   885
            DataOutputStream out = new DataOutputStream(sizeOut);
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
   886
            try { out.writeUTF(value); } catch (IOException ignore) { }
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
   887
            return 1 + sizeOut.size;
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
   888
        }
58b72b096bcb 6866657: add byteLength method to primary classfile types
jjg
parents: 3141
diff changeset
   889
727
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   890
        @Override
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   891
        public String toString() {
3141
79c119fae7fb 6852856: javap changes to facilitate subclassing javap for variants
jjg
parents: 2978
diff changeset
   892
            if (value.length() < 32 && isPrintableAscii(value))
79c119fae7fb 6852856: javap changes to facilitate subclassing javap for variants
jjg
parents: 2978
diff changeset
   893
                return "CONSTANT_Utf8_info[value: \"" + value + "\"]";
79c119fae7fb 6852856: javap changes to facilitate subclassing javap for variants
jjg
parents: 2978
diff changeset
   894
            else
79c119fae7fb 6852856: javap changes to facilitate subclassing javap for variants
jjg
parents: 2978
diff changeset
   895
                return "CONSTANT_Utf8_info[value: (" + value.length() + " chars)]";
79c119fae7fb 6852856: javap changes to facilitate subclassing javap for variants
jjg
parents: 2978
diff changeset
   896
        }
79c119fae7fb 6852856: javap changes to facilitate subclassing javap for variants
jjg
parents: 2978
diff changeset
   897
79c119fae7fb 6852856: javap changes to facilitate subclassing javap for variants
jjg
parents: 2978
diff changeset
   898
        static boolean isPrintableAscii(String s) {
79c119fae7fb 6852856: javap changes to facilitate subclassing javap for variants
jjg
parents: 2978
diff changeset
   899
            for (int i = 0; i < s.length(); i++) {
79c119fae7fb 6852856: javap changes to facilitate subclassing javap for variants
jjg
parents: 2978
diff changeset
   900
                char c = s.charAt(i);
79c119fae7fb 6852856: javap changes to facilitate subclassing javap for variants
jjg
parents: 2978
diff changeset
   901
                if (c < 32 || c >= 127)
79c119fae7fb 6852856: javap changes to facilitate subclassing javap for variants
jjg
parents: 2978
diff changeset
   902
                    return false;
79c119fae7fb 6852856: javap changes to facilitate subclassing javap for variants
jjg
parents: 2978
diff changeset
   903
            }
79c119fae7fb 6852856: javap changes to facilitate subclassing javap for variants
jjg
parents: 2978
diff changeset
   904
            return true;
727
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   905
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   906
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   907
        public <R, D> R accept(Visitor<R, D> visitor, D data) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   908
            return visitor.visitUtf8(this, data);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   909
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   910
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   911
        public final String value;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   912
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   913
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   914
}