本文整理汇总了Java中jdk.internal.org.objectweb.asm.tree.analysis.BasicValue类的典型用法代码示例。如果您正苦于以下问题:Java BasicValue类的具体用法?Java BasicValue怎么用?Java BasicValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BasicValue类属于jdk.internal.org.objectweb.asm.tree.analysis包,在下文中一共展示了BasicValue类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: verify
import jdk.internal.org.objectweb.asm.tree.analysis.BasicValue; //导入依赖的package包/类
/**
* Checks a given class.
*
* @param cr
* a <code>ClassReader</code> that contains bytecode for the
* analysis.
* @param loader
* a <code>ClassLoader</code> which will be used to load
* referenced classes. This is useful if you are verifiying
* multiple interdependent classes.
* @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 ClassLoader loader,
final boolean dump, final PrintWriter pw) {
ClassNode cn = new ClassNode();
cr.accept(new CheckClassAdapter(cn, false), ClassReader.SKIP_DEBUG);
Type syperType = cn.superName == null ? null : Type
.getObjectType(cn.superName);
List<MethodNode> methods = cn.methods;
List<Type> interfaces = new ArrayList<Type>();
for (Iterator<String> i = cn.interfaces.iterator(); i.hasNext();) {
interfaces.add(Type.getObjectType(i.next()));
}
for (int i = 0; i < methods.size(); ++i) {
MethodNode method = methods.get(i);
SimpleVerifier verifier = new SimpleVerifier(
Type.getObjectType(cn.name), syperType, interfaces,
(cn.access & Opcodes.ACC_INTERFACE) != 0);
Analyzer<BasicValue> a = new Analyzer<BasicValue>(verifier);
if (loader != null) {
verifier.setClassLoader(loader);
}
try {
a.analyze(cn.name, method);
if (!dump) {
continue;
}
} catch (Exception e) {
e.printStackTrace(pw);
}
printAnalyzerResult(method, a, pw);
}
pw.flush();
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:52,代码来源:CheckClassAdapter.java
示例2: printAnalyzerResult
import jdk.internal.org.objectweb.asm.tree.analysis.BasicValue; //导入依赖的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();
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:38,代码来源:CheckClassAdapter.java
示例3: CheckMethodAdapter
import jdk.internal.org.objectweb.asm.tree.analysis.BasicValue; //导入依赖的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:SunburstApps,项目名称:OpenJSharp,代码行数:47,代码来源:CheckMethodAdapter.java
示例4: analyze
import jdk.internal.org.objectweb.asm.tree.analysis.BasicValue; //导入依赖的package包/类
private void analyze() throws AnalyzerException {
Analyzer<BasicValue> analyzer = new Analyzer<BasicValue>(new BasicInterpreter()) {
@Override
protected boolean newControlFlowExceptionEdge(int insn,
int successor) {
List<Integer> lst = handlers.get(successor);
if (lst == null) {
lst = new ArrayList<>();
handlers.put(successor, lst);
}
lst.add(insn);
return true;
}
@Override
protected void newControlFlowEdge(int from,
int to) {
if (root == null) {
root = new InstructionNode(from, method.instructions.get(from));
instructions.put(from, root);
}
InstructionNode fromNode = instructions.get(from);
if (fromNode == null) {
fromNode = new InstructionNode(from, method.instructions.get(from));
instructions.put(from, fromNode);
}
InstructionNode toNode = instructions.get(to);
if (toNode == null) {
toNode = new InstructionNode(to, method.instructions.get(to));
instructions.put(to, toNode);
}
if (!fromNode.next.contains(toNode)) {
fromNode.next.add(toNode);
}
}
};
analyzer.analyze(owner, method);
}
开发者ID:campolake,项目名称:openjdk9,代码行数:41,代码来源:ControlFlow.java
示例5: printAnalyzerResult
import jdk.internal.org.objectweb.asm.tree.analysis.BasicValue; //导入依赖的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);
StringBuffer s = new StringBuffer();
Frame<BasicValue> 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 + " : " + 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();
}
开发者ID:RedlineResearch,项目名称:OLD-OpenJDK8,代码行数:38,代码来源:CheckClassAdapter.java
示例6: printAnalyzerResult
import jdk.internal.org.objectweb.asm.tree.analysis.BasicValue; //导入依赖的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);
StringBuffer s = new StringBuffer();
Frame<BasicValue> 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 + " : " + 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();
}
开发者ID:wro4j,项目名称:nashorn-backport,代码行数:41,代码来源:CheckClassAdapter.java
示例7: CheckMethodAdapter
import jdk.internal.org.objectweb.asm.tree.analysis.BasicValue; //导入依赖的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:wro4j,项目名称:nashorn-backport,代码行数:45,代码来源:CheckMethodAdapter.java
示例8: verify
import jdk.internal.org.objectweb.asm.tree.analysis.BasicValue; //导入依赖的package包/类
/**
* Checks a given class.
*
* @param cr a <code>ClassReader</code> that contains bytecode for the
* analysis.
* @param loader a <code>ClassLoader</code> which will be used to load
* referenced classes. This is useful if you are verifiying multiple
* interdependent classes.
* @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 ClassLoader loader,
final boolean dump,
final PrintWriter pw)
{
ClassNode cn = new ClassNode();
cr.accept(new CheckClassAdapter(cn, false), ClassReader.SKIP_DEBUG);
Type syperType = cn.superName == null
? null
: Type.getObjectType(cn.superName);
List<MethodNode> methods = cn.methods;
List<Type> interfaces = new ArrayList<Type>();
for (Iterator<String> i = cn.interfaces.iterator(); i.hasNext();) {
interfaces.add(Type.getObjectType(i.next().toString()));
}
for (int i = 0; i < methods.size(); ++i) {
MethodNode method = methods.get(i);
SimpleVerifier verifier = new SimpleVerifier(Type.getObjectType(cn.name),
syperType,
interfaces,
(cn.access & Opcodes.ACC_INTERFACE) != 0);
Analyzer<BasicValue> a = new Analyzer<BasicValue>(verifier);
if (loader != null) {
verifier.setClassLoader(loader);
}
try {
a.analyze(cn.name, method);
if (!dump) {
continue;
}
} catch (Exception e) {
e.printStackTrace(pw);
}
printAnalyzerResult(method, a, pw);
}
pw.flush();
}
开发者ID:wro4j,项目名称:nashorn-backport,代码行数:54,代码来源:CheckClassAdapter.java
注:本文中的jdk.internal.org.objectweb.asm.tree.analysis.BasicValue类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论