Java Code Examples for jdk.internal.org.objectweb.asm.ClassVisitor#visitMethod()
The following examples show how to use
jdk.internal.org.objectweb.asm.ClassVisitor#visitMethod() .
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: openjdk-8 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 2
Source Project: openjdk-8 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: jdk8u60 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: nashorn 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: hottub 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 6
Source Project: TencentKona-8 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 7
Source Project: openjdk-jdk9 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 8
Source Project: openjdk-jdk8u-backup 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 9
Source Project: hottub 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: jdk8u60 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 11
Source Project: jdk8u-jdk 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 12
Source Project: jdk8u_nashorn 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 13
Source Project: openjdk-jdk8u 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 14
Source Project: jdk8u_nashorn 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); }
Example 15
Source Project: openjdk-jdk9 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); }
Example 16
Source Project: jdk8u60 File: ClassGenerator.java License: GNU General Public License v2.0 | 4 votes |
static MethodGenerator makeStaticInitializer(final ClassVisitor cv, final String name) { final int access = ACC_PUBLIC | ACC_STATIC; final String desc = DEFAULT_INIT_DESC; final MethodVisitor mv = cv.visitMethod(access, name, desc, null, null); return new MethodGenerator(mv, access, name, desc); }
Example 17
Source Project: openjdk-8 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); }
Example 18
Source Project: openjdk-jdk8u File: ClassGenerator.java License: GNU General Public License v2.0 | 4 votes |
static MethodGenerator makeStaticInitializer(final ClassVisitor cv, final String name) { final int access = ACC_PUBLIC | ACC_STATIC; final String desc = DEFAULT_INIT_DESC; final MethodVisitor mv = cv.visitMethod(access, name, desc, null, null); return new MethodGenerator(mv, access, name, desc); }
Example 19
Source Project: openjdk-8-source File: GeneratorAdapter.java License: GNU General Public License v2.0 | 3 votes |
/** * Creates a new {@link GeneratorAdapter}. <i>Subclasses must not use this * constructor</i>. Instead, they must use the * {@link #GeneratorAdapter(int, MethodVisitor, int, String, String)} * version. * * @param access * access flags of the adapted method. * @param method * the adapted method. * @param signature * the signature of the adapted method (may be <tt>null</tt>). * @param exceptions * the exceptions thrown by the adapted method (may be * <tt>null</tt>). * @param cv * the class visitor to which this adapter delegates calls. */ public GeneratorAdapter(final int access, final Method method, final String signature, final Type[] exceptions, final ClassVisitor cv) { this(access, method, cv .visitMethod(access, method.getName(), method.getDescriptor(), signature, getInternalNames(exceptions))); }
Example 20
Source Project: nashorn File: GeneratorAdapter.java License: GNU General Public License v2.0 | 3 votes |
/** * Creates a new {@link GeneratorAdapter}. <i>Subclasses must not use this * constructor</i>. Instead, they must use the * {@link #GeneratorAdapter(int, MethodVisitor, int, String, String)} * version. * * @param access access flags of the adapted method. * @param method the adapted method. * @param signature the signature of the adapted method (may be * <tt>null</tt>). * @param exceptions the exceptions thrown by the adapted method (may be * <tt>null</tt>). * @param cv the class visitor to which this adapter delegates calls. */ public GeneratorAdapter( final int access, final Method method, final String signature, final Type[] exceptions, final ClassVisitor cv) { this(access, method, cv.visitMethod(access, method.getName(), method.getDescriptor(), signature, getInternalNames(exceptions))); }