src/java.base/share/classes/jdk/internal/org/objectweb/asm/ClassReader.java
author psandoz
Fri, 08 Sep 2017 10:46:46 -0700
changeset 48826 c4d9d1b08e2e
parent 48355 4944950606ef
child 50735 2f2af62dfac7
permissions -rw-r--r--
8186209: Tool support for ConstantDynamic 8186046: Minimal ConstantDynamic support 8190972: Ensure that AOT/Graal filters out class files containing CONSTANT_Dynamic ahead of full AOT support Reviewed-by: acorn, coleenp, kvn Contributed-by: lois.foltan@oracle.com, john.r.rose@oracle.com, paul.sandoz@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
     1
/*
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
     2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
     3
 *
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
     4
 * This code is free software; you can redistribute it and/or modify it
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
     5
 * under the terms of the GNU General Public License version 2 only, as
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
     6
 * published by the Free Software Foundation.  Oracle designates this
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
     7
 * particular file as subject to the "Classpath" exception as provided
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
     8
 * by Oracle in the LICENSE file that accompanied this code.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
     9
 *
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    14
 * accompanied this code).
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    15
 *
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    19
 *
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    22
 * questions.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    23
 */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    24
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    25
/*
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    26
 * This file is available under and governed by the GNU General Public
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    27
 * License version 2 only, as published by the Free Software Foundation.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    28
 * However, the following notice accompanied the original version of this
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    29
 * file:
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    30
 *
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    31
 * ASM: a very small and fast Java bytecode manipulation framework
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    32
 * Copyright (c) 2000-2011 INRIA, France Telecom
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    33
 * All rights reserved.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    34
 *
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    35
 * Redistribution and use in source and binary forms, with or without
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    36
 * modification, are permitted provided that the following conditions
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    37
 * are met:
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    38
 * 1. Redistributions of source code must retain the above copyright
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    39
 *    notice, this list of conditions and the following disclaimer.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    40
 * 2. Redistributions in binary form must reproduce the above copyright
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    41
 *    notice, this list of conditions and the following disclaimer in the
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    42
 *    documentation and/or other materials provided with the distribution.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    43
 * 3. Neither the name of the copyright holders nor the names of its
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    44
 *    contributors may be used to endorse or promote products derived from
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    45
 *    this software without specific prior written permission.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    46
 *
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    47
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    48
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    49
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    50
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    51
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    52
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    53
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    54
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    55
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    56
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    57
 * THE POSSIBILITY OF SUCH DAMAGE.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    58
 */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    59
package jdk.internal.org.objectweb.asm;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    60
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    61
import java.io.IOException;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    62
import java.io.InputStream;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    63
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    64
/**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    65
 * A Java class parser to make a {@link ClassVisitor} visit an existing class.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    66
 * This class parses a byte array conforming to the Java class file format and
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    67
 * calls the appropriate visit methods of a given class visitor for each field,
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    68
 * method and bytecode instruction encountered.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    69
 *
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    70
 * @author Eric Bruneton
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    71
 * @author Eugene Kuleshov
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    72
 */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    73
public class ClassReader {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    74
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    75
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    76
     * Flag to skip method code. If this class is set <code>CODE</code>
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    77
     * attribute won't be visited. This can be used, for example, to retrieve
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    78
     * annotations for methods and method parameters.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    79
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    80
    public static final int SKIP_CODE = 1;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    81
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    82
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    83
     * Flag to skip the debug information in the class. If this flag is set the
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    84
     * debug information of the class is not visited, i.e. the
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    85
     * {@link MethodVisitor#visitLocalVariable visitLocalVariable} and
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    86
     * {@link MethodVisitor#visitLineNumber visitLineNumber} methods will not be
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    87
     * called.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    88
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    89
    public static final int SKIP_DEBUG = 2;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    90
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    91
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    92
     * Flag to skip the stack map frames in the class. If this flag is set the
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    93
     * stack map frames of the class is not visited, i.e. the
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    94
     * {@link MethodVisitor#visitFrame visitFrame} method will not be called.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    95
     * This flag is useful when the {@link ClassWriter#COMPUTE_FRAMES} option is
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    96
     * used: it avoids visiting frames that will be ignored and recomputed from
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    97
     * scratch in the class writer.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    98
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    99
    public static final int SKIP_FRAMES = 4;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   100
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   101
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   102
     * Flag to expand the stack map frames. By default stack map frames are
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   103
     * visited in their original format (i.e. "expanded" for classes whose
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   104
     * version is less than V1_6, and "compressed" for the other classes). If
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   105
     * this flag is set, stack map frames are always visited in expanded format
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   106
     * (this option adds a decompression/recompression step in ClassReader and
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   107
     * ClassWriter which degrades performances quite a lot).
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   108
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   109
    public static final int EXPAND_FRAMES = 8;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   110
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   111
    /**
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   112
     * Flag to expand the ASM pseudo instructions into an equivalent sequence of
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   113
     * standard bytecode instructions. When resolving a forward jump it may
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   114
     * happen that the signed 2 bytes offset reserved for it is not sufficient
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   115
     * to store the bytecode offset. In this case the jump instruction is
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   116
     * replaced with a temporary ASM pseudo instruction using an unsigned 2
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   117
     * bytes offset (see Label#resolve). This internal flag is used to re-read
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   118
     * classes containing such instructions, in order to replace them with
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   119
     * standard instructions. In addition, when this flag is used, GOTO_W and
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   120
     * JSR_W are <i>not</i> converted into GOTO and JSR, to make sure that
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   121
     * infinite loops where a GOTO_W is replaced with a GOTO in ClassReader and
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   122
     * converted back to a GOTO_W in ClassWriter cannot occur.
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   123
     */
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   124
    static final int EXPAND_ASM_INSNS = 256;
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   125
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   126
    /**
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   127
     * The class to be parsed. <i>The content of this array must not be
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   128
     * modified. This field is intended for {@link Attribute} sub classes, and
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   129
     * is normally not needed by class generators or adapters.</i>
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   130
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   131
    public final byte[] b;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   132
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   133
    /**
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   134
     * The start index of each constant pool item in {@link #b b}, plus one. The
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   135
     * one byte offset skips the constant pool item tag that indicates its type.
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   136
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   137
    private final int[] items;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   138
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   139
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   140
     * The String objects corresponding to the CONSTANT_Utf8 items. This cache
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   141
     * avoids multiple parsing of a given CONSTANT_Utf8 constant pool item,
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   142
     * which GREATLY improves performances (by a factor 2 to 3). This caching
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   143
     * strategy could be extended to all constant pool items, but its benefit
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   144
     * would not be so great for these items (because they are much less
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   145
     * expensive to parse than CONSTANT_Utf8 items).
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   146
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   147
    private final String[] strings;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   148
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   149
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   150
     * Maximum length of the strings contained in the constant pool of the
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   151
     * class.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   152
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   153
    private final int maxStringLength;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   154
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   155
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   156
     * Start index of the class header information (access, name...) in
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   157
     * {@link #b b}.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   158
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   159
    public final int header;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   160
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   161
    // ------------------------------------------------------------------------
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   162
    // Constructors
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   163
    // ------------------------------------------------------------------------
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   164
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   165
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   166
     * Constructs a new {@link ClassReader} object.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   167
     *
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   168
     * @param b
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   169
     *            the bytecode of the class to be read.
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   170
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   171
    public ClassReader(final byte[] b) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   172
        this(b, 0, b.length);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   173
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   174
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   175
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   176
     * Constructs a new {@link ClassReader} object.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   177
     *
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   178
     * @param b
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   179
     *            the bytecode of the class to be read.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   180
     * @param off
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   181
     *            the start offset of the class data.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   182
     * @param len
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   183
     *            the length of the class data.
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   184
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   185
    public ClassReader(final byte[] b, final int off, final int len) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   186
        this.b = b;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   187
        // checks the class version
48355
4944950606ef 8191913: Bump classfile version number to 55
psandoz
parents: 48081
diff changeset
   188
        if (readShort(off + 6) > Opcodes.V11) {
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   189
            throw new IllegalArgumentException();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   190
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   191
        // parses the constant pool
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   192
        items = new int[readUnsignedShort(off + 8)];
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   193
        int n = items.length;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   194
        strings = new String[n];
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   195
        int max = 0;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   196
        int index = off + 10;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   197
        for (int i = 1; i < n; ++i) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   198
            items[i] = index + 1;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   199
            int size;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   200
            switch (b[index]) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   201
            case ClassWriter.FIELD:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   202
            case ClassWriter.METH:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   203
            case ClassWriter.IMETH:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   204
            case ClassWriter.INT:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   205
            case ClassWriter.FLOAT:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   206
            case ClassWriter.NAME_TYPE:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   207
            case ClassWriter.INDY:
48826
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 48355
diff changeset
   208
            // @@@ ClassWriter.CONDY
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 48355
diff changeset
   209
            // Enables MethodHandles.lookup().defineClass to function correctly
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 48355
diff changeset
   210
            // when it reads the class name
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 48355
diff changeset
   211
            case 17:
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   212
                size = 5;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   213
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   214
            case ClassWriter.LONG:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   215
            case ClassWriter.DOUBLE:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   216
                size = 9;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   217
                ++i;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   218
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   219
            case ClassWriter.UTF8:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   220
                size = 3 + readUnsignedShort(index + 1);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   221
                if (size > max) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   222
                    max = size;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   223
                }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   224
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   225
            case ClassWriter.HANDLE:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   226
                size = 4;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   227
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   228
            // case ClassWriter.CLASS:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   229
            // case ClassWriter.STR:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   230
            // case ClassWriter.MTYPE
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   231
            // case ClassWriter.PACKAGE:
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   232
            // case ClassWriter.MODULE:
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   233
            default:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   234
                size = 3;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   235
                break;
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   236
            }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   237
            index += size;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   238
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   239
        maxStringLength = max;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   240
        // the class header information starts just after the constant pool
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   241
        header = index;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   242
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   243
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   244
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   245
     * Returns the class's access flags (see {@link Opcodes}). This value may
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   246
     * not reflect Deprecated and Synthetic flags when bytecode is before 1.5
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   247
     * and those flags are represented by attributes.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   248
     *
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   249
     * @return the class access flags
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   250
     *
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   251
     * @see ClassVisitor#visit(int, int, String, String, String, String[])
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   252
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   253
    public int getAccess() {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   254
        return readUnsignedShort(header);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   255
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   256
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   257
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   258
     * Returns the internal name of the class (see
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   259
     * {@link Type#getInternalName() getInternalName}).
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   260
     *
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   261
     * @return the internal class name
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   262
     *
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   263
     * @see ClassVisitor#visit(int, int, String, String, String, String[])
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   264
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   265
    public String getClassName() {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   266
        return readClass(header + 2, new char[maxStringLength]);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   267
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   268
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   269
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   270
     * Returns the internal of name of the super class (see
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   271
     * {@link Type#getInternalName() getInternalName}). For interfaces, the
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   272
     * super class is {@link Object}.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   273
     *
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   274
     * @return the internal name of super class, or <tt>null</tt> for
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   275
     *         {@link Object} class.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   276
     *
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   277
     * @see ClassVisitor#visit(int, int, String, String, String, String[])
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   278
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   279
    public String getSuperName() {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   280
        return readClass(header + 4, new char[maxStringLength]);
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   281
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   282
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   283
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   284
     * Returns the internal names of the class's interfaces (see
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   285
     * {@link Type#getInternalName() getInternalName}).
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   286
     *
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   287
     * @return the array of internal names for all implemented interfaces or
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   288
     *         <tt>null</tt>.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   289
     *
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   290
     * @see ClassVisitor#visit(int, int, String, String, String, String[])
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   291
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   292
    public String[] getInterfaces() {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   293
        int index = header + 6;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   294
        int n = readUnsignedShort(index);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   295
        String[] interfaces = new String[n];
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   296
        if (n > 0) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   297
            char[] buf = new char[maxStringLength];
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   298
            for (int i = 0; i < n; ++i) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   299
                index += 2;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   300
                interfaces[i] = readClass(index, buf);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   301
            }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   302
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   303
        return interfaces;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   304
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   305
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   306
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   307
     * Copies the constant pool data into the given {@link ClassWriter}. Should
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   308
     * be called before the {@link #accept(ClassVisitor,int)} method.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   309
     *
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   310
     * @param classWriter
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   311
     *            the {@link ClassWriter} to copy constant pool into.
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   312
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   313
    void copyPool(final ClassWriter classWriter) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   314
        char[] buf = new char[maxStringLength];
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   315
        int ll = items.length;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   316
        Item[] items2 = new Item[ll];
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   317
        for (int i = 1; i < ll; i++) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   318
            int index = items[i];
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   319
            int tag = b[index - 1];
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   320
            Item item = new Item(i);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   321
            int nameType;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   322
            switch (tag) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   323
            case ClassWriter.FIELD:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   324
            case ClassWriter.METH:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   325
            case ClassWriter.IMETH:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   326
                nameType = items[readUnsignedShort(index + 2)];
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   327
                item.set(tag, readClass(index, buf), readUTF8(nameType, buf),
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   328
                        readUTF8(nameType + 2, buf));
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   329
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   330
            case ClassWriter.INT:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   331
                item.set(readInt(index));
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   332
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   333
            case ClassWriter.FLOAT:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   334
                item.set(Float.intBitsToFloat(readInt(index)));
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   335
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   336
            case ClassWriter.NAME_TYPE:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   337
                item.set(tag, readUTF8(index, buf), readUTF8(index + 2, buf),
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   338
                        null);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   339
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   340
            case ClassWriter.LONG:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   341
                item.set(readLong(index));
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   342
                ++i;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   343
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   344
            case ClassWriter.DOUBLE:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   345
                item.set(Double.longBitsToDouble(readLong(index)));
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   346
                ++i;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   347
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   348
            case ClassWriter.UTF8: {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   349
                String s = strings[i];
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   350
                if (s == null) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   351
                    index = items[i];
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   352
                    s = strings[i] = readUTF(index + 2,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   353
                            readUnsignedShort(index), buf);
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   354
                }
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   355
                item.set(tag, s, null, null);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   356
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   357
            }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   358
            case ClassWriter.HANDLE: {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   359
                int fieldOrMethodRef = items[readUnsignedShort(index + 1)];
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   360
                nameType = items[readUnsignedShort(fieldOrMethodRef + 2)];
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   361
                item.set(ClassWriter.HANDLE_BASE + readByte(index),
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   362
                        readClass(fieldOrMethodRef, buf),
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   363
                        readUTF8(nameType, buf), readUTF8(nameType + 2, buf));
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   364
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   365
            }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   366
            case ClassWriter.INDY:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   367
                if (classWriter.bootstrapMethods == null) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   368
                    copyBootstrapMethods(classWriter, items2, buf);
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   369
                }
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   370
                nameType = items[readUnsignedShort(index + 2)];
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   371
                item.set(readUTF8(nameType, buf), readUTF8(nameType + 2, buf),
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   372
                        readUnsignedShort(index));
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   373
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   374
            // case ClassWriter.STR:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   375
            // case ClassWriter.CLASS:
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   376
            // case ClassWriter.MTYPE:
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   377
            // case ClassWriter.MODULE:
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   378
            // case ClassWriter.PACKAGE:
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   379
            default:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   380
                item.set(tag, readUTF8(index, buf), null, null);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   381
                break;
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   382
            }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   383
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   384
            int index2 = item.hashCode % items2.length;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   385
            item.next = items2[index2];
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   386
            items2[index2] = item;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   387
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   388
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   389
        int off = items[1] - 1;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   390
        classWriter.pool.putByteArray(b, off, header - off);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   391
        classWriter.items = items2;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   392
        classWriter.threshold = (int) (0.75d * ll);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   393
        classWriter.index = ll;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   394
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   395
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   396
    /**
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   397
     * Copies the bootstrap method data into the given {@link ClassWriter}.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   398
     * Should be called before the {@link #accept(ClassVisitor,int)} method.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   399
     *
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   400
     * @param classWriter
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   401
     *            the {@link ClassWriter} to copy bootstrap methods into.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   402
     */
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   403
    private void copyBootstrapMethods(final ClassWriter classWriter,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   404
            final Item[] items, final char[] c) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   405
        // finds the "BootstrapMethods" attribute
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   406
        int u = getAttributes();
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   407
        boolean found = false;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   408
        for (int i = readUnsignedShort(u); i > 0; --i) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   409
            String attrName = readUTF8(u + 2, c);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   410
            if ("BootstrapMethods".equals(attrName)) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   411
                found = true;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   412
                break;
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   413
            }
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   414
            u += 6 + readInt(u + 4);
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   415
        }
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   416
        if (!found) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   417
            return;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   418
        }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   419
        // copies the bootstrap methods in the class writer
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   420
        int boostrapMethodCount = readUnsignedShort(u + 8);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   421
        for (int j = 0, v = u + 10; j < boostrapMethodCount; j++) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   422
            int position = v - u - 10;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   423
            int hashCode = readConst(readUnsignedShort(v), c).hashCode();
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   424
            for (int k = readUnsignedShort(v + 2); k > 0; --k) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   425
                hashCode ^= readConst(readUnsignedShort(v + 4), c).hashCode();
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   426
                v += 2;
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   427
            }
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   428
            v += 4;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   429
            Item item = new Item(j);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   430
            item.set(position, hashCode & 0x7FFFFFFF);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   431
            int index = item.hashCode % items.length;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   432
            item.next = items[index];
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   433
            items[index] = item;
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   434
        }
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   435
        int attrSize = readInt(u + 4);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   436
        ByteVector bootstrapMethods = new ByteVector(attrSize + 62);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   437
        bootstrapMethods.putByteArray(b, u + 10, attrSize - 2);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   438
        classWriter.bootstrapMethodsCount = boostrapMethodCount;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   439
        classWriter.bootstrapMethods = bootstrapMethods;
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   440
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   441
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   442
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   443
     * Constructs a new {@link ClassReader} object.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   444
     *
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   445
     * @param is
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   446
     *            an input stream from which to read the class.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   447
     * @throws IOException
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   448
     *             if a problem occurs during reading.
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   449
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   450
    public ClassReader(final InputStream is) throws IOException {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   451
        this(readClass(is, false));
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   452
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   453
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   454
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   455
     * Constructs a new {@link ClassReader} object.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   456
     *
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   457
     * @param name
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   458
     *            the binary qualified name of the class to be read.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   459
     * @throws IOException
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   460
     *             if an exception occurs during reading.
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   461
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   462
    public ClassReader(final String name) throws IOException {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   463
        this(readClass(
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   464
                ClassLoader.getSystemResourceAsStream(name.replace('.', '/')
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   465
                        + ".class"), true));
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   466
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   467
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   468
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   469
     * Reads the bytecode of a class.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   470
     *
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   471
     * @param is
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   472
     *            an input stream from which to read the class.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   473
     * @param close
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   474
     *            true to close the input stream after reading.
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   475
     * @return the bytecode read from the given input stream.
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   476
     * @throws IOException
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   477
     *             if a problem occurs during reading.
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   478
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   479
    private static byte[] readClass(final InputStream is, boolean close)
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   480
            throws IOException {
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   481
        if (is == null) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   482
            throw new IOException("Class not found");
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   483
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   484
        try {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   485
            byte[] b = new byte[is.available()];
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   486
            int len = 0;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   487
            while (true) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   488
                int n = is.read(b, len, b.length - len);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   489
                if (n == -1) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   490
                    if (len < b.length) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   491
                        byte[] c = new byte[len];
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   492
                        System.arraycopy(b, 0, c, 0, len);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   493
                        b = c;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   494
                    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   495
                    return b;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   496
                }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   497
                len += n;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   498
                if (len == b.length) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   499
                    int last = is.read();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   500
                    if (last < 0) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   501
                        return b;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   502
                    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   503
                    byte[] c = new byte[b.length + 1000];
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   504
                    System.arraycopy(b, 0, c, 0, len);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   505
                    c[len++] = (byte) last;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   506
                    b = c;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   507
                }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   508
            }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   509
        } finally {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   510
            if (close) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   511
                is.close();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   512
            }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   513
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   514
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   515
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   516
    // ------------------------------------------------------------------------
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   517
    // Public methods
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   518
    // ------------------------------------------------------------------------
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   519
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   520
    /**
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   521
     * Makes the given visitor visit the Java class of this {@link ClassReader}
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   522
     * . This class is the one specified in the constructor (see
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   523
     * {@link #ClassReader(byte[]) ClassReader}).
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   524
     *
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   525
     * @param classVisitor
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   526
     *            the visitor that must visit this class.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   527
     * @param flags
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   528
     *            option flags that can be used to modify the default behavior
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   529
     *            of this class. See {@link #SKIP_DEBUG}, {@link #EXPAND_FRAMES}
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   530
     *            , {@link #SKIP_FRAMES}, {@link #SKIP_CODE}.
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   531
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   532
    public void accept(final ClassVisitor classVisitor, final int flags) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   533
        accept(classVisitor, new Attribute[0], flags);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   534
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   535
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   536
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   537
     * Makes the given visitor visit the Java class of this {@link ClassReader}.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   538
     * This class is the one specified in the constructor (see
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   539
     * {@link #ClassReader(byte[]) ClassReader}).
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   540
     *
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   541
     * @param classVisitor
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   542
     *            the visitor that must visit this class.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   543
     * @param attrs
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   544
     *            prototypes of the attributes that must be parsed during the
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   545
     *            visit of the class. Any attribute whose type is not equal to
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   546
     *            the type of one the prototypes will not be parsed: its byte
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   547
     *            array value will be passed unchanged to the ClassWriter.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   548
     *            <i>This may corrupt it if this value contains references to
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   549
     *            the constant pool, or has syntactic or semantic links with a
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   550
     *            class element that has been transformed by a class adapter
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   551
     *            between the reader and the writer</i>.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   552
     * @param flags
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   553
     *            option flags that can be used to modify the default behavior
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   554
     *            of this class. See {@link #SKIP_DEBUG}, {@link #EXPAND_FRAMES}
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   555
     *            , {@link #SKIP_FRAMES}, {@link #SKIP_CODE}.
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   556
     */
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   557
    public void accept(final ClassVisitor classVisitor,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   558
            final Attribute[] attrs, final int flags) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   559
        int u = header; // current offset in the class file
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   560
        char[] c = new char[maxStringLength]; // buffer used to read strings
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   561
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   562
        Context context = new Context();
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   563
        context.attrs = attrs;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   564
        context.flags = flags;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   565
        context.buffer = c;
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   566
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   567
        // reads the class declaration
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   568
        int access = readUnsignedShort(u);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   569
        String name = readClass(u + 2, c);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   570
        String superClass = readClass(u + 4, c);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   571
        String[] interfaces = new String[readUnsignedShort(u + 6)];
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   572
        u += 8;
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   573
        for (int i = 0; i < interfaces.length; ++i) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   574
            interfaces[i] = readClass(u, c);
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   575
            u += 2;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   576
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   577
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   578
        // reads the class attributes
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   579
        String signature = null;
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   580
        String sourceFile = null;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   581
        String sourceDebug = null;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   582
        String enclosingOwner = null;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   583
        String enclosingName = null;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   584
        String enclosingDesc = null;
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   585
        String moduleMainClass = null;
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   586
        int anns = 0;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   587
        int ianns = 0;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   588
        int tanns = 0;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   589
        int itanns = 0;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   590
        int innerClasses = 0;
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   591
        int module = 0;
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   592
        int packages = 0;
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   593
        Attribute attributes = null;
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   594
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   595
        u = getAttributes();
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   596
        for (int i = readUnsignedShort(u); i > 0; --i) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   597
            String attrName = readUTF8(u + 2, c);
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   598
            // tests are sorted in decreasing frequency order
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   599
            // (based on frequencies observed on typical classes)
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   600
            if ("SourceFile".equals(attrName)) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   601
                sourceFile = readUTF8(u + 8, c);
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   602
            } else if ("InnerClasses".equals(attrName)) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   603
                innerClasses = u + 8;
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   604
            } else if ("EnclosingMethod".equals(attrName)) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   605
                enclosingOwner = readClass(u + 8, c);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   606
                int item = readUnsignedShort(u + 10);
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   607
                if (item != 0) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   608
                    enclosingName = readUTF8(items[item], c);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   609
                    enclosingDesc = readUTF8(items[item] + 2, c);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   610
                }
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   611
            } else if ("Signature".equals(attrName)) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   612
                signature = readUTF8(u + 8, c);
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   613
            } else if ("RuntimeVisibleAnnotations".equals(attrName)) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   614
                anns = u + 8;
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   615
            } else if ("RuntimeVisibleTypeAnnotations".equals(attrName)) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   616
                tanns = u + 8;
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   617
            } else if ("Deprecated".equals(attrName)) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   618
                access |= Opcodes.ACC_DEPRECATED;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   619
            } else if ("Synthetic".equals(attrName)) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   620
                access |= Opcodes.ACC_SYNTHETIC
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   621
                        | ClassWriter.ACC_SYNTHETIC_ATTRIBUTE;
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   622
            } else if ("SourceDebugExtension".equals(attrName)) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   623
                int len = readInt(u + 4);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   624
                sourceDebug = readUTF(u + 8, len, new char[len]);
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   625
            } else if ("RuntimeInvisibleAnnotations".equals(attrName)) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   626
                ianns = u + 8;
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   627
            } else if ("RuntimeInvisibleTypeAnnotations".equals(attrName)) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   628
                itanns = u + 8;
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   629
            } else if ("Module".equals(attrName)) {
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   630
                module = u + 8;
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   631
            } else if ("ModuleMainClass".equals(attrName)) {
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   632
                moduleMainClass = readClass(u + 8, c);
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   633
            } else if ("ModulePackages".equals(attrName)) {
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   634
                packages = u + 10;
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   635
            } else if ("BootstrapMethods".equals(attrName)) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   636
                int[] bootstrapMethods = new int[readUnsignedShort(u + 8)];
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   637
                for (int j = 0, v = u + 10; j < bootstrapMethods.length; j++) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   638
                    bootstrapMethods[j] = v;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   639
                    v += 2 + readUnsignedShort(v + 2) << 1;
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   640
                }
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   641
                context.bootstrapMethods = bootstrapMethods;
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   642
            } else {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   643
                Attribute attr = readAttribute(attrs, attrName, u + 8,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   644
                        readInt(u + 4), c, -1, null);
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   645
                if (attr != null) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   646
                    attr.next = attributes;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   647
                    attributes = attr;
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   648
                }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   649
            }
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   650
            u += 6 + readInt(u + 4);
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   651
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   652
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   653
        // visits the class declaration
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   654
        classVisitor.visit(readInt(items[1] - 7), access, name, signature,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   655
                superClass, interfaces);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   656
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   657
        // visits the source and debug info
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   658
        if ((flags & SKIP_DEBUG) == 0
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   659
                && (sourceFile != null || sourceDebug != null)) {
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   660
            classVisitor.visitSource(sourceFile, sourceDebug);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   661
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   662
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   663
        // visits the module info and associated attributes
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   664
        if (module != 0) {
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   665
            readModule(classVisitor, context, module,
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   666
                    moduleMainClass, packages);
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   667
        }
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   668
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   669
        // visits the outer class
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   670
        if (enclosingOwner != null) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   671
            classVisitor.visitOuterClass(enclosingOwner, enclosingName,
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   672
                    enclosingDesc);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   673
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   674
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   675
        // visits the class annotations and type annotations
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   676
        if (anns != 0) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   677
            for (int i = readUnsignedShort(anns), v = anns + 2; i > 0; --i) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   678
                v = readAnnotationValues(v + 2, c, true,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   679
                        classVisitor.visitAnnotation(readUTF8(v, c), true));
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   680
            }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   681
        }
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   682
        if (ianns != 0) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   683
            for (int i = readUnsignedShort(ianns), v = ianns + 2; i > 0; --i) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   684
                v = readAnnotationValues(v + 2, c, true,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   685
                        classVisitor.visitAnnotation(readUTF8(v, c), false));
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   686
            }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   687
        }
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   688
        if (tanns != 0) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   689
            for (int i = readUnsignedShort(tanns), v = tanns + 2; i > 0; --i) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   690
                v = readAnnotationTarget(context, v);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   691
                v = readAnnotationValues(v + 2, c, true,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   692
                        classVisitor.visitTypeAnnotation(context.typeRef,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   693
                                context.typePath, readUTF8(v, c), true));
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   694
            }
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   695
        }
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   696
        if (itanns != 0) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   697
            for (int i = readUnsignedShort(itanns), v = itanns + 2; i > 0; --i) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   698
                v = readAnnotationTarget(context, v);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   699
                v = readAnnotationValues(v + 2, c, true,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   700
                        classVisitor.visitTypeAnnotation(context.typeRef,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   701
                                context.typePath, readUTF8(v, c), false));
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   702
            }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   703
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   704
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   705
        // visits the attributes
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   706
        while (attributes != null) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   707
            Attribute attr = attributes.next;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   708
            attributes.next = null;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   709
            classVisitor.visitAttribute(attributes);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   710
            attributes = attr;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   711
        }
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   712
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   713
        // visits the inner classes
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   714
        if (innerClasses != 0) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   715
            int v = innerClasses + 2;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   716
            for (int i = readUnsignedShort(innerClasses); i > 0; --i) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   717
                classVisitor.visitInnerClass(readClass(v, c),
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   718
                        readClass(v + 2, c), readUTF8(v + 4, c),
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   719
                        readUnsignedShort(v + 6));
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   720
                v += 8;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   721
            }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   722
        }
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   723
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   724
        // visits the fields and methods
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   725
        u = header + 10 + 2 * interfaces.length;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   726
        for (int i = readUnsignedShort(u - 2); i > 0; --i) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   727
            u = readField(classVisitor, context, u);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   728
        }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   729
        u += 2;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   730
        for (int i = readUnsignedShort(u - 2); i > 0; --i) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   731
            u = readMethod(classVisitor, context, u);
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   732
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   733
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   734
        // visits the end of the class
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   735
        classVisitor.visitEnd();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   736
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   737
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   738
    /**
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   739
     * Reads the module attribute and visit it.
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   740
     *
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   741
     * @param classVisitor
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   742
     *           the current class visitor
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   743
     * @param context
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   744
     *           information about the class being parsed.
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   745
     * @param u
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   746
     *           start offset of the module attribute in the class file.
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   747
     * @param mainClass
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   748
     *           name of the main class of a module or null.
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   749
     * @param packages
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   750
     *           start offset of the concealed package attribute.
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   751
     */
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   752
    private void readModule(final ClassVisitor classVisitor,
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   753
            final Context context, int u,
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   754
            final String mainClass, int packages) {
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   755
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   756
        char[] buffer = context.buffer;
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   757
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   758
        // reads module name, flags and version
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   759
        String name = readModule(u, buffer);
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   760
        int flags = readUnsignedShort(u + 2);
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   761
        String version = readUTF8(u + 4, buffer);
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   762
        u += 6;
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   763
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   764
        ModuleVisitor mv = classVisitor.visitModule(name, flags, version);
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   765
        if (mv == null) {
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   766
            return;
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   767
        }
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   768
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   769
        // module attributes (main class, packages)
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   770
        if (mainClass != null) {
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   771
            mv.visitMainClass(mainClass);
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   772
        }
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   773
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   774
        if (packages != 0) {
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   775
            for (int i = readUnsignedShort(packages - 2); i > 0; --i) {
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   776
                String packaze = readPackage(packages, buffer);
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   777
                mv.visitPackage(packaze);
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   778
                packages += 2;
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   779
            }
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   780
        }
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   781
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   782
        // reads requires
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   783
        u += 2;
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   784
        for (int i = readUnsignedShort(u - 2); i > 0; --i) {
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   785
            String module = readModule(u, buffer);
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   786
            int access = readUnsignedShort(u + 2);
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   787
            String requireVersion = readUTF8(u + 4, buffer);
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   788
            mv.visitRequire(module, access, requireVersion);
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   789
            u += 6;
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   790
        }
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   791
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   792
        // reads exports
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   793
        u += 2;
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   794
        for (int i = readUnsignedShort(u - 2); i > 0; --i) {
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   795
            String export = readPackage(u, buffer);
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   796
            int access = readUnsignedShort(u + 2);
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   797
            int exportToCount = readUnsignedShort(u + 4);
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   798
            u += 6;
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   799
            String[] tos = null;
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   800
            if (exportToCount != 0) {
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   801
                tos = new String[exportToCount];
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   802
                for (int j = 0; j < tos.length; ++j) {
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   803
                    tos[j] = readModule(u, buffer);
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   804
                    u += 2;
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   805
                }
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   806
            }
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   807
            mv.visitExport(export, access, tos);
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   808
        }
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   809
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   810
        // reads opens
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   811
        u += 2;
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   812
        for (int i = readUnsignedShort(u - 2); i > 0; --i) {
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   813
            String open = readPackage(u, buffer);
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   814
            int access = readUnsignedShort(u + 2);
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   815
            int openToCount = readUnsignedShort(u + 4);
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   816
            u += 6;
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   817
            String[] tos = null;
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   818
            if (openToCount != 0) {
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   819
                tos = new String[openToCount];
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   820
                for (int j = 0; j < tos.length; ++j) {
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   821
                    tos[j] = readModule(u, buffer);
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   822
                    u += 2;
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   823
                }
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   824
            }
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   825
            mv.visitOpen(open, access, tos);
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   826
        }
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   827
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   828
        // read uses
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   829
        u += 2;
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   830
        for (int i = readUnsignedShort(u - 2); i > 0; --i) {
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   831
            mv.visitUse(readClass(u, buffer));
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   832
            u += 2;
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   833
        }
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   834
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   835
        // read provides
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   836
        u += 2;
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   837
        for (int i = readUnsignedShort(u - 2); i > 0; --i) {
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   838
            String service = readClass(u, buffer);
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   839
            int provideWithCount = readUnsignedShort(u + 2);
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   840
            u += 4;
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   841
            String[] withs = new String[provideWithCount];
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   842
            for (int j = 0; j < withs.length; ++j) {
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   843
                withs[j] = readClass(u, buffer);
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   844
                u += 2;
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   845
            }
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   846
            mv.visitProvide(service, withs);
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   847
        }
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   848
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   849
        mv.visitEnd();
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   850
    }
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   851
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   852
    /**
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   853
     * Reads a field and makes the given visitor visit it.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   854
     *
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   855
     * @param classVisitor
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   856
     *            the visitor that must visit the field.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   857
     * @param context
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   858
     *            information about the class being parsed.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   859
     * @param u
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   860
     *            the start offset of the field in the class file.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   861
     * @return the offset of the first byte following the field in the class.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   862
     */
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   863
    private int readField(final ClassVisitor classVisitor,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   864
            final Context context, int u) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   865
        // reads the field declaration
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   866
        char[] c = context.buffer;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   867
        int access = readUnsignedShort(u);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   868
        String name = readUTF8(u + 2, c);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   869
        String desc = readUTF8(u + 4, c);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   870
        u += 6;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   871
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   872
        // reads the field attributes
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   873
        String signature = null;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   874
        int anns = 0;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   875
        int ianns = 0;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   876
        int tanns = 0;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   877
        int itanns = 0;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   878
        Object value = null;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   879
        Attribute attributes = null;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   880
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   881
        for (int i = readUnsignedShort(u); i > 0; --i) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   882
            String attrName = readUTF8(u + 2, c);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   883
            // tests are sorted in decreasing frequency order
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   884
            // (based on frequencies observed on typical classes)
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   885
            if ("ConstantValue".equals(attrName)) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   886
                int item = readUnsignedShort(u + 8);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   887
                value = item == 0 ? null : readConst(item, c);
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   888
            } else if ("Signature".equals(attrName)) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   889
                signature = readUTF8(u + 8, c);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   890
            } else if ("Deprecated".equals(attrName)) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   891
                access |= Opcodes.ACC_DEPRECATED;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   892
            } else if ("Synthetic".equals(attrName)) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   893
                access |= Opcodes.ACC_SYNTHETIC
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   894
                        | ClassWriter.ACC_SYNTHETIC_ATTRIBUTE;
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   895
            } else if ("RuntimeVisibleAnnotations".equals(attrName)) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   896
                anns = u + 8;
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   897
            } else if ("RuntimeVisibleTypeAnnotations".equals(attrName)) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   898
                tanns = u + 8;
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   899
            } else if ("RuntimeInvisibleAnnotations".equals(attrName)) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   900
                ianns = u + 8;
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   901
            } else if ("RuntimeInvisibleTypeAnnotations".equals(attrName)) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   902
                itanns = u + 8;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   903
            } else {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   904
                Attribute attr = readAttribute(context.attrs, attrName, u + 8,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   905
                        readInt(u + 4), c, -1, null);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   906
                if (attr != null) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   907
                    attr.next = attributes;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   908
                    attributes = attr;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   909
                }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   910
            }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   911
            u += 6 + readInt(u + 4);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   912
        }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   913
        u += 2;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   914
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   915
        // visits the field declaration
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   916
        FieldVisitor fv = classVisitor.visitField(access, name, desc,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   917
                signature, value);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   918
        if (fv == null) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   919
            return u;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   920
        }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   921
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   922
        // visits the field annotations and type annotations
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   923
        if (anns != 0) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   924
            for (int i = readUnsignedShort(anns), v = anns + 2; i > 0; --i) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   925
                v = readAnnotationValues(v + 2, c, true,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   926
                        fv.visitAnnotation(readUTF8(v, c), true));
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   927
            }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   928
        }
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   929
        if (ianns != 0) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   930
            for (int i = readUnsignedShort(ianns), v = ianns + 2; i > 0; --i) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   931
                v = readAnnotationValues(v + 2, c, true,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   932
                        fv.visitAnnotation(readUTF8(v, c), false));
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   933
            }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   934
        }
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   935
        if (tanns != 0) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   936
            for (int i = readUnsignedShort(tanns), v = tanns + 2; i > 0; --i) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   937
                v = readAnnotationTarget(context, v);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   938
                v = readAnnotationValues(v + 2, c, true,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   939
                        fv.visitTypeAnnotation(context.typeRef,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   940
                                context.typePath, readUTF8(v, c), true));
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   941
            }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   942
        }
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   943
        if (itanns != 0) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   944
            for (int i = readUnsignedShort(itanns), v = itanns + 2; i > 0; --i) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   945
                v = readAnnotationTarget(context, v);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   946
                v = readAnnotationValues(v + 2, c, true,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   947
                        fv.visitTypeAnnotation(context.typeRef,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   948
                                context.typePath, readUTF8(v, c), false));
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   949
            }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   950
        }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   951
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   952
        // visits the field attributes
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   953
        while (attributes != null) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   954
            Attribute attr = attributes.next;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   955
            attributes.next = null;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   956
            fv.visitAttribute(attributes);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   957
            attributes = attr;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   958
        }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   959
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   960
        // visits the end of the field
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   961
        fv.visitEnd();
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   962
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   963
        return u;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   964
    }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   965
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   966
    /**
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   967
     * Reads a method and makes the given visitor visit it.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   968
     *
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   969
     * @param classVisitor
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   970
     *            the visitor that must visit the method.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   971
     * @param context
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   972
     *            information about the class being parsed.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   973
     * @param u
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   974
     *            the start offset of the method in the class file.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   975
     * @return the offset of the first byte following the method in the class.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   976
     */
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   977
    private int readMethod(final ClassVisitor classVisitor,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   978
            final Context context, int u) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   979
        // reads the method declaration
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   980
        char[] c = context.buffer;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   981
        context.access = readUnsignedShort(u);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   982
        context.name = readUTF8(u + 2, c);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   983
        context.desc = readUTF8(u + 4, c);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   984
        u += 6;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   985
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   986
        // reads the method attributes
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   987
        int code = 0;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   988
        int exception = 0;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   989
        String[] exceptions = null;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   990
        String signature = null;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   991
        int methodParameters = 0;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   992
        int anns = 0;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   993
        int ianns = 0;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   994
        int tanns = 0;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   995
        int itanns = 0;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   996
        int dann = 0;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   997
        int mpanns = 0;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   998
        int impanns = 0;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   999
        int firstAttribute = u;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1000
        Attribute attributes = null;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1001
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1002
        for (int i = readUnsignedShort(u); i > 0; --i) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1003
            String attrName = readUTF8(u + 2, c);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1004
            // tests are sorted in decreasing frequency order
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1005
            // (based on frequencies observed on typical classes)
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1006
            if ("Code".equals(attrName)) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1007
                if ((context.flags & SKIP_CODE) == 0) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1008
                    code = u + 8;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1009
                }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1010
            } else if ("Exceptions".equals(attrName)) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1011
                exceptions = new String[readUnsignedShort(u + 8)];
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1012
                exception = u + 10;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1013
                for (int j = 0; j < exceptions.length; ++j) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1014
                    exceptions[j] = readClass(exception, c);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1015
                    exception += 2;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1016
                }
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1017
            } else if ("Signature".equals(attrName)) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1018
                signature = readUTF8(u + 8, c);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1019
            } else if ("Deprecated".equals(attrName)) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1020
                context.access |= Opcodes.ACC_DEPRECATED;
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1021
            } else if ("RuntimeVisibleAnnotations".equals(attrName)) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1022
                anns = u + 8;
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1023
            } else if ("RuntimeVisibleTypeAnnotations".equals(attrName)) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1024
                tanns = u + 8;
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1025
            } else if ("AnnotationDefault".equals(attrName)) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1026
                dann = u + 8;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1027
            } else if ("Synthetic".equals(attrName)) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1028
                context.access |= Opcodes.ACC_SYNTHETIC
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1029
                        | ClassWriter.ACC_SYNTHETIC_ATTRIBUTE;
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1030
            } else if ("RuntimeInvisibleAnnotations".equals(attrName)) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1031
                ianns = u + 8;
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1032
            } else if ("RuntimeInvisibleTypeAnnotations".equals(attrName)) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1033
                itanns = u + 8;
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1034
            } else if ("RuntimeVisibleParameterAnnotations".equals(attrName)) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1035
                mpanns = u + 8;
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1036
            } else if ("RuntimeInvisibleParameterAnnotations".equals(attrName)) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1037
                impanns = u + 8;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1038
            } else if ("MethodParameters".equals(attrName)) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1039
                methodParameters = u + 8;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1040
            } else {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1041
                Attribute attr = readAttribute(context.attrs, attrName, u + 8,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1042
                        readInt(u + 4), c, -1, null);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1043
                if (attr != null) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1044
                    attr.next = attributes;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1045
                    attributes = attr;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1046
                }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1047
            }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1048
            u += 6 + readInt(u + 4);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1049
        }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1050
        u += 2;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1051
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1052
        // visits the method declaration
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1053
        MethodVisitor mv = classVisitor.visitMethod(context.access,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1054
                context.name, context.desc, signature, exceptions);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1055
        if (mv == null) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1056
            return u;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1057
        }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1058
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1059
        /*
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1060
         * if the returned MethodVisitor is in fact a MethodWriter, it means
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1061
         * there is no method adapter between the reader and the writer. If, in
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1062
         * addition, the writer's constant pool was copied from this reader
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1063
         * (mw.cw.cr == this), and the signature and exceptions of the method
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1064
         * have not been changed, then it is possible to skip all visit events
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1065
         * and just copy the original code of the method to the writer (the
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1066
         * access, name and descriptor can have been changed, this is not
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1067
         * important since they are not copied as is from the reader).
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1068
         */
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1069
        if (mv instanceof MethodWriter) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1070
            MethodWriter mw = (MethodWriter) mv;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1071
            if (mw.cw.cr == this && signature == mw.signature) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1072
                boolean sameExceptions = false;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1073
                if (exceptions == null) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1074
                    sameExceptions = mw.exceptionCount == 0;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1075
                } else if (exceptions.length == mw.exceptionCount) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1076
                    sameExceptions = true;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1077
                    for (int j = exceptions.length - 1; j >= 0; --j) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1078
                        exception -= 2;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1079
                        if (mw.exceptions[j] != readUnsignedShort(exception)) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1080
                            sameExceptions = false;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1081
                            break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1082
                        }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1083
                    }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1084
                }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1085
                if (sameExceptions) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1086
                    /*
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1087
                     * we do not copy directly the code into MethodWriter to
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1088
                     * save a byte array copy operation. The real copy will be
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1089
                     * done in ClassWriter.toByteArray().
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1090
                     */
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1091
                    mw.classReaderOffset = firstAttribute;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1092
                    mw.classReaderLength = u - firstAttribute;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1093
                    return u;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1094
                }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1095
            }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1096
        }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1097
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1098
        // visit the method parameters
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1099
        if (methodParameters != 0) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1100
            for (int i = b[methodParameters] & 0xFF, v = methodParameters + 1; i > 0; --i, v = v + 4) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1101
                mv.visitParameter(readUTF8(v, c), readUnsignedShort(v + 2));
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1102
            }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1103
        }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1104
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1105
        // visits the method annotations
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1106
        if (dann != 0) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1107
            AnnotationVisitor dv = mv.visitAnnotationDefault();
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1108
            readAnnotationValue(dann, c, null, dv);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1109
            if (dv != null) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1110
                dv.visitEnd();
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1111
            }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1112
        }
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1113
        if (anns != 0) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1114
            for (int i = readUnsignedShort(anns), v = anns + 2; i > 0; --i) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1115
                v = readAnnotationValues(v + 2, c, true,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1116
                        mv.visitAnnotation(readUTF8(v, c), true));
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1117
            }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1118
        }
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1119
        if (ianns != 0) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1120
            for (int i = readUnsignedShort(ianns), v = ianns + 2; i > 0; --i) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1121
                v = readAnnotationValues(v + 2, c, true,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1122
                        mv.visitAnnotation(readUTF8(v, c), false));
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1123
            }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1124
        }
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1125
        if (tanns != 0) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1126
            for (int i = readUnsignedShort(tanns), v = tanns + 2; i > 0; --i) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1127
                v = readAnnotationTarget(context, v);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1128
                v = readAnnotationValues(v + 2, c, true,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1129
                        mv.visitTypeAnnotation(context.typeRef,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1130
                                context.typePath, readUTF8(v, c), true));
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1131
            }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1132
        }
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1133
        if (itanns != 0) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1134
            for (int i = readUnsignedShort(itanns), v = itanns + 2; i > 0; --i) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1135
                v = readAnnotationTarget(context, v);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1136
                v = readAnnotationValues(v + 2, c, true,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1137
                        mv.visitTypeAnnotation(context.typeRef,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1138
                                context.typePath, readUTF8(v, c), false));
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1139
            }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1140
        }
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1141
        if (mpanns != 0) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1142
            readParameterAnnotations(mv, context, mpanns, true);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1143
        }
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1144
        if (impanns != 0) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1145
            readParameterAnnotations(mv, context, impanns, false);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1146
        }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1147
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1148
        // visits the method attributes
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1149
        while (attributes != null) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1150
            Attribute attr = attributes.next;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1151
            attributes.next = null;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1152
            mv.visitAttribute(attributes);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1153
            attributes = attr;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1154
        }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1155
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1156
        // visits the method code
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1157
        if (code != 0) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1158
            mv.visitCode();
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1159
            readCode(mv, context, code);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1160
        }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1161
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1162
        // visits the end of the method
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1163
        mv.visitEnd();
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1164
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1165
        return u;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1166
    }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1167
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1168
    /**
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1169
     * Reads the bytecode of a method and makes the given visitor visit it.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1170
     *
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1171
     * @param mv
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1172
     *            the visitor that must visit the method's code.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1173
     * @param context
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1174
     *            information about the class being parsed.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1175
     * @param u
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1176
     *            the start offset of the code attribute in the class file.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1177
     */
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1178
    private void readCode(final MethodVisitor mv, final Context context, int u) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1179
        // reads the header
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1180
        byte[] b = this.b;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1181
        char[] c = context.buffer;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1182
        int maxStack = readUnsignedShort(u);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1183
        int maxLocals = readUnsignedShort(u + 2);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1184
        int codeLength = readInt(u + 4);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1185
        u += 8;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1186
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1187
        // reads the bytecode to find the labels
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1188
        int codeStart = u;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1189
        int codeEnd = u + codeLength;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1190
        Label[] labels = context.labels = new Label[codeLength + 2];
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1191
        createLabel(codeLength + 1, labels);
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1192
        while (u < codeEnd) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1193
            int offset = u - codeStart;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1194
            int opcode = b[u] & 0xFF;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1195
            switch (ClassWriter.TYPE[opcode]) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1196
            case ClassWriter.NOARG_INSN:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1197
            case ClassWriter.IMPLVAR_INSN:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1198
                u += 1;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1199
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1200
            case ClassWriter.LABEL_INSN:
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1201
                createLabel(offset + readShort(u + 1), labels);
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1202
                u += 3;
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1203
                break;
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1204
            case ClassWriter.ASM_LABEL_INSN:
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1205
                createLabel(offset + readUnsignedShort(u + 1), labels);
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1206
                u += 3;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1207
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1208
            case ClassWriter.LABELW_INSN:
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1209
            case ClassWriter.ASM_LABELW_INSN:
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1210
                createLabel(offset + readInt(u + 1), labels);
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1211
                u += 5;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1212
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1213
            case ClassWriter.WIDE_INSN:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1214
                opcode = b[u + 1] & 0xFF;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1215
                if (opcode == Opcodes.IINC) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1216
                    u += 6;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1217
                } else {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1218
                    u += 4;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1219
                }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1220
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1221
            case ClassWriter.TABL_INSN:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1222
                // skips 0 to 3 padding bytes
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1223
                u = u + 4 - (offset & 3);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1224
                // reads instruction
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1225
                createLabel(offset + readInt(u), labels);
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1226
                for (int i = readInt(u + 8) - readInt(u + 4) + 1; i > 0; --i) {
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1227
                    createLabel(offset + readInt(u + 12), labels);
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1228
                    u += 4;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1229
                }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1230
                u += 12;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1231
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1232
            case ClassWriter.LOOK_INSN:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1233
                // skips 0 to 3 padding bytes
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1234
                u = u + 4 - (offset & 3);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1235
                // reads instruction
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1236
                createLabel(offset + readInt(u), labels);
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1237
                for (int i = readInt(u + 4); i > 0; --i) {
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1238
                    createLabel(offset + readInt(u + 12), labels);
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1239
                    u += 8;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1240
                }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1241
                u += 8;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1242
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1243
            case ClassWriter.VAR_INSN:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1244
            case ClassWriter.SBYTE_INSN:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1245
            case ClassWriter.LDC_INSN:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1246
                u += 2;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1247
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1248
            case ClassWriter.SHORT_INSN:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1249
            case ClassWriter.LDCW_INSN:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1250
            case ClassWriter.FIELDORMETH_INSN:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1251
            case ClassWriter.TYPE_INSN:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1252
            case ClassWriter.IINC_INSN:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1253
                u += 3;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1254
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1255
            case ClassWriter.ITFMETH_INSN:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1256
            case ClassWriter.INDYMETH_INSN:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1257
                u += 5;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1258
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1259
            // case MANA_INSN:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1260
            default:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1261
                u += 4;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1262
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1263
            }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1264
        }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1265
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1266
        // reads the try catch entries to find the labels, and also visits them
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1267
        for (int i = readUnsignedShort(u); i > 0; --i) {
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1268
            Label start = createLabel(readUnsignedShort(u + 2), labels);
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1269
            Label end = createLabel(readUnsignedShort(u + 4), labels);
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1270
            Label handler = createLabel(readUnsignedShort(u + 6), labels);
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1271
            String type = readUTF8(items[readUnsignedShort(u + 8)], c);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1272
            mv.visitTryCatchBlock(start, end, handler, type);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1273
            u += 8;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1274
        }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1275
        u += 2;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1276
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1277
        // reads the code attributes
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1278
        int[] tanns = null; // start index of each visible type annotation
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1279
        int[] itanns = null; // start index of each invisible type annotation
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1280
        int tann = 0; // current index in tanns array
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1281
        int itann = 0; // current index in itanns array
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1282
        int ntoff = -1; // next visible type annotation code offset
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1283
        int nitoff = -1; // next invisible type annotation code offset
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1284
        int varTable = 0;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1285
        int varTypeTable = 0;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1286
        boolean zip = true;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1287
        boolean unzip = (context.flags & EXPAND_FRAMES) != 0;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1288
        int stackMap = 0;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1289
        int stackMapSize = 0;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1290
        int frameCount = 0;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1291
        Context frame = null;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1292
        Attribute attributes = null;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1293
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1294
        for (int i = readUnsignedShort(u); i > 0; --i) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1295
            String attrName = readUTF8(u + 2, c);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1296
            if ("LocalVariableTable".equals(attrName)) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1297
                if ((context.flags & SKIP_DEBUG) == 0) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1298
                    varTable = u + 8;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1299
                    for (int j = readUnsignedShort(u + 8), v = u; j > 0; --j) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1300
                        int label = readUnsignedShort(v + 10);
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1301
                        createDebugLabel(label, labels);
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1302
                        label += readUnsignedShort(v + 12);
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1303
                        createDebugLabel(label, labels);
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1304
                        v += 10;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1305
                    }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1306
                }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1307
            } else if ("LocalVariableTypeTable".equals(attrName)) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1308
                varTypeTable = u + 8;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1309
            } else if ("LineNumberTable".equals(attrName)) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1310
                if ((context.flags & SKIP_DEBUG) == 0) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1311
                    for (int j = readUnsignedShort(u + 8), v = u; j > 0; --j) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1312
                        int label = readUnsignedShort(v + 10);
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1313
                        createDebugLabel(label, labels);
36635
f0147be2f50f 8147755: ASM should create correct constant tag for invokestatic on handle point to interface static method
ksrini
parents: 27195
diff changeset
  1314
                        Label l = labels[label];
f0147be2f50f 8147755: ASM should create correct constant tag for invokestatic on handle point to interface static method
ksrini
parents: 27195
diff changeset
  1315
                        while (l.line > 0) {
f0147be2f50f 8147755: ASM should create correct constant tag for invokestatic on handle point to interface static method
ksrini
parents: 27195
diff changeset
  1316
                            if (l.next == null) {
f0147be2f50f 8147755: ASM should create correct constant tag for invokestatic on handle point to interface static method
ksrini
parents: 27195
diff changeset
  1317
                                l.next = new Label();
f0147be2f50f 8147755: ASM should create correct constant tag for invokestatic on handle point to interface static method
ksrini
parents: 27195
diff changeset
  1318
                            }
f0147be2f50f 8147755: ASM should create correct constant tag for invokestatic on handle point to interface static method
ksrini
parents: 27195
diff changeset
  1319
                            l = l.next;
f0147be2f50f 8147755: ASM should create correct constant tag for invokestatic on handle point to interface static method
ksrini
parents: 27195
diff changeset
  1320
                        }
f0147be2f50f 8147755: ASM should create correct constant tag for invokestatic on handle point to interface static method
ksrini
parents: 27195
diff changeset
  1321
                        l.line = readUnsignedShort(v + 12);
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1322
                        v += 4;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1323
                    }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1324
                }
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1325
            } else if ("RuntimeVisibleTypeAnnotations".equals(attrName)) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1326
                tanns = readTypeAnnotations(mv, context, u + 8, true);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1327
                ntoff = tanns.length == 0 || readByte(tanns[0]) < 0x43 ? -1
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1328
                        : readUnsignedShort(tanns[0] + 1);
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1329
            } else if ("RuntimeInvisibleTypeAnnotations".equals(attrName)) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1330
                itanns = readTypeAnnotations(mv, context, u + 8, false);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1331
                nitoff = itanns.length == 0 || readByte(itanns[0]) < 0x43 ? -1
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1332
                        : readUnsignedShort(itanns[0] + 1);
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1333
            } else if ("StackMapTable".equals(attrName)) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1334
                if ((context.flags & SKIP_FRAMES) == 0) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1335
                    stackMap = u + 10;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1336
                    stackMapSize = readInt(u + 4);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1337
                    frameCount = readUnsignedShort(u + 8);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1338
                }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1339
                /*
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1340
                 * here we do not extract the labels corresponding to the
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1341
                 * attribute content. This would require a full parsing of the
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1342
                 * attribute, which would need to be repeated in the second
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1343
                 * phase (see below). Instead the content of the attribute is
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1344
                 * read one frame at a time (i.e. after a frame has been
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1345
                 * visited, the next frame is read), and the labels it contains
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1346
                 * are also extracted one frame at a time. Thanks to the
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1347
                 * ordering of frames, having only a "one frame lookahead" is
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1348
                 * not a problem, i.e. it is not possible to see an offset
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1349
                 * smaller than the offset of the current insn and for which no
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1350
                 * Label exist.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1351
                 */
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1352
                /*
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1353
                 * This is not true for UNINITIALIZED type offsets. We solve
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1354
                 * this by parsing the stack map table without a full decoding
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1355
                 * (see below).
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1356
                 */
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1357
            } else if ("StackMap".equals(attrName)) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1358
                if ((context.flags & SKIP_FRAMES) == 0) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1359
                    zip = false;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1360
                    stackMap = u + 10;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1361
                    stackMapSize = readInt(u + 4);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1362
                    frameCount = readUnsignedShort(u + 8);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1363
                }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1364
                /*
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1365
                 * IMPORTANT! here we assume that the frames are ordered, as in
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1366
                 * the StackMapTable attribute, although this is not guaranteed
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1367
                 * by the attribute format.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1368
                 */
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1369
            } else {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1370
                for (int j = 0; j < context.attrs.length; ++j) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1371
                    if (context.attrs[j].type.equals(attrName)) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1372
                        Attribute attr = context.attrs[j].read(this, u + 8,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1373
                                readInt(u + 4), c, codeStart - 8, labels);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1374
                        if (attr != null) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1375
                            attr.next = attributes;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1376
                            attributes = attr;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1377
                        }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1378
                    }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1379
                }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1380
            }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1381
            u += 6 + readInt(u + 4);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1382
        }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1383
        u += 2;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1384
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1385
        // generates the first (implicit) stack map frame
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1386
        if (stackMap != 0) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1387
            /*
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1388
             * for the first explicit frame the offset is not offset_delta + 1
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1389
             * but only offset_delta; setting the implicit frame offset to -1
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1390
             * allow the use of the "offset_delta + 1" rule in all cases
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1391
             */
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1392
            frame = context;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1393
            frame.offset = -1;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1394
            frame.mode = 0;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1395
            frame.localCount = 0;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1396
            frame.localDiff = 0;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1397
            frame.stackCount = 0;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1398
            frame.local = new Object[maxLocals];
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1399
            frame.stack = new Object[maxStack];
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1400
            if (unzip) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1401
                getImplicitFrame(context);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1402
            }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1403
            /*
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1404
             * Finds labels for UNINITIALIZED frame types. Instead of decoding
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1405
             * each element of the stack map table, we look for 3 consecutive
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1406
             * bytes that "look like" an UNINITIALIZED type (tag 8, offset
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1407
             * within code bounds, NEW instruction at this offset). We may find
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1408
             * false positives (i.e. not real UNINITIALIZED types), but this
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1409
             * should be rare, and the only consequence will be the creation of
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1410
             * an unneeded label. This is better than creating a label for each
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1411
             * NEW instruction, and faster than fully decoding the whole stack
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1412
             * map table.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1413
             */
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1414
            for (int i = stackMap; i < stackMap + stackMapSize - 2; ++i) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1415
                if (b[i] == 8) { // UNINITIALIZED FRAME TYPE
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1416
                    int v = readUnsignedShort(i + 1);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1417
                    if (v >= 0 && v < codeLength) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1418
                        if ((b[codeStart + v] & 0xFF) == Opcodes.NEW) {
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1419
                            createLabel(v, labels);
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1420
                        }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1421
                    }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1422
                }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1423
            }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1424
        }
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1425
        if ((context.flags & EXPAND_ASM_INSNS) != 0
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1426
            && (context.flags & EXPAND_FRAMES) != 0) {
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1427
            // Expanding the ASM pseudo instructions can introduce F_INSERT
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1428
            // frames, even if the method does not currently have any frame.
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1429
            // Also these inserted frames must be computed by simulating the
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1430
            // effect of the bytecode instructions one by one, starting from the
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1431
            // first one and the last existing frame (or the implicit first
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1432
            // one). Finally, due to the way MethodWriter computes this (with
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1433
            // the compute = INSERTED_FRAMES option), MethodWriter needs to know
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1434
            // maxLocals before the first instruction is visited. For all these
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1435
            // reasons we always visit the implicit first frame in this case
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1436
            // (passing only maxLocals - the rest can be and is computed in
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1437
            // MethodWriter).
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1438
            mv.visitFrame(Opcodes.F_NEW, maxLocals, null, 0, null);
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1439
        }
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1440
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1441
        // visits the instructions
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1442
        int opcodeDelta = (context.flags & EXPAND_ASM_INSNS) == 0 ? -33 : 0;
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1443
        boolean insertFrame = false;
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1444
        u = codeStart;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1445
        while (u < codeEnd) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1446
            int offset = u - codeStart;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1447
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1448
            // visits the label and line number for this offset, if any
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1449
            Label l = labels[offset];
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1450
            if (l != null) {
36635
f0147be2f50f 8147755: ASM should create correct constant tag for invokestatic on handle point to interface static method
ksrini
parents: 27195
diff changeset
  1451
                Label next = l.next;
f0147be2f50f 8147755: ASM should create correct constant tag for invokestatic on handle point to interface static method
ksrini
parents: 27195
diff changeset
  1452
                l.next = null;
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1453
                mv.visitLabel(l);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1454
                if ((context.flags & SKIP_DEBUG) == 0 && l.line > 0) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1455
                    mv.visitLineNumber(l.line, l);
36635
f0147be2f50f 8147755: ASM should create correct constant tag for invokestatic on handle point to interface static method
ksrini
parents: 27195
diff changeset
  1456
                    while (next != null) {
f0147be2f50f 8147755: ASM should create correct constant tag for invokestatic on handle point to interface static method
ksrini
parents: 27195
diff changeset
  1457
                        mv.visitLineNumber(next.line, l);
f0147be2f50f 8147755: ASM should create correct constant tag for invokestatic on handle point to interface static method
ksrini
parents: 27195
diff changeset
  1458
                        next = next.next;
f0147be2f50f 8147755: ASM should create correct constant tag for invokestatic on handle point to interface static method
ksrini
parents: 27195
diff changeset
  1459
                    }
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1460
                }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1461
            }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1462
21617
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
  1463
            // visits the frame for this offset, if any
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1464
            while (frame != null
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1465
                    && (frame.offset == offset || frame.offset == -1)) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1466
                // if there is a frame for this offset, makes the visitor visit
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1467
                // it, and reads the next frame if there is one.
21617
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
  1468
                if (frame.offset != -1) {
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
  1469
                    if (!zip || unzip) {
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
  1470
                        mv.visitFrame(Opcodes.F_NEW, frame.localCount,
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
  1471
                                frame.local, frame.stackCount, frame.stack);
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
  1472
                    } else {
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
  1473
                        mv.visitFrame(frame.mode, frame.localDiff, frame.local,
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
  1474
                                frame.stackCount, frame.stack);
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
  1475
                    }
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1476
                    // if there is already a frame for this offset, there is no
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1477
                    // need to insert a new one.
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1478
                    insertFrame = false;
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1479
                }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1480
                if (frameCount > 0) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1481
                    stackMap = readFrame(stackMap, zip, unzip, frame);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1482
                    --frameCount;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1483
                } else {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1484
                    frame = null;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1485
                }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1486
            }
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1487
            // inserts a frame for this offset, if requested by setting
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1488
            // insertFrame to true during the previous iteration. The actual
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1489
            // frame content will be computed in MethodWriter.
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1490
            if (insertFrame) {
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1491
                mv.visitFrame(ClassWriter.F_INSERT, 0, null, 0, null);
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1492
                insertFrame = false;
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1493
            }
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1494
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1495
            // visits the instruction at this offset
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1496
            int opcode = b[u] & 0xFF;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1497
            switch (ClassWriter.TYPE[opcode]) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1498
            case ClassWriter.NOARG_INSN:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1499
                mv.visitInsn(opcode);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1500
                u += 1;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1501
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1502
            case ClassWriter.IMPLVAR_INSN:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1503
                if (opcode > Opcodes.ISTORE) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1504
                    opcode -= 59; // ISTORE_0
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1505
                    mv.visitVarInsn(Opcodes.ISTORE + (opcode >> 2),
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1506
                            opcode & 0x3);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1507
                } else {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1508
                    opcode -= 26; // ILOAD_0
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1509
                    mv.visitVarInsn(Opcodes.ILOAD + (opcode >> 2), opcode & 0x3);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1510
                }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1511
                u += 1;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1512
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1513
            case ClassWriter.LABEL_INSN:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1514
                mv.visitJumpInsn(opcode, labels[offset + readShort(u + 1)]);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1515
                u += 3;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1516
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1517
            case ClassWriter.LABELW_INSN:
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1518
                mv.visitJumpInsn(opcode + opcodeDelta, labels[offset
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1519
                        + readInt(u + 1)]);
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1520
                u += 5;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1521
                break;
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1522
            case ClassWriter.ASM_LABEL_INSN: {
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1523
                // changes temporary opcodes 202 to 217 (inclusive), 218
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1524
                // and 219 to IFEQ ... JSR (inclusive), IFNULL and
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1525
                // IFNONNULL
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1526
                opcode = opcode < 218 ? opcode - 49 : opcode - 20;
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1527
                Label target = labels[offset + readUnsignedShort(u + 1)];
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1528
                // replaces GOTO with GOTO_W, JSR with JSR_W and IFxxx
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1529
                // <l> with IFNOTxxx <L> GOTO_W <l> L:..., where IFNOTxxx is
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1530
                // the "opposite" opcode of IFxxx (i.e., IFNE for IFEQ)
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1531
                // and where <L> designates the instruction just after
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1532
                // the GOTO_W.
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1533
                if (opcode == Opcodes.GOTO || opcode == Opcodes.JSR) {
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1534
                    mv.visitJumpInsn(opcode + 33, target);
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1535
                } else {
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1536
                    opcode = opcode <= 166 ? ((opcode + 1) ^ 1) - 1
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1537
                            : opcode ^ 1;
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1538
                    Label endif = createLabel(offset + 3, labels);
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1539
                    mv.visitJumpInsn(opcode, endif);
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1540
                    mv.visitJumpInsn(200, target); // GOTO_W
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1541
                    // endif designates the instruction just after GOTO_W,
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1542
                    // and is visited as part of the next instruction. Since
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1543
                    // it is a jump target, we need to insert a frame here.
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1544
                    insertFrame = true;
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1545
                }
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1546
                u += 3;
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1547
                break;
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1548
            }
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1549
            case ClassWriter.ASM_LABELW_INSN: {
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1550
                // replaces the pseudo GOTO_W instruction with a real one.
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1551
                mv.visitJumpInsn(200, labels[offset + readInt(u + 1)]);
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1552
                // The instruction just after is a jump target (because pseudo
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1553
                // GOTO_W are used in patterns IFNOTxxx <L> GOTO_W <l> L:...,
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1554
                // see MethodWriter), so we need to insert a frame here.
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1555
                insertFrame = true;
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1556
                u += 5;
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1557
                break;
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1558
            }
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1559
            case ClassWriter.WIDE_INSN:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1560
                opcode = b[u + 1] & 0xFF;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1561
                if (opcode == Opcodes.IINC) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1562
                    mv.visitIincInsn(readUnsignedShort(u + 2), readShort(u + 4));
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1563
                    u += 6;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1564
                } else {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1565
                    mv.visitVarInsn(opcode, readUnsignedShort(u + 2));
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1566
                    u += 4;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1567
                }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1568
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1569
            case ClassWriter.TABL_INSN: {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1570
                // skips 0 to 3 padding bytes
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1571
                u = u + 4 - (offset & 3);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1572
                // reads instruction
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1573
                int label = offset + readInt(u);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1574
                int min = readInt(u + 4);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1575
                int max = readInt(u + 8);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1576
                Label[] table = new Label[max - min + 1];
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1577
                u += 12;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1578
                for (int i = 0; i < table.length; ++i) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1579
                    table[i] = labels[offset + readInt(u)];
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1580
                    u += 4;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1581
                }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1582
                mv.visitTableSwitchInsn(min, max, labels[label], table);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1583
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1584
            }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1585
            case ClassWriter.LOOK_INSN: {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1586
                // skips 0 to 3 padding bytes
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1587
                u = u + 4 - (offset & 3);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1588
                // reads instruction
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1589
                int label = offset + readInt(u);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1590
                int len = readInt(u + 4);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1591
                int[] keys = new int[len];
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1592
                Label[] values = new Label[len];
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1593
                u += 8;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1594
                for (int i = 0; i < len; ++i) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1595
                    keys[i] = readInt(u);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1596
                    values[i] = labels[offset + readInt(u + 4)];
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1597
                    u += 8;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1598
                }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1599
                mv.visitLookupSwitchInsn(labels[label], keys, values);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1600
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1601
            }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1602
            case ClassWriter.VAR_INSN:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1603
                mv.visitVarInsn(opcode, b[u + 1] & 0xFF);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1604
                u += 2;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1605
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1606
            case ClassWriter.SBYTE_INSN:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1607
                mv.visitIntInsn(opcode, b[u + 1]);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1608
                u += 2;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1609
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1610
            case ClassWriter.SHORT_INSN:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1611
                mv.visitIntInsn(opcode, readShort(u + 1));
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1612
                u += 3;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1613
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1614
            case ClassWriter.LDC_INSN:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1615
                mv.visitLdcInsn(readConst(b[u + 1] & 0xFF, c));
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1616
                u += 2;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1617
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1618
            case ClassWriter.LDCW_INSN:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1619
                mv.visitLdcInsn(readConst(readUnsignedShort(u + 1), c));
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1620
                u += 3;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1621
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1622
            case ClassWriter.FIELDORMETH_INSN:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1623
            case ClassWriter.ITFMETH_INSN: {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1624
                int cpIndex = items[readUnsignedShort(u + 1)];
21617
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
  1625
                boolean itf = b[cpIndex - 1] == ClassWriter.IMETH;
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1626
                String iowner = readClass(cpIndex, c);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1627
                cpIndex = items[readUnsignedShort(cpIndex + 2)];
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1628
                String iname = readUTF8(cpIndex, c);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1629
                String idesc = readUTF8(cpIndex + 2, c);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1630
                if (opcode < Opcodes.INVOKEVIRTUAL) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1631
                    mv.visitFieldInsn(opcode, iowner, iname, idesc);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1632
                } else {
21617
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
  1633
                    mv.visitMethodInsn(opcode, iowner, iname, idesc, itf);
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1634
                }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1635
                if (opcode == Opcodes.INVOKEINTERFACE) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1636
                    u += 5;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1637
                } else {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1638
                    u += 3;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1639
                }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1640
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1641
            }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1642
            case ClassWriter.INDYMETH_INSN: {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1643
                int cpIndex = items[readUnsignedShort(u + 1)];
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1644
                int bsmIndex = context.bootstrapMethods[readUnsignedShort(cpIndex)];
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1645
                Handle bsm = (Handle) readConst(readUnsignedShort(bsmIndex), c);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1646
                int bsmArgCount = readUnsignedShort(bsmIndex + 2);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1647
                Object[] bsmArgs = new Object[bsmArgCount];
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1648
                bsmIndex += 4;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1649
                for (int i = 0; i < bsmArgCount; i++) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1650
                    bsmArgs[i] = readConst(readUnsignedShort(bsmIndex), c);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1651
                    bsmIndex += 2;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1652
                }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1653
                cpIndex = items[readUnsignedShort(cpIndex + 2)];
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1654
                String iname = readUTF8(cpIndex, c);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1655
                String idesc = readUTF8(cpIndex + 2, c);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1656
                mv.visitInvokeDynamicInsn(iname, idesc, bsm, bsmArgs);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1657
                u += 5;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1658
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1659
            }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1660
            case ClassWriter.TYPE_INSN:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1661
                mv.visitTypeInsn(opcode, readClass(u + 1, c));
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1662
                u += 3;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1663
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1664
            case ClassWriter.IINC_INSN:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1665
                mv.visitIincInsn(b[u + 1] & 0xFF, b[u + 2]);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1666
                u += 3;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1667
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1668
            // case MANA_INSN:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1669
            default:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1670
                mv.visitMultiANewArrayInsn(readClass(u + 1, c), b[u + 3] & 0xFF);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1671
                u += 4;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1672
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1673
            }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1674
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1675
            // visit the instruction annotations, if any
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1676
            while (tanns != null && tann < tanns.length && ntoff <= offset) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1677
                if (ntoff == offset) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1678
                    int v = readAnnotationTarget(context, tanns[tann]);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1679
                    readAnnotationValues(v + 2, c, true,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1680
                            mv.visitInsnAnnotation(context.typeRef,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1681
                                    context.typePath, readUTF8(v, c), true));
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1682
                }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1683
                ntoff = ++tann >= tanns.length || readByte(tanns[tann]) < 0x43 ? -1
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1684
                        : readUnsignedShort(tanns[tann] + 1);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1685
            }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1686
            while (itanns != null && itann < itanns.length && nitoff <= offset) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1687
                if (nitoff == offset) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1688
                    int v = readAnnotationTarget(context, itanns[itann]);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1689
                    readAnnotationValues(v + 2, c, true,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1690
                            mv.visitInsnAnnotation(context.typeRef,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1691
                                    context.typePath, readUTF8(v, c), false));
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1692
                }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1693
                nitoff = ++itann >= itanns.length
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1694
                        || readByte(itanns[itann]) < 0x43 ? -1
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1695
                        : readUnsignedShort(itanns[itann] + 1);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1696
            }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1697
        }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1698
        if (labels[codeLength] != null) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1699
            mv.visitLabel(labels[codeLength]);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1700
        }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1701
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1702
        // visits the local variable tables
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1703
        if ((context.flags & SKIP_DEBUG) == 0 && varTable != 0) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1704
            int[] typeTable = null;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1705
            if (varTypeTable != 0) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1706
                u = varTypeTable + 2;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1707
                typeTable = new int[readUnsignedShort(varTypeTable) * 3];
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1708
                for (int i = typeTable.length; i > 0;) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1709
                    typeTable[--i] = u + 6; // signature
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1710
                    typeTable[--i] = readUnsignedShort(u + 8); // index
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1711
                    typeTable[--i] = readUnsignedShort(u); // start
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1712
                    u += 10;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1713
                }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1714
            }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1715
            u = varTable + 2;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1716
            for (int i = readUnsignedShort(varTable); i > 0; --i) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1717
                int start = readUnsignedShort(u);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1718
                int length = readUnsignedShort(u + 2);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1719
                int index = readUnsignedShort(u + 8);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1720
                String vsignature = null;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1721
                if (typeTable != null) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1722
                    for (int j = 0; j < typeTable.length; j += 3) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1723
                        if (typeTable[j] == start && typeTable[j + 1] == index) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1724
                            vsignature = readUTF8(typeTable[j + 2], c);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1725
                            break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1726
                        }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1727
                    }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1728
                }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1729
                mv.visitLocalVariable(readUTF8(u + 4, c), readUTF8(u + 6, c),
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1730
                        vsignature, labels[start], labels[start + length],
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1731
                        index);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1732
                u += 10;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1733
            }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1734
        }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1735
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1736
        // visits the local variables type annotations
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1737
        if (tanns != null) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1738
            for (int i = 0; i < tanns.length; ++i) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1739
                if ((readByte(tanns[i]) >> 1) == (0x40 >> 1)) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1740
                    int v = readAnnotationTarget(context, tanns[i]);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1741
                    v = readAnnotationValues(v + 2, c, true,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1742
                            mv.visitLocalVariableAnnotation(context.typeRef,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1743
                                    context.typePath, context.start,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1744
                                    context.end, context.index, readUTF8(v, c),
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1745
                                    true));
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1746
                }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1747
            }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1748
        }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1749
        if (itanns != null) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1750
            for (int i = 0; i < itanns.length; ++i) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1751
                if ((readByte(itanns[i]) >> 1) == (0x40 >> 1)) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1752
                    int v = readAnnotationTarget(context, itanns[i]);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1753
                    v = readAnnotationValues(v + 2, c, true,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1754
                            mv.visitLocalVariableAnnotation(context.typeRef,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1755
                                    context.typePath, context.start,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1756
                                    context.end, context.index, readUTF8(v, c),
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1757
                                    false));
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1758
                }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1759
            }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1760
        }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1761
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1762
        // visits the code attributes
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1763
        while (attributes != null) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1764
            Attribute attr = attributes.next;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1765
            attributes.next = null;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1766
            mv.visitAttribute(attributes);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1767
            attributes = attr;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1768
        }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1769
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1770
        // visits the max stack and max locals values
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1771
        mv.visitMaxs(maxStack, maxLocals);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1772
    }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1773
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1774
    /**
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1775
     * Parses a type annotation table to find the labels, and to visit the try
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1776
     * catch block annotations.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1777
     *
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1778
     * @param u
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1779
     *            the start offset of a type annotation table.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1780
     * @param mv
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1781
     *            the method visitor to be used to visit the try catch block
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1782
     *            annotations.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1783
     * @param context
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1784
     *            information about the class being parsed.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1785
     * @param visible
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1786
     *            if the type annotation table to parse contains runtime visible
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1787
     *            annotations.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1788
     * @return the start offset of each type annotation in the parsed table.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1789
     */
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1790
    private int[] readTypeAnnotations(final MethodVisitor mv,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1791
            final Context context, int u, boolean visible) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1792
        char[] c = context.buffer;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1793
        int[] offsets = new int[readUnsignedShort(u)];
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1794
        u += 2;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1795
        for (int i = 0; i < offsets.length; ++i) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1796
            offsets[i] = u;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1797
            int target = readInt(u);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1798
            switch (target >>> 24) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1799
            case 0x00: // CLASS_TYPE_PARAMETER
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1800
            case 0x01: // METHOD_TYPE_PARAMETER
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1801
            case 0x16: // METHOD_FORMAL_PARAMETER
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1802
                u += 2;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1803
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1804
            case 0x13: // FIELD
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1805
            case 0x14: // METHOD_RETURN
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1806
            case 0x15: // METHOD_RECEIVER
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1807
                u += 1;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1808
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1809
            case 0x40: // LOCAL_VARIABLE
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1810
            case 0x41: // RESOURCE_VARIABLE
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1811
                for (int j = readUnsignedShort(u + 1); j > 0; --j) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1812
                    int start = readUnsignedShort(u + 3);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1813
                    int length = readUnsignedShort(u + 5);
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1814
                    createLabel(start, context.labels);
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1815
                    createLabel(start + length, context.labels);
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1816
                    u += 6;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1817
                }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1818
                u += 3;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1819
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1820
            case 0x47: // CAST
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1821
            case 0x48: // CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1822
            case 0x49: // METHOD_INVOCATION_TYPE_ARGUMENT
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1823
            case 0x4A: // CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1824
            case 0x4B: // METHOD_REFERENCE_TYPE_ARGUMENT
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1825
                u += 4;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1826
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1827
            // case 0x10: // CLASS_EXTENDS
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1828
            // case 0x11: // CLASS_TYPE_PARAMETER_BOUND
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1829
            // case 0x12: // METHOD_TYPE_PARAMETER_BOUND
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1830
            // case 0x17: // THROWS
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1831
            // case 0x42: // EXCEPTION_PARAMETER
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1832
            // case 0x43: // INSTANCEOF
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1833
            // case 0x44: // NEW
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1834
            // case 0x45: // CONSTRUCTOR_REFERENCE
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1835
            // case 0x46: // METHOD_REFERENCE
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1836
            default:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1837
                u += 3;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1838
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1839
            }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1840
            int pathLength = readByte(u);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1841
            if ((target >>> 24) == 0x42) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1842
                TypePath path = pathLength == 0 ? null : new TypePath(b, u);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1843
                u += 1 + 2 * pathLength;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1844
                u = readAnnotationValues(u + 2, c, true,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1845
                        mv.visitTryCatchAnnotation(target, path,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1846
                                readUTF8(u, c), visible));
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1847
            } else {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1848
                u = readAnnotationValues(u + 3 + 2 * pathLength, c, true, null);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1849
            }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1850
        }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1851
        return offsets;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1852
    }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1853
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1854
    /**
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1855
     * Parses the header of a type annotation to extract its target_type and
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1856
     * target_path (the result is stored in the given context), and returns the
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1857
     * start offset of the rest of the type_annotation structure (i.e. the
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1858
     * offset to the type_index field, which is followed by
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1859
     * num_element_value_pairs and then the name,value pairs).
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1860
     *
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1861
     * @param context
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1862
     *            information about the class being parsed. This is where the
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1863
     *            extracted target_type and target_path must be stored.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1864
     * @param u
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1865
     *            the start offset of a type_annotation structure.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1866
     * @return the start offset of the rest of the type_annotation structure.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1867
     */
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1868
    private int readAnnotationTarget(final Context context, int u) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1869
        int target = readInt(u);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1870
        switch (target >>> 24) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1871
        case 0x00: // CLASS_TYPE_PARAMETER
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1872
        case 0x01: // METHOD_TYPE_PARAMETER
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1873
        case 0x16: // METHOD_FORMAL_PARAMETER
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1874
            target &= 0xFFFF0000;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1875
            u += 2;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1876
            break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1877
        case 0x13: // FIELD
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1878
        case 0x14: // METHOD_RETURN
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1879
        case 0x15: // METHOD_RECEIVER
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1880
            target &= 0xFF000000;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1881
            u += 1;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1882
            break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1883
        case 0x40: // LOCAL_VARIABLE
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1884
        case 0x41: { // RESOURCE_VARIABLE
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1885
            target &= 0xFF000000;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1886
            int n = readUnsignedShort(u + 1);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1887
            context.start = new Label[n];
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1888
            context.end = new Label[n];
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1889
            context.index = new int[n];
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1890
            u += 3;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1891
            for (int i = 0; i < n; ++i) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1892
                int start = readUnsignedShort(u);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1893
                int length = readUnsignedShort(u + 2);
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1894
                context.start[i] = createLabel(start, context.labels);
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  1895
                context.end[i] = createLabel(start + length, context.labels);
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1896
                context.index[i] = readUnsignedShort(u + 4);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1897
                u += 6;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1898
            }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1899
            break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1900
        }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1901
        case 0x47: // CAST
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1902
        case 0x48: // CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1903
        case 0x49: // METHOD_INVOCATION_TYPE_ARGUMENT
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1904
        case 0x4A: // CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1905
        case 0x4B: // METHOD_REFERENCE_TYPE_ARGUMENT
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1906
            target &= 0xFF0000FF;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1907
            u += 4;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1908
            break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1909
        // case 0x10: // CLASS_EXTENDS
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1910
        // case 0x11: // CLASS_TYPE_PARAMETER_BOUND
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1911
        // case 0x12: // METHOD_TYPE_PARAMETER_BOUND
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1912
        // case 0x17: // THROWS
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1913
        // case 0x42: // EXCEPTION_PARAMETER
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1914
        // case 0x43: // INSTANCEOF
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1915
        // case 0x44: // NEW
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1916
        // case 0x45: // CONSTRUCTOR_REFERENCE
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1917
        // case 0x46: // METHOD_REFERENCE
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1918
        default:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1919
            target &= (target >>> 24) < 0x43 ? 0xFFFFFF00 : 0xFF000000;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1920
            u += 3;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1921
            break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1922
        }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1923
        int pathLength = readByte(u);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1924
        context.typeRef = target;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1925
        context.typePath = pathLength == 0 ? null : new TypePath(b, u);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1926
        return u + 1 + 2 * pathLength;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1927
    }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1928
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1929
    /**
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1930
     * Reads parameter annotations and makes the given visitor visit them.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1931
     *
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1932
     * @param mv
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1933
     *            the visitor that must visit the annotations.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1934
     * @param context
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1935
     *            information about the class being parsed.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1936
     * @param v
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1937
     *            start offset in {@link #b b} of the annotations to be read.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1938
     * @param visible
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1939
     *            <tt>true</tt> if the annotations to be read are visible at
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1940
     *            runtime.
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1941
     */
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1942
    private void readParameterAnnotations(final MethodVisitor mv,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1943
            final Context context, int v, final boolean visible) {
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1944
        int i;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1945
        int n = b[v++] & 0xFF;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1946
        // workaround for a bug in javac (javac compiler generates a parameter
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1947
        // annotation array whose size is equal to the number of parameters in
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1948
        // the Java source file, while it should generate an array whose size is
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1949
        // equal to the number of parameters in the method descriptor - which
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1950
        // includes the synthetic parameters added by the compiler). This work-
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1951
        // around supposes that the synthetic parameters are the first ones.
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1952
        int synthetics = Type.getArgumentTypes(context.desc).length - n;
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1953
        AnnotationVisitor av;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1954
        for (i = 0; i < synthetics; ++i) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1955
            // virtual annotation to detect synthetic parameters in MethodWriter
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1956
            av = mv.visitParameterAnnotation(i, "Ljava/lang/Synthetic;", false);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1957
            if (av != null) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1958
                av.visitEnd();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1959
            }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1960
        }
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1961
        char[] c = context.buffer;
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1962
        for (; i < n + synthetics; ++i) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1963
            int j = readUnsignedShort(v);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1964
            v += 2;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1965
            for (; j > 0; --j) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1966
                av = mv.visitParameterAnnotation(i, readUTF8(v, c), visible);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1967
                v = readAnnotationValues(v + 2, c, true, av);
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1968
            }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1969
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1970
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1971
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1972
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1973
     * Reads the values of an annotation and makes the given visitor visit them.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1974
     *
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1975
     * @param v
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1976
     *            the start offset in {@link #b b} of the values to be read
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1977
     *            (including the unsigned short that gives the number of
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1978
     *            values).
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1979
     * @param buf
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1980
     *            buffer to be used to call {@link #readUTF8 readUTF8},
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1981
     *            {@link #readClass(int,char[]) readClass} or {@link #readConst
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1982
     *            readConst}.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1983
     * @param named
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1984
     *            if the annotation values are named or not.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1985
     * @param av
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1986
     *            the visitor that must visit the values.
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1987
     * @return the end offset of the annotation values.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1988
     */
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1989
    private int readAnnotationValues(int v, final char[] buf,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1990
            final boolean named, final AnnotationVisitor av) {
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1991
        int i = readUnsignedShort(v);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1992
        v += 2;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1993
        if (named) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1994
            for (; i > 0; --i) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1995
                v = readAnnotationValue(v + 2, buf, readUTF8(v, buf), av);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1996
            }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1997
        } else {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1998
            for (; i > 0; --i) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1999
                v = readAnnotationValue(v, buf, null, av);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2000
            }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2001
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2002
        if (av != null) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2003
            av.visitEnd();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2004
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2005
        return v;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2006
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2007
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2008
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2009
     * Reads a value of an annotation and makes the given visitor visit it.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2010
     *
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2011
     * @param v
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2012
     *            the start offset in {@link #b b} of the value to be read
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2013
     *            (<i>not including the value name constant pool index</i>).
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2014
     * @param buf
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2015
     *            buffer to be used to call {@link #readUTF8 readUTF8},
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2016
     *            {@link #readClass(int,char[]) readClass} or {@link #readConst
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2017
     *            readConst}.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2018
     * @param name
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2019
     *            the name of the value to be read.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2020
     * @param av
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2021
     *            the visitor that must visit the value.
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2022
     * @return the end offset of the annotation value.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2023
     */
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2024
    private int readAnnotationValue(int v, final char[] buf, final String name,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2025
            final AnnotationVisitor av) {
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2026
        int i;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2027
        if (av == null) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2028
            switch (b[v] & 0xFF) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2029
            case 'e': // enum_const_value
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2030
                return v + 5;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2031
            case '@': // annotation_value
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2032
                return readAnnotationValues(v + 3, buf, true, null);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2033
            case '[': // array_value
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2034
                return readAnnotationValues(v + 1, buf, false, null);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2035
            default:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2036
                return v + 3;
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2037
            }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2038
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2039
        switch (b[v++] & 0xFF) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2040
        case 'I': // pointer to CONSTANT_Integer
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2041
        case 'J': // pointer to CONSTANT_Long
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2042
        case 'F': // pointer to CONSTANT_Float
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2043
        case 'D': // pointer to CONSTANT_Double
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2044
            av.visit(name, readConst(readUnsignedShort(v), buf));
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2045
            v += 2;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2046
            break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2047
        case 'B': // pointer to CONSTANT_Byte
36635
f0147be2f50f 8147755: ASM should create correct constant tag for invokestatic on handle point to interface static method
ksrini
parents: 27195
diff changeset
  2048
            av.visit(name, (byte) readInt(items[readUnsignedShort(v)]));
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2049
            v += 2;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2050
            break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2051
        case 'Z': // pointer to CONSTANT_Boolean
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2052
            av.visit(name,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2053
                    readInt(items[readUnsignedShort(v)]) == 0 ? Boolean.FALSE
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2054
                            : Boolean.TRUE);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2055
            v += 2;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2056
            break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2057
        case 'S': // pointer to CONSTANT_Short
36635
f0147be2f50f 8147755: ASM should create correct constant tag for invokestatic on handle point to interface static method
ksrini
parents: 27195
diff changeset
  2058
            av.visit(name, (short) readInt(items[readUnsignedShort(v)]));
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2059
            v += 2;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2060
            break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2061
        case 'C': // pointer to CONSTANT_Char
36635
f0147be2f50f 8147755: ASM should create correct constant tag for invokestatic on handle point to interface static method
ksrini
parents: 27195
diff changeset
  2062
            av.visit(name, (char) readInt(items[readUnsignedShort(v)]));
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2063
            v += 2;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2064
            break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2065
        case 's': // pointer to CONSTANT_Utf8
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2066
            av.visit(name, readUTF8(v, buf));
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2067
            v += 2;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2068
            break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2069
        case 'e': // enum_const_value
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2070
            av.visitEnum(name, readUTF8(v, buf), readUTF8(v + 2, buf));
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2071
            v += 4;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2072
            break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2073
        case 'c': // class_info
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2074
            av.visit(name, Type.getType(readUTF8(v, buf)));
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2075
            v += 2;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2076
            break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2077
        case '@': // annotation_value
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2078
            v = readAnnotationValues(v + 2, buf, true,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2079
                    av.visitAnnotation(name, readUTF8(v, buf)));
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2080
            break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2081
        case '[': // array_value
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2082
            int size = readUnsignedShort(v);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2083
            v += 2;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2084
            if (size == 0) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2085
                return readAnnotationValues(v - 2, buf, false,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2086
                        av.visitArray(name));
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2087
            }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2088
            switch (this.b[v++] & 0xFF) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2089
            case 'B':
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2090
                byte[] bv = new byte[size];
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2091
                for (i = 0; i < size; i++) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2092
                    bv[i] = (byte) readInt(items[readUnsignedShort(v)]);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2093
                    v += 3;
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2094
                }
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2095
                av.visit(name, bv);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2096
                --v;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2097
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2098
            case 'Z':
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2099
                boolean[] zv = new boolean[size];
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2100
                for (i = 0; i < size; i++) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2101
                    zv[i] = readInt(items[readUnsignedShort(v)]) != 0;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2102
                    v += 3;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2103
                }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2104
                av.visit(name, zv);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2105
                --v;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2106
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2107
            case 'S':
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2108
                short[] sv = new short[size];
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2109
                for (i = 0; i < size; i++) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2110
                    sv[i] = (short) readInt(items[readUnsignedShort(v)]);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2111
                    v += 3;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2112
                }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2113
                av.visit(name, sv);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2114
                --v;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2115
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2116
            case 'C':
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2117
                char[] cv = new char[size];
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2118
                for (i = 0; i < size; i++) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2119
                    cv[i] = (char) readInt(items[readUnsignedShort(v)]);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2120
                    v += 3;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2121
                }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2122
                av.visit(name, cv);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2123
                --v;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2124
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2125
            case 'I':
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2126
                int[] iv = new int[size];
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2127
                for (i = 0; i < size; i++) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2128
                    iv[i] = readInt(items[readUnsignedShort(v)]);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2129
                    v += 3;
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2130
                }
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2131
                av.visit(name, iv);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2132
                --v;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2133
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2134
            case 'J':
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2135
                long[] lv = new long[size];
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2136
                for (i = 0; i < size; i++) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2137
                    lv[i] = readLong(items[readUnsignedShort(v)]);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2138
                    v += 3;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2139
                }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2140
                av.visit(name, lv);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2141
                --v;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2142
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2143
            case 'F':
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2144
                float[] fv = new float[size];
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2145
                for (i = 0; i < size; i++) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2146
                    fv[i] = Float
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2147
                            .intBitsToFloat(readInt(items[readUnsignedShort(v)]));
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2148
                    v += 3;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2149
                }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2150
                av.visit(name, fv);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2151
                --v;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2152
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2153
            case 'D':
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2154
                double[] dv = new double[size];
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2155
                for (i = 0; i < size; i++) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2156
                    dv[i] = Double
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2157
                            .longBitsToDouble(readLong(items[readUnsignedShort(v)]));
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2158
                    v += 3;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2159
                }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2160
                av.visit(name, dv);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2161
                --v;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2162
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2163
            default:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2164
                v = readAnnotationValues(v - 3, buf, false, av.visitArray(name));
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2165
            }
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2166
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2167
        return v;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2168
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2169
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2170
    /**
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2171
     * Computes the implicit frame of the method currently being parsed (as
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2172
     * defined in the given {@link Context}) and stores it in the given context.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2173
     *
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2174
     * @param frame
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2175
     *            information about the class being parsed.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2176
     */
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2177
    private void getImplicitFrame(final Context frame) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2178
        String desc = frame.desc;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2179
        Object[] locals = frame.local;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2180
        int local = 0;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2181
        if ((frame.access & Opcodes.ACC_STATIC) == 0) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2182
            if ("<init>".equals(frame.name)) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2183
                locals[local++] = Opcodes.UNINITIALIZED_THIS;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2184
            } else {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2185
                locals[local++] = readClass(header + 2, frame.buffer);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2186
            }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2187
        }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2188
        int i = 1;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2189
        loop: while (true) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2190
            int j = i;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2191
            switch (desc.charAt(i++)) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2192
            case 'Z':
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2193
            case 'C':
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2194
            case 'B':
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2195
            case 'S':
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2196
            case 'I':
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2197
                locals[local++] = Opcodes.INTEGER;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2198
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2199
            case 'F':
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2200
                locals[local++] = Opcodes.FLOAT;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2201
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2202
            case 'J':
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2203
                locals[local++] = Opcodes.LONG;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2204
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2205
            case 'D':
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2206
                locals[local++] = Opcodes.DOUBLE;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2207
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2208
            case '[':
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2209
                while (desc.charAt(i) == '[') {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2210
                    ++i;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2211
                }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2212
                if (desc.charAt(i) == 'L') {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2213
                    ++i;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2214
                    while (desc.charAt(i) != ';') {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2215
                        ++i;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2216
                    }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2217
                }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2218
                locals[local++] = desc.substring(j, ++i);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2219
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2220
            case 'L':
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2221
                while (desc.charAt(i) != ';') {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2222
                    ++i;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2223
                }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2224
                locals[local++] = desc.substring(j + 1, i++);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2225
                break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2226
            default:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2227
                break loop;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2228
            }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2229
        }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2230
        frame.localCount = local;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2231
    }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2232
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2233
    /**
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2234
     * Reads a stack map frame and stores the result in the given
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2235
     * {@link Context} object.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2236
     *
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2237
     * @param stackMap
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2238
     *            the start offset of a stack map frame in the class file.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2239
     * @param zip
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2240
     *            if the stack map frame at stackMap is compressed or not.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2241
     * @param unzip
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2242
     *            if the stack map frame must be uncompressed.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2243
     * @param frame
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2244
     *            where the parsed stack map frame must be stored.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2245
     * @return the offset of the first byte following the parsed frame.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2246
     */
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2247
    private int readFrame(int stackMap, boolean zip, boolean unzip,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2248
            Context frame) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2249
        char[] c = frame.buffer;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2250
        Label[] labels = frame.labels;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2251
        int tag;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2252
        int delta;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2253
        if (zip) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2254
            tag = b[stackMap++] & 0xFF;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2255
        } else {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2256
            tag = MethodWriter.FULL_FRAME;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2257
            frame.offset = -1;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2258
        }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2259
        frame.localDiff = 0;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2260
        if (tag < MethodWriter.SAME_LOCALS_1_STACK_ITEM_FRAME) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2261
            delta = tag;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2262
            frame.mode = Opcodes.F_SAME;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2263
            frame.stackCount = 0;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2264
        } else if (tag < MethodWriter.RESERVED) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2265
            delta = tag - MethodWriter.SAME_LOCALS_1_STACK_ITEM_FRAME;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2266
            stackMap = readFrameType(frame.stack, 0, stackMap, c, labels);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2267
            frame.mode = Opcodes.F_SAME1;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2268
            frame.stackCount = 1;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2269
        } else {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2270
            delta = readUnsignedShort(stackMap);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2271
            stackMap += 2;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2272
            if (tag == MethodWriter.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2273
                stackMap = readFrameType(frame.stack, 0, stackMap, c, labels);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2274
                frame.mode = Opcodes.F_SAME1;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2275
                frame.stackCount = 1;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2276
            } else if (tag >= MethodWriter.CHOP_FRAME
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2277
                    && tag < MethodWriter.SAME_FRAME_EXTENDED) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2278
                frame.mode = Opcodes.F_CHOP;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2279
                frame.localDiff = MethodWriter.SAME_FRAME_EXTENDED - tag;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2280
                frame.localCount -= frame.localDiff;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2281
                frame.stackCount = 0;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2282
            } else if (tag == MethodWriter.SAME_FRAME_EXTENDED) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2283
                frame.mode = Opcodes.F_SAME;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2284
                frame.stackCount = 0;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2285
            } else if (tag < MethodWriter.FULL_FRAME) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2286
                int local = unzip ? frame.localCount : 0;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2287
                for (int i = tag - MethodWriter.SAME_FRAME_EXTENDED; i > 0; i--) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2288
                    stackMap = readFrameType(frame.local, local++, stackMap, c,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2289
                            labels);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2290
                }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2291
                frame.mode = Opcodes.F_APPEND;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2292
                frame.localDiff = tag - MethodWriter.SAME_FRAME_EXTENDED;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2293
                frame.localCount += frame.localDiff;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2294
                frame.stackCount = 0;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2295
            } else { // if (tag == FULL_FRAME) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2296
                frame.mode = Opcodes.F_FULL;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2297
                int n = readUnsignedShort(stackMap);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2298
                stackMap += 2;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2299
                frame.localDiff = n;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2300
                frame.localCount = n;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2301
                for (int local = 0; n > 0; n--) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2302
                    stackMap = readFrameType(frame.local, local++, stackMap, c,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2303
                            labels);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2304
                }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2305
                n = readUnsignedShort(stackMap);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2306
                stackMap += 2;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2307
                frame.stackCount = n;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2308
                for (int stack = 0; n > 0; n--) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2309
                    stackMap = readFrameType(frame.stack, stack++, stackMap, c,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2310
                            labels);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2311
                }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2312
            }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2313
        }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2314
        frame.offset += delta + 1;
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2315
        createLabel(frame.offset, labels);
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2316
        return stackMap;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2317
    }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2318
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2319
    /**
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2320
     * Reads a stack map frame type and stores it at the given index in the
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2321
     * given array.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2322
     *
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2323
     * @param frame
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2324
     *            the array where the parsed type must be stored.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2325
     * @param index
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2326
     *            the index in 'frame' where the parsed type must be stored.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2327
     * @param v
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2328
     *            the start offset of the stack map frame type to read.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2329
     * @param buf
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2330
     *            a buffer to read strings.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2331
     * @param labels
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2332
     *            the labels of the method currently being parsed, indexed by
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2333
     *            their offset. If the parsed type is an Uninitialized type, a
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2334
     *            new label for the corresponding NEW instruction is stored in
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2335
     *            this array if it does not already exist.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2336
     * @return the offset of the first byte after the parsed type.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2337
     */
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2338
    private int readFrameType(final Object[] frame, final int index, int v,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2339
            final char[] buf, final Label[] labels) {
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2340
        int type = b[v++] & 0xFF;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2341
        switch (type) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2342
        case 0:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2343
            frame[index] = Opcodes.TOP;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2344
            break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2345
        case 1:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2346
            frame[index] = Opcodes.INTEGER;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2347
            break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2348
        case 2:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2349
            frame[index] = Opcodes.FLOAT;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2350
            break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2351
        case 3:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2352
            frame[index] = Opcodes.DOUBLE;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2353
            break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2354
        case 4:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2355
            frame[index] = Opcodes.LONG;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2356
            break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2357
        case 5:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2358
            frame[index] = Opcodes.NULL;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2359
            break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2360
        case 6:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2361
            frame[index] = Opcodes.UNINITIALIZED_THIS;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2362
            break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2363
        case 7: // Object
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2364
            frame[index] = readClass(v, buf);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2365
            v += 2;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2366
            break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2367
        default: // Uninitialized
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2368
            frame[index] = createLabel(readUnsignedShort(v), labels);
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2369
            v += 2;
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2370
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2371
        return v;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2372
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2373
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2374
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2375
     * Returns the label corresponding to the given offset. The default
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2376
     * implementation of this method creates a label for the given offset if it
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2377
     * has not been already created.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2378
     *
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2379
     * @param offset
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2380
     *            a bytecode offset in a method.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2381
     * @param labels
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2382
     *            the already created labels, indexed by their offset. If a
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2383
     *            label already exists for offset this method must not create a
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2384
     *            new one. Otherwise it must store the new label in this array.
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2385
     * @return a non null Label, which must be equal to labels[offset].
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2386
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2387
    protected Label readLabel(int offset, Label[] labels) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2388
        if (labels[offset] == null) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2389
            labels[offset] = new Label();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2390
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2391
        return labels[offset];
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2392
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2393
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2394
    /**
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2395
     * Creates a label without the Label.DEBUG flag set, for the given offset.
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2396
     * The label is created with a call to {@link #readLabel} and its
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2397
     * Label.DEBUG flag is cleared.
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2398
     *
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2399
     * @param offset
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2400
     *            a bytecode offset in a method.
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2401
     * @param labels
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2402
     *            the already created labels, indexed by their offset.
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2403
     * @return a Label without the Label.DEBUG flag set.
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2404
     */
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2405
    private Label createLabel(int offset, Label[] labels) {
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2406
      Label label = readLabel(offset, labels);
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2407
      label.status &= ~Label.DEBUG;
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2408
      return label;
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2409
    }
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2410
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2411
    /**
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2412
     * Creates a label with the Label.DEBUG flag set, if there is no already
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2413
     * existing label for the given offset (otherwise does nothing). The label
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2414
     * is created with a call to {@link #readLabel}.
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2415
     *
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2416
     * @param offset
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2417
     *            a bytecode offset in a method.
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2418
     * @param labels
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2419
     *            the already created labels, indexed by their offset.
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2420
     */
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2421
    private void createDebugLabel(int offset, Label[] labels) {
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2422
        if (labels[offset] == null) {
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2423
            readLabel(offset, labels).status |= Label.DEBUG;
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2424
        }
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2425
    }
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2426
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2427
    /**
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2428
     * Returns the start index of the attribute_info structure of this class.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2429
     *
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2430
     * @return the start index of the attribute_info structure of this class.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2431
     */
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2432
    private int getAttributes() {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2433
        // skips the header
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2434
        int u = header + 8 + readUnsignedShort(header + 6) * 2;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2435
        // skips fields and methods
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2436
        for (int i = readUnsignedShort(u); i > 0; --i) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2437
            for (int j = readUnsignedShort(u + 8); j > 0; --j) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2438
                u += 6 + readInt(u + 12);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2439
            }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2440
            u += 8;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2441
        }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2442
        u += 2;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2443
        for (int i = readUnsignedShort(u); i > 0; --i) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2444
            for (int j = readUnsignedShort(u + 8); j > 0; --j) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2445
                u += 6 + readInt(u + 12);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2446
            }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2447
            u += 8;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2448
        }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2449
        // the attribute_info structure starts just after the methods
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2450
        return u + 2;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2451
    }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2452
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2453
    /**
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2454
     * Reads an attribute in {@link #b b}.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2455
     *
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2456
     * @param attrs
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2457
     *            prototypes of the attributes that must be parsed during the
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2458
     *            visit of the class. Any attribute whose type is not equal to
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2459
     *            the type of one the prototypes is ignored (i.e. an empty
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2460
     *            {@link Attribute} instance is returned).
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2461
     * @param type
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2462
     *            the type of the attribute.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2463
     * @param off
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2464
     *            index of the first byte of the attribute's content in
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2465
     *            {@link #b b}. The 6 attribute header bytes, containing the
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2466
     *            type and the length of the attribute, are not taken into
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2467
     *            account here (they have already been read).
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2468
     * @param len
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2469
     *            the length of the attribute's content.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2470
     * @param buf
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2471
     *            buffer to be used to call {@link #readUTF8 readUTF8},
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2472
     *            {@link #readClass(int,char[]) readClass} or {@link #readConst
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2473
     *            readConst}.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2474
     * @param codeOff
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2475
     *            index of the first byte of code's attribute content in
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2476
     *            {@link #b b}, or -1 if the attribute to be read is not a code
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2477
     *            attribute. The 6 attribute header bytes, containing the type
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2478
     *            and the length of the attribute, are not taken into account
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2479
     *            here.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2480
     * @param labels
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2481
     *            the labels of the method's code, or <tt>null</tt> if the
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2482
     *            attribute to be read is not a code attribute.
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2483
     * @return the attribute that has been read, or <tt>null</tt> to skip this
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2484
     *         attribute.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2485
     */
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2486
    private Attribute readAttribute(final Attribute[] attrs, final String type,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2487
            final int off, final int len, final char[] buf, final int codeOff,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2488
            final Label[] labels) {
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2489
        for (int i = 0; i < attrs.length; ++i) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2490
            if (attrs[i].type.equals(type)) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2491
                return attrs[i].read(this, off, len, buf, codeOff, labels);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2492
            }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2493
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2494
        return new Attribute(type).read(this, off, len, null, -1, null);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2495
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2496
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2497
    // ------------------------------------------------------------------------
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2498
    // Utility methods: low level parsing
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2499
    // ------------------------------------------------------------------------
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2500
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2501
    /**
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2502
     * Returns the number of constant pool items in {@link #b b}.
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2503
     *
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2504
     * @return the number of constant pool items in {@link #b b}.
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2505
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2506
    public int getItemCount() {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2507
        return items.length;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2508
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2509
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2510
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2511
     * Returns the start index of the constant pool item in {@link #b b}, plus
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2512
     * one. <i>This method is intended for {@link Attribute} sub classes, and is
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2513
     * normally not needed by class generators or adapters.</i>
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2514
     *
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2515
     * @param item
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2516
     *            the index a constant pool item.
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2517
     * @return the start index of the constant pool item in {@link #b b}, plus
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2518
     *         one.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2519
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2520
    public int getItem(final int item) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2521
        return items[item];
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2522
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2523
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2524
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2525
     * Returns the maximum length of the strings contained in the constant pool
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2526
     * of the class.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2527
     *
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2528
     * @return the maximum length of the strings contained in the constant pool
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2529
     *         of the class.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2530
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2531
    public int getMaxStringLength() {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2532
        return maxStringLength;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2533
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2534
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2535
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2536
     * Reads a byte value in {@link #b b}. <i>This method is intended for
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2537
     * {@link Attribute} sub classes, and is normally not needed by class
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2538
     * generators or adapters.</i>
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2539
     *
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2540
     * @param index
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2541
     *            the start index of the value to be read in {@link #b b}.
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2542
     * @return the read value.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2543
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2544
    public int readByte(final int index) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2545
        return b[index] & 0xFF;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2546
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2547
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2548
    /**
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2549
     * Reads an unsigned short value in {@link #b b}. <i>This method is intended
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2550
     * for {@link Attribute} sub classes, and is normally not needed by class
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2551
     * generators or adapters.</i>
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2552
     *
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2553
     * @param index
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2554
     *            the start index of the value to be read in {@link #b b}.
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2555
     * @return the read value.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2556
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2557
    public int readUnsignedShort(final int index) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2558
        byte[] b = this.b;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2559
        return ((b[index] & 0xFF) << 8) | (b[index + 1] & 0xFF);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2560
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2561
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2562
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2563
     * Reads a signed short value in {@link #b b}. <i>This method is intended
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2564
     * for {@link Attribute} sub classes, and is normally not needed by class
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2565
     * generators or adapters.</i>
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2566
     *
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2567
     * @param index
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2568
     *            the start index of the value to be read in {@link #b b}.
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2569
     * @return the read value.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2570
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2571
    public short readShort(final int index) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2572
        byte[] b = this.b;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2573
        return (short) (((b[index] & 0xFF) << 8) | (b[index + 1] & 0xFF));
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2574
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2575
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2576
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2577
     * Reads a signed int value in {@link #b b}. <i>This method is intended for
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2578
     * {@link Attribute} sub classes, and is normally not needed by class
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2579
     * generators or adapters.</i>
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2580
     *
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2581
     * @param index
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2582
     *            the start index of the value to be read in {@link #b b}.
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2583
     * @return the read value.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2584
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2585
    public int readInt(final int index) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2586
        byte[] b = this.b;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2587
        return ((b[index] & 0xFF) << 24) | ((b[index + 1] & 0xFF) << 16)
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2588
                | ((b[index + 2] & 0xFF) << 8) | (b[index + 3] & 0xFF);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2589
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2590
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2591
    /**
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2592
     * Reads a signed long value in {@link #b b}. <i>This method is intended for
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2593
     * {@link Attribute} sub classes, and is normally not needed by class
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2594
     * generators or adapters.</i>
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2595
     *
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2596
     * @param index
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2597
     *            the start index of the value to be read in {@link #b b}.
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2598
     * @return the read value.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2599
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2600
    public long readLong(final int index) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2601
        long l1 = readInt(index);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2602
        long l0 = readInt(index + 4) & 0xFFFFFFFFL;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2603
        return (l1 << 32) | l0;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2604
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2605
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2606
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2607
     * Reads an UTF8 string constant pool item in {@link #b b}. <i>This method
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2608
     * is intended for {@link Attribute} sub classes, and is normally not needed
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2609
     * by class generators or adapters.</i>
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2610
     *
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2611
     * @param index
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2612
     *            the start index of an unsigned short value in {@link #b b},
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2613
     *            whose value is the index of an UTF8 constant pool item.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2614
     * @param buf
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2615
     *            buffer to be used to read the item. This buffer must be
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2616
     *            sufficiently large. It is not automatically resized.
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2617
     * @return the String corresponding to the specified UTF8 item.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2618
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2619
    public String readUTF8(int index, final char[] buf) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2620
        int item = readUnsignedShort(index);
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2621
        if (index == 0 || item == 0) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2622
            return null;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2623
        }
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2624
        String s = strings[item];
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2625
        if (s != null) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2626
            return s;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2627
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2628
        index = items[item];
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2629
        return strings[item] = readUTF(index + 2, readUnsignedShort(index), buf);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2630
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2631
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2632
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2633
     * Reads UTF8 string in {@link #b b}.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2634
     *
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2635
     * @param index
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2636
     *            start offset of the UTF8 string to be read.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2637
     * @param utfLen
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2638
     *            length of the UTF8 string to be read.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2639
     * @param buf
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2640
     *            buffer to be used to read the string. This buffer must be
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2641
     *            sufficiently large. It is not automatically resized.
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2642
     * @return the String corresponding to the specified UTF8 string.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2643
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2644
    private String readUTF(int index, final int utfLen, final char[] buf) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2645
        int endIndex = index + utfLen;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2646
        byte[] b = this.b;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2647
        int strLen = 0;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2648
        int c;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2649
        int st = 0;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2650
        char cc = 0;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2651
        while (index < endIndex) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2652
            c = b[index++];
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2653
            switch (st) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2654
            case 0:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2655
                c = c & 0xFF;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2656
                if (c < 0x80) { // 0xxxxxxx
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2657
                    buf[strLen++] = (char) c;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2658
                } else if (c < 0xE0 && c > 0xBF) { // 110x xxxx 10xx xxxx
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2659
                    cc = (char) (c & 0x1F);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2660
                    st = 1;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2661
                } else { // 1110 xxxx 10xx xxxx 10xx xxxx
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2662
                    cc = (char) (c & 0x0F);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2663
                    st = 2;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2664
                }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2665
                break;
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2666
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2667
            case 1: // byte 2 of 2-byte char or byte 3 of 3-byte char
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2668
                buf[strLen++] = (char) ((cc << 6) | (c & 0x3F));
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2669
                st = 0;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2670
                break;
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2671
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2672
            case 2: // byte 2 of 3-byte char
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2673
                cc = (char) ((cc << 6) | (c & 0x3F));
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2674
                st = 1;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2675
                break;
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2676
            }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2677
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2678
        return new String(buf, 0, strLen);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2679
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2680
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2681
    /**
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2682
     * Read a stringish constant item (CONSTANT_Class, CONSTANT_String,
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2683
     * CONSTANT_MethodType, CONSTANT_Module or CONSTANT_Package
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2684
     * @param index
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2685
     * @param buf
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2686
     * @return
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2687
     */
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2688
    private String readStringish(final int index, final char[] buf) {
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2689
        // computes the start index of the item in b
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2690
        // and reads the CONSTANT_Utf8 item designated by
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2691
        // the first two bytes of this item
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2692
        return readUTF8(items[readUnsignedShort(index)], buf);
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2693
    }
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2694
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2695
    /**
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2696
     * Reads a class constant pool item in {@link #b b}. <i>This method is
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2697
     * intended for {@link Attribute} sub classes, and is normally not needed by
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2698
     * class generators or adapters.</i>
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2699
     *
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2700
     * @param index
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2701
     *            the start index of an unsigned short value in {@link #b b},
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2702
     *            whose value is the index of a class constant pool item.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2703
     * @param buf
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2704
     *            buffer to be used to read the item. This buffer must be
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2705
     *            sufficiently large. It is not automatically resized.
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2706
     * @return the String corresponding to the specified class item.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2707
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2708
    public String readClass(final int index, final char[] buf) {
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2709
        return readStringish(index, buf);
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2710
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2711
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2712
    /**
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2713
     * Reads a module constant pool item in {@link #b b}. <i>This method is
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2714
     * intended for {@link Attribute} sub classes, and is normally not needed by
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2715
     * class generators or adapters.</i>
42703
20c39ea4a507 8170987: Module system implementation refresh (12/2016)
alanb
parents: 36636
diff changeset
  2716
     *
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2717
     * @param index
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2718
     *            the start index of an unsigned short value in {@link #b b},
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2719
     *            whose value is the index of a module constant pool item.
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2720
     * @param buf
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2721
     *            buffer to be used to read the item. This buffer must be
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2722
     *            sufficiently large. It is not automatically resized.
42703
20c39ea4a507 8170987: Module system implementation refresh (12/2016)
alanb
parents: 36636
diff changeset
  2723
     * @return the String corresponding to the specified module item.
20c39ea4a507 8170987: Module system implementation refresh (12/2016)
alanb
parents: 36636
diff changeset
  2724
     */
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2725
    public String readModule(final int index, final char[] buf) {
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2726
        return readStringish(index, buf);
42703
20c39ea4a507 8170987: Module system implementation refresh (12/2016)
alanb
parents: 36636
diff changeset
  2727
    }
20c39ea4a507 8170987: Module system implementation refresh (12/2016)
alanb
parents: 36636
diff changeset
  2728
20c39ea4a507 8170987: Module system implementation refresh (12/2016)
alanb
parents: 36636
diff changeset
  2729
    /**
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2730
     * Reads a module constant pool item in {@link #b b}. <i>This method is
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2731
     * intended for {@link Attribute} sub classes, and is normally not needed by
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2732
     * class generators or adapters.</i>
42703
20c39ea4a507 8170987: Module system implementation refresh (12/2016)
alanb
parents: 36636
diff changeset
  2733
     *
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2734
     * @param index
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2735
     *            the start index of an unsigned short value in {@link #b b},
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2736
     *            whose value is the index of a module constant pool item.
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2737
     * @param buf
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2738
     *            buffer to be used to read the item. This buffer must be
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2739
     *            sufficiently large. It is not automatically resized.
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2740
     * @return the String corresponding to the specified module item.
42703
20c39ea4a507 8170987: Module system implementation refresh (12/2016)
alanb
parents: 36636
diff changeset
  2741
     */
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2742
    public String readPackage(final int index, final char[] buf) {
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
  2743
        return readStringish(index, buf);
42703
20c39ea4a507 8170987: Module system implementation refresh (12/2016)
alanb
parents: 36636
diff changeset
  2744
    }
20c39ea4a507 8170987: Module system implementation refresh (12/2016)
alanb
parents: 36636
diff changeset
  2745
20c39ea4a507 8170987: Module system implementation refresh (12/2016)
alanb
parents: 36636
diff changeset
  2746
    /**
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2747
     * Reads a numeric or string constant pool item in {@link #b b}. <i>This
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2748
     * method is intended for {@link Attribute} sub classes, and is normally not
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2749
     * needed by class generators or adapters.</i>
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2750
     *
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2751
     * @param item
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2752
     *            the index of a constant pool item.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2753
     * @param buf
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2754
     *            buffer to be used to read the item. This buffer must be
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2755
     *            sufficiently large. It is not automatically resized.
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2756
     * @return the {@link Integer}, {@link Float}, {@link Long}, {@link Double},
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2757
     *         {@link String}, {@link Type} or {@link Handle} corresponding to
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2758
     *         the given constant pool item.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2759
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2760
    public Object readConst(final int item, final char[] buf) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2761
        int index = items[item];
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2762
        switch (b[index - 1]) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2763
        case ClassWriter.INT:
27195
b33768211561 8061830: [asm] refresh internal ASM version v5.0.3
ksrini
parents: 25859
diff changeset
  2764
            return readInt(index);
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2765
        case ClassWriter.FLOAT:
27195
b33768211561 8061830: [asm] refresh internal ASM version v5.0.3
ksrini
parents: 25859
diff changeset
  2766
            return Float.intBitsToFloat(readInt(index));
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2767
        case ClassWriter.LONG:
27195
b33768211561 8061830: [asm] refresh internal ASM version v5.0.3
ksrini
parents: 25859
diff changeset
  2768
            return readLong(index);
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2769
        case ClassWriter.DOUBLE:
27195
b33768211561 8061830: [asm] refresh internal ASM version v5.0.3
ksrini
parents: 25859
diff changeset
  2770
            return Double.longBitsToDouble(readLong(index));
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2771
        case ClassWriter.CLASS:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2772
            return Type.getObjectType(readUTF8(index, buf));
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2773
        case ClassWriter.STR:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2774
            return readUTF8(index, buf);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2775
        case ClassWriter.MTYPE:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2776
            return Type.getMethodType(readUTF8(index, buf));
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2777
        default: // case ClassWriter.HANDLE_BASE + [1..9]:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2778
            int tag = readByte(index);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2779
            int[] items = this.items;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2780
            int cpIndex = items[readUnsignedShort(index + 1)];
36635
f0147be2f50f 8147755: ASM should create correct constant tag for invokestatic on handle point to interface static method
ksrini
parents: 27195
diff changeset
  2781
            boolean itf = b[cpIndex - 1] == ClassWriter.IMETH;
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2782
            String owner = readClass(cpIndex, buf);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2783
            cpIndex = items[readUnsignedShort(cpIndex + 2)];
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2784
            String name = readUTF8(cpIndex, buf);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  2785
            String desc = readUTF8(cpIndex + 2, buf);
36635
f0147be2f50f 8147755: ASM should create correct constant tag for invokestatic on handle point to interface static method
ksrini
parents: 27195
diff changeset
  2786
            return new Handle(tag, owner, name, desc, itf);
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2787
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2788
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  2789
}