⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 constantnameandtypeinfo.java

📁 本人根据自己的实际情况
💻 JAVA
字号:
/**
 *
 */
package gen.info.constant;

import gen.ClassFile;
import java.io.DataOutputStream;
import java.io.IOException;

/**
 * @author liuyi
 *
 */
public class ConstantNameAndTypeInfo extends CpInfo {
    
    /** index of constant pool */
    private short nameIndex;
    
    /** index of constant pool */
    private short descriptorIndex;
    
    /**
     * @param tag
     */
    public ConstantNameAndTypeInfo(ClassFile classFile) {
        super(CONSTANT_NameAndType, classFile);
    }
    
    public void setNameIndex(int index){
        this.nameIndex = (short)index;
    }
    
    public void setDescriptorIndex(int index){
        this.descriptorIndex = (short) index;
    }
    
    public short getNameIndex(){
        return this.nameIndex;
    }
    
    public short getDescriptorIndex(){
        return this.descriptorIndex;
    }
    
    public String getRefString(){
        return classFile.getRefString(nameIndex) + ":" + classFile.getRefString(descriptorIndex);
    }
    
    public String toString(){
        return "const #" + index + " = NameAndType\t#" + nameIndex + ":#" + descriptorIndex + ";\t// "
                + getRefString();
    }

    public void toBinary(DataOutputStream writer) throws IOException{
        writer.writeByte(tag);
        writer.writeShort(nameIndex);
        writer.writeShort(descriptorIndex);
    }    
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -