exceptionsattr.java

来自「本人根据自己的实际情况」· Java 代码 · 共 56 行

JAVA
56
字号
/**
 *
 */
package gen.info.attr;

import gen.constvalue.AttrInfoTag;
import java.io.DataOutputStream;
import java.io.IOException;

/**
 *  Exceptions_attribute {
 *      u2 attribute_name_index;
 *      u4 attribute_length;
 *      u2 number_of_exceptions;
 *      u2 exception_index_table[number_of_exceptions];
 *  }
 *
 * @author liuyi
 *
 */
public class ExceptionsAttr extends AttributeInfo implements AttrInfoTag {
    
    private final short number_of_exceptions = 1;
    
    //special here
    private short exceptionIndex; 
    
    /**
     * @param tag
     */
    public ExceptionsAttr() {
        super(ATTR_Exceptions);
        length = 4;
    }
    
    public short getExceptionNumber(){
        return number_of_exceptions;
    }
    
    public void setExceptionIndex(int exceptionIndex){
        this.exceptionIndex = (short)exceptionIndex;
    }
    
    public int getExceptionIndex(){
        return exceptionIndex;
    }

    public void toBinary(DataOutputStream writer) throws IOException {
        writer.writeShort(nameIndex);
        writer.writeInt(length);
        writer.writeShort(number_of_exceptions);
        writer.writeShort(exceptionIndex);
    }
    
}

⌨️ 快捷键说明

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