Java Code Examples for jdk.internal.org.objectweb.asm.ClassVisitor
The following examples show how to use
jdk.internal.org.objectweb.asm.ClassVisitor. These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: jdk8u-jdk Source File: Test.java License: GNU General Public License v2.0 | 6 votes |
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); } }; }
Example 2
Source Project: openjdk-jdk9 Source File: ClassGenerator.java License: GNU General Public License v2.0 | 6 votes |
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(); }
Example 3
Source Project: openjdk-jdk8u Source File: ClassGenerator.java License: GNU General Public License v2.0 | 6 votes |
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(); }
Example 4
Source Project: openjdk-8-source Source File: ClassGenerator.java License: GNU General Public License v2.0 | 6 votes |
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(); }
Example 5
Source Project: openjdk-jdk9 Source File: Main.java License: GNU General Public License v2.0 | 6 votes |
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; }
Example 6
Source Project: dragonwell8_jdk Source File: JIMethodMergeAdapter.java License: GNU General Public License v2.0 | 5 votes |
/** * Methods in methodFilter that exist in cn will be merged into cv. If the method already exists, * the original method will be deleted. * * @param cv * @param cn - a ClassNode with Methods that will be merged into this class * @param methodFilter - only methods in this list will be merged * @param typeMappings - while merging, type references in the methods will be changed according to this map */ public JIMethodMergeAdapter(ClassVisitor cv, ClassNode cn, List<Method> methodFilter, JITypeMapping[] typeMappings) { super(Opcodes.ASM5, cv); this.cn = cn; this.methodFilter = methodFilter; this.typeMap = new HashMap<>(); for (JITypeMapping tm : typeMappings) { typeMap.put(tm.from().replace('.', '/'), tm.to().replace('.', '/')); } }
Example 7
Source Project: dragonwell8_jdk Source File: MethodNode.java License: GNU General Public License v2.0 | 5 votes |
/** * 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); } }
Example 8
Source Project: openjdk-jdk9 Source File: RedefineAnnotations.java License: GNU General Public License v2.0 | 5 votes |
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(); }
Example 9
Source Project: openjdk-8 Source File: ClassGenerator.java License: GNU General Public License v2.0 | 5 votes |
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); }
Example 10
Source Project: TencentKona-8 Source File: JIInliner.java License: GNU General Public License v2.0 | 5 votes |
/** * A ClassVisitor which will check all methods of the class it visits against the instrumentationMethods * list. If a method is on that list, the method will be further processed for inlining into that * method. */ JIInliner(int api, ClassVisitor cv, String targetClassName, String instrumentationClassName, ClassReader targetClassReader, List<Method> instrumentationMethods) { super(api, cv); this.targetClassName = targetClassName; this.instrumentationClassName = instrumentationClassName; this.instrumentationMethods = instrumentationMethods; ClassNode cn = new ClassNode(Opcodes.ASM5); targetClassReader.accept(cn, ClassReader.EXPAND_FRAMES); this.targetClassNode = cn; }
Example 11
Source Project: openjdk-jdk9 Source File: Method.java License: GNU General Public License v2.0 | 5 votes |
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(); }
Example 12
Source Project: openjdk-8-source Source File: ClassGenerator.java License: GNU General Public License v2.0 | 5 votes |
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(); } }
Example 13
Source Project: nashorn Source File: ClassGenerator.java License: GNU General Public License v2.0 | 5 votes |
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(); } }
Example 14
Source Project: openjdk-jdk8u Source File: JIMethodMergeAdapter.java License: GNU General Public License v2.0 | 5 votes |
/** * Methods in methodFilter that exist in cn will be merged into cv. If the method already exists, * the original method will be deleted. * * @param cv * @param cn - a ClassNode with Methods that will be merged into this class * @param methodFilter - only methods in this list will be merged * @param typeMappings - while merging, type references in the methods will be changed according to this map */ public JIMethodMergeAdapter(ClassVisitor cv, ClassNode cn, List<Method> methodFilter, JITypeMapping[] typeMappings) { super(Opcodes.ASM5, cv); this.cn = cn; this.methodFilter = methodFilter; this.typeMap = new HashMap<>(); for (JITypeMapping tm : typeMappings) { typeMap.put(tm.from().replace('.', '/'), tm.to().replace('.', '/')); } }
Example 15
Source Project: hottub Source File: MethodNode.java License: GNU General Public License v2.0 | 5 votes |
/** * 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); } }
Example 16
Source Project: TencentKona-8 Source File: ScriptClassInstrumentor.java License: GNU General Public License v2.0 | 5 votes |
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(); }
Example 17
Source Project: hottub Source File: ClassGenerator.java License: GNU General Public License v2.0 | 5 votes |
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(); } }
Example 18
Source Project: openjdk-jdk8u-backup Source File: ScriptClassInstrumentor.java License: GNU General Public License v2.0 | 5 votes |
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(); }
Example 19
Source Project: hottub Source File: RedefineAnnotations.java License: GNU General Public License v2.0 | 5 votes |
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(); }
Example 20
Source Project: openjdk-jdk8u-backup Source File: RedefineAnnotations.java License: GNU General Public License v2.0 | 5 votes |
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(); }
Example 21
Source Project: dragonwell8_jdk Source File: ConstructorTracerWriter.java License: GNU General Public License v2.0 | 4 votes |
private ConstructorTracerWriter(ClassVisitor cv, Class<?> classToChange) { super(Opcodes.ASM5, cv); useInputParameter = new ConstructorWriter(classToChange, true); noUseInputParameter = new ConstructorWriter(classToChange, false); }
Example 22
Source Project: jdk8u_nashorn Source File: ClassGenerator.java License: GNU General Public License v2.0 | 4 votes |
static MethodGenerator makeStaticInitializer(final ClassVisitor cv) { return makeStaticInitializer(cv, CLINIT); }
Example 23
Source Project: jdk8u-dev-jdk Source File: RemappingClassAdapter.java License: GNU General Public License v2.0 | 4 votes |
protected RemappingClassAdapter(final int api, final ClassVisitor cv, final Remapper remapper) { super(api, cv); this.remapper = remapper; }
Example 24
Source Project: openjdk-jdk8u Source File: ClassGenerator.java License: GNU General Public License v2.0 | 4 votes |
static void addField(final ClassVisitor cv, final String name, final String desc) { final FieldVisitor fv = cv.visitField(ACC_PRIVATE, name, desc, null, null); if (fv != null) { fv.visitEnd(); } }
Example 25
Source Project: dragonwell8_jdk Source File: StaticInitMerger.java License: GNU General Public License v2.0 | 4 votes |
public StaticInitMerger(final String prefix, final ClassVisitor cv) { this(Opcodes.ASM5, prefix, cv); }
Example 26
Source Project: dragonwell8_jdk Source File: RemappingClassAdapter.java License: GNU General Public License v2.0 | 4 votes |
public RemappingClassAdapter(final ClassVisitor cv, final Remapper remapper) { this(Opcodes.ASM5, cv, remapper); }
Example 27
Source Project: jdk8u60 Source File: ScriptClassInfoCollector.java License: GNU General Public License v2.0 | 4 votes |
ScriptClassInfoCollector(final ClassVisitor visitor) { super(Opcodes.ASM4, visitor); }
Example 28
Source Project: nashorn Source File: ScriptClassInfoCollector.java License: GNU General Public License v2.0 | 4 votes |
ScriptClassInfoCollector(final ClassVisitor visitor) { super(Opcodes.ASM4, visitor); }
Example 29
Source Project: openjdk-jdk9 Source File: ModuleInfoExtender.java License: GNU General Public License v2.0 | 4 votes |
AttributeAddingClassVisitor(int api, ClassVisitor cv) { super(api, cv); }
Example 30
Source Project: openjdk-jdk8u-backup Source File: ClassGenerator.java License: GNU General Public License v2.0 | 4 votes |
static MethodGenerator makeMethod(final ClassVisitor cv, final int access, final String name, final String desc) { final MethodVisitor mv = cv.visitMethod(access, name, desc, null, null); return new MethodGenerator(mv, access, name, desc); }