jdk/src/share/classes/jdk/internal/org/objectweb/asm/util/CheckMethodAdapter.java
author ksrini
Wed, 06 Nov 2013 11:22:15 -0800
changeset 21617 53b88e4ac6ed
parent 17420 6163a8236046
permissions -rw-r--r--
8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces Reviewed-by: ksrini, lagergren Contributed-by: ebruneton@free.fr, forax@univ-mlv.fr, 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.util;
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.PrintWriter;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    62
import java.io.StringWriter;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    63
import java.lang.reflect.Field;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    64
import java.util.ArrayList;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    65
import java.util.HashMap;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    66
import java.util.HashSet;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    67
import java.util.List;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    68
import java.util.Map;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    69
import java.util.Set;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    70
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    71
import jdk.internal.org.objectweb.asm.AnnotationVisitor;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    72
import jdk.internal.org.objectweb.asm.Attribute;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    73
import jdk.internal.org.objectweb.asm.Handle;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    74
import jdk.internal.org.objectweb.asm.Label;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    75
import jdk.internal.org.objectweb.asm.MethodVisitor;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    76
import jdk.internal.org.objectweb.asm.Opcodes;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    77
import jdk.internal.org.objectweb.asm.Type;
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
    78
import jdk.internal.org.objectweb.asm.TypePath;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
    79
import jdk.internal.org.objectweb.asm.TypeReference;
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    80
import jdk.internal.org.objectweb.asm.tree.MethodNode;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    81
import jdk.internal.org.objectweb.asm.tree.analysis.Analyzer;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    82
import jdk.internal.org.objectweb.asm.tree.analysis.BasicValue;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    83
import jdk.internal.org.objectweb.asm.tree.analysis.BasicVerifier;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    84
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    85
/**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    86
 * A {@link MethodVisitor} that checks that its methods are properly used. More
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    87
 * precisely this method adapter checks each instruction individually, i.e.,
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    88
 * each visit method checks some preconditions based <i>only</i> on its
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    89
 * arguments - such as the fact that the given opcode is correct for a given
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    90
 * visit method. This adapter can also perform some basic data flow checks (more
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    91
 * precisely those that can be performed without the full class hierarchy - see
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    92
 * {@link jdk.internal.org.objectweb.asm.tree.analysis.BasicVerifier}). For instance in a
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    93
 * method whose signature is <tt>void m ()</tt>, the invalid instruction
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    94
 * IRETURN, or the invalid sequence IADD L2I will be detected if the data flow
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    95
 * checks are enabled. These checks are enabled by using the
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    96
 * {@link #CheckMethodAdapter(int,String,String,MethodVisitor,Map)} constructor.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    97
 * They are not performed if any other constructor is used.
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
 * @author Eric Bruneton
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
public class CheckMethodAdapter extends MethodVisitor {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   102
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   103
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   104
     * The class version number.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   105
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   106
    public int version;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   107
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   108
    /**
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   109
     * The access flags of the method.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   110
     */
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   111
    private int access;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   112
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   113
    /**
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   114
     * <tt>true</tt> if the visitCode method has been called.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   115
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   116
    private boolean startCode;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   117
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   118
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   119
     * <tt>true</tt> if the visitMaxs method has been called.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   120
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   121
    private boolean endCode;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   122
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   123
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   124
     * <tt>true</tt> if the visitEnd method has been called.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   125
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   126
    private boolean endMethod;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   127
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   128
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   129
     * Number of visited instructions.
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
    private int insnCount;
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
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   134
     * The already visited labels. This map associate Integer values to pseudo
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   135
     * code offsets.
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 Map<Label, Integer> labels;
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 labels used in this method. Every used label must be visited with
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   141
     * visitLabel before the end of the method (i.e. should be in #labels).
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   142
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   143
    private Set<Label> usedLabels;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   144
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   145
    /**
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   146
     * Number of visited frames in expanded form.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   147
     */
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   148
    private int expandedFrames;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   149
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   150
    /**
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   151
     * Number of visited frames in compressed form.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   152
     */
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   153
    private int compressedFrames;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   154
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   155
    /**
21617
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
   156
     * Number of instructions before the last visited frame.
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
   157
     */
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
   158
    private int lastFrame = -1;
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
   159
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
   160
    /**
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   161
     * The exception handler ranges. Each pair of list element contains the
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   162
     * start and end labels of an exception handler block.
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
    private List<Label> handlers;
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
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   167
     * Code of the visit method to be used for each opcode.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   168
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   169
    private static final int[] TYPE;
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
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   172
     * The Label.status field.
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
    private static Field labelStatusField;
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
    static {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   177
        String s = "BBBBBBBBBBBBBBBBCCIAADDDDDAAAAAAAAAAAAAAAAAAAABBBBBBBBDD"
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   178
                + "DDDAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   179
                + "BBBBBBBBBBBBBBBBBBBJBBBBBBBBBBBBBBBBBBBBHHHHHHHHHHHHHHHHD"
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   180
                + "KLBBBBBBFFFFGGGGAECEBBEEBBAMHHAA";
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   181
        TYPE = new int[s.length()];
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   182
        for (int i = 0; i < TYPE.length; ++i) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   183
            TYPE[i] = s.charAt(i) - 'A' - 1;
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
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   186
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   187
    // code to generate the above string
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   188
    // public static void main (String[] args) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   189
    // int[] TYPE = new int[] {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   190
    // 0, //NOP
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   191
    // 0, //ACONST_NULL
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   192
    // 0, //ICONST_M1
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   193
    // 0, //ICONST_0
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   194
    // 0, //ICONST_1
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   195
    // 0, //ICONST_2
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   196
    // 0, //ICONST_3
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   197
    // 0, //ICONST_4
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   198
    // 0, //ICONST_5
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   199
    // 0, //LCONST_0
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   200
    // 0, //LCONST_1
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   201
    // 0, //FCONST_0
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   202
    // 0, //FCONST_1
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   203
    // 0, //FCONST_2
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   204
    // 0, //DCONST_0
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   205
    // 0, //DCONST_1
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   206
    // 1, //BIPUSH
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   207
    // 1, //SIPUSH
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   208
    // 7, //LDC
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   209
    // -1, //LDC_W
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   210
    // -1, //LDC2_W
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   211
    // 2, //ILOAD
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   212
    // 2, //LLOAD
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   213
    // 2, //FLOAD
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   214
    // 2, //DLOAD
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   215
    // 2, //ALOAD
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   216
    // -1, //ILOAD_0
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   217
    // -1, //ILOAD_1
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   218
    // -1, //ILOAD_2
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   219
    // -1, //ILOAD_3
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   220
    // -1, //LLOAD_0
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   221
    // -1, //LLOAD_1
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   222
    // -1, //LLOAD_2
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   223
    // -1, //LLOAD_3
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   224
    // -1, //FLOAD_0
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   225
    // -1, //FLOAD_1
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   226
    // -1, //FLOAD_2
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   227
    // -1, //FLOAD_3
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   228
    // -1, //DLOAD_0
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   229
    // -1, //DLOAD_1
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   230
    // -1, //DLOAD_2
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   231
    // -1, //DLOAD_3
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   232
    // -1, //ALOAD_0
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   233
    // -1, //ALOAD_1
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   234
    // -1, //ALOAD_2
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   235
    // -1, //ALOAD_3
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   236
    // 0, //IALOAD
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   237
    // 0, //LALOAD
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   238
    // 0, //FALOAD
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   239
    // 0, //DALOAD
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   240
    // 0, //AALOAD
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   241
    // 0, //BALOAD
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   242
    // 0, //CALOAD
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   243
    // 0, //SALOAD
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   244
    // 2, //ISTORE
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   245
    // 2, //LSTORE
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   246
    // 2, //FSTORE
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   247
    // 2, //DSTORE
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   248
    // 2, //ASTORE
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   249
    // -1, //ISTORE_0
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   250
    // -1, //ISTORE_1
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   251
    // -1, //ISTORE_2
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   252
    // -1, //ISTORE_3
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   253
    // -1, //LSTORE_0
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   254
    // -1, //LSTORE_1
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   255
    // -1, //LSTORE_2
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   256
    // -1, //LSTORE_3
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   257
    // -1, //FSTORE_0
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   258
    // -1, //FSTORE_1
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   259
    // -1, //FSTORE_2
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   260
    // -1, //FSTORE_3
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   261
    // -1, //DSTORE_0
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   262
    // -1, //DSTORE_1
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   263
    // -1, //DSTORE_2
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   264
    // -1, //DSTORE_3
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   265
    // -1, //ASTORE_0
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   266
    // -1, //ASTORE_1
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   267
    // -1, //ASTORE_2
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   268
    // -1, //ASTORE_3
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   269
    // 0, //IASTORE
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   270
    // 0, //LASTORE
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   271
    // 0, //FASTORE
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   272
    // 0, //DASTORE
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   273
    // 0, //AASTORE
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   274
    // 0, //BASTORE
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   275
    // 0, //CASTORE
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   276
    // 0, //SASTORE
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   277
    // 0, //POP
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   278
    // 0, //POP2
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   279
    // 0, //DUP
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   280
    // 0, //DUP_X1
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   281
    // 0, //DUP_X2
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   282
    // 0, //DUP2
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   283
    // 0, //DUP2_X1
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   284
    // 0, //DUP2_X2
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   285
    // 0, //SWAP
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   286
    // 0, //IADD
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   287
    // 0, //LADD
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   288
    // 0, //FADD
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   289
    // 0, //DADD
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   290
    // 0, //ISUB
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   291
    // 0, //LSUB
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   292
    // 0, //FSUB
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   293
    // 0, //DSUB
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   294
    // 0, //IMUL
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   295
    // 0, //LMUL
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   296
    // 0, //FMUL
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   297
    // 0, //DMUL
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   298
    // 0, //IDIV
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   299
    // 0, //LDIV
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   300
    // 0, //FDIV
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   301
    // 0, //DDIV
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   302
    // 0, //IREM
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   303
    // 0, //LREM
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   304
    // 0, //FREM
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   305
    // 0, //DREM
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   306
    // 0, //INEG
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   307
    // 0, //LNEG
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   308
    // 0, //FNEG
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   309
    // 0, //DNEG
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   310
    // 0, //ISHL
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   311
    // 0, //LSHL
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   312
    // 0, //ISHR
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   313
    // 0, //LSHR
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   314
    // 0, //IUSHR
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   315
    // 0, //LUSHR
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   316
    // 0, //IAND
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   317
    // 0, //LAND
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   318
    // 0, //IOR
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   319
    // 0, //LOR
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   320
    // 0, //IXOR
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   321
    // 0, //LXOR
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   322
    // 8, //IINC
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   323
    // 0, //I2L
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   324
    // 0, //I2F
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   325
    // 0, //I2D
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   326
    // 0, //L2I
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   327
    // 0, //L2F
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   328
    // 0, //L2D
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   329
    // 0, //F2I
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   330
    // 0, //F2L
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   331
    // 0, //F2D
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   332
    // 0, //D2I
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   333
    // 0, //D2L
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   334
    // 0, //D2F
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   335
    // 0, //I2B
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   336
    // 0, //I2C
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   337
    // 0, //I2S
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   338
    // 0, //LCMP
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   339
    // 0, //FCMPL
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   340
    // 0, //FCMPG
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   341
    // 0, //DCMPL
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   342
    // 0, //DCMPG
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   343
    // 6, //IFEQ
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   344
    // 6, //IFNE
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   345
    // 6, //IFLT
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   346
    // 6, //IFGE
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   347
    // 6, //IFGT
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   348
    // 6, //IFLE
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   349
    // 6, //IF_ICMPEQ
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   350
    // 6, //IF_ICMPNE
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   351
    // 6, //IF_ICMPLT
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   352
    // 6, //IF_ICMPGE
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   353
    // 6, //IF_ICMPGT
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   354
    // 6, //IF_ICMPLE
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   355
    // 6, //IF_ACMPEQ
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   356
    // 6, //IF_ACMPNE
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   357
    // 6, //GOTO
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   358
    // 6, //JSR
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   359
    // 2, //RET
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   360
    // 9, //TABLESWITCH
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   361
    // 10, //LOOKUPSWITCH
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   362
    // 0, //IRETURN
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   363
    // 0, //LRETURN
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   364
    // 0, //FRETURN
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   365
    // 0, //DRETURN
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   366
    // 0, //ARETURN
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   367
    // 0, //RETURN
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   368
    // 4, //GETSTATIC
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   369
    // 4, //PUTSTATIC
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   370
    // 4, //GETFIELD
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   371
    // 4, //PUTFIELD
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   372
    // 5, //INVOKEVIRTUAL
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   373
    // 5, //INVOKESPECIAL
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   374
    // 5, //INVOKESTATIC
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   375
    // 5, //INVOKEINTERFACE
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   376
    // -1, //INVOKEDYNAMIC
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   377
    // 3, //NEW
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   378
    // 1, //NEWARRAY
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   379
    // 3, //ANEWARRAY
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   380
    // 0, //ARRAYLENGTH
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   381
    // 0, //ATHROW
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   382
    // 3, //CHECKCAST
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   383
    // 3, //INSTANCEOF
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   384
    // 0, //MONITORENTER
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   385
    // 0, //MONITOREXIT
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   386
    // -1, //WIDE
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   387
    // 11, //MULTIANEWARRAY
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   388
    // 6, //IFNULL
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   389
    // 6, //IFNONNULL
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   390
    // -1, //GOTO_W
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   391
    // -1 //JSR_W
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   392
    // };
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   393
    // for (int i = 0; i < TYPE.length; ++i) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   394
    // System.out.print((char)(TYPE[i] + 1 + 'A'));
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   395
    // }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   396
    // System.out.println();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   397
    // }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   398
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   399
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   400
     * Constructs a new {@link CheckMethodAdapter} object. This method adapter
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   401
     * will not perform any data flow check (see
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   402
     * {@link #CheckMethodAdapter(int,String,String,MethodVisitor,Map)}).
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   403
     * <i>Subclasses must not use this constructor</i>. Instead, they must use
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   404
     * the {@link #CheckMethodAdapter(int, MethodVisitor, Map)} version.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   405
     *
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   406
     * @param mv
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   407
     *            the method visitor to which this adapter must delegate calls.
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   408
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   409
    public CheckMethodAdapter(final MethodVisitor mv) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   410
        this(mv, new HashMap<Label, Integer>());
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   411
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   412
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   413
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   414
     * Constructs a new {@link CheckMethodAdapter} object. This method adapter
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   415
     * will not perform any data flow check (see
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   416
     * {@link #CheckMethodAdapter(int,String,String,MethodVisitor,Map)}).
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   417
     * <i>Subclasses must not use this constructor</i>. Instead, they must use
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   418
     * the {@link #CheckMethodAdapter(int, MethodVisitor, Map)} version.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   419
     *
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   420
     * @param mv
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   421
     *            the method visitor to which this adapter must delegate calls.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   422
     * @param labels
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   423
     *            a map of already visited labels (in other methods).
21617
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
   424
     * @throws IllegalStateException
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
   425
     *             If a subclass calls this constructor.
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   426
     */
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   427
    public CheckMethodAdapter(final MethodVisitor mv,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   428
            final Map<Label, Integer> labels) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   429
        this(Opcodes.ASM5, mv, labels);
21617
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
   430
        if (getClass() != CheckMethodAdapter.class) {
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
   431
            throw new IllegalStateException();
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
   432
        }
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   433
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   434
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   435
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   436
     * Constructs a new {@link CheckMethodAdapter} object. This method adapter
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   437
     * will not perform any data flow check (see
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   438
     * {@link #CheckMethodAdapter(int,String,String,MethodVisitor,Map)}).
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   439
     *
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   440
     * @param mv
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   441
     *            the method visitor to which this adapter must delegate calls.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   442
     * @param labels
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   443
     *            a map of already visited labels (in other methods).
14198
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
    protected CheckMethodAdapter(final int api, final MethodVisitor mv,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   446
            final Map<Label, Integer> labels) {
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   447
        super(api, mv);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   448
        this.labels = labels;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   449
        this.usedLabels = new HashSet<Label>();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   450
        this.handlers = new ArrayList<Label>();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   451
    }
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
     * Constructs a new {@link CheckMethodAdapter} object. This method adapter
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   455
     * will perform basic data flow checks. For instance in a method whose
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   456
     * signature is <tt>void m ()</tt>, the invalid instruction IRETURN, or the
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   457
     * invalid sequence IADD L2I will be detected.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   458
     *
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   459
     * @param access
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   460
     *            the method's access flags.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   461
     * @param name
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   462
     *            the method's name.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   463
     * @param desc
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   464
     *            the method's descriptor (see {@link Type Type}).
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   465
     * @param cmv
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   466
     *            the method visitor to which this adapter must delegate calls.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   467
     * @param labels
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   468
     *            a map of already visited labels (in other methods).
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   469
     */
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   470
    public CheckMethodAdapter(final int access, final String name,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   471
            final String desc, final MethodVisitor cmv,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   472
            final Map<Label, Integer> labels) {
21617
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
   473
        this(new MethodNode(Opcodes.ASM5, access, name, desc, null, null) {
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   474
            @Override
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   475
            public void visitEnd() {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   476
                Analyzer<BasicValue> a = new Analyzer<BasicValue>(
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   477
                        new BasicVerifier());
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   478
                try {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   479
                    a.analyze("dummy", this);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   480
                } catch (Exception e) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   481
                    if (e instanceof IndexOutOfBoundsException
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   482
                            && maxLocals == 0 && maxStack == 0) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   483
                        throw new RuntimeException(
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   484
                                "Data flow checking option requires valid, non zero maxLocals and maxStack values.");
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   485
                    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   486
                    e.printStackTrace();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   487
                    StringWriter sw = new StringWriter();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   488
                    PrintWriter pw = new PrintWriter(sw, true);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   489
                    CheckClassAdapter.printAnalyzerResult(this, a, pw);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   490
                    pw.close();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   491
                    throw new RuntimeException(e.getMessage() + ' '
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   492
                            + sw.toString());
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   493
                }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   494
                accept(cmv);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   495
            }
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   496
        }, labels);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   497
        this.access = access;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   498
    }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   499
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   500
    @Override
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   501
    public void visitParameter(String name, int access) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   502
        if (name != null) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   503
            checkUnqualifiedName(version, name, "name");
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   504
        }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   505
        CheckClassAdapter.checkAccess(access, Opcodes.ACC_FINAL
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   506
                + Opcodes.ACC_MANDATED + Opcodes.ACC_SYNTHETIC);
21617
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
   507
        super.visitParameter(name, access);
14198
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
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   510
    @Override
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   511
    public AnnotationVisitor visitAnnotation(final String desc,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   512
            final boolean visible) {
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   513
        checkEndMethod();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   514
        checkDesc(desc, false);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   515
        return new CheckAnnotationAdapter(super.visitAnnotation(desc, visible));
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
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   518
    @Override
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   519
    public AnnotationVisitor visitTypeAnnotation(final int typeRef,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   520
            final TypePath typePath, final String desc, final boolean visible) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   521
        checkEndMethod();
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   522
        int sort = typeRef >>> 24;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   523
        if (sort != TypeReference.METHOD_TYPE_PARAMETER
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   524
                && sort != TypeReference.METHOD_TYPE_PARAMETER_BOUND
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   525
                && sort != TypeReference.METHOD_RETURN
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   526
                && sort != TypeReference.METHOD_RECEIVER
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   527
                && sort != TypeReference.METHOD_FORMAL_PARAMETER
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   528
                && sort != TypeReference.THROWS) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   529
            throw new IllegalArgumentException("Invalid type reference sort 0x"
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   530
                    + Integer.toHexString(sort));
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   531
        }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   532
        CheckClassAdapter.checkTypeRefAndPath(typeRef, typePath);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   533
        CheckMethodAdapter.checkDesc(desc, false);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   534
        return new CheckAnnotationAdapter(super.visitTypeAnnotation(typeRef,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   535
                typePath, desc, visible));
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   536
    }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   537
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   538
    @Override
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   539
    public AnnotationVisitor visitAnnotationDefault() {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   540
        checkEndMethod();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   541
        return new CheckAnnotationAdapter(super.visitAnnotationDefault(), false);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   542
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   543
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   544
    @Override
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   545
    public AnnotationVisitor visitParameterAnnotation(final int parameter,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   546
            final String desc, final boolean visible) {
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   547
        checkEndMethod();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   548
        checkDesc(desc, false);
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   549
        return new CheckAnnotationAdapter(super.visitParameterAnnotation(
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   550
                parameter, desc, visible));
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   551
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   552
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   553
    @Override
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   554
    public void visitAttribute(final Attribute attr) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   555
        checkEndMethod();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   556
        if (attr == null) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   557
            throw new IllegalArgumentException(
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   558
                    "Invalid attribute (must not be null)");
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   559
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   560
        super.visitAttribute(attr);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   561
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   562
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   563
    @Override
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   564
    public void visitCode() {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   565
        if ((access & Opcodes.ACC_ABSTRACT) != 0) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   566
            throw new RuntimeException("Abstract methods cannot have code");
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   567
        }
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   568
        startCode = true;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   569
        super.visitCode();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   570
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   571
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   572
    @Override
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   573
    public void visitFrame(final int type, final int nLocal,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   574
            final Object[] local, final int nStack, final Object[] stack) {
21617
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
   575
        if (insnCount == lastFrame) {
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
   576
            throw new IllegalStateException(
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
   577
                    "At most one frame can be visited at a given code location.");
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
   578
        }
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
   579
        lastFrame = insnCount;
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   580
        int mLocal;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   581
        int mStack;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   582
        switch (type) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   583
        case Opcodes.F_NEW:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   584
        case Opcodes.F_FULL:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   585
            mLocal = Integer.MAX_VALUE;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   586
            mStack = Integer.MAX_VALUE;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   587
            break;
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   588
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   589
        case Opcodes.F_SAME:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   590
            mLocal = 0;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   591
            mStack = 0;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   592
            break;
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   593
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   594
        case Opcodes.F_SAME1:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   595
            mLocal = 0;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   596
            mStack = 1;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   597
            break;
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   598
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   599
        case Opcodes.F_APPEND:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   600
        case Opcodes.F_CHOP:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   601
            mLocal = 3;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   602
            mStack = 0;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   603
            break;
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   604
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   605
        default:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   606
            throw new IllegalArgumentException("Invalid frame type " + type);
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   607
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   608
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   609
        if (nLocal > mLocal) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   610
            throw new IllegalArgumentException("Invalid nLocal=" + nLocal
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   611
                    + " for frame type " + type);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   612
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   613
        if (nStack > mStack) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   614
            throw new IllegalArgumentException("Invalid nStack=" + nStack
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   615
                    + " for frame type " + type);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   616
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   617
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   618
        if (type != Opcodes.F_CHOP) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   619
            if (nLocal > 0 && (local == null || local.length < nLocal)) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   620
                throw new IllegalArgumentException(
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   621
                        "Array local[] is shorter than nLocal");
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   622
            }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   623
            for (int i = 0; i < nLocal; ++i) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   624
                checkFrameValue(local[i]);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   625
            }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   626
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   627
        if (nStack > 0 && (stack == null || stack.length < nStack)) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   628
            throw new IllegalArgumentException(
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   629
                    "Array stack[] is shorter than nStack");
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   630
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   631
        for (int i = 0; i < nStack; ++i) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   632
            checkFrameValue(stack[i]);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   633
        }
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   634
        if (type == Opcodes.F_NEW) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   635
            ++expandedFrames;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   636
        } else {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   637
            ++compressedFrames;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   638
        }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   639
        if (expandedFrames > 0 && compressedFrames > 0) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   640
            throw new RuntimeException(
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   641
                    "Expanded and compressed frames must not be mixed.");
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   642
        }
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   643
        super.visitFrame(type, nLocal, local, nStack, stack);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   644
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   645
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   646
    @Override
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   647
    public void visitInsn(final int opcode) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   648
        checkStartCode();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   649
        checkEndCode();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   650
        checkOpcode(opcode, 0);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   651
        super.visitInsn(opcode);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   652
        ++insnCount;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   653
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   654
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   655
    @Override
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   656
    public void visitIntInsn(final int opcode, final int operand) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   657
        checkStartCode();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   658
        checkEndCode();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   659
        checkOpcode(opcode, 1);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   660
        switch (opcode) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   661
        case Opcodes.BIPUSH:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   662
            checkSignedByte(operand, "Invalid operand");
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   663
            break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   664
        case Opcodes.SIPUSH:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   665
            checkSignedShort(operand, "Invalid operand");
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   666
            break;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   667
        // case Constants.NEWARRAY:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   668
        default:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   669
            if (operand < Opcodes.T_BOOLEAN || operand > Opcodes.T_LONG) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   670
                throw new IllegalArgumentException(
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   671
                        "Invalid operand (must be an array type code T_...): "
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   672
                                + operand);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   673
            }
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   674
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   675
        super.visitIntInsn(opcode, operand);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   676
        ++insnCount;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   677
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   678
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   679
    @Override
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   680
    public void visitVarInsn(final int opcode, final int var) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   681
        checkStartCode();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   682
        checkEndCode();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   683
        checkOpcode(opcode, 2);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   684
        checkUnsignedShort(var, "Invalid variable index");
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   685
        super.visitVarInsn(opcode, var);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   686
        ++insnCount;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   687
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   688
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   689
    @Override
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   690
    public void visitTypeInsn(final int opcode, final String type) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   691
        checkStartCode();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   692
        checkEndCode();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   693
        checkOpcode(opcode, 3);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   694
        checkInternalName(type, "type");
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   695
        if (opcode == Opcodes.NEW && type.charAt(0) == '[') {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   696
            throw new IllegalArgumentException(
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   697
                    "NEW cannot be used to create arrays: " + type);
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   698
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   699
        super.visitTypeInsn(opcode, type);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   700
        ++insnCount;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   701
    }
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
    @Override
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   704
    public void visitFieldInsn(final int opcode, final String owner,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   705
            final String name, final String desc) {
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   706
        checkStartCode();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   707
        checkEndCode();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   708
        checkOpcode(opcode, 4);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   709
        checkInternalName(owner, "owner");
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   710
        checkUnqualifiedName(version, name, "name");
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   711
        checkDesc(desc, false);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   712
        super.visitFieldInsn(opcode, owner, name, desc);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   713
        ++insnCount;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   714
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   715
21617
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
   716
    @Deprecated
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   717
    @Override
21617
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
   718
    public void visitMethodInsn(int opcode, String owner, String name,
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
   719
            String desc) {
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
   720
        if (api >= Opcodes.ASM5) {
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
   721
            super.visitMethodInsn(opcode, owner, name, desc);
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
   722
            return;
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
   723
        }
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
   724
        doVisitMethodInsn(opcode, owner, name, desc,
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
   725
                opcode == Opcodes.INVOKEINTERFACE);
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
   726
    }
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
   727
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
   728
    @Override
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
   729
    public void visitMethodInsn(int opcode, String owner, String name,
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
   730
            String desc, boolean itf) {
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
   731
        if (api < Opcodes.ASM5) {
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
   732
            super.visitMethodInsn(opcode, owner, name, desc, itf);
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
   733
            return;
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
   734
        }
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
   735
        doVisitMethodInsn(opcode, owner, name, desc, itf);
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
   736
    }
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
   737
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
   738
    private void doVisitMethodInsn(int opcode, final String owner,
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
   739
            final String name, final String desc, final boolean itf) {
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   740
        checkStartCode();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   741
        checkEndCode();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   742
        checkOpcode(opcode, 5);
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   743
        if (opcode != Opcodes.INVOKESPECIAL || !"<init>".equals(name)) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   744
            checkMethodIdentifier(version, name, "name");
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   745
        }
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   746
        checkInternalName(owner, "owner");
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   747
        checkMethodDesc(desc);
21617
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
   748
        if (opcode == Opcodes.INVOKEVIRTUAL && itf) {
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
   749
            throw new IllegalArgumentException(
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
   750
                    "INVOKEVIRTUAL can't be used with interfaces");
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
   751
        }
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
   752
        if (opcode == Opcodes.INVOKEINTERFACE && !itf) {
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
   753
            throw new IllegalArgumentException(
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
   754
                    "INVOKEINTERFACE can't be used with classes");
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
   755
        }
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
   756
        // Calling super.visitMethodInsn requires to call the correct version
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
   757
        // depending on this.api (otherwise infinite loops can occur). To
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
   758
        // simplify and to make it easier to automatically remove the backward
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
   759
        // compatibility code, we inline the code of the overridden method here.
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
   760
        if (mv != null) {
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
   761
            mv.visitMethodInsn(opcode, owner, name, desc, itf);
53b88e4ac6ed 8027227: [asm] generate CONSTANT_InterfaceMethodref for invoke{special/static) of non-abstract methods on ifaces
ksrini
parents: 17420
diff changeset
   762
        }
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   763
        ++insnCount;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   764
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   765
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   766
    @Override
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   767
    public void visitInvokeDynamicInsn(String name, String desc, Handle bsm,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   768
            Object... bsmArgs) {
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   769
        checkStartCode();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   770
        checkEndCode();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   771
        checkMethodIdentifier(version, name, "name");
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   772
        checkMethodDesc(desc);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   773
        if (bsm.getTag() != Opcodes.H_INVOKESTATIC
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   774
                && bsm.getTag() != Opcodes.H_NEWINVOKESPECIAL) {
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   775
            throw new IllegalArgumentException("invalid handle tag "
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   776
                    + bsm.getTag());
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   777
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   778
        for (int i = 0; i < bsmArgs.length; i++) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   779
            checkLDCConstant(bsmArgs[i]);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   780
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   781
        super.visitInvokeDynamicInsn(name, desc, bsm, bsmArgs);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   782
        ++insnCount;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   783
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   784
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   785
    @Override
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   786
    public void visitJumpInsn(final int opcode, final Label label) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   787
        checkStartCode();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   788
        checkEndCode();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   789
        checkOpcode(opcode, 6);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   790
        checkLabel(label, false, "label");
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   791
        checkNonDebugLabel(label);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   792
        super.visitJumpInsn(opcode, label);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   793
        usedLabels.add(label);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   794
        ++insnCount;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   795
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   796
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   797
    @Override
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   798
    public void visitLabel(final Label label) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   799
        checkStartCode();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   800
        checkEndCode();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   801
        checkLabel(label, false, "label");
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   802
        if (labels.get(label) != null) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   803
            throw new IllegalArgumentException("Already visited label");
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   804
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   805
        labels.put(label, new Integer(insnCount));
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   806
        super.visitLabel(label);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   807
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   808
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   809
    @Override
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   810
    public void visitLdcInsn(final Object cst) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   811
        checkStartCode();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   812
        checkEndCode();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   813
        checkLDCConstant(cst);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   814
        super.visitLdcInsn(cst);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   815
        ++insnCount;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   816
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   817
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   818
    @Override
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   819
    public void visitIincInsn(final int var, final int increment) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   820
        checkStartCode();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   821
        checkEndCode();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   822
        checkUnsignedShort(var, "Invalid variable index");
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   823
        checkSignedShort(increment, "Invalid increment");
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   824
        super.visitIincInsn(var, increment);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   825
        ++insnCount;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   826
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   827
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   828
    @Override
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   829
    public void visitTableSwitchInsn(final int min, final int max,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   830
            final Label dflt, final Label... labels) {
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   831
        checkStartCode();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   832
        checkEndCode();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   833
        if (max < min) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   834
            throw new IllegalArgumentException("Max = " + max
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   835
                    + " must be greater than or equal to min = " + min);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   836
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   837
        checkLabel(dflt, false, "default label");
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   838
        checkNonDebugLabel(dflt);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   839
        if (labels == null || labels.length != max - min + 1) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   840
            throw new IllegalArgumentException(
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   841
                    "There must be max - min + 1 labels");
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   842
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   843
        for (int i = 0; i < labels.length; ++i) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   844
            checkLabel(labels[i], false, "label at index " + i);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   845
            checkNonDebugLabel(labels[i]);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   846
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   847
        super.visitTableSwitchInsn(min, max, dflt, labels);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   848
        for (int i = 0; i < labels.length; ++i) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   849
            usedLabels.add(labels[i]);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   850
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   851
        ++insnCount;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   852
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   853
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   854
    @Override
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   855
    public void visitLookupSwitchInsn(final Label dflt, final int[] keys,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   856
            final Label[] labels) {
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   857
        checkEndCode();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   858
        checkStartCode();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   859
        checkLabel(dflt, false, "default label");
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   860
        checkNonDebugLabel(dflt);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   861
        if (keys == null || labels == null || keys.length != labels.length) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   862
            throw new IllegalArgumentException(
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   863
                    "There must be the same number of keys and labels");
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   864
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   865
        for (int i = 0; i < labels.length; ++i) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   866
            checkLabel(labels[i], false, "label at index " + i);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   867
            checkNonDebugLabel(labels[i]);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   868
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   869
        super.visitLookupSwitchInsn(dflt, keys, labels);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   870
        usedLabels.add(dflt);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   871
        for (int i = 0; i < labels.length; ++i) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   872
            usedLabels.add(labels[i]);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   873
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   874
        ++insnCount;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   875
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   876
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   877
    @Override
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   878
    public void visitMultiANewArrayInsn(final String desc, final int dims) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   879
        checkStartCode();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   880
        checkEndCode();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   881
        checkDesc(desc, false);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   882
        if (desc.charAt(0) != '[') {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   883
            throw new IllegalArgumentException(
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   884
                    "Invalid descriptor (must be an array type descriptor): "
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   885
                            + desc);
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   886
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   887
        if (dims < 1) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   888
            throw new IllegalArgumentException(
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   889
                    "Invalid dimensions (must be greater than 0): " + dims);
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   890
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   891
        if (dims > desc.lastIndexOf('[') + 1) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   892
            throw new IllegalArgumentException(
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   893
                    "Invalid dimensions (must not be greater than dims(desc)): "
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   894
                            + dims);
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   895
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   896
        super.visitMultiANewArrayInsn(desc, dims);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   897
        ++insnCount;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   898
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   899
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   900
    @Override
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   901
    public AnnotationVisitor visitInsnAnnotation(final int typeRef,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   902
            final TypePath typePath, final String desc, final boolean visible) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   903
        checkStartCode();
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   904
        checkEndCode();
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   905
        int sort = typeRef >>> 24;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   906
        if (sort != TypeReference.INSTANCEOF && sort != TypeReference.NEW
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   907
                && sort != TypeReference.CONSTRUCTOR_REFERENCE
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   908
                && sort != TypeReference.METHOD_REFERENCE
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   909
                && sort != TypeReference.CAST
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   910
                && sort != TypeReference.CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   911
                && sort != TypeReference.METHOD_INVOCATION_TYPE_ARGUMENT
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   912
                && sort != TypeReference.CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   913
                && sort != TypeReference.METHOD_REFERENCE_TYPE_ARGUMENT) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   914
            throw new IllegalArgumentException("Invalid type reference sort 0x"
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   915
                    + Integer.toHexString(sort));
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   916
        }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   917
        CheckClassAdapter.checkTypeRefAndPath(typeRef, typePath);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   918
        CheckMethodAdapter.checkDesc(desc, false);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   919
        return new CheckAnnotationAdapter(super.visitInsnAnnotation(typeRef,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   920
                typePath, desc, visible));
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
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   923
    @Override
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   924
    public void visitTryCatchBlock(final Label start, final Label end,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   925
            final Label handler, final String type) {
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   926
        checkStartCode();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   927
        checkEndCode();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   928
        checkLabel(start, false, "start label");
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   929
        checkLabel(end, false, "end label");
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   930
        checkLabel(handler, false, "handler label");
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   931
        checkNonDebugLabel(start);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   932
        checkNonDebugLabel(end);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   933
        checkNonDebugLabel(handler);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   934
        if (labels.get(start) != null || labels.get(end) != null
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   935
                || labels.get(handler) != null) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   936
            throw new IllegalStateException(
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   937
                    "Try catch blocks must be visited before their labels");
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   938
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   939
        if (type != null) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   940
            checkInternalName(type, "type");
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   941
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   942
        super.visitTryCatchBlock(start, end, handler, type);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   943
        handlers.add(start);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   944
        handlers.add(end);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   945
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   946
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   947
    @Override
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   948
    public AnnotationVisitor visitTryCatchAnnotation(final int typeRef,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   949
            final TypePath typePath, final String desc, final boolean visible) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   950
        checkStartCode();
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   951
        checkEndCode();
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   952
        int sort = typeRef >>> 24;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   953
        if (sort != TypeReference.EXCEPTION_PARAMETER) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   954
            throw new IllegalArgumentException("Invalid type reference sort 0x"
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   955
                    + Integer.toHexString(sort));
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   956
        }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   957
        CheckClassAdapter.checkTypeRefAndPath(typeRef, typePath);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   958
        CheckMethodAdapter.checkDesc(desc, false);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   959
        return new CheckAnnotationAdapter(super.visitTryCatchAnnotation(
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   960
                typeRef, typePath, desc, visible));
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   961
    }
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
    @Override
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   964
    public void visitLocalVariable(final String name, final String desc,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   965
            final String signature, final Label start, final Label end,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   966
            final int index) {
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   967
        checkStartCode();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   968
        checkEndCode();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   969
        checkUnqualifiedName(version, name, "name");
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   970
        checkDesc(desc, false);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   971
        checkLabel(start, true, "start label");
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   972
        checkLabel(end, true, "end label");
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   973
        checkUnsignedShort(index, "Invalid variable index");
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   974
        int s = labels.get(start).intValue();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   975
        int e = labels.get(end).intValue();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   976
        if (e < s) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   977
            throw new IllegalArgumentException(
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   978
                    "Invalid start and end labels (end must be greater than start)");
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   979
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   980
        super.visitLocalVariable(name, desc, signature, start, end, index);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   981
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   982
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   983
    @Override
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   984
    public AnnotationVisitor visitLocalVariableAnnotation(int typeRef,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   985
            TypePath typePath, Label[] start, Label[] end, int[] index,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   986
            String desc, boolean visible) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   987
        checkStartCode();
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   988
        checkEndCode();
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   989
        int sort = typeRef >>> 24;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   990
        if (sort != TypeReference.LOCAL_VARIABLE
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   991
                && sort != TypeReference.RESOURCE_VARIABLE) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   992
            throw new IllegalArgumentException("Invalid type reference sort 0x"
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   993
                    + Integer.toHexString(sort));
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   994
        }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   995
        CheckClassAdapter.checkTypeRefAndPath(typeRef, typePath);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   996
        checkDesc(desc, false);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   997
        if (start == null || end == null || index == null
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   998
                || end.length != start.length || index.length != start.length) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   999
            throw new IllegalArgumentException(
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1000
                    "Invalid start, end and index arrays (must be non null and of identical length");
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 = 0; i < start.length; ++i) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1003
            checkLabel(start[i], true, "start label");
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1004
            checkLabel(end[i], true, "end label");
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1005
            checkUnsignedShort(index[i], "Invalid variable index");
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1006
            int s = labels.get(start[i]).intValue();
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1007
            int e = labels.get(end[i]).intValue();
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1008
            if (e < s) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1009
                throw new IllegalArgumentException(
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1010
                        "Invalid start and end labels (end must be greater than start)");
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1011
            }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1012
        }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1013
        return super.visitLocalVariableAnnotation(typeRef, typePath, start,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1014
                end, index, desc, visible);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1015
    }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1016
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1017
    @Override
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1018
    public void visitLineNumber(final int line, final Label start) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1019
        checkStartCode();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1020
        checkEndCode();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1021
        checkUnsignedShort(line, "Invalid line number");
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1022
        checkLabel(start, true, "start label");
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1023
        super.visitLineNumber(line, start);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1024
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1025
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1026
    @Override
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1027
    public void visitMaxs(final int maxStack, final int maxLocals) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1028
        checkStartCode();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1029
        checkEndCode();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1030
        endCode = true;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1031
        for (Label l : usedLabels) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1032
            if (labels.get(l) == null) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1033
                throw new IllegalStateException("Undefined label used");
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1034
            }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1035
        }
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1036
        for (int i = 0; i < handlers.size();) {
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1037
            Integer start = labels.get(handlers.get(i++));
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1038
            Integer end = labels.get(handlers.get(i++));
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1039
            if (start == null || end == null) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1040
                throw new IllegalStateException(
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1041
                        "Undefined try catch block labels");
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1042
            }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1043
            if (end.intValue() <= start.intValue()) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1044
                throw new IllegalStateException(
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1045
                        "Emty try catch block handler range");
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1046
            }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1047
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1048
        checkUnsignedShort(maxStack, "Invalid max stack");
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1049
        checkUnsignedShort(maxLocals, "Invalid max locals");
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1050
        super.visitMaxs(maxStack, maxLocals);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1051
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1052
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1053
    @Override
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1054
    public void visitEnd() {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1055
        checkEndMethod();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1056
        endMethod = true;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1057
        super.visitEnd();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1058
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1059
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1060
    // -------------------------------------------------------------------------
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1061
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1062
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1063
     * Checks that the visitCode method has been called.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1064
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1065
    void checkStartCode() {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1066
        if (!startCode) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1067
            throw new IllegalStateException(
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1068
                    "Cannot visit instructions before visitCode has been called.");
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1069
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1070
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1071
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1072
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1073
     * Checks that the visitMaxs method has not been called.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1074
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1075
    void checkEndCode() {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1076
        if (endCode) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1077
            throw new IllegalStateException(
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1078
                    "Cannot visit instructions after visitMaxs has been called.");
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1079
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1080
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1081
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1082
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1083
     * Checks that the visitEnd method has not been called.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1084
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1085
    void checkEndMethod() {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1086
        if (endMethod) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1087
            throw new IllegalStateException(
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1088
                    "Cannot visit elements after visitEnd has been called.");
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1089
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1090
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1091
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1092
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1093
     * Checks a stack frame value.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1094
     *
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1095
     * @param value
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1096
     *            the value to be checked.
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1097
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1098
    void checkFrameValue(final Object value) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1099
        if (value == Opcodes.TOP || value == Opcodes.INTEGER
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1100
                || value == Opcodes.FLOAT || value == Opcodes.LONG
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1101
                || value == Opcodes.DOUBLE || value == Opcodes.NULL
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1102
                || value == Opcodes.UNINITIALIZED_THIS) {
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1103
            return;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1104
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1105
        if (value instanceof String) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1106
            checkInternalName((String) value, "Invalid stack frame value");
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1107
            return;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1108
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1109
        if (!(value instanceof Label)) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1110
            throw new IllegalArgumentException("Invalid stack frame value: "
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1111
                    + value);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1112
        } else {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1113
            usedLabels.add((Label) value);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1114
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1115
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1116
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1117
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1118
     * Checks that the type of the given opcode is equal to the given type.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1119
     *
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1120
     * @param opcode
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1121
     *            the opcode to be checked.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1122
     * @param type
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1123
     *            the expected opcode type.
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1124
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1125
    static void checkOpcode(final int opcode, final int type) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1126
        if (opcode < 0 || opcode > 199 || TYPE[opcode] != type) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1127
            throw new IllegalArgumentException("Invalid opcode: " + opcode);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1128
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1129
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1130
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1131
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1132
     * Checks that the given value is a signed byte.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1133
     *
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1134
     * @param value
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1135
     *            the value to be checked.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1136
     * @param msg
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1137
     *            an message to be used in case of error.
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1138
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1139
    static void checkSignedByte(final int value, final String msg) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1140
        if (value < Byte.MIN_VALUE || value > Byte.MAX_VALUE) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1141
            throw new IllegalArgumentException(msg
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1142
                    + " (must be a signed byte): " + value);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1143
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1144
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1145
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1146
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1147
     * Checks that the given value is a signed short.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1148
     *
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1149
     * @param value
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1150
     *            the value to be checked.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1151
     * @param msg
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1152
     *            an message to be used in case of error.
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1153
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1154
    static void checkSignedShort(final int value, final String msg) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1155
        if (value < Short.MIN_VALUE || value > Short.MAX_VALUE) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1156
            throw new IllegalArgumentException(msg
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1157
                    + " (must be a signed short): " + value);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1158
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1159
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1160
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1161
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1162
     * Checks that the given value is an unsigned short.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1163
     *
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1164
     * @param value
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1165
     *            the value to be checked.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1166
     * @param msg
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1167
     *            an message to be used in case of error.
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1168
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1169
    static void checkUnsignedShort(final int value, final String msg) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1170
        if (value < 0 || value > 65535) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1171
            throw new IllegalArgumentException(msg
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1172
                    + " (must be an unsigned short): " + value);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1173
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1174
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1175
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1176
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1177
     * Checks that the given value is an {@link Integer}, a{@link Float}, a
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1178
     * {@link Long}, a {@link Double} or a {@link String}.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1179
     *
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1180
     * @param cst
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1181
     *            the value to be checked.
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1182
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1183
    static void checkConstant(final Object cst) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1184
        if (!(cst instanceof Integer) && !(cst instanceof Float)
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1185
                && !(cst instanceof Long) && !(cst instanceof Double)
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1186
                && !(cst instanceof String)) {
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1187
            throw new IllegalArgumentException("Invalid constant: " + cst);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1188
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1189
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1190
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1191
    void checkLDCConstant(final Object cst) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1192
        if (cst instanceof Type) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1193
            int s = ((Type) cst).getSort();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1194
            if (s != Type.OBJECT && s != Type.ARRAY && s != Type.METHOD) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1195
                throw new IllegalArgumentException("Illegal LDC constant value");
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1196
            }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1197
            if (s != Type.METHOD && (version & 0xFFFF) < Opcodes.V1_5) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1198
                throw new IllegalArgumentException(
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1199
                        "ldc of a constant class requires at least version 1.5");
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1200
            }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1201
            if (s == Type.METHOD && (version & 0xFFFF) < Opcodes.V1_7) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1202
                throw new IllegalArgumentException(
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1203
                        "ldc of a method type requires at least version 1.7");
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1204
            }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1205
        } else if (cst instanceof Handle) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1206
            if ((version & 0xFFFF) < Opcodes.V1_7) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1207
                throw new IllegalArgumentException(
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1208
                        "ldc of a handle requires at least version 1.7");
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1209
            }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1210
            int tag = ((Handle) cst).getTag();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1211
            if (tag < Opcodes.H_GETFIELD || tag > Opcodes.H_INVOKEINTERFACE) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1212
                throw new IllegalArgumentException("invalid handle tag " + tag);
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1213
            }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1214
        } else {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1215
            checkConstant(cst);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1216
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1217
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1218
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1219
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1220
     * Checks that the given string is a valid unqualified name.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1221
     *
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1222
     * @param version
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1223
     *            the class version.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1224
     * @param name
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1225
     *            the string to be checked.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1226
     * @param msg
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1227
     *            a message to be used in case of error.
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1228
     */
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1229
    static void checkUnqualifiedName(int version, final String name,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1230
            final String msg) {
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1231
        if ((version & 0xFFFF) < Opcodes.V1_5) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1232
            checkIdentifier(name, msg);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1233
        } else {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1234
            for (int i = 0; i < name.length(); ++i) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1235
                if (".;[/".indexOf(name.charAt(i)) != -1) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1236
                    throw new IllegalArgumentException("Invalid " + msg
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1237
                            + " (must be a valid unqualified name): " + name);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1238
                }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1239
            }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1240
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1241
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1242
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1243
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1244
     * Checks that the given string is a valid Java identifier.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1245
     *
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1246
     * @param name
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1247
     *            the string to be checked.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1248
     * @param msg
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1249
     *            a message to be used in case of error.
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1250
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1251
    static void checkIdentifier(final String name, final String msg) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1252
        checkIdentifier(name, 0, -1, msg);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1253
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1254
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1255
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1256
     * Checks that the given substring is a valid Java identifier.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1257
     *
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1258
     * @param name
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1259
     *            the string to be checked.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1260
     * @param start
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1261
     *            index of the first character of the identifier (inclusive).
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1262
     * @param end
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1263
     *            index of the last character of the identifier (exclusive). -1
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1264
     *            is equivalent to <tt>name.length()</tt> if name is not
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1265
     *            <tt>null</tt>.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1266
     * @param msg
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1267
     *            a message to be used in case of error.
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1268
     */
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1269
    static void checkIdentifier(final String name, final int start,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1270
            final int end, final String msg) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1271
        if (name == null || (end == -1 ? name.length() <= start : end <= start)) {
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1272
            throw new IllegalArgumentException("Invalid " + msg
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1273
                    + " (must not be null or empty)");
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1274
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1275
        if (!Character.isJavaIdentifierStart(name.charAt(start))) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1276
            throw new IllegalArgumentException("Invalid " + msg
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1277
                    + " (must be a valid Java identifier): " + name);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1278
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1279
        int max = end == -1 ? name.length() : end;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1280
        for (int i = start + 1; i < max; ++i) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1281
            if (!Character.isJavaIdentifierPart(name.charAt(i))) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1282
                throw new IllegalArgumentException("Invalid " + msg
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1283
                        + " (must be a valid Java identifier): " + name);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1284
            }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1285
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1286
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1287
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1288
    /**
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1289
     * Checks that the given string is a valid Java identifier.
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1290
     *
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1291
     * @param version
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1292
     *            the class version.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1293
     * @param name
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1294
     *            the string to be checked.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1295
     * @param msg
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1296
     *            a message to be used in case of error.
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1297
     */
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1298
    static void checkMethodIdentifier(int version, final String name,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1299
            final String msg) {
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1300
        if (name == null || name.length() == 0) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1301
            throw new IllegalArgumentException("Invalid " + msg
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1302
                    + " (must not be null or empty)");
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1303
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1304
        if ((version & 0xFFFF) >= Opcodes.V1_5) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1305
            for (int i = 0; i < name.length(); ++i) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1306
                if (".;[/<>".indexOf(name.charAt(i)) != -1) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1307
                    throw new IllegalArgumentException("Invalid " + msg
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1308
                            + " (must be a valid unqualified name): " + name);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1309
                }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1310
            }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1311
            return;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1312
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1313
        if (!Character.isJavaIdentifierStart(name.charAt(0))) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1314
            throw new IllegalArgumentException(
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1315
                    "Invalid "
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1316
                            + msg
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1317
                            + " (must be a '<init>', '<clinit>' or a valid Java identifier): "
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1318
                            + name);
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1319
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1320
        for (int i = 1; i < name.length(); ++i) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1321
            if (!Character.isJavaIdentifierPart(name.charAt(i))) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1322
                throw new IllegalArgumentException(
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1323
                        "Invalid "
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1324
                                + msg
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1325
                                + " (must be '<init>' or '<clinit>' or a valid Java identifier): "
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1326
                                + name);
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1327
            }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1328
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1329
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1330
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1331
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1332
     * Checks that the given string is a valid internal class name.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1333
     *
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1334
     * @param name
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1335
     *            the string to be checked.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1336
     * @param msg
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1337
     *            a message to be used in case of error.
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1338
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1339
    static void checkInternalName(final String name, final String msg) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1340
        if (name == null || name.length() == 0) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1341
            throw new IllegalArgumentException("Invalid " + msg
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1342
                    + " (must not be null or empty)");
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1343
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1344
        if (name.charAt(0) == '[') {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1345
            checkDesc(name, false);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1346
        } else {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1347
            checkInternalName(name, 0, -1, msg);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1348
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1349
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1350
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1351
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1352
     * Checks that the given substring is a valid internal class name.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1353
     *
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1354
     * @param name
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1355
     *            the string to be checked.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1356
     * @param start
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1357
     *            index of the first character of the identifier (inclusive).
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1358
     * @param end
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1359
     *            index of the last character of the identifier (exclusive). -1
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1360
     *            is equivalent to <tt>name.length()</tt> if name is not
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1361
     *            <tt>null</tt>.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1362
     * @param msg
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1363
     *            a message to be used in case of error.
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1364
     */
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1365
    static void checkInternalName(final String name, final int start,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1366
            final int end, final String msg) {
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1367
        int max = end == -1 ? name.length() : end;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1368
        try {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1369
            int begin = start;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1370
            int slash;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1371
            do {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1372
                slash = name.indexOf('/', begin + 1);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1373
                if (slash == -1 || slash > max) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1374
                    slash = max;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1375
                }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1376
                checkIdentifier(name, begin, slash, null);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1377
                begin = slash + 1;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1378
            } while (slash != max);
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1379
        } catch (IllegalArgumentException unused) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1380
            throw new IllegalArgumentException(
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1381
                    "Invalid "
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1382
                            + msg
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1383
                            + " (must be a fully qualified class name in internal form): "
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1384
                            + name);
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1385
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1386
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1387
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1388
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1389
     * Checks that the given string is a valid type descriptor.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1390
     *
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1391
     * @param desc
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1392
     *            the string to be checked.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1393
     * @param canBeVoid
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1394
     *            <tt>true</tt> if <tt>V</tt> can be considered valid.
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1395
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1396
    static void checkDesc(final String desc, final boolean canBeVoid) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1397
        int end = checkDesc(desc, 0, canBeVoid);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1398
        if (end != desc.length()) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1399
            throw new IllegalArgumentException("Invalid descriptor: " + desc);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1400
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1401
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1402
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1403
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1404
     * Checks that a the given substring is a valid type descriptor.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1405
     *
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1406
     * @param desc
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1407
     *            the string to be checked.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1408
     * @param start
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1409
     *            index of the first character of the identifier (inclusive).
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1410
     * @param canBeVoid
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1411
     *            <tt>true</tt> if <tt>V</tt> can be considered valid.
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1412
     * @return the index of the last character of the type decriptor, plus one.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1413
     */
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1414
    static int checkDesc(final String desc, final int start,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1415
            final boolean canBeVoid) {
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1416
        if (desc == null || start >= desc.length()) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1417
            throw new IllegalArgumentException(
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1418
                    "Invalid type descriptor (must not be null or empty)");
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1419
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1420
        int index;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1421
        switch (desc.charAt(start)) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1422
        case 'V':
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1423
            if (canBeVoid) {
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1424
                return start + 1;
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1425
            } else {
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1426
                throw new IllegalArgumentException("Invalid descriptor: "
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1427
                        + desc);
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1428
            }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1429
        case 'Z':
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1430
        case 'C':
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1431
        case 'B':
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1432
        case 'S':
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1433
        case 'I':
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1434
        case 'F':
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1435
        case 'J':
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1436
        case 'D':
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1437
            return start + 1;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1438
        case '[':
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1439
            index = start + 1;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1440
            while (index < desc.length() && desc.charAt(index) == '[') {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1441
                ++index;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1442
            }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1443
            if (index < desc.length()) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1444
                return checkDesc(desc, index, false);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1445
            } else {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1446
                throw new IllegalArgumentException("Invalid descriptor: "
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1447
                        + desc);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1448
            }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1449
        case 'L':
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1450
            index = desc.indexOf(';', start);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1451
            if (index == -1 || index - start < 2) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1452
                throw new IllegalArgumentException("Invalid descriptor: "
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1453
                        + desc);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1454
            }
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1455
            try {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1456
                checkInternalName(desc, start + 1, index, null);
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1457
            } catch (IllegalArgumentException unused) {
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1458
                throw new IllegalArgumentException("Invalid descriptor: "
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1459
                        + desc);
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
            return index + 1;
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1462
        default:
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1463
            throw new IllegalArgumentException("Invalid descriptor: " + desc);
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1464
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1465
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1466
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1467
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1468
     * Checks that the given string is a valid method descriptor.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1469
     *
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1470
     * @param desc
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1471
     *            the string to be checked.
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1472
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1473
    static void checkMethodDesc(final String desc) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1474
        if (desc == null || desc.length() == 0) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1475
            throw new IllegalArgumentException(
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1476
                    "Invalid method descriptor (must not be null or empty)");
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1477
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1478
        if (desc.charAt(0) != '(' || desc.length() < 3) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1479
            throw new IllegalArgumentException("Invalid descriptor: " + desc);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1480
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1481
        int start = 1;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1482
        if (desc.charAt(start) != ')') {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1483
            do {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1484
                if (desc.charAt(start) == 'V') {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1485
                    throw new IllegalArgumentException("Invalid descriptor: "
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1486
                            + desc);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1487
                }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1488
                start = checkDesc(desc, start, false);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1489
            } while (start < desc.length() && desc.charAt(start) != ')');
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1490
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1491
        start = checkDesc(desc, start + 1, true);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1492
        if (start != desc.length()) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1493
            throw new IllegalArgumentException("Invalid descriptor: " + desc);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1494
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1495
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1496
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1497
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1498
     * Checks that the given label is not null. This method can also check that
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1499
     * the label has been visited.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1500
     *
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1501
     * @param label
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1502
     *            the label to be checked.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1503
     * @param checkVisited
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1504
     *            <tt>true</tt> to check that the label has been visited.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1505
     * @param msg
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1506
     *            a message to be used in case of error.
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1507
     */
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1508
    void checkLabel(final Label label, final boolean checkVisited,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1509
            final String msg) {
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1510
        if (label == null) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1511
            throw new IllegalArgumentException("Invalid " + msg
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1512
                    + " (must not be null)");
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1513
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1514
        if (checkVisited && labels.get(label) == null) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1515
            throw new IllegalArgumentException("Invalid " + msg
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1516
                    + " (must be visited first)");
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1517
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1518
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1519
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1520
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1521
     * Checks that the given label is not a label used only for debug purposes.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1522
     *
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1523
     * @param label
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1524
     *            the label to be checked.
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1525
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1526
    private static void checkNonDebugLabel(final Label label) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1527
        Field f = getLabelStatusField();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1528
        int status = 0;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1529
        try {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1530
            status = f == null ? 0 : ((Integer) f.get(label)).intValue();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1531
        } catch (IllegalAccessException e) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1532
            throw new Error("Internal error");
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1533
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1534
        if ((status & 0x01) != 0) {
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1535
            throw new IllegalArgumentException(
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1536
                    "Labels used for debug info cannot be reused for control flow");
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1537
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1538
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1539
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1540
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1541
     * Returns the Field object corresponding to the Label.status field.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1542
     *
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1543
     * @return the Field object corresponding to the Label.status field.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1544
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1545
    private static Field getLabelStatusField() {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1546
        if (labelStatusField == null) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1547
            labelStatusField = getLabelField("a");
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1548
            if (labelStatusField == null) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1549
                labelStatusField = getLabelField("status");
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1550
            }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1551
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1552
        return labelStatusField;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1553
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1554
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1555
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1556
     * Returns the field of the Label class whose name is given.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1557
     *
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1558
     * @param name
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
  1559
     *            a field name.
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1560
     * @return the field of the Label class whose name is given, or null.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1561
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1562
    private static Field getLabelField(final String name) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1563
        try {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1564
            Field f = Label.class.getDeclaredField(name);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1565
            f.setAccessible(true);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1566
            return f;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1567
        } catch (NoSuchFieldException e) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1568
            return null;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1569
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1570
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
  1571
}