ksrini@826: /* jjg@1358: * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. ksrini@826: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ksrini@826: * ksrini@826: * This code is free software; you can redistribute it and/or modify it ksrini@826: * under the terms of the GNU General Public License version 2 only, as ksrini@826: * published by the Free Software Foundation. Oracle designates this ksrini@826: * particular file as subject to the "Classpath" exception as provided ksrini@826: * by Oracle in the LICENSE file that accompanied this code. ksrini@826: * ksrini@826: * This code is distributed in the hope that it will be useful, but WITHOUT ksrini@826: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ksrini@826: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ksrini@826: * version 2 for more details (a copy is included in the LICENSE file that ksrini@826: * accompanied this code). ksrini@826: * ksrini@826: * You should have received a copy of the GNU General Public License version ksrini@826: * 2 along with this work; if not, write to the Free Software Foundation, ksrini@826: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. ksrini@826: * ksrini@826: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ksrini@826: * or visit www.oracle.com if you need additional information or have any ksrini@826: * questions. ksrini@826: */ ksrini@826: ksrini@826: package com.sun.tools.classfile; ksrini@826: ksrini@826: import java.io.IOException; ksrini@826: ksrini@826: /** jjg@1358: * See JVMS 4.7.21 jjg@1358: * http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.7.21 ksrini@826: * ksrini@826: *
This is NOT part of any supported API.
ksrini@826: * If you write code that depends on this, you do so at your own risk.
ksrini@826: * This code and its internal interfaces are subject to change or
ksrini@826: * deletion without notice.
ksrini@826: */
ksrini@826: public class BootstrapMethods_attribute extends Attribute {
ksrini@826: public final BootstrapMethodSpecifier[] bootstrap_method_specifiers;
ksrini@826:
ksrini@826: BootstrapMethods_attribute(ClassReader cr, int name_index, int length)
ksrini@826: throws IOException, AttributeException {
ksrini@826: super(name_index, length);
ksrini@826: int bootstrap_method_count = cr.readUnsignedShort();
ksrini@826: bootstrap_method_specifiers = new BootstrapMethodSpecifier[bootstrap_method_count];
ksrini@826: for (int i = 0; i < bootstrap_method_specifiers.length; i++)
ksrini@826: bootstrap_method_specifiers[i] = new BootstrapMethodSpecifier(cr);
ksrini@826: }
ksrini@826:
ksrini@826: public BootstrapMethods_attribute(int name_index, BootstrapMethodSpecifier[] bootstrap_method_specifiers) {
ksrini@826: super(name_index, length(bootstrap_method_specifiers));
ksrini@826: this.bootstrap_method_specifiers = bootstrap_method_specifiers;
ksrini@826: }
ksrini@826:
ksrini@826: public static int length(BootstrapMethodSpecifier[] bootstrap_method_specifiers) {
ksrini@826: int n = 2;
ksrini@826: for (BootstrapMethodSpecifier b : bootstrap_method_specifiers)
ksrini@826: n += b.length();
ksrini@826: return n;
ksrini@826: }
ksrini@826:
ksrini@826: @Override
ksrini@826: public