langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/ConcealedPackages_attribute.java
author skovalev
Wed, 14 Sep 2016 17:28:17 +0300
changeset 40949 be7a612613ae
parent 36526 3b41f1c69604
permissions -rw-r--r--
8166032: Fix module dependencies for javax.SSL tests Reviewed-by: xuelei, weijun
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
     1
/*
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
     4
 *
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    10
 *
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    15
 * accompanied this code).
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    16
 *
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    20
 *
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    23
 * questions.
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    24
 */
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    25
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    26
package com.sun.tools.classfile;
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    27
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    28
import java.io.IOException;
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    29
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    30
/**
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    31
 * See JVMS, section 4.8.15.
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    32
 *
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    33
 *  <p><b>This is NOT part of any supported API.
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    34
 *  If you write code that depends on this, you do so at your own risk.
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    35
 *  This code and its internal interfaces are subject to change or
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    36
 *  deletion without notice.</b>
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    37
 */
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    38
public class ConcealedPackages_attribute extends Attribute {
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    39
    ConcealedPackages_attribute(ClassReader cr, int name_index, int length)
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    40
            throws IOException {
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    41
        super(name_index, length);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    42
        packages_count = cr.readUnsignedShort();
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    43
        packages_index = new int[packages_count];
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    44
        for (int i = 0; i < packages_count; i++)
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    45
            packages_index[i] = cr.readUnsignedShort();
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    46
    }
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    47
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    48
    public ConcealedPackages_attribute(ConstantPool constant_pool,
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    49
                                       int[] packages_index)
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    50
            throws ConstantPoolException {
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    51
        this(constant_pool.getUTF8Index(Attribute.ConcealedPackages),
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    52
             packages_index);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    53
    }
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    54
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    55
    public ConcealedPackages_attribute(int name_index,
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    56
                                       int[] packages_index) {
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    57
        super(name_index, 2 + packages_index.length * 2);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    58
        this.packages_count = packages_index.length;
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    59
        this.packages_index = packages_index;
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    60
    }
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    61
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    62
    public String getPackage(int index, ConstantPool constant_pool) throws ConstantPoolException {
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    63
        int package_index = packages_index[index];
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    64
        return constant_pool.getUTF8Value(package_index);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    65
    }
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    66
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    67
    @Override
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    68
    public <R, D> R accept(Visitor<R, D> visitor, D data) {
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    69
        return visitor.visitConcealedPackages(this, data);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    70
    }
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    71
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    72
    public final int packages_count;
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    73
    public final int[] packages_index;
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    74
}