本文整理匯總了Java中org.objectweb.asm.util.Textifier.print方法的典型用法代碼示例。如果您正苦於以下問題:Java Textifier.print方法的具體用法?Java Textifier.print怎麽用?Java Textifier.print使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.objectweb.asm.util.Textifier
的用法示例。
在下文中一共展示了Textifier.print方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: dump
import org.objectweb.asm.util.Textifier; //導入方法依賴的package包/類
private static void dump(MethodNode method) {
Textifier textifier = new Textifier();
method.accept(new TraceMethodVisitor(textifier));
StringWriter writer = new StringWriter();
try (PrintWriter pw = new PrintWriter(writer)) {
textifier.print(pw);
}
System.out.println(writer.toString());
}
示例2: toString
import org.objectweb.asm.util.Textifier; //導入方法依賴的package包/類
/** compiles to bytecode, and returns debugging output */
static String toString(Class<?> iface, String source, CompilerSettings settings) {
StringWriter output = new StringWriter();
PrintWriter outputWriter = new PrintWriter(output);
Textifier textifier = new Textifier();
try {
Compiler.compile(iface, "<debugging>", source, settings, textifier);
} catch (Exception e) {
textifier.print(outputWriter);
e.addSuppressed(new Exception("current bytecode: \n" + output));
IOUtils.reThrowUnchecked(e);
throw new AssertionError();
}
textifier.print(outputWriter);
return output.toString();
}
示例3: visitEnd
import org.objectweb.asm.util.Textifier; //導入方法依賴的package包/類
@Override
public void visitEnd() {
try {
accept(inner);
super.visitEnd();
} catch(Exception e){
Textifier t = new Textifier();
accept(new TraceMethodVisitor(t));
StringBuilderWriter sw = new StringBuilderWriter();
PrintWriter pw = new PrintWriter(sw);
t.print(pw);
pw.flush();
String bytecode = sw.getBuilder().toString();
logger.error(String.format("Failure while rendering method %s, %s, %s. ByteCode:\n %s", name, desc, signature, bytecode), e);
throw new RuntimeException(String.format("Failure while rendering method %s, %s, %s. ByteCode:\n %s", name, desc, signature, bytecode), e);
}
}
示例4: trace
import org.objectweb.asm.util.Textifier; //導入方法依賴的package包/類
/** Returns a human readable string for the code that this {@link BytecodeProducer} generates. */
public final String trace() {
// TODO(lukes): textifier has support for custom label names by overriding appendLabel.
// Consider trying to make use of (using the Label.info field? adding a custom NamedLabel
// sub type?)
Textifier textifier =
new Textifier(Opcodes.ASM6) {
{
// reset tab sizes. Since we don't care about formatting class names or method
// signatures (only code). We only need to set the tab2,tab3 and ltab settings (tab is
// for class members).
this.tab = null; // trigger an error if used.
this.tab2 = " "; // tab setting for instructions
this.tab3 = ""; // tab setting for switch cases
this.ltab = ""; // tab setting for labels
}
};
gen(new CodeBuilder(new TraceMethodVisitor(textifier), 0, "trace", "()V"));
StringWriter writer = new StringWriter();
textifier.print(new PrintWriter(writer));
return writer.toString(); // Note textifier always adds a trailing newline
}
示例5: toString
import org.objectweb.asm.util.Textifier; //導入方法依賴的package包/類
public String toString() {
Textifier t = new Textifier();
accept(new TraceMethodVisitor(t));
StringWriter sw = new StringWriter();
t.print(new PrintWriter(sw));
return sw.toString();
}
示例6: print
import org.objectweb.asm.util.Textifier; //導入方法依賴的package包/類
/**
* Prints an individual method behavior. [debugging]
*
* @param node the node to print
*
* @since 1.00
*/
public static void print(MethodNode node) {
Textifier tf = new Textifier();
node.accept(new TraceMethodVisitor(tf));
PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
tf.print(pw);
pw.flush();
}
示例7: visitMethod
import org.objectweb.asm.util.Textifier; //導入方法依賴的package包/類
@Override
public MethodVisitor visitMethod(final int access, final String name,
final String desc, final String signature, final String[] exceptions)
{
// Unused?
/*
final MethodVisitor mv = super.visitMethod(access, name, desc,
signature, exceptions);
*/
return new MethodNode(Opcodes.ASM5, access, name, desc, signature,
exceptions)
{
@Override
public void visitEnd()
{
super.visitEnd();
try {
final BasicInterpreter basicInterpreter
= new BasicInterpreter();
final Analyzer<BasicValue> analyzer
= new Analyzer<>(basicInterpreter);
final AbstractInsnNode[] nodes = instructions.toArray();
final Frame<BasicValue>[] frames
= analyzer.analyze(className, this);
int areturn = -1;
for (int i = nodes.length -1; i >= 0; i--)
{
if (nodes[i].getOpcode() == Opcodes.ARETURN) {
areturn = i;
System.out.println(className + "." + name + desc);
System.out.println("Found areturn at: " + i);
} else if (areturn != -1
&& nodes[i].getOpcode() != -1
&& frames[i].getStackSize() == 0) {
System.out.println("Found start of block at: " + i);
final InsnList list = new InsnList();
for (int j = i; j <= areturn; j++)
list.add(nodes[j]);
final Textifier textifier = new Textifier();
final PrintWriter pw = new PrintWriter(System.out);
list.accept(new TraceMethodVisitor(textifier));
textifier.print(pw);
pw.flush();
System.out.println("\n\n");
areturn = -1;
}
}
}
catch (AnalyzerException e) {
e.printStackTrace();
}
if (mv != null)
accept(mv);
}
};
}