ModuleMainClass_attribute.java revision 3792:d516975e8110
154359Sroberto/* 254359Sroberto * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. 354359Sroberto * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 454359Sroberto * 554359Sroberto * This code is free software; you can redistribute it and/or modify it 654359Sroberto * under the terms of the GNU General Public License version 2 only, as 754359Sroberto * published by the Free Software Foundation. Oracle designates this 854359Sroberto * particular file as subject to the "Classpath" exception as provided 954359Sroberto * by Oracle in the LICENSE file that accompanied this code. 1054359Sroberto * 1154359Sroberto * This code is distributed in the hope that it will be useful, but WITHOUT 1254359Sroberto * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13106424Sroberto * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14280849Scy * version 2 for more details (a copy is included in the LICENSE file that 15280849Scy * accompanied this code). 16280849Scy * 17280849Scy * You should have received a copy of the GNU General Public License version 18280849Scy * 2 along with this work; if not, write to the Free Software Foundation, 19280849Scy * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2054359Sroberto * 21280849Scy * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22280849Scy * or visit www.oracle.com if you need additional information or have any 23280849Scy * questions. 24280849Scy */ 25280849Scy 26280849Scypackage com.sun.tools.classfile; 27280849Scy 28280849Scyimport java.io.IOException; 2954359Sroberto 30280849Scy/** 3154359Sroberto * See JVMS, section 4.8.15. 3254359Sroberto * 3354359Sroberto * <p><b>This is NOT part of any supported API. 3454359Sroberto * If you write code that depends on this, you do so at your own risk. 3554359Sroberto * This code and its internal interfaces are subject to change or 3654359Sroberto * deletion without notice.</b> 3754359Sroberto */ 3854359Srobertopublic class ModuleMainClass_attribute extends Attribute { 39280849Scy ModuleMainClass_attribute(ClassReader cr, int name_index, int length) throws IOException { 40280849Scy super(name_index, length); 4154359Sroberto main_class_index = cr.readUnsignedShort(); 4254359Sroberto } 4354359Sroberto 44280849Scy public ModuleMainClass_attribute(ConstantPool constant_pool, int mainClass_index) 45280849Scy throws ConstantPoolException { 4682498Sroberto this(constant_pool.getUTF8Index(Attribute.ModuleMainClass), mainClass_index); 47280849Scy } 48280849Scy 49280849Scy public ModuleMainClass_attribute(int name_index, int mainClass_index) { 5054359Sroberto super(name_index, 2); 51280849Scy this.main_class_index = mainClass_index; 52280849Scy } 53280849Scy 54280849Scy public String getMainClassName(ConstantPool constant_pool) throws ConstantPoolException { 5554359Sroberto return constant_pool.getClassInfo(main_class_index).getName(); 56280849Scy } 57 58 @Override 59 public <R, D> R accept(Visitor<R, D> visitor, D data) { 60 return visitor.visitModuleMainClass(this, data); 61 } 62 63 public final int main_class_index; 64} 65