Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
* This program 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program.If not, write to
* The Free Software Foundation, Inc.,
* 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package jreversepro.reflect;
import jreversepro.common.Helper;
import jreversepro.common.JJvmOpcodes;
import jreversepro.common.JJvmSet;
import jreversepro.common.KeyWords;
import jreversepro.reflect.method.JBlockObject;
import jreversepro.reflect.method.JMethodBlock;
import jreversepro.runtime.JSymbolTable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.*;
/**
* JMethod is the abstract representation of a method in
* the class method..
*
* @author Karthik Kumar
*/
public class JMethod extends JMember implements KeyWords {
private static final Logger log = LoggerFactory.getLogger(JMethod.class);
/**
* Structure used during method building containing stack of
* code blocks currently open
*/
private final Stack blockStack;
/**
* This list contains the exception tables that are
* defined for this method.
* The members of this list are -
* JException
*/
private final List exceptionBlocks; // exception table
/**
* Information about fields, methods of the class being reverse engineered.
*/
private final JClassInfo mInfoClass;
/**
* Structure containing code
*/
private final JMethodBlock methodBlock;
/**
* First instruction in the method pool *
*/
JInstruction firstIns;
/**
* This contains the stringifed (disassembled) bytecodes for
* the method.
*/
private String bytecodeAsString;
/**
* This contains the bytecodes that are present for
* the method.
*/
private byte[] bytecodes;
/**
* This list contains the exception tables that are
* defined for this method.
* The members of this list are -
* JException
*/
private List instructions; // Instructions here.
/**
* This contains the LineNumberTable that may be
* compiled for this method. Nevertheless for decompiling
* purposes this cant be used since this is optional information
* in a class file. If debugging is turned off then the
* compiler wont bother to generate this LineNumberTable.
*/
private JLineNumberTable lineTable;
/**
* Maximum number of local variables present in
* the local variable table at any time.
*/
private int maxLocals;
/**
* Maximum size that the JVM stack will
* occupy on execution of all instructions
* present in this method.
*/
private int maxStack;
/**
* Signature of a method.
* For example for a method as follows.
* "public void doSomething( int ,int ) {"
* the signature will be (II)V
*/
private String signature;
/**
* Symbol table
*/
private JSymbolTable symbolTable;
/**
* Throws classes is a List containing String of
* the java data types that are thrown by this
* method.
*/
private List throwsClasses;
/**
* @param info The JSymbolTable associated with this class
* Creates a new JMethod
*/
public JMethod(JClassInfo info) {
mInfoClass = info;
blockStack = new Stack<>();
methodBlock = new JMethodBlock();
blockStack.push(methodBlock);
exceptionBlocks = new ArrayList<>();
throwsClasses = new ArrayList(2);
firstIns = null;
}
/**
* Add a new JBlockObject to the stack - indicates that a block
* is opening
*
* @param jbo JBlockObject to be added.
*/
public void addBlock(JBlockObject jbo) {
JBlockObject peekjbo = blockStack.peek();
peekjbo.addBlock(jbo);
blockStack.push(jbo); //push new block as the current open block
}
/**
* Add an exception block.
*
* @param startPc Start of the try block
* @param endPc End of try block
* @param handlerPc Beginning of handler block
* @param datatype Type of the class that the
* handler is going to handle.
*/
public void addExceptionBlock(int startPc, int endPc, int handlerPc, String datatype) {
JException exc = new JException(startPc, endPc, handlerPc, datatype);
//Probably some changes to the keys put in the list.
int tryIndex = exceptionBlocks.indexOf(exc);
if (tryIndex == -1) {
exceptionBlocks.add(exc);
} else {
JException oldTry = exceptionBlocks.get(tryIndex);
oldTry.addCatchBlock(handlerPc, datatype);
}
}
/**
* Adds a line of code to the current block
*
* @param loc Line Of Code to be added.
*/
public void addLineOfCode(JLineOfCode loc) {
JBlockObject jbo = blockStack.peek();
if (jbo == null) {
//yikes! Should NEVER happen, here for debugging
log.info("*** No blocks on the stack -- " + " cannot add code!!! ***");
return;
}
jbo.addStatement(loc); //add the LineOfCode to the current block
loc.setBlock(jbo); //set the LineOfCode's containing block
}
/**
* Close the current JBlockObject -- pop it from the stack
* Called when an end of block is reached.
*/
public void closeBlock() {
blockStack.pop();
}
/**
* Returns a map
*
* @return Returns a map of exception tables.
*/
public Map