本文整理汇总了Java中org.objectweb.asm.tree.analysis.AnalyzerException类的典型用法代码示例。如果您正苦于以下问题:Java AnalyzerException类的具体用法?Java AnalyzerException怎么用?Java AnalyzerException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AnalyzerException类属于org.objectweb.asm.tree.analysis包,在下文中一共展示了AnalyzerException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newOperation
import org.objectweb.asm.tree.analysis.AnalyzerException; //导入依赖的package包/类
@Override
public BasicValue newOperation(AbstractInsnNode insnNode) throws AnalyzerException {
switch (insnNode.getOpcode()) {
case ICONST_0: return new IntegerConstantBasicValue(Type.INT_TYPE, 0);
case ICONST_1: return new IntegerConstantBasicValue(Type.INT_TYPE, 1);
case ICONST_2: return new IntegerConstantBasicValue(Type.INT_TYPE, 2);
case ICONST_3: return new IntegerConstantBasicValue(Type.INT_TYPE, 3);
case ICONST_4: return new IntegerConstantBasicValue(Type.INT_TYPE, 4);
case ICONST_5: return new IntegerConstantBasicValue(Type.INT_TYPE, 5);
case BIPUSH:
case SIPUSH: return new IntegerConstantBasicValue(Type.INT_TYPE, ((IntInsnNode)insnNode).operand);
case Opcodes.LDC: {
Object constant = ((LdcInsnNode)insnNode).cst;
if (constant instanceof Integer) {
return new IntegerConstantBasicValue(Type.INT_TYPE, (Integer)constant);
} else {
return super.newOperation(insnNode);
}
}
default: return super.newOperation(insnNode);
}
}
示例2: binaryOperation
import org.objectweb.asm.tree.analysis.AnalyzerException; //导入依赖的package包/类
@Override
public BasicValue binaryOperation(final AbstractInsnNode insn,
final BasicValue value1, final BasicValue value2) throws AnalyzerException {
/*
* We're looking for the assignment of a local holder objectref to a member variable.
* If we spot that, then the local holder can't be replaced, since we don't (yet)
* have the mechanics to replace the member variable with the holder's members or
* to assign all of them when this happens.
*/
if (insn.getOpcode() == Opcodes.PUTFIELD) {
if (value2.isReference() && (value1 instanceof ReplacingBasicValue)) {
final ReplacingBasicValue possibleThis = (ReplacingBasicValue) value1;
if (possibleThis.isThis() && (value2 instanceof ReplacingBasicValue)) {
// if this is a reference for a holder class, we can't replace it
if (HOLDERS.get(value2.getType().getDescriptor()) != null) {
final ReplacingBasicValue localRef = (ReplacingBasicValue) value2;
localRef.setAssignedToMember();
}
}
}
}
return super.binaryOperation(insn, value1, value2);
}
示例3: naryOperation
import org.objectweb.asm.tree.analysis.AnalyzerException; //导入依赖的package包/类
@Override
public BasicValue naryOperation(final AbstractInsnNode insn,
final List<? extends BasicValue> values) throws AnalyzerException {
if (insn instanceof MethodInsnNode) {
boolean skipOne = insn.getOpcode() != Opcodes.INVOKESTATIC;
// Note if the argument is a holder, and is used as a function argument
for(BasicValue value : values) {
// if non-static method, skip over the receiver
if (skipOne) {
skipOne = false;
continue;
}
if (value instanceof ReplacingBasicValue) {
final ReplacingBasicValue argument = (ReplacingBasicValue) value;
argument.setFunctionArgument();
}
}
}
return super.naryOperation(insn, values);
}
示例4: generateCDG
import org.objectweb.asm.tree.analysis.AnalyzerException; //导入依赖的package包/类
private void generateCDG(MethodNode mn) {
if(BytecodeInstructionPool.getInstance(classLoader).hasMethod(className, mn.name + mn.desc))
return;
BytecodeInstructionPool.getInstance(classLoader).registerMethodNode(mn,
className,
mn.name
+ mn.desc); // TODO: Adapt for multiple classLoaders
BytecodeAnalyzer bytecodeAnalyzer = new BytecodeAnalyzer();
logger.info("Generating initial CFG for method " + mn.name);
try {
bytecodeAnalyzer.analyze(classLoader, className,
mn.name + mn.desc, mn); // TODO
} catch (AnalyzerException e) {
logger.error("Analyzer exception while analyzing " + className + "."
+ mn.name + ": " + e);
e.printStackTrace();
}
// compute Raw and ActualCFG and put both into GraphPool
bytecodeAnalyzer.retrieveCFGGenerator().registerCFGs();
}
示例5: newOperation
import org.objectweb.asm.tree.analysis.AnalyzerException; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public BasicValue newOperation(AbstractInsnNode insn) throws AnalyzerException {
if (insn.getOpcode() == ICONST_0) {
return BOOLEAN_VALUE;
} else if (insn.getOpcode() == ICONST_1) {
return BOOLEAN_VALUE;
} else if (insn.getOpcode() == Opcodes.GETSTATIC) {
FieldInsnNode fieldNode = (FieldInsnNode) insn;
if (BooleanTestabilityTransformation.isTransformedField(fieldNode.owner,
fieldNode.name,
fieldNode.desc))
return BOOLEAN_VALUE;
}
return super.newOperation(insn);
}
示例6: copyOperation
import org.objectweb.asm.tree.analysis.AnalyzerException; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public BasicValue copyOperation(AbstractInsnNode insn, BasicValue value)
throws AnalyzerException {
if (insn.getOpcode() == Opcodes.ILOAD) {
VarInsnNode varNode = (VarInsnNode) insn;
if (isStatic) {
if (varNode.var < types.length) {
if (types[varNode.var] == Type.BOOLEAN_TYPE) {
return BOOLEAN_VALUE;
}
}
} else {
if (varNode.var > 0 && varNode.var - 1 < types.length) {
if (types[varNode.var - 1] == Type.BOOLEAN_TYPE) {
return BOOLEAN_VALUE;
}
}
}
}
return super.copyOperation(insn, value);
}
示例7: naryOperation
import org.objectweb.asm.tree.analysis.AnalyzerException; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
/** {@inheritDoc} */
@Override
public BasicValue naryOperation(AbstractInsnNode insn, List values)
throws AnalyzerException {
if (insn instanceof MethodInsnNode) {
MethodInsnNode mi = (MethodInsnNode) insn;
if (Type.getReturnType(BooleanTestabilityTransformation.getOriginalDesc(mi.owner,
mi.name,
mi.desc)) == Type.BOOLEAN_TYPE) {
return BOOLEAN_VALUE;
}
}
return super.naryOperation(insn, values);
}
示例8: merge
import org.objectweb.asm.tree.analysis.AnalyzerException; //导入依赖的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);
}
示例9: testErrorReporting
import org.objectweb.asm.tree.analysis.AnalyzerException; //导入依赖的package包/类
@Test
public void testErrorReporting() throws IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchMethodException, IOException, AnalyzerException
{
ClassReader cr = new ClassReader(InvalidAwaitCall.class.getResourceAsStream(InvalidAwaitCall.class.getName().replaceAll("^.*[.]", "") + ".class"));
assertTrue(mentionsAwait(cr));
AtomicReference<String> reference = new AtomicReference<>();
final Transformer transformer = new Transformer();
transformer.setErrorListener(t -> reference.set(t));
final byte[] bytes = transformer.transform(getClass().getClassLoader(), cr);
assertNotNull(reference.get());
assertTrue(reference.get().contains("invalidAwaitCall"));
ClassReader cr2 = new ClassReader(bytes);
assertFalse(mentionsAwait(cr2));
}
示例10: merge
import org.objectweb.asm.tree.analysis.AnalyzerException; //导入依赖的package包/类
/**
* Merges this frame with the given frame.
*
* @param frame
* a frame.
* @param interpreter
* the interpreter used to merge values.
* @return <tt>true</tt> if this frame has been changed as a result of the
* merge operation, or <tt>false</tt> otherwise.
* @throws AnalyzerException
* if the frames have incompatible sizes.
*/
public boolean merge(final Frame<? extends V> frame,
final Interpreter interpreter) throws AnalyzerException {
if (top != frame.top) {
throw new AnalyzerException(null, "Incompatible stack heights");
}
boolean changes = false;
for (int i = 0; i < locals + top; ++i) {
V v = (V) interpreter.merge(values[i], frame.values[i]);
if (!v.equals(values[i])) {
values[i] = v;
changes = true;
}
}
return changes;
}
示例11: printClass
import org.objectweb.asm.tree.analysis.AnalyzerException; //导入依赖的package包/类
@SuppressWarnings("unused")
private static void printClass(final byte[] classfileBuffer, final String classname) {
/*
final TraceClassVisitor v = new TraceClassVisitor(new PrintWriter(System.out));
new ClassReader(classfileBuffer).accept(v, ClassReader.SKIP_DEBUG);
*/
final ClassNode cn = new ClassNode();
final ClassReader cr = new ClassReader(classfileBuffer);
//cr.accept(new CheckClassAdapter(cn), ClassReader.SKIP_DEBUG);
cr.accept(new CheckClassAdapter(cn), 0);
for (final Object methodObj : cn.methods) {
final MethodNode method = (MethodNode) methodObj;
final Analyzer a = new Analyzer(new BasicVerifier());
//final Analyzer a = new Analyzer(new SimpleVerifier());
try {
a.analyze(cn.name, method);
} catch (final AnalyzerException e) {
System.err.println("// error in method " + classname + "." + method.name
+ method.desc + ":" + e);
}
printMethod(a, System.err, method);
}
}
示例12: rewrite
import org.objectweb.asm.tree.analysis.AnalyzerException; //导入依赖的package包/类
public byte[] rewrite(final String classToAnalyze, final File[] classPathEntries,IJoinpointFilter filter) throws IOException, AnalyzerException
{
final IClassReaderProvider provider = new IClassReaderProvider() {
@Override
public ClassReader getClassReader() throws IOException
{
return ASMUtil.createClassReader( classToAnalyze , classPathEntries );
}
@Override
public String getClassName()
{
return classToAnalyze;
}
};
return rewrite( provider , filter );
}
示例13: visitMethod
import org.objectweb.asm.tree.analysis.AnalyzerException; //导入依赖的package包/类
private void visitMethod(MethodNode method,String owner) throws AnalyzerException, FileNotFoundException
{
final ControlFlowGraph graph = analyzer.analyze(owner, method );
final String dot = new DOTRenderer().render( graph );
final File outputFile;
if ( outputDir != null ) {
outputFile = new File( outputDir , toFilename( method )+".dot" );
} else {
outputFile = new File( toFilename( method )+".dot" );
}
logVerbose("Writing "+outputFile.getAbsolutePath());
if ( ! outputFile.getParentFile().exists() ) {
outputFile.getParentFile().mkdirs();
}
final PrintWriter writer = new PrintWriter( outputFile);
writer.write( dot );
writer.close();
}
示例14: unaryOperation
import org.objectweb.asm.tree.analysis.AnalyzerException; //导入依赖的package包/类
@Override
public BasicValue unaryOperation(AbstractInsnNode insnNode, BasicValue value) throws AnalyzerException {
if (insnNode.getOpcode() == Opcodes.ANEWARRAY && value instanceof IntegerConstantBasicValue) {
IntegerConstantBasicValue constantBasicValue = (IntegerConstantBasicValue) value;
String desc = ((TypeInsnNode) insnNode).desc;
return new ArraySizeBasicValue(Type.getType("[" + Type.getObjectType(desc)), constantBasicValue.minValue,
constantBasicValue.maxValue);
}
return super.unaryOperation(insnNode, value);
}
示例15: ternaryOperation
import org.objectweb.asm.tree.analysis.AnalyzerException; //导入依赖的package包/类
@Override
public BasicValue ternaryOperation(AbstractInsnNode insnNode, BasicValue value1, BasicValue value2, BasicValue value3)
throws AnalyzerException {
if (insnNode.getOpcode() == Opcodes.AASTORE && value1 instanceof ArraySizeBasicValue) {
return value1;
}
return super.ternaryOperation(insnNode, value1, value2, value3);
}