热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

org.objectweb.asm.commons.GeneratorAdapter.visitFieldInsn()方法的使用及代码示例

本文整理了Java中org.objectweb.asm.commons.GeneratorAdapter.visitFieldInsn()方法的一些代码示例,展示了

本文整理了Java中org.objectweb.asm.commons.GeneratorAdapter.visitFieldInsn()方法的一些代码示例,展示了GeneratorAdapter.visitFieldInsn()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GeneratorAdapter.visitFieldInsn()方法的具体详情如下:
包路径:org.objectweb.asm.commons.GeneratorAdapter
类名称:GeneratorAdapter
方法名:visitFieldInsn

GeneratorAdapter.visitFieldInsn介绍

暂无

代码示例

代码示例来源:origin: Meituan-Dianping/Robust

switch (arg.getDescriptor()) {
case "Z":
mv.visitFieldInsn(Opcodes.GETSTATIC, "java/lang/Boolean", "TYPE", "Ljava/lang/Class;");
break;
case "B":
mv.visitFieldInsn(Opcodes.GETSTATIC, "java/lang/Byte", "TYPE", "Ljava/lang/Class;");
break;
case "C":
mv.visitFieldInsn(Opcodes.GETSTATIC, "java/lang/Character", "TYPE", "Ljava/lang/Class;");
break;
case "S":
mv.visitFieldInsn(Opcodes.GETSTATIC, "java/lang/Short", "TYPE", "Ljava/lang/Class;");
break;
case "I":
mv.visitFieldInsn(Opcodes.GETSTATIC, "java/lang/Integer", "TYPE", "Ljava/lang/Class;");
break;
case "F":
mv.visitFieldInsn(Opcodes.GETSTATIC, "java/lang/Float", "TYPE", "Ljava/lang/Class;");
break;
case "D":
mv.visitFieldInsn(Opcodes.GETSTATIC, "java/lang/Double", "TYPE", "Ljava/lang/Class;");
break;
case "J":
mv.visitFieldInsn(Opcodes.GETSTATIC, "java/lang/Long", "TYPE", "Ljava/lang/Class;");
break;
case "V":
mv.visitFieldInsn(Opcodes.GETSTATIC, "java/lang/Void", "TYPE", "Ljava/lang/Class;");
break;
default:

代码示例来源:origin: Meituan-Dianping/Robust

mv.loadLocal(local);
mv.visitFieldInsn(Opcodes.GETFIELD, "com/meituan/robust/PatchProxyResult", "isSupported", "Z");
} else {
mv.loadLocal(local);
mv.visitFieldInsn(Opcodes.GETFIELD, "com/meituan/robust/PatchProxyResult", "result", "Ljava/lang/Object;");

代码示例来源:origin: Meituan-Dianping/Robust

private static void prepareMethodParameters(GeneratorAdapter mv, String className, List args, Type returnType, boolean isStatic, int methodId) {
//第一个参数:new Object[]{...};,如果方法没有参数直接传入new Object[0]
if (args.size() == 0) {
mv.visitInsn(Opcodes.ICONST_0);
mv.visitTypeInsn(Opcodes.ANEWARRAY, "java/lang/Object");
} else {
createObjectArray(mv, args, isStatic);
}
//第二个参数:this,如果方法是static的话就直接传入null
if (isStatic) {
mv.visitInsn(Opcodes.ACONST_NULL);
} else {
mv.visitVarInsn(Opcodes.ALOAD, 0);
}
//第三个参数:changeQuickRedirect
mv.visitFieldInsn(Opcodes.GETSTATIC,
className,
REDIRECTFIELD_NAME,
REDIRECTCLASSNAME);
//第四个参数:false,标志是否为static
mv.visitInsn(isStatic ? Opcodes.ICONST_1 : Opcodes.ICONST_0);
//第五个参数:
mv.push(methodId);
//第六个参数:参数class数组
createClassArray(mv, args);
//第七个参数:返回值类型class
createReturnClass(mv, returnType);
}

代码示例来源:origin: glowroot/glowroot

@Override
public void visitFieldInsn(final int opcode, final String owner, final String name,
final String descriptor) {
super.visitFieldInsn(opcode, owner, name, descriptor);
if (stackFrameTracking) {
char firstDescriptorChar = descriptor.charAt(0);

代码示例来源:origin: com.nitorcreations/junit-runners

public void loadConstructorArgs(GeneratorAdapter mv) {
mv.visitFieldInsn(GETSTATIC, nameRaw, FIELD_CONSTRUCTOR_ARGS,
"[Ljava/lang/Object;");
}

代码示例来源:origin: com.nitorcreations/junit-runners

public void loadConstructorArgs(GeneratorAdapter mv) {
mv.visitFieldInsn(GETSTATIC, powerMockHelperClassRaw,
FIELD_CONSTRUCTOR_ARGS, "[Ljava/lang/Object;");
}

代码示例来源:origin: EvoSuite/evosuite

/** {@inheritDoc} */
@Override
public void visitFieldInsn(int opcode, String owner, String name, String desc) {
if(!inInstrumentation) {
inInstrumentation = true;
for(ErrorBranchInstrumenter instrumenter : instrumentation) {
instrumenter.visitFieldInsn(opcode, owner, name, desc);
}
inInstrumentation = false;
}
super.visitFieldInsn(opcode, owner, name, desc);
}

代码示例来源:origin: apache/felix

super.visitFieldInsn(opcode, owner, name, desc);

代码示例来源:origin: apache/felix

/**
* Visit an instruction modifying a method (GETFIELD/PUTFIELD).
* @see org.objectweb.asm.MethodVisitor#visitFieldInsn(int, String, String, String)
* @param opcode : visited operation code
* @param owner : owner of the field
* @param name : name of the field
* @param desc : descriptor of the field
*/
public void visitFieldInsn(final int opcode, final String owner, final String name, final String desc) {
if (owner.equals(m_owner) && m_fields.contains(name)) {
if (opcode == GETFIELD) {
String gDesc = "()" + desc;
visitMethodInsn(INVOKEVIRTUAL, owner, "__get" + name, gDesc, false);
return;
} else if (opcode == PUTFIELD) {
String sDesc = "(" + desc + ")V";
visitMethodInsn(INVOKEVIRTUAL, owner, "__set" + name, sDesc, false);
return;
}
}
super.visitFieldInsn(opcode, owner, name, desc);
}

代码示例来源:origin: gradle.plugin.com.xk/wormhole-gradle

super.visitFieldInsn(opcode, owner, name, desc);

代码示例来源:origin: org.glassfish.ejb/ejb-container

private static void generateSetDelegateMethod(ClassVisitor cv, Class delegateClass,
String subClassName)
throws Exception {
String delegateInternalName = Type.getType(delegateClass).getInternalName();
Class optProxyClass = OptionalLocalInterfaceProvider.class;
java.lang.reflect.Method proxyMethod = optProxyClass.getMethod(
"setOptionalLocalIntfProxy", java.lang.reflect.Proxy.class);
String methodName = proxyMethod.getName();
Type returnType = Type.getReturnType(proxyMethod);
Type[] argTypes = Type.getArgumentTypes(proxyMethod);
Type[] eTypes = getExceptionTypes(proxyMethod);
Method asmMethod = new Method(methodName, returnType, argTypes);
GeneratorAdapter mg2 = new GeneratorAdapter(ACC_PUBLIC, asmMethod, null, eTypes, cv);
mg2.visitVarInsn(ALOAD, 0);
mg2.visitVarInsn(ALOAD, 1);
mg2.visitTypeInsn(CHECKCAST, delegateClass.getName().replace('.', '/'));
String delIntClassDesc = Type.getType(delegateClass).getDescriptor();
mg2.visitFieldInsn(PUTFIELD, subClassName.replace('.', '/'),
DELEGATE_FIELD_NAME, delIntClassDesc);
mg2.returnValue();
mg2.endMethod();
}

代码示例来源:origin: org.glassfish.main.ejb/ejb-container

private static void generateSetDelegateMethod(ClassVisitor cv, Class delegateClass,
String subClassName)
throws Exception {
Class optProxyClass = OptionalLocalInterfaceProvider.class;
java.lang.reflect.Method proxyMethod = optProxyClass.getMethod(
"setOptionalLocalIntfProxy", java.lang.reflect.Proxy.class);
String methodName = proxyMethod.getName();
Type returnType = Type.getReturnType(proxyMethod);
Type[] argTypes = Type.getArgumentTypes(proxyMethod);
Type[] eTypes = getExceptionTypes(proxyMethod);
Method asmMethod = new Method(methodName, returnType, argTypes);
GeneratorAdapter mg2 = new GeneratorAdapter(ACC_PUBLIC, asmMethod, null, eTypes, cv);
mg2.visitVarInsn(ALOAD, 0);
mg2.visitVarInsn(ALOAD, 1);
mg2.visitTypeInsn(CHECKCAST, delegateClass.getName().replace('.', '/'));
String delIntClassDesc = Type.getType(delegateClass).getDescriptor();
mg2.visitFieldInsn(PUTFIELD, subClassName.replace('.', '/'),
DELEGATE_FIELD_NAME, delIntClassDesc);
mg2.returnValue();
mg2.endMethod();
}

代码示例来源:origin: org.glassfish.main.ejb/ejb-container

private static void generateBeanMethod(ClassVisitor cv, String subClassName,
java.lang.reflect.Method m, Class delegateClass)
throws Exception {
String methodName = m.getName();
Type returnType = Type.getReturnType(m);
Type[] argTypes = Type.getArgumentTypes(m);
Method asmMethod = new Method(methodName, returnType, argTypes);
GeneratorAdapter mg = new GeneratorAdapter(ACC_PUBLIC, asmMethod, null,
getExceptionTypes(m), cv);
mg.loadThis();
mg.visitFieldInsn(GETFIELD, subClassName.replace('.', '/'),
DELEGATE_FIELD_NAME, Type.getType(delegateClass).getDescriptor());
mg.loadArgs();
mg.invokeInterface(Type.getType(delegateClass), asmMethod);
mg.returnValue();
mg.endMethod();
}

代码示例来源:origin: org.glassfish.ejb/ejb-container

private static void generateBeanMethod(ClassVisitor cv, String subClassName,
java.lang.reflect.Method m, Class delegateClass)
throws Exception {
String methodName = m.getName();
Type returnType = Type.getReturnType(m);
Type[] argTypes = Type.getArgumentTypes(m);
Method asmMethod = new Method(methodName, returnType, argTypes);
GeneratorAdapter mg = new GeneratorAdapter(ACC_PUBLIC, asmMethod, null,
getExceptionTypes(m), cv);
mg.loadThis();
mg.visitFieldInsn(GETFIELD, subClassName.replace('.', '/'),
DELEGATE_FIELD_NAME, Type.getType(delegateClass).getDescriptor());
mg.loadArgs();
mg.invokeInterface(Type.getType(delegateClass), asmMethod);
mg.returnValue();
mg.endMethod();
}

代码示例来源:origin: EvoSuite/evosuite

super.visitFieldInsn(opcode, owner, name, desc); // user ByteCode

代码示例来源:origin: openl-tablets/openl-tablets

public void write(ClassWriter classWriter) {
GeneratorAdapter mg = new GeneratorAdapter(Opcodes.ACC_PUBLIC, DEF_CONSTR, null, null, classWriter);
// invokes the super class constructor
mg.loadThis();
mg.invokeConstructor(Type.getType(getParentClass()), DEF_CONSTR);
for (Map.Entry field : getBeanFields().entrySet()) {
FieldDescription fieldDescription = field.getValue();
if (fieldDescription.hasDefaultValue()) {
mg.loadThis();
Object value = fieldDescription.getDefaultValue();
String retClass = fieldDescription.getTypeDescriptor();
Type type = Type.getType(retClass);
pushValue(mg, type, value);
String fieldTypeName = fieldDescription.getTypeDescriptor();
mg.visitFieldInsn(Opcodes.PUTFIELD, getBeanNameWithPackage(), field.getKey(), fieldTypeName);
}
}
mg.returnValue();
mg.endMethod();
}
}

代码示例来源:origin: org.apache.aries.spifly/org.apache.aries.spifly.dynamic.bundle

@Override
public void visitFieldInsn(
final int opcode, final String owner, final String name, final String descriptor) {
super.visitFieldInsn(opcode, owner, name, descriptor);
if (isConstructor && !superClassConstructorCalled) {
char firstDescriptorChar = descriptor.charAt(0);

代码示例来源:origin: org.ow2.asm/asm-commons

@Override
public void visitFieldInsn(
final int opcode, final String owner, final String name, final String descriptor) {
super.visitFieldInsn(opcode, owner, name, descriptor);
if (isConstructor && !superClassConstructorCalled) {
char firstDescriptorChar = descriptor.charAt(0);

代码示例来源:origin: org.glassfish.main.flashlight/flashlight-framework

private void generateConstructor(ClassWriter cw, String generatedClassName, FlashlightProbeProvider provider) {
Method m = Method.getMethod("void ()");
GeneratorAdapter gen = new GeneratorAdapter(Opcodes.ACC_PUBLIC, m, null, null, cw);
gen.loadThis();
gen.invokeConstructor(Type.getType(Object.class), m);
Type probeRegType = Type.getType(ProbeRegistry.class);
Type probeType = Type.getType(FlashlightProbe.class);
gen.loadThis();
for (FlashlightProbe probe : provider.getProbes()) {
gen.dup();
String fieldName = "_flashlight_" + probe.getProbeName();
gen.push(probe.getId());
gen.invokeStatic(probeRegType,
Method.getMethod("org.glassfish.flashlight.provider.FlashlightProbe getProbeById(int)"));
gen.visitFieldInsn(Opcodes.PUTFIELD,
generatedClassName,
fieldName, probeType.getDescriptor());
}
gen.pop();
//return the value from constructor
gen.returnValue();
gen.endMethod();
}
}

代码示例来源:origin: org.apache.aries.spifly/org.apache.aries.spifly.dynamic.framework.extension

@Override
public void visitFieldInsn(
final int opcode, final String owner, final String name, final String descriptor) {
super.visitFieldInsn(opcode, owner, name, descriptor);
if (isConstructor && !superClassConstructorCalled) {
char firstDescriptorChar = descriptor.charAt(0);

推荐阅读
author-avatar
武艺最新单曲问月09
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有