Java Bytecode Editor 是一个 JAVA 的字节码反汇编和修改器。它可以很方便的修改已经编译成 Class 文件的 JAVA 文件。

源代码在线查看: linenumbertableentry.java

软件大小: 1057 K
上传用户: kzdai22
关键词: JAVA Bytecode Editor Class
下载地址: 免注册下载 普通下载 VIP

相关代码

				/*
				    This library is free software; you can redistribute it and/or
				    modify it under the terms of the GNU General Public
				    License as published by the Free Software Foundation; either
				    version 2 of the license, or (at your option) any later version.
				*/
				
				package org.gjt.jclasslib.structures.attributes;
				
				import org.gjt.jclasslib.structures.*;
				
				import java.io.*;
				
				/**
				 * Describes an entry in a LineNumberTable attribute structure.
				 *
				 * @author Ingo Kegel, Vitor Carreira
				 * @version $Revision: 1.1 $ $Date: 2005/11/01 13:18:24 $
				 */
				public class LineNumberTableEntry extends AbstractStructure {
				
				    /**
				     * Length in bytes of a line number association.
				     */
				    public static final int LENGTH = 4;
				
				    private int startPc;
				    private int lineNumber;
				
				    /**
				     * Factory method for creating LineNumberTableEntry structures.
				     *
				     * @param in        the DataInput from which to read the
				     *                  LineNumberTableEntry structure
				     * @param classFile the parent class file of the structure to be created
				     * @return the new LineNumberTableEntry structure
				     * @throws InvalidByteCodeException if the byte code is invalid
				     * @throws IOException              if an exception occurs with the DataInput
				     */
				    public static LineNumberTableEntry create(DataInput in, ClassFile classFile)
				            throws InvalidByteCodeException, IOException {
				
				        LineNumberTableEntry lineNumberTableEntry = new LineNumberTableEntry();
				        lineNumberTableEntry.setClassFile(classFile);
				        lineNumberTableEntry.read(in);
				
				        return lineNumberTableEntry;
				    }
				
				    /**
				     * Get the start_pc of this line number association.
				     *
				     * @return the start_pc
				     */
				    public int getStartPc() {
				        return startPc;
				    }
				
				    /**
				     * Set the start_pc of this line number association.
				     *
				     * @param startPc the start_pc
				     */
				    public void setStartPc(int startPc) {
				        this.startPc = startPc;
				    }
				
				    /**
				     * Get the line number of this line number association.
				     *
				     * @return the line number
				     */
				    public int getLineNumber() {
				        return lineNumber;
				    }
				
				    /**
				     * Set the line number of this line number association.
				     *
				     * @param lineNumber the line number
				     */
				    public void setLineNumber(int lineNumber) {
				        this.lineNumber = lineNumber;
				    }
				
				    public void read(DataInput in)
				            throws InvalidByteCodeException, IOException {
				
				        startPc = in.readUnsignedShort();
				        lineNumber = in.readUnsignedShort();
				
				        if (debug) debug("read ");
				    }
				
				    public void write(DataOutput out)
				            throws InvalidByteCodeException, IOException {
				
				        super.write(out);
				        out.writeShort(startPc);
				        out.writeShort(lineNumber);
				        if (debug) debug("wrote ");
				    }
				
				    protected void debug(String message) {
				        super.debug(message + "LineNumberTable entry with start_pc " + startPc +
				                ", line_number " + lineNumber);
				    }
				
				    protected String printAccessFlagsVerbose(int accessFlags) {
				        if (accessFlags != 0)
				            throw new RuntimeException("Access flags should be zero: " + Integer.toHexString(accessFlags));
				        return "";
				    }
				
				}
							

相关资源