src/java.base/share/classes/jdk/internal/org/objectweb/asm/Attribute.java
author dholmes
Sat, 23 Jun 2018 01:32:41 -0400
changeset 50735 2f2af62dfac7
parent 47216 71c04702a3d5
child 52515 746df0ae4fe1
permissions -rw-r--r--
8010319: Implementation of JEP 181: Nest-Based Access Control Reviewed-by: alanb, psandoz, mchung, coleenp, acorn, mcimadamore, forax, jlahoda, sspitsyn, abuckley Contributed-by: alex.buckley@oracle.com, maurizio.mimadamore@oracle.com, mandy.chung@oracle.com, tobias.hartmann@oracle.com, david.holmes@oracle.com, vladimir.x.ivanov@oracle.com, karen.kinnear@oracle.com, vladimir.kozlov@oracle.com, john.r.rose@oracle.com, daniel.smith@oracle.com, serguei.spitsyn@oracle.com, kumardotsrinivasan@gmail.com, boris.ulasevich@bell-sw.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
     1
/*
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
     2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
     3
 *
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
     4
 * This code is free software; you can redistribute it and/or modify it
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
     5
 * under the terms of the GNU General Public License version 2 only, as
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
     6
 * published by the Free Software Foundation.  Oracle designates this
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
     7
 * particular file as subject to the "Classpath" exception as provided
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
     8
 * by Oracle in the LICENSE file that accompanied this code.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
     9
 *
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    14
 * accompanied this code).
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    15
 *
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    19
 *
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    22
 * questions.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    23
 */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    24
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    25
/*
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    26
 * This file is available under and governed by the GNU General Public
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    27
 * License version 2 only, as published by the Free Software Foundation.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    28
 * However, the following notice accompanied the original version of this
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    29
 * file:
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    30
 *
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    31
 * ASM: a very small and fast Java bytecode manipulation framework
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    32
 * Copyright (c) 2000-2011 INRIA, France Telecom
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    33
 * All rights reserved.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    34
 *
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    35
 * Redistribution and use in source and binary forms, with or without
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    36
 * modification, are permitted provided that the following conditions
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    37
 * are met:
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    38
 * 1. Redistributions of source code must retain the above copyright
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    39
 *    notice, this list of conditions and the following disclaimer.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    40
 * 2. Redistributions in binary form must reproduce the above copyright
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    41
 *    notice, this list of conditions and the following disclaimer in the
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    42
 *    documentation and/or other materials provided with the distribution.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    43
 * 3. Neither the name of the copyright holders nor the names of its
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    44
 *    contributors may be used to endorse or promote products derived from
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    45
 *    this software without specific prior written permission.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    46
 *
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    47
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    48
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    49
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    50
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    51
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    52
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    53
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    54
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    55
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    56
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    57
 * THE POSSIBILITY OF SUCH DAMAGE.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    58
 */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    59
package jdk.internal.org.objectweb.asm;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    60
50735
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
    61
import java.util.Arrays;
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
    62
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    63
/**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    64
 * A non standard class, field, method or code attribute.
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
 * @author Eric Bruneton
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    67
 * @author Eugene Kuleshov
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    68
 */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    69
public class Attribute {
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
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    72
     * The type of this attribute.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    73
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    74
    public final String type;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    75
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    76
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    77
     * The raw value of this attribute, used only for unknown attributes.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    78
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    79
    byte[] value;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    80
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    81
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    82
     * The next attribute in this attribute list. May be <tt>null</tt>.
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
    Attribute next;
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
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    87
     * Constructs a new empty attribute.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    88
     *
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
    89
     * @param type
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
    90
     *            the type of the attribute.
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    91
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    92
    protected Attribute(final String type) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    93
        this.type = type;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    94
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    95
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    96
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    97
     * Returns <tt>true</tt> if this type of attribute is unknown. The default
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    98
     * implementation of this method always returns <tt>true</tt>.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
    99
     *
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   100
     * @return <tt>true</tt> if this type of attribute is unknown.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   101
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   102
    public boolean isUnknown() {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   103
        return true;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   104
    }
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
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   107
     * Returns <tt>true</tt> if this type of attribute is a code attribute.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   108
     *
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   109
     * @return <tt>true</tt> if this type of attribute is a code attribute.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   110
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   111
    public boolean isCodeAttribute() {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   112
        return false;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   113
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   114
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
     * Returns the labels corresponding to this attribute.
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
     * @return the labels corresponding to this attribute, or <tt>null</tt> if
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   119
     *         this attribute is not a code attribute that contains labels.
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
    protected Label[] getLabels() {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   122
        return null;
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
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   125
    /**
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   126
     * Reads a {@link #type type} attribute. This method must return a
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   127
     * <i>new</i> {@link Attribute} object, of type {@link #type type},
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   128
     * corresponding to the <tt>len</tt> bytes starting at the given offset, in
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   129
     * the given class reader.
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   130
     *
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   131
     * @param cr
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   132
     *            the class that contains the attribute to be read.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   133
     * @param off
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   134
     *            index of the first byte of the attribute's content in
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   135
     *            {@link ClassReader#b cr.b}. The 6 attribute header bytes,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   136
     *            containing the type and the length of the attribute, are not
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   137
     *            taken into account here.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   138
     * @param len
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   139
     *            the length of the attribute's content.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   140
     * @param buf
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   141
     *            buffer to be used to call {@link ClassReader#readUTF8
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   142
     *            readUTF8}, {@link ClassReader#readClass(int,char[]) readClass}
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   143
     *            or {@link ClassReader#readConst readConst}.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   144
     * @param codeOff
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   145
     *            index of the first byte of code's attribute content in
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   146
     *            {@link ClassReader#b cr.b}, or -1 if the attribute to be read
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   147
     *            is not a code attribute. The 6 attribute header bytes,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   148
     *            containing the type and the length of the attribute, are not
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   149
     *            taken into account here.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   150
     * @param labels
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   151
     *            the labels of the method's code, or <tt>null</tt> if the
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   152
     *            attribute to be read is not a code attribute.
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   153
     * @return a <i>new</i> {@link Attribute} object corresponding to the given
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   154
     *         bytes.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   155
     */
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   156
    protected Attribute read(final ClassReader cr, final int off,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   157
            final int len, final char[] buf, final int codeOff,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   158
            final Label[] labels) {
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   159
        Attribute attr = new Attribute(type);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   160
        attr.value = new byte[len];
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   161
        System.arraycopy(cr.b, off, attr.value, 0, len);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   162
        return attr;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   163
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   164
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   165
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   166
     * Returns the byte array form of this attribute.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   167
     *
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   168
     * @param cw
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   169
     *            the class to which this attribute must be added. This
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   170
     *            parameter can be used to add to the constant pool of this
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   171
     *            class the items that corresponds to this attribute.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   172
     * @param code
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   173
     *            the bytecode of the method corresponding to this code
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   174
     *            attribute, or <tt>null</tt> if this attribute is not a code
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   175
     *            attributes.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   176
     * @param len
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   177
     *            the length of the bytecode of the method corresponding to this
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   178
     *            code attribute, or <tt>null</tt> if this attribute is not a
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   179
     *            code attribute.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   180
     * @param maxStack
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   181
     *            the maximum stack size of the method corresponding to this
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   182
     *            code attribute, or -1 if this attribute is not a code
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   183
     *            attribute.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   184
     * @param maxLocals
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   185
     *            the maximum number of local variables of the method
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   186
     *            corresponding to this code attribute, or -1 if this attribute
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   187
     *            is not a code attribute.
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   188
     * @return the byte array form of this attribute.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   189
     */
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   190
    protected ByteVector write(final ClassWriter cw, final byte[] code,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   191
            final int len, final int maxStack, final int maxLocals) {
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   192
        ByteVector v = new ByteVector();
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   193
        v.data = value;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   194
        v.length = value.length;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   195
        return v;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   196
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   197
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   198
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   199
     * Returns the length of the attribute list that begins with this attribute.
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
     * @return the length of the attribute list that begins with this attribute.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   202
     */
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   203
    final int getCount() {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   204
        int count = 0;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   205
        Attribute attr = this;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   206
        while (attr != null) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   207
            count += 1;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   208
            attr = attr.next;
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
        return count;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   211
    }
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
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   214
     * Returns the size of all the attributes in this attribute list.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   215
     *
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   216
     * @param cw
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   217
     *            the class writer to be used to convert the attributes into
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   218
     *            byte arrays, with the {@link #write write} method.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   219
     * @param code
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   220
     *            the bytecode of the method corresponding to these code
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   221
     *            attributes, or <tt>null</tt> if these attributes are not code
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   222
     *            attributes.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   223
     * @param len
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   224
     *            the length of the bytecode of the method corresponding to
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   225
     *            these code attributes, or <tt>null</tt> if these attributes
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   226
     *            are not code attributes.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   227
     * @param maxStack
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   228
     *            the maximum stack size of the method corresponding to these
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   229
     *            code attributes, or -1 if these attributes are not code
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   230
     *            attributes.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   231
     * @param maxLocals
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   232
     *            the maximum number of local variables of the method
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   233
     *            corresponding to these code attributes, or -1 if these
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   234
     *            attributes are not code attributes.
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   235
     * @return the size of all the attributes in this attribute list. This size
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   236
     *         includes the size of the attribute headers.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   237
     */
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   238
    final int getSize(final ClassWriter cw, final byte[] code, final int len,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   239
            final int maxStack, final int maxLocals) {
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   240
        Attribute attr = this;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   241
        int size = 0;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   242
        while (attr != null) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   243
            cw.newUTF8(attr.type);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   244
            size += attr.write(cw, code, len, maxStack, maxLocals).length + 6;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   245
            attr = attr.next;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   246
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   247
        return size;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   248
    }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   249
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   250
    /**
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   251
     * Writes all the attributes of this attribute list in the given byte
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   252
     * vector.
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   253
     *
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   254
     * @param cw
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   255
     *            the class writer to be used to convert the attributes into
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   256
     *            byte arrays, with the {@link #write write} method.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   257
     * @param code
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   258
     *            the bytecode of the method corresponding to these code
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   259
     *            attributes, or <tt>null</tt> if these attributes are not code
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   260
     *            attributes.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   261
     * @param len
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   262
     *            the length of the bytecode of the method corresponding to
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   263
     *            these code attributes, or <tt>null</tt> if these attributes
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   264
     *            are not code attributes.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   265
     * @param maxStack
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   266
     *            the maximum stack size of the method corresponding to these
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   267
     *            code attributes, or -1 if these attributes are not code
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   268
     *            attributes.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   269
     * @param maxLocals
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   270
     *            the maximum number of local variables of the method
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   271
     *            corresponding to these code attributes, or -1 if these
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   272
     *            attributes are not code attributes.
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   273
     * @param out
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   274
     *            where the attributes must be written.
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   275
     */
17420
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   276
    final void put(final ClassWriter cw, final byte[] code, final int len,
6163a8236046 8013225: Refresh jdk's private ASM to the latest.
ksrini
parents: 14198
diff changeset
   277
            final int maxStack, final int maxLocals, final ByteVector out) {
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   278
        Attribute attr = this;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   279
        while (attr != null) {
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   280
            ByteVector b = attr.write(cw, code, len, maxStack, maxLocals);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   281
            out.putShort(cw.newUTF8(attr.type)).putInt(b.length);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   282
            out.putByteArray(b.data, 0, b.length);
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   283
            attr = attr.next;
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   284
        }
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   285
    }
50735
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   286
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   287
    //The stuff below is temporary - once proper support for nestmate attribute has been added, it can be safely removed.
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   288
    //see also changes in ClassReader.accept.
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   289
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   290
    public static class NestMembers extends Attribute {
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   291
        public NestMembers() {
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   292
            super("NestMembers");
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   293
        }
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   294
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   295
        byte[] bytes;
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   296
        String[] classes;
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   297
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   298
        @Override
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   299
        protected Attribute read(ClassReader cr, int off, int len, char[] buf, int codeOff, Label[] labels) {
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   300
            int offset = off;
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   301
            NestMembers a = new NestMembers();
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   302
            int size = cr.readShort(off);
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   303
            a.classes = new String[size];
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   304
            off += 2;
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   305
            for (int i = 0; i < size ; i++) {
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   306
                a.classes[i] = cr.readClass(off, buf);
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   307
                off += 2;
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   308
            }
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   309
            a.bytes = Arrays.copyOfRange(cr.b, offset, offset + len);
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   310
            return a;
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   311
        }
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   312
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   313
        @Override
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   314
        protected ByteVector write(ClassWriter cw, byte[] code, int len, int maxStack, int maxLocals) {
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   315
            ByteVector v = new ByteVector(bytes.length);
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   316
            v.putShort(classes.length);
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   317
            for (String s : classes) {
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   318
                v.putShort(cw.newClass(s));
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   319
            }
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   320
            return v;
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   321
        }
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   322
    }
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   323
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   324
    public static class NestHost extends Attribute {
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   325
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   326
        byte[] bytes;
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   327
        String clazz;
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   328
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   329
        public NestHost() {
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   330
            super("NestHost");
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   331
        }
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   332
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   333
        @Override
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   334
        protected Attribute read(ClassReader cr, int off, int len, char[] buf, int codeOff, Label[] labels) {
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   335
            int offset = off;
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   336
            NestHost a = new NestHost();
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   337
            a.clazz = cr.readClass(off, buf);
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   338
            a.bytes = Arrays.copyOfRange(cr.b, offset, offset + len);
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   339
            return a;
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   340
        }
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   341
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   342
        @Override
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   343
        protected ByteVector write(ClassWriter cw, byte[] code, int len, int maxStack, int maxLocals) {
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   344
            ByteVector v = new ByteVector(bytes.length);
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   345
            v.putShort(cw.newClass(clazz));
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   346
            return v;
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   347
        }
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   348
    }
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   349
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   350
    static final Attribute[] DEFAULT_ATTRIBUTE_PROTOS = new Attribute[] {
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   351
        new NestMembers(),
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   352
        new NestHost()
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 47216
diff changeset
   353
    };
14198
071fd6fd257d 7197401: Add a subset of the org.objectweb.asm packages to jdk8
jjh
parents:
diff changeset
   354
}