本文整理汇总了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;
}
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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());
}
示例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());
}
示例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();
}
示例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;
}
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
}
示例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;
}