当前位置: 首页>>代码示例>>Java>>正文


Java Frame类代码示例

本文整理汇总了Java中org.objectweb.asm.tree.analysis.Frame的典型用法代码示例。如果您正苦于以下问题:Java Frame类的具体用法?Java Frame怎么用?Java Frame使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Frame类属于org.objectweb.asm.tree.analysis包,在下文中一共展示了Frame类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkArrayArgs

import org.objectweb.asm.tree.analysis.Frame; //导入依赖的package包/类
private void checkArrayArgs(MethodNode methodNode, Frame<BasicValue> logMessageFrame, Frame<BasicValue> arraySizeFrame,
                            int lineNumber, MethodInsnNode methodInsn, int messageIndex, int arrayIndex) {
    BasicValue arraySizeObject = getStackValue(arraySizeFrame, methodInsn, arrayIndex);
    if (arraySizeObject instanceof ArraySizeBasicValue == false) {
        wrongUsageCallback.accept(new WrongLoggerUsage(className, methodNode.name, methodInsn.name, lineNumber,
            "Could not determine size of array"));
        return;
    }
    ArraySizeBasicValue arraySize = (ArraySizeBasicValue) arraySizeObject;
    PlaceHolderStringBasicValue logMessageLength = checkLogMessageConsistency(methodNode, logMessageFrame, lineNumber, methodInsn,
        messageIndex, arraySize.minValue);
    if (logMessageLength == null) {
        return;
    }
    if (arraySize.minValue != arraySize.maxValue) {
        wrongUsageCallback.accept(new WrongLoggerUsage(className, methodNode.name, methodInsn.name, lineNumber,
            "Multiple parameter arrays with conflicting sizes"));
        return;
    }
    assert logMessageLength.minValue == logMessageLength.maxValue && arraySize.minValue == arraySize.maxValue;
    if (logMessageLength.minValue != arraySize.minValue) {
        wrongUsageCallback.accept(new WrongLoggerUsage(className, methodNode.name, methodInsn.name, lineNumber,
            "Expected " + logMessageLength.minValue + " arguments but got " + arraySize.minValue));
        return;
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:27,代码来源:ESLoggerUsageChecker.java

示例2: checkLogMessageConsistency

import org.objectweb.asm.tree.analysis.Frame; //导入依赖的package包/类
private PlaceHolderStringBasicValue checkLogMessageConsistency(MethodNode methodNode, Frame<BasicValue> logMessageFrame,
                                                               int lineNumber, MethodInsnNode methodInsn, int messageIndex,
                                                               int argsSize) {
    BasicValue logMessageLengthObject = getStackValue(logMessageFrame, methodInsn, messageIndex);
    if (logMessageLengthObject instanceof PlaceHolderStringBasicValue == false) {
        if (argsSize > 0) {
            wrongUsageCallback.accept(new WrongLoggerUsage(className, methodNode.name, methodInsn.name, lineNumber,
                "First argument must be a string constant so that we can statically ensure proper place holder usage"));
        } else {
            // don't check logger usage for logger.warn(someObject)
        }
        return null;
    }
    PlaceHolderStringBasicValue logMessageLength = (PlaceHolderStringBasicValue) logMessageLengthObject;
    if (logMessageLength.minValue != logMessageLength.maxValue) {
        wrongUsageCallback.accept(new WrongLoggerUsage(className, methodNode.name, methodInsn.name, lineNumber,
            "Multiple log messages with conflicting number of place holders"));
        return null;
    }
    return logMessageLength;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:ESLoggerUsageChecker.java

示例3: transformTypeInsnNode

import org.objectweb.asm.tree.analysis.Frame; //导入依赖的package包/类
@Override
protected AbstractInsnNode transformTypeInsnNode(MethodNode mn,
        TypeInsnNode typeNode) {
	if (frames == null)
		return typeNode;

	if (typeNode.getOpcode() == Opcodes.CHECKCAST) {
		Frame current = frames[mn.instructions.indexOf(typeNode)];
		int size = current.getStackSize();
		if (current.getStack(size - 1) == BooleanArrayInterpreter.INT_ARRAY) {
			BooleanTestabilityTransformation.logger.info("Array is of boolean type, changing CHECKCAST to [I");
			TypeInsnNode replacement = new TypeInsnNode(Opcodes.CHECKCAST, "[I");
			mn.instructions.insertBefore(typeNode, replacement);
			mn.instructions.remove(typeNode);
			return replacement;
		}
	}
	return typeNode;
}
 
开发者ID:EvoSuite,项目名称:evosuite,代码行数:20,代码来源:BooleanArrayIndexTransformer.java

示例4: apply

import org.objectweb.asm.tree.analysis.Frame; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public List<Mutation> apply(MethodNode mn, String className, String methodName,
        BytecodeInstruction instruction, Frame frame) {

	List<Mutation> mutations = new LinkedList<Mutation>();

	JumpInsnNode node = (JumpInsnNode) instruction.getASMNode();
	LabelNode target = node.label;

	// insert mutation into bytecode with conditional
	JumpInsnNode mutation = new JumpInsnNode(getOpposite(node.getOpcode()), target);
	// insert mutation into pool
	Mutation mutationObject = MutationPool.addMutation(className,
	                                                   methodName,
	                                                   NAME,
	                                                   instruction,
	                                                   mutation,
	                                                   Mutation.getDefaultInfectionDistance());

	mutations.add(mutationObject);
	return mutations;
}
 
开发者ID:EvoSuite,项目名称:evosuite,代码行数:24,代码来源:NegateCondition.java

示例5: merge

import org.objectweb.asm.tree.analysis.Frame; //导入依赖的package包/类
@Override
public boolean merge(final Frame<? extends BasicValue> frame,
                     final Interpreter<BasicValue> interpreter) throws AnalyzerException
{
    if (force)
    {
        // uses the current frame
        return true;
    }
    if (frame instanceof ExtendedFrame && ((ExtendedFrame) frame).force)
    {
        init(frame);
        return true;
    }
    return super.merge(frame, interpreter);
}
 
开发者ID:electronicarts,项目名称:ea-async,代码行数:17,代码来源:FrameAnalyzer.java

示例6: uninitializedInTheStack

import org.objectweb.asm.tree.analysis.Frame; //导入依赖的package包/类
@Test
public void uninitializedInTheStack() throws Exception
{
    MethodNode mv = new MethodNode(ACC_PUBLIC, "apply", "(Ljava/lang/String;)Ljava/lang/Integer;", null, null);
    mv.visitTypeInsn(NEW, "java/lang/Integer");
    mv.visitInsn(DUP);
    mv.visitVarInsn(ALOAD, 1);
    // insn 3
    mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Integer", "<init>", "(Ljava/lang/String;)V", false);
    // insn 4
    mv.visitInsn(ARETURN);
    mv.visitMaxs(3, 2);

    Frame<BasicValue>[] frames = new FrameAnalyzer().analyze("com/ea/async/Bogus", mv);
    assertEquals(3, frames[3].getStackSize());
    assertTrue(((ExtendedValue) frames[3].getStack(0)).isUninitialized());
    assertFalse(((ExtendedValue) frames[4].getStack(0)).isUninitialized());
}
 
开发者ID:electronicarts,项目名称:ea-async,代码行数:19,代码来源:AnalyserTest.java

示例7: uninitializedInTheStackCheckOrder

import org.objectweb.asm.tree.analysis.Frame; //导入依赖的package包/类
@Test
public void uninitializedInTheStackCheckOrder() throws Exception
{
    MethodNode mv = new MethodNode(ACC_PUBLIC, "apply", "(Ljava/lang/String;)Ljava/lang/Integer;", null, null);
    mv.visitIntInsn(SIPUSH, 99);
    mv.visitTypeInsn(NEW, "java/lang/Integer");
    mv.visitInsn(DUP);
    mv.visitVarInsn(ALOAD, 1);
    // insn 4
    mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Integer", "<init>", "(Ljava/lang/String;)V", false);
    // insn 5
    mv.visitInsn(SWAP);
    mv.visitInsn(POP);
    mv.visitInsn(ARETURN);
    mv.visitMaxs(4, 2);

    Frame<BasicValue>[] frames = new FrameAnalyzer().analyze("com/ea/async/Bogus", mv);
    assertEquals(3, frames[3].getStackSize());
    assertTrue(((ExtendedValue) frames[4].getStack(1)).isUninitialized());
    assertFalse(((ExtendedValue) frames[5].getStack(1)).isUninitialized());
}
 
开发者ID:electronicarts,项目名称:ea-async,代码行数:22,代码来源:AnalyserTest.java

示例8: printAnalyzerResult

import org.objectweb.asm.tree.analysis.Frame; //导入依赖的package包/类
static void printAnalyzerResult(MethodNode method, Analyzer<BasicValue> a,
        final PrintWriter pw) {
    Frame<BasicValue>[] frames = a.getFrames();
    Textifier t = new Textifier();
    TraceMethodVisitor mv = new TraceMethodVisitor(t);

    pw.println(method.name + method.desc);
    for (int j = 0; j < method.instructions.size(); ++j) {
        method.instructions.get(j).accept(mv);

        StringBuilder sb = new StringBuilder();
        Frame<BasicValue> f = frames[j];
        if (f == null) {
            sb.append('?');
        } else {
            for (int k = 0; k < f.getLocals(); ++k) {
                sb.append(getShortName(f.getLocal(k).toString()))
                        .append(' ');
            }
            sb.append(" : ");
            for (int k = 0; k < f.getStackSize(); ++k) {
                sb.append(getShortName(f.getStack(k).toString()))
                        .append(' ');
            }
        }
        while (sb.length() < method.maxStack + method.maxLocals + 1) {
            sb.append(' ');
        }
        pw.print(Integer.toString(j + 100000).substring(1));
        pw.print(" " + sb + " : " + t.text.get(t.text.size() - 1));
    }
    for (int j = 0; j < method.tryCatchBlocks.size(); ++j) {
        method.tryCatchBlocks.get(j).accept(mv);
        pw.print(" " + t.text.get(t.text.size() - 1));
    }
    pw.println();
}
 
开发者ID:ItzSomebody,项目名称:DirectLeaks-AntiReleak-Remover,代码行数:38,代码来源:CheckClassAdapter.java

示例9: checkFixedArityArgs

import org.objectweb.asm.tree.analysis.Frame; //导入依赖的package包/类
private void checkFixedArityArgs(MethodNode methodNode, Frame<BasicValue> logMessageFrame, int lineNumber,
                                 MethodInsnNode methodInsn, int messageIndex, int positionalArgsLength) {
    PlaceHolderStringBasicValue logMessageLength = checkLogMessageConsistency(methodNode, logMessageFrame, lineNumber, methodInsn,
        messageIndex, positionalArgsLength);
    if (logMessageLength == null) {
        return;
    }
    if (logMessageLength.minValue != positionalArgsLength) {
        wrongUsageCallback.accept(new WrongLoggerUsage(className, methodNode.name, methodInsn.name, lineNumber,
            "Expected " + logMessageLength.minValue + " arguments but got " + positionalArgsLength));
        return;
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:14,代码来源:ESLoggerUsageChecker.java

示例10: collectCodeBlocks

import org.objectweb.asm.tree.analysis.Frame; //导入依赖的package包/类
public boolean collectCodeBlocks() {
    int numIns = mn.instructions.size();

    codeBlocks[0] = FrameInfo.FIRST;
    for(int i=0 ; i<numIns ; i++) {
        Frame f = frames[i];
        if(f != null) { // reachable ?
            AbstractInsnNode in = mn.instructions.get(i);
            if(in.getType() == AbstractInsnNode.METHOD_INSN) {
                MethodInsnNode min = (MethodInsnNode)in;
                int opcode = min.getOpcode();
                if(db.isMethodSuspendable(min.owner, min.name, min.desc,
                        opcode == Opcodes.INVOKEVIRTUAL || opcode == Opcodes.INVOKESTATIC)) {
                    db.log(LogLevel.DEBUG, "Method call at instruction %d to %s#%s%s is suspendable", i, min.owner, min.name, min.desc);
                    FrameInfo fi = addCodeBlock(f, i);
                    splitTryCatch(fi);
                } else {
                    int blockingId = isBlockingCall(min);
                    if(blockingId >= 0) {
                        int mask = 1 << blockingId;
                        if(!db.isAllowBlocking()) {
                            throw new UnableToInstrumentException("blocking call to " +
                                    min.owner + "#" + min.name + min.desc, className, mn.name, mn.desc);
                        } else if((warnedAboutBlocking & mask) == 0) {
                            warnedAboutBlocking |= mask;
                            db.log(LogLevel.WARNING, "Method %s#%s%s contains potentially blocking call to " +
                                    min.owner + "#" + min.name + min.desc, className, mn.name, mn.desc);
                        }
                    }
                }
            }
        }
    }
    addCodeBlock(null, numIns);

    return numCodeBlocks > 1;
}
 
开发者ID:oltolm,项目名称:continuations,代码行数:38,代码来源:InstrumentMethod.java

示例11: addCodeBlock

import org.objectweb.asm.tree.analysis.Frame; //导入依赖的package包/类
private FrameInfo addCodeBlock(Frame f, int end) {
    if(++numCodeBlocks == codeBlocks.length) {
        FrameInfo[] newArray = new FrameInfo[numCodeBlocks*2];
        System.arraycopy(codeBlocks, 0, newArray, 0, codeBlocks.length);
        codeBlocks = newArray;
    }
    FrameInfo fi = new FrameInfo(f, firstLocal, end, mn.instructions, db);
    codeBlocks[numCodeBlocks] = fi;
    return  fi;
}
 
开发者ID:oltolm,项目名称:continuations,代码行数:11,代码来源:InstrumentMethod.java

示例12: getSource

import org.objectweb.asm.tree.analysis.Frame; //导入依赖的package包/类
private AbstractInsnNode getSource(MethodNode methodNode, Frame<SourceValue>[] frames, AbstractInsnNode now, int... wants) {
    Frame<SourceValue> currentFrame = frames[methodNode.instructions.indexOf(now)];
    SourceValue currentValue;

    for (int want : wants)
        if (want == now.getOpcode()) return now;
    switch (now.getOpcode()) {
        case ALOAD: {
            currentValue = currentFrame.getLocal(((VarInsnNode) now).var);
            break;
        }
        case ASTORE: {
            currentValue = currentFrame.getStack(currentFrame.getStackSize() - 1);
            break;
        }
        case DUP: {
            currentValue = currentFrame.getStack(currentFrame.getStackSize() - 1);
            break;
        }
        case PUTSTATIC: {
            currentValue = currentFrame.getStack(currentFrame.getStackSize() - 1);
            break;
        }
        case SWAP: {
            currentValue = currentFrame.getStack(currentFrame.getStackSize() - 1);
            break;
        }
        default: {
            oops("Unexpected opcode {}", now.getOpcode());
            return null;
        }
    }

    if (currentValue.insns.size() != 1) {
        oops("Expected 1 source insn, found {}", TransformerHelper.insnsToString(currentValue.insns));
        return null;
    }

    return getSource(methodNode, frames, currentValue.insns.iterator().next(), wants);
}
 
开发者ID:java-deobfuscator,项目名称:deobfuscator,代码行数:41,代码来源:SimpleStringEncryptionTransformer.java

示例13: isBooleanOnStack

import org.objectweb.asm.tree.analysis.Frame; //导入依赖的package包/类
public boolean isBooleanOnStack(MethodNode mn, AbstractInsnNode node, int position) {
	int insnPosition = mn.instructions.indexOf(node);
	if (insnPosition >= currentFrames.length) {
		logger.info("Trying to access frame out of scope: " + insnPosition + "/"
		        + currentFrames.length);
		return false;
	}
	Frame frame = currentFrames[insnPosition];
	return frame.getStack(frame.getStackSize() - 1 - position) == BooleanValueInterpreter.BOOLEAN_VALUE;
}
 
开发者ID:EvoSuite,项目名称:evosuite,代码行数:11,代码来源:BooleanTestabilityTransformation.java

示例14: getArrayFrames

import org.objectweb.asm.tree.analysis.Frame; //导入依赖的package包/类
private Frame[] getArrayFrames(MethodNode mn) {
	try {
		Analyzer a = new Analyzer(new BooleanArrayInterpreter());
		a.analyze(cn.name, mn);
		return a.getFrames();
	} catch (Exception e) {
		logger.info("[Array] Error during analysis: " + e);
		return null;
	}
}
 
开发者ID:EvoSuite,项目名称:evosuite,代码行数:11,代码来源:BooleanTestabilityTransformation.java

示例15: apply

import org.objectweb.asm.tree.analysis.Frame; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public List<Mutation> apply(MethodNode mn, String className, String methodName,
        BytecodeInstruction instruction, Frame frame) {

	numVariable = getNextIndex(mn);
	List<Mutation> mutations = new LinkedList<Mutation>();

	InsnNode node = (InsnNode) instruction.getASMNode();

	for (int opcode : getMutations(node.getOpcode())) {

		InsnNode mutation = new InsnNode(opcode);
		// insert mutation into pool
		Mutation mutationObject = MutationPool.addMutation(className,
		                                                   methodName,
		                                                   NAME + " "
		                                                           + getOp(node.getOpcode())
		                                                           + " -> "
		                                                           + getOp(opcode),
		                                                   instruction,
		                                                   mutation,
		                                                   getInfectionDistance(node.getOpcode(),
		                                                                        opcode));
		mutations.add(mutationObject);
	}

	return mutations;
}
 
开发者ID:EvoSuite,项目名称:evosuite,代码行数:30,代码来源:ReplaceArithmeticOperator.java


注:本文中的org.objectweb.asm.tree.analysis.Frame类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。