本文整理汇总了Java中jdk.internal.org.objectweb.asm.ClassVisitor类的典型用法代码示例。如果您正苦于以下问题:Java ClassVisitor类的具体用法?Java ClassVisitor怎么用?Java ClassVisitor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ClassVisitor类属于jdk.internal.org.objectweb.asm包,在下文中一共展示了ClassVisitor类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: addGetter
import jdk.internal.org.objectweb.asm.ClassVisitor; //导入依赖的package包/类
static void addGetter(final ClassVisitor cv, final String owner, final MemberInfo memInfo) {
final int access = ACC_PUBLIC;
final String name = GETTER_PREFIX + memInfo.getJavaName();
final String desc = getterDesc(memInfo);
final MethodVisitor mv = cv.visitMethod(access, name, desc, null, null);
final MethodGenerator mi = new MethodGenerator(mv, access, name, desc);
mi.visitCode();
if (memInfo.isStatic() && memInfo.getKind() == Kind.PROPERTY) {
mi.getStatic(owner, memInfo.getJavaName(), memInfo.getJavaDesc());
} else {
mi.loadLocal(0);
mi.getField(owner, memInfo.getJavaName(), memInfo.getJavaDesc());
}
mi.returnValue();
mi.computeMaxs();
mi.visitEnd();
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:ClassGenerator.java
示例2: addSetter
import jdk.internal.org.objectweb.asm.ClassVisitor; //导入依赖的package包/类
static void addSetter(final ClassVisitor cv, final String owner, final MemberInfo memInfo) {
final int access = ACC_PUBLIC;
final String name = SETTER_PREFIX + memInfo.getJavaName();
final String desc = setterDesc(memInfo);
final MethodVisitor mv = cv.visitMethod(access, name, desc, null, null);
final MethodGenerator mi = new MethodGenerator(mv, access, name, desc);
mi.visitCode();
if (memInfo.isStatic() && memInfo.getKind() == Kind.PROPERTY) {
mi.loadLocal(1);
mi.putStatic(owner, memInfo.getJavaName(), memInfo.getJavaDesc());
} else {
mi.loadLocal(0);
mi.loadLocal(1);
mi.putField(owner, memInfo.getJavaName(), memInfo.getJavaDesc());
}
mi.returnVoid();
mi.computeMaxs();
mi.visitEnd();
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:ClassGenerator.java
示例3: make
import jdk.internal.org.objectweb.asm.ClassVisitor; //导入依赖的package包/类
public ClassVisitor make(ClassVisitor cv) {
return new ClassVisitor(Opcodes.ASM5, cv) {
@Override
public void visitInnerClass(String name, String outerName,
String innerName, int access) {
if (whenVisitInner) {
int access_ = (ACC_PROTECTED | access) & ~(ACC_PRIVATE | ACC_PUBLIC);
System.out.println("visitInnerClass: name = " + name
+ ", outerName = " + outerName
+ ", innerName = " + innerName
+ ", access original = 0x" + Integer.toHexString(access)
+ ", access modified to 0x" + Integer.toHexString(access_));
access = access_;
}
super.visitInnerClass(name, outerName, innerName, access);
}
};
}
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:Test.java
示例4: hasModulePackages
import jdk.internal.org.objectweb.asm.ClassVisitor; //导入依赖的package包/类
boolean hasModulePackages() throws IOException {
Set<String> attrTypes = new HashSet<>();
ClassVisitor cv = new ClassVisitor(Opcodes.ASM5) {
@Override
public void visitAttribute(Attribute attr) {
attrTypes.add(attr.type);
}
};
// prototype of attributes that should be parsed
Attribute[] attrs = new Attribute[] {
new ClassFileAttributes.ModulePackagesAttribute()
};
try (InputStream in = getInputStream()) {
// parse module-info.class
ClassReader cr = new ClassReader(in);
cr.accept(cv, attrs, 0);
return attrTypes.contains(ClassFileConstants.MODULE_PACKAGES);
}
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:SystemModulesPlugin.java
示例5: read
import jdk.internal.org.objectweb.asm.ClassVisitor; //导入依赖的package包/类
public static ModuleTarget read(InputStream in) throws IOException {
ModuleTargetAttribute[] modTargets = new ModuleTargetAttribute[1];
ClassVisitor cv = new ClassVisitor(Opcodes.ASM5) {
@Override
public void visitAttribute(Attribute attr) {
if (attr instanceof ModuleTargetAttribute) {
modTargets[0] = (ModuleTargetAttribute)attr;
}
}
};
// prototype of attributes that should be parsed
Attribute[] attrs = new Attribute[] {
new ModuleTargetAttribute()
};
// parse module-info.class
ClassReader cr = new ClassReader(in);
cr.accept(cv, attrs, 0);
if (modTargets[0] != null) {
return new ModuleTarget(modTargets[0].targetPlatform());
}
return null;
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:ModuleTargetHelper.java
示例6: hasModuleTarget
import jdk.internal.org.objectweb.asm.ClassVisitor; //导入依赖的package包/类
private static boolean hasModuleTarget(InputStream in) throws IOException {
ModuleTargetAttribute[] modTargets = new ModuleTargetAttribute[1];
ClassVisitor cv = new ClassVisitor(Opcodes.ASM5) {
@Override
public void visitAttribute(Attribute attr) {
if (attr instanceof ModuleTargetAttribute) {
modTargets[0] = (ModuleTargetAttribute)attr;
}
}
};
// prototype of attributes that should be parsed
Attribute[] attrs = new Attribute[] {
new ModuleTargetAttribute()
};
// parse module-info.class
ClassReader cr = new ClassReader(in);
cr.accept(cv, attrs, 0);
return modTargets[0] != null && modTargets[0].targetPlatform() != null;
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:Main.java
示例7: addMethodEntryInjection
import jdk.internal.org.objectweb.asm.ClassVisitor; //导入依赖的package包/类
public synchronized Instrumentor addMethodEntryInjection(String methodName, Consumer<InstrHelper> injector) {
instrumentingVisitor = new ClassVisitor(Opcodes.ASM5, instrumentingVisitor) {
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions);
if (name.equals(methodName)) {
matches.getAndIncrement();
mv = new MethodVisitor(Opcodes.ASM5, mv) {
@Override
public void visitCode() {
injector.accept(new InstrHelper(mv, name));
}
};
}
return mv;
}
};
return this;
}
开发者ID:campolake,项目名称:openjdk9,代码行数:22,代码来源:Instrumentor.java
示例8: visit
import jdk.internal.org.objectweb.asm.ClassVisitor; //导入依赖的package包/类
@Override
public ClassWriter visit(ClassReader reader) {
if ((amount++ % 2) == 0) {
String className = reader.getClassName();
if (className.endsWith("module-info")) {
return null;
}
ClassWriter cw = new ClassWriter(reader, ClassWriter.COMPUTE_FRAMES);
reader.accept(new ClassVisitor(Opcodes.ASM5, cw) {
@Override
public void visit(int i, int i1, String s, String s1, String s2, String[] strings) {
super.visit(i, i1, s + "Changed", s1, s2, strings);
}
}, ClassReader.EXPAND_FRAMES);
++changed;
return cw;
} else {
return null;
}
}
开发者ID:campolake,项目名称:openjdk9,代码行数:21,代码来源:VisitorTest.java
示例9: accept
import jdk.internal.org.objectweb.asm.ClassVisitor; //导入依赖的package包/类
/**
* Makes the given class visitor visit this method.
*
* @param cv
* a class visitor.
*/
public void accept(final ClassVisitor cv) {
String[] exceptions = new String[this.exceptions.size()];
this.exceptions.toArray(exceptions);
MethodVisitor mv = cv.visitMethod(access, name, desc, signature,
exceptions);
if (mv != null) {
accept(mv);
}
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:16,代码来源:MethodNode.java
示例10: makeConstructor
import jdk.internal.org.objectweb.asm.ClassVisitor; //导入依赖的package包/类
static MethodGenerator makeConstructor(final ClassVisitor cv) {
final int access = 0;
final String name = INIT;
final String desc = DEFAULT_INIT_DESC;
final MethodVisitor mv = cv.visitMethod(access, name, desc, null, null);
return new MethodGenerator(mv, access, name, desc);
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:8,代码来源:ClassGenerator.java
示例11: addMapField
import jdk.internal.org.objectweb.asm.ClassVisitor; //导入依赖的package包/类
static void addMapField(final ClassVisitor cv) {
// add a PropertyMap static field
final FieldVisitor fv = cv.visitField(ACC_PRIVATE | ACC_STATIC | ACC_FINAL,
PROPERTYMAP_FIELD_NAME, PROPERTYMAP_DESC, null, null);
if (fv != null) {
fv.visitEnd();
}
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:ClassGenerator.java
示例12: ScriptClassInstrumentor
import jdk.internal.org.objectweb.asm.ClassVisitor; //导入依赖的package包/类
ScriptClassInstrumentor(final ClassVisitor visitor, final ScriptClassInfo sci) {
super(Opcodes.ASM4, visitor);
if (sci == null) {
throw new IllegalArgumentException("Null ScriptClassInfo, is the class annotated?");
}
this.scriptClassInfo = sci;
this.memberCount = scriptClassInfo.getInstancePropertyCount();
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:ScriptClassInstrumentor.java
示例13: Method
import jdk.internal.org.objectweb.asm.ClassVisitor; //导入依赖的package包/类
public Method(ClassConstruct ownerClass, ClassVisitor cv, String name, String descriptor, int access,
ClassBuilder.ExecutionMode execMode) {
this.ownerClassName = ownerClass.getName();
this.ownerClass = ownerClass;
this.execMode = execMode;
this.cv = cv;
mv = cv.visitMethod(access, name, descriptor, null, null);
mv.visitCode();
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:Method.java
示例14: asm
import jdk.internal.org.objectweb.asm.ClassVisitor; //导入依赖的package包/类
public byte[] asm(ClassLoader loader, String className,
Class<?> classBeingRedefined,
ProtectionDomain protectionDomain, byte[] classfileBuffer)
throws IllegalClassFormatException {
ClassWriter cw = new ClassWriter(0);
ClassVisitor cv = new ReAddDummyFieldsClassVisitor(ASM5, cw) { };
ClassReader cr = new ClassReader(classfileBuffer);
cr.accept(cv, 0);
return cw.toByteArray();
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:RedefineAnnotations.java
示例15: generateTestMethod
import jdk.internal.org.objectweb.asm.ClassVisitor; //导入依赖的package包/类
private static void generateTestMethod(ClassVisitor cv,
Label unstableIfLocation) {
MethodVisitor mv = cv.visitMethod(ACC_PUBLIC | ACC_STATIC, METHOD_NAME,
"(Z)V", null, null);
mv.visitCode();
Label end = new Label();
Label falseBranch = new Label();
// push "field" field's value and 1 to stack
mv.visitFieldInsn(GETSTATIC, CLASS_NAME, FIELD_NAME, "I");
mv.visitInsn(ICONST_1);
// load argument's value
mv.visitVarInsn(ILOAD, 0); // alwaysTrue
// here is our unstable if
mv.visitLabel(unstableIfLocation);
mv.visitJumpInsn(IFEQ, falseBranch);
// increment on "true"
mv.visitInsn(IADD);
mv.visitJumpInsn(GOTO, end);
// decrement on "false"
mv.visitLabel(falseBranch);
mv.visitInsn(ISUB);
mv.visitLabel(end);
// bye bye
mv.visitInsn(RETURN);
mv.visitMaxs(0, 0);
mv.visitEnd();
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:31,代码来源:TestUnstableIfTrap.java
示例16: ScriptClassInstrumentor
import jdk.internal.org.objectweb.asm.ClassVisitor; //导入依赖的package包/类
ScriptClassInstrumentor(final ClassVisitor visitor, final ScriptClassInfo sci) {
super(Main.ASM_VERSION, visitor);
if (sci == null) {
throw new IllegalArgumentException("Null ScriptClassInfo, is the class annotated?");
}
this.scriptClassInfo = sci;
this.memberCount = scriptClassInfo.getInstancePropertyCount();
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:ScriptClassInstrumentor.java
示例17: check
import jdk.internal.org.objectweb.asm.ClassVisitor; //导入依赖的package包/类
public static boolean check() {
Class<?> cls = HotSpotVMConfig.class;
String classFilePath = "/" + cls.getName().replace('.', '/') + ".class";
try {
InputStream classfile = cls.getResourceAsStream(classFilePath);
ClassReader cr = new ClassReader(Objects.requireNonNull(classfile, "Could not find class file for " + cls.getName()));
ClassVisitor cv = new HotSpotVMConfigVerifier();
cr.accept(cv, 0);
return true;
} catch (IOException e) {
throw new JVMCIError(e);
}
}
开发者ID:campolake,项目名称:openjdk9,代码行数:14,代码来源:HotSpotVMConfigVerifier.java
示例18: Method
import jdk.internal.org.objectweb.asm.ClassVisitor; //导入依赖的package包/类
public Method(ClassConstruct ownerClass, ClassVisitor cv, String name, String descriptor, int access,
ClassBuilder.ExecutionMode execMode) {
this.ownerClassName = ownerClass.getName();
this.ownerClass = ownerClass;
this.isInterface = ownerClass.isInterface();
this.execMode = execMode;
this.cv = cv;
mv = cv.visitMethod(access, name, descriptor, null, null);
mv.visitCode();
}
开发者ID:campolake,项目名称:openjdk9,代码行数:11,代码来源:Method.java
注:本文中的jdk.internal.org.objectweb.asm.ClassVisitor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论