1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/classes/com/sun/tools/classfile/EnclosingMethod_attribute.java Wed Apr 27 01:34:52 2016 +0800 1.3 @@ -0,0 +1,73 @@ 1.4 + 1.5 +/* 1.6 + * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. 1.7 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 + * 1.9 + * This code is free software; you can redistribute it and/or modify it 1.10 + * under the terms of the GNU General Public License version 2 only, as 1.11 + * published by the Free Software Foundation. Oracle designates this 1.12 + * particular file as subject to the "Classpath" exception as provided 1.13 + * by Oracle in the LICENSE file that accompanied this code. 1.14 + * 1.15 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.16 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.17 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.18 + * version 2 for more details (a copy is included in the LICENSE file that 1.19 + * accompanied this code). 1.20 + * 1.21 + * You should have received a copy of the GNU General Public License version 1.22 + * 2 along with this work; if not, write to the Free Software Foundation, 1.23 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.24 + * 1.25 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.26 + * or visit www.oracle.com if you need additional information or have any 1.27 + * questions. 1.28 + */ 1.29 + 1.30 +package com.sun.tools.classfile; 1.31 + 1.32 +import java.io.IOException; 1.33 + 1.34 +/** 1.35 + * See JVMS, section 4.8.7. 1.36 + * 1.37 + * <p><b>This is NOT part of any supported API. 1.38 + * If you write code that depends on this, you do so at your own risk. 1.39 + * This code and its internal interfaces are subject to change or 1.40 + * deletion without notice.</b> 1.41 + */ 1.42 +public class EnclosingMethod_attribute extends Attribute { 1.43 + EnclosingMethod_attribute(ClassReader cr, int name_index, int length) throws IOException { 1.44 + super(name_index, length); 1.45 + class_index = cr.readUnsignedShort(); 1.46 + method_index = cr.readUnsignedShort(); 1.47 + } 1.48 + 1.49 + public EnclosingMethod_attribute(ConstantPool constant_pool, int class_index, int method_index) 1.50 + throws ConstantPoolException { 1.51 + this(constant_pool.getUTF8Index(Attribute.EnclosingMethod), class_index, method_index); 1.52 + } 1.53 + 1.54 + public EnclosingMethod_attribute(int name_index, int class_index, int method_index) { 1.55 + super(name_index, 4); 1.56 + this.class_index = class_index; 1.57 + this.method_index = method_index; 1.58 + } 1.59 + 1.60 + public String getClassName(ConstantPool constant_pool) throws ConstantPoolException { 1.61 + return constant_pool.getClassInfo(class_index).getName(); 1.62 + } 1.63 + 1.64 + public String getMethodName(ConstantPool constant_pool) throws ConstantPoolException { 1.65 + if (method_index == 0) 1.66 + return ""; 1.67 + return constant_pool.getNameAndTypeInfo(method_index).getName(); 1.68 + } 1.69 + 1.70 + public <R, D> R accept(Visitor<R, D> visitor, D data) { 1.71 + return visitor.visitEnclosingMethod(this, data); 1.72 + } 1.73 + 1.74 + public final int class_index; 1.75 + public final int method_index; 1.76 +}