|
|
|
|
|
|
|
*/ |
|
/* |
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
|
* contributor license agreements. See the NOTICE file distributed with |
|
* this work for additional information regarding copyright ownership. |
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
|
* (the "License"); you may not use this file except in compliance with |
|
* the License. You may obtain a copy of the License at |
|
* |
|
* http://www.apache.org/licenses/LICENSE-2.0 |
|
* |
|
* Unless required by applicable law or agreed to in writing, software |
|
* distributed under the License is distributed on an "AS IS" BASIS, |
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
* See the License for the specific language governing permissions and |
|
* limitations under the License. |
|
*/ |
|
|
|
package com.sun.org.apache.bcel.internal.classfile; |
|
|
|
import java.io.DataInput; |
|
import java.io.DataOutputStream; |
|
import java.io.IOException; |
|
|
|
import com.sun.org.apache.bcel.internal.Const; |
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public final class ModuleMainClass extends Attribute { |
|
|
|
private int mainClassIndex; |
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public ModuleMainClass(final ModuleMainClass c) { |
|
this(c.getNameIndex(), c.getLength(), c.getHostClassIndex(), c.getConstantPool()); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public ModuleMainClass(final int name_index, final int length, final int mainClassIndex, |
|
final ConstantPool constantPool) { |
|
super(Const.ATTR_NEST_MEMBERS, name_index, length, constantPool); |
|
this.mainClassIndex = mainClassIndex; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
ModuleMainClass(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException { |
|
this(nameIndex, length, 0, constantPool); |
|
mainClassIndex = input.readUnsignedShort(); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
@Override |
|
public void accept( final Visitor v ) { |
|
v.visitModuleMainClass(this); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
@Override |
|
public void dump( final DataOutputStream file ) throws IOException { |
|
super.dump(file); |
|
file.writeShort(mainClassIndex); |
|
} |
|
|
|
|
|
|
|
|
|
*/ |
|
public int getHostClassIndex() { |
|
return mainClassIndex; |
|
} |
|
|
|
|
|
|
|
|
|
*/ |
|
public void setHostClassIndex( final int mainClassIndex ) { |
|
this.mainClassIndex = mainClassIndex; |
|
} |
|
|
|
|
|
|
|
|
|
*/ |
|
@Override |
|
public String toString() { |
|
final StringBuilder buf = new StringBuilder(); |
|
buf.append("ModuleMainClass: "); |
|
final String class_name = super.getConstantPool().getConstantString(mainClassIndex, Const.CONSTANT_Class); |
|
buf.append(Utility.compactClassName(class_name, false)); |
|
return buf.toString(); |
|
} |
|
|
|
|
|
|
|
|
|
*/ |
|
@Override |
|
public Attribute copy( final ConstantPool _constant_pool ) { |
|
final ModuleMainClass c = (ModuleMainClass) clone(); |
|
c.setConstantPool(_constant_pool); |
|
return c; |
|
} |
|
} |