Package bytecodeparser.analysis.stack

Examples of bytecodeparser.analysis.stack.StackAnalyzer


                    CtField signature = CtField.make("public static String[] $" + behavior.getName() + "0 = new String[0];", ctClass);
                    ctClass.addField(signature);
                    continue;
                }

                StackAnalyzer parser = new StackAnalyzer(behavior);

                // first, compute hash for parameter names
                CtClass[] signatureTypes = behavior.getParameterTypes();
                int memberShift = Modifier.isStatic(behavior.getModifiers()) ? 0 : 1;

                if(signatureTypes.length > parser.context.localVariables.size() - memberShift) {
                    Logger.debug("ignoring method: %s %s (local vars numbers differs : %s != %s)", Modifier.toString(behavior.getModifiers()), behavior.getLongName(), signatureTypes.length, parser.context.localVariables.size() - memberShift);
                    continue;
                }

                StringBuffer signatureNames;
                if(signatureTypes.length == 0)
                    signatureNames = new StringBuffer("new String[0];");
                else {
                    signatureNames = new StringBuffer("new String[] {");

                    for(int i = memberShift; i < signatureTypes.length + memberShift; i++) {
                        if(i > memberShift)
                            signatureNames.append(",");

                        signatureNames.append("\"").append(parser.context.localVariables.get(i).name).append("\"");
                    }
                    signatureNames.append("};");
                }

                CtField signature = CtField.make("public static String[] $" + behavior.getName() + computeMethodHash(signatureTypes) + " = " + signatureNames.toString(), ctClass);
                ctClass.addField(signature);
                // end

                Frames frames = parser.analyze();
                CodeAttribute codeAttribute = behavior.getMethodInfo().getCodeAttribute();
                FrameIterator iterator = frames.iterator();
                while(iterator.hasNext()) {
                    Frame frame = iterator.next();
                    if(!frame.isAccessible) {
View Full Code Here


  @org.junit.Test
  public void simpleMultinewarray() throws BadBytecode {
    System.out.println("multinewarray");
    CtClass clazz = getCtClass("test.subjects.SimpleSubjects");
    CtMethod method = getMethod(clazz, "multinewarray");
    StackAnalyzer analyzer = new StackAnalyzer(method);
    analyzer.analyze();
  }
View Full Code Here

  @org.junit.Test
  public void wideTest() throws BadBytecode {
    System.out.println("WideTestSubject.wideTestSubject");
    CtClass clazz = getCtClass("test.subjects.WideTestSubject");
    CtMethod method = getMethod(clazz, "wideTestSubject");
    StackAnalyzer analyzer = new StackAnalyzer(method);
    Frames frames = analyzer.analyze();
    for(Frame frame : frames) {
      if(frame.decodedOp instanceof DecodedMethodInvocationOp) {
        DecodedMethodInvocationOp dmio = (DecodedMethodInvocationOp) frame.decodedOp;
        String[] names = DecodedMethodInvocationOp.resolveParametersNames(frame, true);
        if(dmio.getName().equals("mixed2")) {
View Full Code Here

  @org.junit.Test
  public void simpleSubjectsSimple() throws BadBytecode {
    System.out.println("simpleSubjectsSimple");
    CtClass clazz = getCtClass("test.subjects.SimpleSubjects");
    CtMethod method = getMethod(clazz, "simple");
    StackAnalyzer analyzer = new StackAnalyzer(method);
    Frames frames = analyzer.analyze();
    for(Frame frame : frames) {
      if(frame.decodedOp instanceof DecodedMethodInvocationOp) {
        DecodedMethodInvocationOp dmio = (DecodedMethodInvocationOp) frame.decodedOp;
        if(dmio.getName().equals("classic")) {
          String[] names = DecodedMethodInvocationOp.resolveParametersNames(frame, false);
View Full Code Here

  @org.junit.Test
  public void simpleSubjectsSimpleWithParams() throws BadBytecode {
    System.out.println("simpleSubjectsSimpleWithParams");
    CtClass clazz = getCtClass("test.subjects.SimpleSubjects");
    CtMethod method = getMethod(clazz, "simpleWithParams");
    StackAnalyzer analyzer = new StackAnalyzer(method);
    Frames frames = analyzer.analyze();
    for(Frame frame : frames) {
      if(frame.decodedOp instanceof DecodedMethodInvocationOp) {
        DecodedMethodInvocationOp dmio = (DecodedMethodInvocationOp) frame.decodedOp;
        if(dmio.getName().equals("classic")) {
          String[] names = DecodedMethodInvocationOp.resolveParametersNames(frame, false);
View Full Code Here

  @org.junit.Test
  public void simpleSubjectsSimpleWithConditionals() throws BadBytecode {
    System.out.println("simpleSubjectsSimpleWithConditionals");
    CtClass clazz = getCtClass("test.subjects.SimpleSubjects");
    CtMethod method = getMethod(clazz, "simpleWithConditionals");
    StackAnalyzer analyzer = new StackAnalyzer(method);
    Frames frames = analyzer.analyze();
    for(Frame frame : frames) {
      if(frame.decodedOp instanceof DecodedMethodInvocationOp) {
        DecodedMethodInvocationOp dmio = (DecodedMethodInvocationOp) frame.decodedOp;
        if(dmio.getName().equals("classic")) {
          String[] names = DecodedMethodInvocationOp.resolveParametersNames(frame, false);
View Full Code Here

  @org.junit.Test
  public void simpleSubjectsVarargs() throws BadBytecode {
    System.out.println("simpleSubjectsVarargs");
    CtClass clazz = getCtClass("test.subjects.SimpleSubjects");
    CtMethod method = getMethod(clazz, "varargs");
    StackAnalyzer analyzer = new StackAnalyzer(method);
    Frames frames = analyzer.analyze();
    for(Frame frame : frames) {
      if(frame.decodedOp instanceof DecodedMethodInvocationOp) {
        DecodedMethodInvocationOp dmio = (DecodedMethodInvocationOp) frame.decodedOp;
        if(dmio.getName().equals("varargs")) {
          String[] names = DecodedMethodInvocationOp.resolveParametersNames(frame, true);
View Full Code Here

  @org.junit.Test
  public void simpleSubjectsExceptions() throws BadBytecode {
    System.out.println("simpleSubjectsExceptions");
    CtClass clazz = getCtClass("test.subjects.SimpleSubjects");
    CtMethod method = getMethod(clazz, "exceptions");
    StackAnalyzer analyzer = new StackAnalyzer(method);
    Frames frames = analyzer.analyze();
    for(Frame frame : frames) {
      if(frame.decodedOp instanceof DecodedMethodInvocationOp) {
        DecodedMethodInvocationOp dmio = (DecodedMethodInvocationOp) frame.decodedOp;
        if(dmio.getName().equals("classic")) {
          String[] names = DecodedMethodInvocationOp.resolveParametersNames(frame, false);
View Full Code Here

  @org.junit.Test
  public void simpleSubjectsTableSwitchBlock() throws BadBytecode {
    System.out.println("simpleSubjectsTableSwitchBlock");
    CtClass clazz = getCtClass("test.subjects.SimpleSubjects");
    CtMethod method = getMethod(clazz, "tableswitchBlock");
    StackAnalyzer analyzer = new StackAnalyzer(method);
    Frames frames = analyzer.analyze();
    for(Frame frame : frames) {
      if(frame.decodedOp instanceof DecodedMethodInvocationOp) {
        DecodedMethodInvocationOp dmio = (DecodedMethodInvocationOp) frame.decodedOp;
        if(dmio.getName().equals("classic")) {
          String[] names = DecodedMethodInvocationOp.resolveParametersNames(frame, false);
View Full Code Here

  @org.junit.Test
  public void simpleSubjectsLookupSwitchBlock() throws BadBytecode {
    System.out.println("simpleSubjectsLookupSwitchBlock");
    CtClass clazz = getCtClass("test.subjects.SimpleSubjects");
    CtMethod method = getMethod(clazz, "lookupswitchBlock");
    StackAnalyzer analyzer = new StackAnalyzer(method);
    Frames frames = analyzer.analyze();
    for(Frame frame : frames) {
      if(frame.decodedOp instanceof DecodedMethodInvocationOp) {
        DecodedMethodInvocationOp dmio = (DecodedMethodInvocationOp) frame.decodedOp;
        if(dmio.getName().equals("classic")) {
          String[] names = DecodedMethodInvocationOp.resolveParametersNames(frame, false);
View Full Code Here

TOP

Related Classes of bytecodeparser.analysis.stack.StackAnalyzer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.