src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/CheckSignatureAdapter.java
author redestad
Thu, 13 Dec 2018 15:31:05 +0100
changeset 53018 8bf9268df0e2
parent 52515 746df0ae4fe1
permissions -rw-r--r--
8215281: Use String.isEmpty() when applicable in java.base Reviewed-by: dfuchs, alanb
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
52515
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
    61
import java.util.EnumSet;
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    62
import jdk.internal.org.objectweb.asm.Opcodes;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    63
import jdk.internal.org.objectweb.asm.signature.SignatureVisitor;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    64
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    65
/**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    66
 * A {@link SignatureVisitor} that checks that its methods are properly used.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    67
 *
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    68
 * @author Eric Bruneton
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    69
 */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    70
public class CheckSignatureAdapter extends SignatureVisitor {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    71
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    72
    /**
52515
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
    73
      * Type to be used to check class signatures. See {@link #CheckSignatureAdapter(int,
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
    74
      * SignatureVisitor)}.
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
    75
      */
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    76
    public static final int CLASS_SIGNATURE = 0;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    77
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    78
    /**
52515
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
    79
      * Type to be used to check method signatures. See {@link #CheckSignatureAdapter(int,
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
    80
      * SignatureVisitor)}.
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
    81
      */
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    82
    public static final int METHOD_SIGNATURE = 1;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    83
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    84
    /**
52515
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
    85
      * Type to be used to check type signatures.See {@link #CheckSignatureAdapter(int,
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
    86
      * SignatureVisitor)}.
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
    87
      */
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    88
    public static final int TYPE_SIGNATURE = 2;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    89
52515
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
    90
    /** The valid automaton states for a {@link #visitFormalTypeParameter} method call. */
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
    91
    private static final EnumSet<State> VISIT_FORMAL_TYPE_PARAMETER_STATES =
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
    92
            EnumSet.of(State.EMPTY, State.FORMAL, State.BOUND);
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    93
52515
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
    94
    /** The valid automaton states for a {@link #visitClassBound} method call. */
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
    95
    private static final EnumSet<State> VISIT_CLASS_BOUND_STATES = EnumSet.of(State.FORMAL);
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
    96
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
    97
    /** The valid automaton states for a {@link #visitInterfaceBound} method call. */
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
    98
    private static final EnumSet<State> VISIT_INTERFACE_BOUND_STATES =
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
    99
            EnumSet.of(State.FORMAL, State.BOUND);
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   100
52515
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   101
    /** The valid automaton states for a {@link #visitSuperclass} method call. */
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   102
    private static final EnumSet<State> VISIT_SUPER_CLASS_STATES =
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   103
            EnumSet.of(State.EMPTY, State.FORMAL, State.BOUND);
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   104
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   105
    /** The valid automaton states for a {@link #visitInterface} method call. */
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   106
    private static final EnumSet<State> VISIT_INTERFACE_STATES = EnumSet.of(State.SUPER);
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   107
52515
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   108
    /** The valid automaton states for a {@link #visitParameterType} method call. */
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   109
    private static final EnumSet<State> VISIT_PARAMETER_TYPE_STATES =
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   110
            EnumSet.of(State.EMPTY, State.FORMAL, State.BOUND, State.PARAM);
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   111
52515
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   112
    /** The valid automaton states for a {@link #visitReturnType} method call. */
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   113
    private static final EnumSet<State> VISIT_RETURN_TYPE_STATES =
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   114
            EnumSet.of(State.EMPTY, State.FORMAL, State.BOUND, State.PARAM);
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   115
52515
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   116
    /** The valid automaton states for a {@link #visitExceptionType} method call. */
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   117
    private static final EnumSet<State> VISIT_EXCEPTION_TYPE_STATES = EnumSet.of(State.RETURN);
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   118
52515
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   119
    /** The possible states of the automaton used to check the order of method calls. */
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   120
    private enum State {
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   121
        EMPTY,
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   122
        FORMAL,
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   123
        BOUND,
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   124
        SUPER,
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   125
        PARAM,
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   126
        RETURN,
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   127
        SIMPLE_TYPE,
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   128
        CLASS_TYPE,
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   129
        END;
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   130
    }
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   131
52515
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   132
    private static final String INVALID = "Invalid ";
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   133
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   134
    /** The type of the visited signature. */
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   135
    private final int type;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   136
52515
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   137
    /** The current state of the automaton used to check the order of method calls. */
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   138
    private State state;
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   139
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   140
    /** Whether the visited signature can be 'V'. */
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   141
    private boolean canBeVoid;
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   142
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   143
    /** The visitor to which this adapter must delegate calls. May be {@literal null}. */
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   144
    private final SignatureVisitor signatureVisitor;
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   145
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   146
    /**
52515
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   147
      * Constructs a new {@link CheckSignatureAdapter}. <i>Subclasses must not use this
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   148
      * constructor</i>. Instead, they must use the {@link #CheckSignatureAdapter(int, int,
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   149
      * SignatureVisitor)} version.
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   150
      *
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   151
      * @param type the type of signature to be checked. See {@link #CLASS_SIGNATURE}, {@link
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   152
      *     #METHOD_SIGNATURE} and {@link #TYPE_SIGNATURE}.
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   153
      * @param signatureVisitor the visitor to which this adapter must delegate calls. May be {@literal
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   154
      *     null}.
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   155
      */
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   156
    public CheckSignatureAdapter(final int type, final SignatureVisitor signatureVisitor) {
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   157
        this(Opcodes.ASM7, type, signatureVisitor);
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   158
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   159
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   160
    /**
52515
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   161
      * Constructs a new {@link CheckSignatureAdapter}.
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   162
      *
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   163
      * @param api the ASM API version implemented by this visitor. Must be one of {@link
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   164
      *     Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6} or {@link Opcodes#ASM7}.
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   165
      * @param type the type of signature to be checked. See {@link #CLASS_SIGNATURE}, {@link
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   166
      *     #METHOD_SIGNATURE} and {@link #TYPE_SIGNATURE}.
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   167
      * @param signatureVisitor the visitor to which this adapter must delegate calls. May be {@literal
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   168
      *     null}.
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   169
      */
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   170
    protected CheckSignatureAdapter(
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   171
            final int api, final int type, final SignatureVisitor signatureVisitor) {
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   172
        super(api);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   173
        this.type = type;
52515
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   174
        this.state = State.EMPTY;
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   175
        this.signatureVisitor = signatureVisitor;
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   176
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   177
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   178
    // class and method signatures
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   179
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   180
    @Override
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   181
    public void visitFormalTypeParameter(final String name) {
52515
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   182
        if (type == TYPE_SIGNATURE || !VISIT_FORMAL_TYPE_PARAMETER_STATES.contains(state)) {
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   183
            throw new IllegalStateException();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   184
        }
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   185
        checkIdentifier(name, "formal type parameter");
52515
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   186
        state = State.FORMAL;
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   187
        if (signatureVisitor != null) {
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   188
            signatureVisitor.visitFormalTypeParameter(name);
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   189
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   190
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   191
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   192
    @Override
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   193
    public SignatureVisitor visitClassBound() {
52515
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   194
        if (type == TYPE_SIGNATURE || !VISIT_CLASS_BOUND_STATES.contains(state)) {
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   195
            throw new IllegalStateException();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   196
        }
52515
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   197
        state = State.BOUND;
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   198
        return new CheckSignatureAdapter(
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   199
                TYPE_SIGNATURE, signatureVisitor == null ? null : signatureVisitor.visitClassBound());
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   200
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   201
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   202
    @Override
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   203
    public SignatureVisitor visitInterfaceBound() {
52515
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   204
        if (type == TYPE_SIGNATURE || !VISIT_INTERFACE_BOUND_STATES.contains(state)) {
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   205
            throw new IllegalArgumentException();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   206
        }
52515
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   207
        return new CheckSignatureAdapter(
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   208
                TYPE_SIGNATURE, signatureVisitor == null ? null : signatureVisitor.visitInterfaceBound());
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   209
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   210
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   211
    // class signatures
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   212
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   213
    @Override
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   214
    public SignatureVisitor visitSuperclass() {
52515
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   215
        if (type != CLASS_SIGNATURE || !VISIT_SUPER_CLASS_STATES.contains(state)) {
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   216
            throw new IllegalArgumentException();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   217
        }
52515
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   218
        state = State.SUPER;
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   219
        return new CheckSignatureAdapter(
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   220
                TYPE_SIGNATURE, signatureVisitor == null ? null : signatureVisitor.visitSuperclass());
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   221
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   222
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   223
    @Override
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   224
    public SignatureVisitor visitInterface() {
52515
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   225
        if (type != CLASS_SIGNATURE || !VISIT_INTERFACE_STATES.contains(state)) {
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   226
            throw new IllegalStateException();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   227
        }
52515
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   228
        return new CheckSignatureAdapter(
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   229
                TYPE_SIGNATURE, signatureVisitor == null ? null : signatureVisitor.visitInterface());
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   230
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   231
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   232
    // method signatures
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   233
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   234
    @Override
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   235
    public SignatureVisitor visitParameterType() {
52515
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   236
        if (type != METHOD_SIGNATURE || !VISIT_PARAMETER_TYPE_STATES.contains(state)) {
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   237
            throw new IllegalArgumentException();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   238
        }
52515
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   239
        state = State.PARAM;
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   240
        return new CheckSignatureAdapter(
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   241
                TYPE_SIGNATURE, signatureVisitor == null ? null : signatureVisitor.visitParameterType());
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   242
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   243
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   244
    @Override
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   245
    public SignatureVisitor visitReturnType() {
52515
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   246
        if (type != METHOD_SIGNATURE || !VISIT_RETURN_TYPE_STATES.contains(state)) {
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   247
            throw new IllegalArgumentException();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   248
        }
52515
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   249
        state = State.RETURN;
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   250
        CheckSignatureAdapter checkSignatureAdapter =
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   251
                new CheckSignatureAdapter(
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   252
                        TYPE_SIGNATURE, signatureVisitor == null ? null : signatureVisitor.visitReturnType());
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   253
        checkSignatureAdapter.canBeVoid = true;
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   254
        return checkSignatureAdapter;
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   255
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   256
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   257
    @Override
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   258
    public SignatureVisitor visitExceptionType() {
52515
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   259
        if (type != METHOD_SIGNATURE || !VISIT_EXCEPTION_TYPE_STATES.contains(state)) {
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   260
            throw new IllegalStateException();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   261
        }
52515
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   262
        return new CheckSignatureAdapter(
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   263
                TYPE_SIGNATURE, signatureVisitor == null ? null : signatureVisitor.visitExceptionType());
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   264
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   265
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   266
    // type signatures
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   267
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   268
    @Override
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   269
    public void visitBaseType(final char descriptor) {
52515
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   270
        if (type != TYPE_SIGNATURE || state != State.EMPTY) {
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   271
            throw new IllegalStateException();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   272
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   273
        if (descriptor == 'V') {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   274
            if (!canBeVoid) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   275
                throw new IllegalArgumentException();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   276
            }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   277
        } else {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   278
            if ("ZCBSIFJD".indexOf(descriptor) == -1) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   279
                throw new IllegalArgumentException();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   280
            }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   281
        }
52515
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   282
        state = State.SIMPLE_TYPE;
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   283
        if (signatureVisitor != null) {
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   284
            signatureVisitor.visitBaseType(descriptor);
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   285
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   286
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   287
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   288
    @Override
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   289
    public void visitTypeVariable(final String name) {
52515
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   290
        if (type != TYPE_SIGNATURE || state != State.EMPTY) {
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   291
            throw new IllegalStateException();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   292
        }
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   293
        checkIdentifier(name, "type variable");
52515
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   294
        state = State.SIMPLE_TYPE;
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   295
        if (signatureVisitor != null) {
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   296
            signatureVisitor.visitTypeVariable(name);
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   297
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   298
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   299
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   300
    @Override
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   301
    public SignatureVisitor visitArrayType() {
52515
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   302
        if (type != TYPE_SIGNATURE || state != State.EMPTY) {
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   303
            throw new IllegalStateException();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   304
        }
52515
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   305
        state = State.SIMPLE_TYPE;
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   306
        return new CheckSignatureAdapter(
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   307
                TYPE_SIGNATURE, signatureVisitor == null ? null : signatureVisitor.visitArrayType());
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   308
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   309
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   310
    @Override
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   311
    public void visitClassType(final String name) {
52515
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   312
        if (type != TYPE_SIGNATURE || state != State.EMPTY) {
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   313
            throw new IllegalStateException();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   314
        }
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   315
        checkClassName(name, "class name");
52515
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   316
        state = State.CLASS_TYPE;
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   317
        if (signatureVisitor != null) {
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   318
            signatureVisitor.visitClassType(name);
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   319
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   320
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   321
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   322
    @Override
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   323
    public void visitInnerClassType(final String name) {
52515
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   324
        if (state != State.CLASS_TYPE) {
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   325
            throw new IllegalStateException();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   326
        }
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   327
        checkIdentifier(name, "inner class name");
52515
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   328
        if (signatureVisitor != null) {
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   329
            signatureVisitor.visitInnerClassType(name);
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   330
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   331
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   332
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   333
    @Override
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   334
    public void visitTypeArgument() {
52515
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   335
        if (state != State.CLASS_TYPE) {
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   336
            throw new IllegalStateException();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   337
        }
52515
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   338
        if (signatureVisitor != null) {
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   339
            signatureVisitor.visitTypeArgument();
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   340
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   341
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   342
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   343
    @Override
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   344
    public SignatureVisitor visitTypeArgument(final char wildcard) {
52515
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   345
        if (state != State.CLASS_TYPE) {
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   346
            throw new IllegalStateException();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   347
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   348
        if ("+-=".indexOf(wildcard) == -1) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   349
            throw new IllegalArgumentException();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   350
        }
52515
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   351
        return new CheckSignatureAdapter(
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   352
                TYPE_SIGNATURE,
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   353
                signatureVisitor == null ? null : signatureVisitor.visitTypeArgument(wildcard));
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   354
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   355
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   356
    @Override
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   357
    public void visitEnd() {
52515
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   358
        if (state != State.CLASS_TYPE) {
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   359
            throw new IllegalStateException();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   360
        }
52515
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   361
        state = State.END;
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   362
        if (signatureVisitor != null) {
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   363
            signatureVisitor.visitEnd();
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   364
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   365
    }
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   366
52515
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   367
    private void checkClassName(final String name, final String message) {
53018
8bf9268df0e2 8215281: Use String.isEmpty() when applicable in java.base
redestad
parents: 52515
diff changeset
   368
        if (name == null || name.isEmpty()) {
52515
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   369
            throw new IllegalArgumentException(INVALID + message + " (must not be null or empty)");
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   370
        }
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   371
        for (int i = 0; i < name.length(); ++i) {
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   372
            if (".;[<>:".indexOf(name.charAt(i)) != -1) {
52515
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   373
                throw new IllegalArgumentException(
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   374
                        INVALID + message + " (must not contain . ; [ < > or :): " + name);
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   375
            }
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   376
        }
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   377
    }
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   378
52515
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   379
    private void checkIdentifier(final String name, final String message) {
53018
8bf9268df0e2 8215281: Use String.isEmpty() when applicable in java.base
redestad
parents: 52515
diff changeset
   380
        if (name == null || name.isEmpty()) {
52515
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   381
            throw new IllegalArgumentException(INVALID + message + " (must not be null or empty)");
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   382
        }
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   383
        for (int i = 0; i < name.length(); ++i) {
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   384
            if (".;[/<>:".indexOf(name.charAt(i)) != -1) {
52515
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   385
                throw new IllegalArgumentException(
746df0ae4fe1 8213480: update internal ASM version to 7.0
vromero
parents: 47488
diff changeset
   386
                        INVALID + message + " (must not contain . ; [ / < > or :): " + name);
47488
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   387
            }
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   388
        }
2af7932c2f6f 8190287: Update JDK's internal ASM to ASMv6
ksrini
parents: 47216
diff changeset
   389
    }
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   390
}