本文整理汇总了Java中org.objectweb.asm.tree.analysis.BasicVerifier类的典型用法代码示例。如果您正苦于以下问题:Java BasicVerifier类的具体用法?Java BasicVerifier怎么用?Java BasicVerifier使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BasicVerifier类属于org.objectweb.asm.tree.analysis包,在下文中一共展示了BasicVerifier类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: printClass
import org.objectweb.asm.tree.analysis.BasicVerifier; //导入依赖的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);
}
}
开发者ID:hammacher,项目名称:javaslicer,代码行数:25,代码来源:Transformer.java
示例2: CheckMethodAdapter
import org.objectweb.asm.tree.analysis.BasicVerifier; //导入依赖的package包/类
/**
* Constructs a new {@link CheckMethodAdapter} object. This method adapter
* will perform basic data flow checks. For instance in a method whose
* signature is <tt>void m ()</tt>, the invalid instruction IRETURN, or the
* invalid sequence IADD L2I will be detected.
*
* @param access
* the method's access flags.
* @param name
* the method's name.
* @param desc
* the method's descriptor (see {@link Type Type}).
* @param cmv
* the method visitor to which this adapter must delegate calls.
* @param labels
* a map of already visited labels (in other methods).
*/
public CheckMethodAdapter(final int access, final String name,
final String desc, final MethodVisitor cmv,
final Map<Label, Integer> labels) {
this(new MethodNode(Opcodes.ASM5, access, name, desc, null, null) {
@Override
public void visitEnd() {
Analyzer<BasicValue> a = new Analyzer<BasicValue>(
new BasicVerifier());
try {
a.analyze("dummy", this);
} catch (Exception e) {
if (e instanceof IndexOutOfBoundsException
&& maxLocals == 0 && maxStack == 0) {
throw new RuntimeException(
"Data flow checking option requires valid, non zero maxLocals and maxStack values.");
}
e.printStackTrace();
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw, true);
CheckClassAdapter.printAnalyzerResult(this, a, pw);
pw.close();
throw new RuntimeException(e.getMessage() + ' '
+ sw.toString());
}
accept(cmv);
}
}, labels);
this.access = access;
}
开发者ID:ItzSomebody,项目名称:DirectLeaks-AntiReleak-Remover,代码行数:47,代码来源:CheckMethodAdapter.java
示例3: CheckMethodAdapter
import org.objectweb.asm.tree.analysis.BasicVerifier; //导入依赖的package包/类
/**
* Constructs a new {@link CheckMethodAdapter} object. This method adapter
* will perform basic data flow checks. For instance in a method whose
* signature is <tt>void m ()</tt>, the invalid instruction IRETURN, or the
* invalid sequence IADD L2I will be detected.
*
* @param access
* the method's access flags.
* @param name
* the method's name.
* @param desc
* the method's descriptor (see {@link Type Type}).
* @param cmv
* the method visitor to which this adapter must delegate calls.
* @param labels
* a map of already visited labels (in other methods).
*/
public CheckMethodAdapter(final int access, final String name,
final String desc, final MethodVisitor cmv,
final Map<Label, Integer> labels) {
this(new MethodNode(Opcodes.ASM5, null, access, name, desc, null, null) {
@Override
public void visitEnd() {
Analyzer<BasicValue> a = new Analyzer<BasicValue>(
new BasicVerifier());
try {
a.analyze("dummy", this);
} catch (Exception e) {
if (e instanceof IndexOutOfBoundsException
&& maxLocals == 0 && maxStack == 0) {
throw new RuntimeException(
"Data flow checking option requires valid, non zero maxLocals and maxStack values.");
}
e.printStackTrace();
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw, true);
CheckClassAdapter.printAnalyzerResult(this, a, pw);
pw.close();
throw new RuntimeException(e.getMessage() + ' '
+ sw.toString());
}
accept(cmv);
}
}, labels);
this.access = access;
}
开发者ID:8BitPlus,项目名称:BitPlus,代码行数:47,代码来源:CheckMethodAdapter.java
示例4: CheckMethodAdapter
import org.objectweb.asm.tree.analysis.BasicVerifier; //导入依赖的package包/类
/**
* Constructs a new {@link CheckMethodAdapter} object. This method adapter
* will perform basic data flow checks. For instance in a method whose
* signature is <tt>void m ()</tt>, the invalid instruction IRETURN, or the
* invalid sequence IADD L2I will be detected.
*
* @param access
* the method's access flags.
* @param name
* the method's name.
* @param desc
* the method's descriptor (see {@link Type Type}).
* @param cmv
* the method visitor to which this adapter must delegate calls.
* @param labels
* a map of already visited labels (in other methods).
*/
public CheckMethodAdapter(final int access, final String name,
final String desc, final MethodVisitor cmv,
final Map<Label, Integer> labels) {
this(new MethodNode(access, name, desc, null, null) {
@Override
public void visitEnd() {
Analyzer<BasicValue> a = new Analyzer<BasicValue>(
new BasicVerifier());
try {
a.analyze("dummy", this);
} catch (Exception e) {
if (e instanceof IndexOutOfBoundsException
&& maxLocals == 0 && maxStack == 0) {
throw new RuntimeException(
"Data flow checking option requires valid, non zero maxLocals and maxStack values.");
}
e.printStackTrace();
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw, true);
CheckClassAdapter.printAnalyzerResult(this, a, pw);
pw.close();
throw new RuntimeException(e.getMessage() + ' '
+ sw.toString());
}
accept(cmv);
}
}, labels);
this.access = access;
}
开发者ID:bcleenders,项目名称:Bramspr,代码行数:47,代码来源:CheckMethodAdapter.java
示例5: checkClass
import org.objectweb.asm.tree.analysis.BasicVerifier; //导入依赖的package包/类
private boolean checkClass(final byte[] newClassfileBuffer, final String classname, byte[] origClassfileBuffer) {
final ClassNode cn = new ClassNode();
final ClassReader cr = new ClassReader(newClassfileBuffer);
//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());
// SimpleVerifier has problems with sub-classes, e.g. you cannot use PrintStream for Appendable and so on...
//final Analyzer a = new Analyzer(new SimpleVerifier(
// Type.getObjectType(cn.name), Type.getObjectType(cn.superName),
// (cn.access & Opcodes.ACC_INTERFACE) != 0));
try {
a.analyze(cn.name, method);
} catch (final AnalyzerException e) {
System.err.println("Error in method " + classname + "." + method.name
+ method.desc + ": " + e);
//e.printStackTrace(System.err);
printMethod(a, System.err, method);
if (newClassfileBuffer == origClassfileBuffer) {
System.err.println("This is the original bytecode!");
} else {
System.err.println("original bytecode:");
ClassReader origClassReader = new ClassReader(origClassfileBuffer);
ClassNode origClassNode = new ClassNode();
origClassReader.accept(origClassNode, 0);
for (Object origMethodObj : origClassNode.methods) {
MethodNode origMethod = (MethodNode) origMethodObj;
if (origMethod.name.equals(method.name) && origMethod.desc.equals(method.desc))
printMethod(System.err, origMethod);
}
}
return false;
}
}
return true;
}
开发者ID:hammacher,项目名称:javaslicer,代码行数:40,代码来源:Transformer.java
示例6: CheckMethodAdapter
import org.objectweb.asm.tree.analysis.BasicVerifier; //导入依赖的package包/类
/**
* Constructs a new {@link CheckMethodAdapter} object. This method adapter
* will perform basic data flow checks. For instance in a method whose
* signature is <tt>void m ()</tt>, the invalid instruction IRETURN, or the
* invalid sequence IADD L2I will be detected.
*
* @param access the method's access flags.
* @param name the method's name.
* @param desc the method's descriptor (see {@link Type Type}).
* @param cmv the method visitor to which this adapter must delegate calls.
* @param labels a map of already visited labels (in other methods).
*/
public CheckMethodAdapter(
final int access,
final String name,
final String desc,
final MethodVisitor cmv,
final Map<Label, Integer> labels)
{
this(new MethodNode(access, name, desc, null, null) {
@Override
public void visitEnd() {
Analyzer<BasicValue> a = new Analyzer<BasicValue>(new BasicVerifier());
try {
a.analyze("dummy", this);
} catch (Exception e) {
if (e instanceof IndexOutOfBoundsException
&& maxLocals == 0 && maxStack == 0)
{
throw new RuntimeException("Data flow checking option requires valid, non zero maxLocals and maxStack values.");
}
e.printStackTrace();
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw, true);
CheckClassAdapter.printAnalyzerResult(this, a, pw);
pw.close();
throw new RuntimeException(e.getMessage() + ' '
+ sw.toString());
}
accept(cmv);
}
},
labels);
}
开发者ID:nxmatic,项目名称:objectweb-asm-4.0,代码行数:45,代码来源:CheckMethodAdapter.java
示例7: main
import org.objectweb.asm.tree.analysis.BasicVerifier; //导入依赖的package包/类
public static void main(final String[] args) throws Exception {
ClassReader cr = new ClassReader("Analysis");
ClassNode cn = new ClassNode();
cr.accept(cn, ClassReader.SKIP_DEBUG);
List<MethodNode> methods = cn.methods;
for (int i = 0; i < methods.size(); ++i) {
MethodNode method = methods.get(i);
if (method.instructions.size() > 0) {
if (!analyze(cn, method)) {
Analyzer<?> a = new Analyzer<BasicValue>(
new BasicVerifier());
try {
a.analyze(cn.name, method);
} catch (Exception ignored) {
}
final Frame<?>[] frames = a.getFrames();
Textifier t = new Textifier() {
@Override
public void visitMaxs(final int maxStack,
final int maxLocals) {
for (int i = 0; i < text.size(); ++i) {
StringBuilder s = new StringBuilder(
frames[i] == null ? "null"
: frames[i].toString());
while (s.length() < Math.max(20, maxStack
+ maxLocals + 1)) {
s.append(' ');
}
System.err.print(Integer.toString(i + 1000)
.substring(1)
+ " "
+ s
+ " : "
+ text.get(i));
}
System.err.println();
}
};
MethodVisitor mv = new TraceMethodVisitor(t);
for (int j = 0; j < method.instructions.size(); ++j) {
Object insn = method.instructions.get(j);
((AbstractInsnNode) insn).accept(mv);
}
mv.visitMaxs(0, 0);
}
}
}
}
开发者ID:lrytz,项目名称:asm-legacy-svn-clone,代码行数:51,代码来源:Analysis.java
示例8: main
import org.objectweb.asm.tree.analysis.BasicVerifier; //导入依赖的package包/类
public static void main(final String[] args) throws Exception {
ClassReader cr = new ClassReader("Analysis");
ClassNode cn = new ClassNode();
cr.accept(cn, ClassReader.SKIP_DEBUG);
List<MethodNode> methods = cn.methods;
for (int i = 0; i < methods.size(); ++i) {
MethodNode method = methods.get(i);
if (method.instructions.size() > 0) {
if (!analyze(cn, method)) {
Analyzer<?> a = new Analyzer<BasicValue>(
new BasicVerifier());
try {
a.analyze(cn.name, method);
} catch (Exception ignored) {
}
final Frame<?>[] frames = a.getFrames();
Textifier t = new Textifier() {
@Override
public void visitMaxs(final int maxStack,
final int maxLocals) {
for (int i = 0; i < text.size(); ++i) {
StringBuffer s = new StringBuffer(
frames[i] == null ? "null"
: frames[i].toString());
while (s.length() < Math.max(20, maxStack
+ maxLocals + 1)) {
s.append(' ');
}
System.err.print(Integer.toString(i + 1000)
.substring(1)
+ " "
+ s
+ " : "
+ text.get(i));
}
System.err.println();
}
};
MethodVisitor mv = new TraceMethodVisitor(t);
for (int j = 0; j < method.instructions.size(); ++j) {
Object insn = method.instructions.get(j);
((AbstractInsnNode) insn).accept(mv);
}
mv.visitMaxs(0, 0);
}
}
}
}
开发者ID:llbit,项目名称:ow2-asm,代码行数:51,代码来源:Analysis.java
示例9: main
import org.objectweb.asm.tree.analysis.BasicVerifier; //导入依赖的package包/类
public static void main(final String[] args) throws Exception {
ClassReader cr = new ClassReader("Analysis");
ClassNode cn = new ClassNode();
cr.accept(cn, ClassReader.SKIP_DEBUG);
List<MethodNode> methods = cn.methods;
for (int i = 0; i < methods.size(); ++i) {
MethodNode method = methods.get(i);
if (method.instructions.size() > 0) {
if (!analyze(cn, method)) {
Analyzer<?> a = new Analyzer<BasicValue>(new BasicVerifier());
try {
a.analyze(cn.name, method);
} catch (Exception ignored) {
}
final Frame<?>[] frames = a.getFrames();
Textifier t = new Textifier() {
@Override
public void visitMaxs(
final int maxStack,
final int maxLocals)
{
for (int i = 0; i < text.size(); ++i) {
StringBuffer s = new StringBuffer(frames[i] == null
? "null"
: frames[i].toString());
while (s.length() < Math.max(20, maxStack
+ maxLocals + 1))
{
s.append(' ');
}
System.err.print(Integer.toString(i + 1000)
.substring(1)
+ " " + s + " : " + text.get(i));
}
System.err.println();
}
};
MethodVisitor mv = new TraceMethodVisitor(t);
for (int j = 0; j < method.instructions.size(); ++j) {
Object insn = method.instructions.get(j);
((AbstractInsnNode) insn).accept(mv);
}
mv.visitMaxs(0, 0);
}
}
}
}
开发者ID:nxmatic,项目名称:objectweb-asm-4.0,代码行数:50,代码来源:Analysis.java
注:本文中的org.objectweb.asm.tree.analysis.BasicVerifier类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论