本文整理汇总了Java中org.mockito.asm.ClassReader.accept方法的典型用法代码示例。如果您正苦于以下问题:Java ClassReader.accept方法的具体用法?Java ClassReader.accept怎么用?Java ClassReader.accept使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mockito.asm.ClassReader
的用法示例。
在下文中一共展示了ClassReader.accept方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getClassInfo
import org.mockito.asm.ClassReader; //导入方法依赖的package包/类
public static String[] getClassInfo(ClassReader r) {
final List array = new ArrayList();
try {
r.accept(new ClassAdapter(null) {
public void visit(int version,
int access,
String name,
String signature,
String superName,
String[] interfaces) {
array.add( name.replace('/', '.') );
if(superName != null){
array.add( superName.replace('/', '.') );
}
for(int i = 0; i < interfaces.length; i++ ){
array.add( interfaces[i].replace('/', '.') );
}
throw EARLY_EXIT;
}
}, ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES);
} catch (EarlyExitException e) { }
return (String[])array.toArray( new String[]{} );
}
示例2: verify
import org.mockito.asm.ClassReader; //导入方法依赖的package包/类
/**
* Checks a given class
*
* @param cr a <code>ClassReader</code> that contains bytecode for the
* analysis.
* @param dump true if bytecode should be printed out not only when errors
* are found.
* @param pw write where results going to be printed
*/
public static void verify(
final ClassReader cr,
final boolean dump,
final PrintWriter pw)
{
ClassNode cn = new ClassNode();
cr.accept(new CheckClassAdapter(cn), ClassReader.SKIP_DEBUG);
Type syperType = cn.superName == null
? null
: Type.getObjectType(cn.superName);
List methods = cn.methods;
for (int i = 0; i < methods.size(); ++i) {
MethodNode method = (MethodNode) methods.get(i);
Analyzer a = new Analyzer(new SimpleVerifier(Type.getObjectType(cn.name),
syperType,
false));
try {
a.analyze(cn.name, method);
if (!dump) {
continue;
}
} catch (Exception e) {
e.printStackTrace(pw);
}
Frame[] frames = a.getFrames();
TraceMethodVisitor mv = new TraceMethodVisitor();
pw.println(method.name + method.desc);
for (int j = 0; j < method.instructions.size(); ++j) {
method.instructions.get(j).accept(mv);
StringBuffer s = new StringBuffer();
Frame f = frames[j];
if (f == null) {
s.append('?');
} else {
for (int k = 0; k < f.getLocals(); ++k) {
s.append(getShortName(f.getLocal(k).toString()))
.append(' ');
}
s.append(" : ");
for (int k = 0; k < f.getStackSize(); ++k) {
s.append(getShortName(f.getStack(k).toString()))
.append(' ');
}
}
while (s.length() < method.maxStack + method.maxLocals + 1) {
s.append(' ');
}
pw.print(Integer.toString(j + 100000).substring(1));
pw.print(" " + s + " : " + mv.buf); // mv.text.get(j));
}
for (int j = 0; j < method.tryCatchBlocks.size(); ++j) {
((TryCatchBlockNode) method.tryCatchBlocks.get(j)).accept(mv);
pw.print(" " + mv.buf);
}
pw.println();
}
pw.flush();
}
示例3: assertCommandEnum
import org.mockito.asm.ClassReader; //导入方法依赖的package包/类
@Test
public void assertCommandEnum() throws IOException {
ClassReader cr = new ClassReader(NedisClientImpl.class.getName());
cr.accept(CV, ClassReader.SKIP_DEBUG);
}