本文整理汇总了Java中org.springframework.asm.MethodVisitor.visitFieldInsn方法的典型用法代码示例。如果您正苦于以下问题:Java MethodVisitor.visitFieldInsn方法的具体用法?Java MethodVisitor.visitFieldInsn怎么用?Java MethodVisitor.visitFieldInsn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.asm.MethodVisitor
的用法示例。
在下文中一共展示了MethodVisitor.visitFieldInsn方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateClinitCode
import org.springframework.asm.MethodVisitor; //导入方法依赖的package包/类
void generateClinitCode(String clazzname, String constantFieldName, MethodVisitor mv, CodeFlow codeflow, boolean nested) {
mv.visitTypeInsn(NEW, "java/util/ArrayList");
mv.visitInsn(DUP);
mv.visitMethodInsn(INVOKESPECIAL, "java/util/ArrayList", "<init>", "()V", false);
if (!nested) {
mv.visitFieldInsn(PUTSTATIC, clazzname, constantFieldName, "Ljava/util/List;");
}
int childcount = getChildCount();
for (int c=0; c < childcount; c++) {
if (!nested) {
mv.visitFieldInsn(GETSTATIC, clazzname, constantFieldName, "Ljava/util/List;");
}
else {
mv.visitInsn(DUP);
}
// The children might be further lists if they are not constants. In this
// situation do not call back into generateCode() because it will register another clinit adder.
// Instead, directly build the list here:
if (children[c] instanceof InlineList) {
((InlineList)children[c]).generateClinitCode(clazzname, constantFieldName, mv, codeflow, true);
}
else {
children[c].generateCode(mv, codeflow);
if (CodeFlow.isPrimitive(codeflow.lastDescriptor())) {
CodeFlow.insertBoxIfNecessary(mv, codeflow.lastDescriptor().charAt(0));
}
}
mv.visitMethodInsn(INVOKEINTERFACE, "java/util/List", "add", "(Ljava/lang/Object;)Z", true);
mv.visitInsn(POP);
}
}
示例2: generateCode
import org.springframework.asm.MethodVisitor; //导入方法依赖的package包/类
@Override
public void generateCode(MethodVisitor mv, CodeFlow cf) {
// TODO Future optimization - if followed by a static method call, skip generating code here
if (this.type.isPrimitive()) {
if (this.type == Integer.TYPE) {
mv.visitFieldInsn(GETSTATIC, "java/lang/Integer", "TYPE", "Ljava/lang/Class;");
}
else if (this.type == Boolean.TYPE) {
mv.visitFieldInsn(GETSTATIC, "java/lang/Boolean", "TYPE", "Ljava/lang/Class;");
}
else if (this.type == Byte.TYPE) {
mv.visitFieldInsn(GETSTATIC, "java/lang/Byte", "TYPE", "Ljava/lang/Class;");
}
else if (this.type == Short.TYPE) {
mv.visitFieldInsn(GETSTATIC, "java/lang/Short", "TYPE", "Ljava/lang/Class;");
}
else if (this.type == Double.TYPE) {
mv.visitFieldInsn(GETSTATIC, "java/lang/Double", "TYPE", "Ljava/lang/Class;");
}
else if (this.type == Character.TYPE) {
mv.visitFieldInsn(GETSTATIC, "java/lang/Character", "TYPE", "Ljava/lang/Class;");
}
else if (this.type == Float.TYPE) {
mv.visitFieldInsn(GETSTATIC, "java/lang/Float", "TYPE", "Ljava/lang/Class;");
}
else if (this.type == Long.TYPE) {
mv.visitFieldInsn(GETSTATIC, "java/lang/Long", "TYPE", "Ljava/lang/Class;");
}
else if (this.type == Boolean.TYPE) {
mv.visitFieldInsn(GETSTATIC, "java/lang/Boolean", "TYPE", "Ljava/lang/Class;");
}
}
else {
mv.visitLdcInsn(Type.getType(this.type));
}
cf.pushDescriptor(this.exitTypeDescriptor);
}
示例3: generateCode
import org.springframework.asm.MethodVisitor; //导入方法依赖的package包/类
@Override
public void generateCode(String propertyName, MethodVisitor mv, CodeFlow cf) {
boolean isStatic = Modifier.isStatic(this.member.getModifiers());
String descriptor = cf.lastDescriptor();
String classDesc = this.member.getDeclaringClass().getName().replace('.', '/');
if (!isStatic) {
if (descriptor == null) {
cf.loadTarget(mv);
}
if (descriptor == null || !classDesc.equals(descriptor.substring(1))) {
mv.visitTypeInsn(CHECKCAST, classDesc);
}
}
else {
if (descriptor != null) {
// A static field/method call will not consume what is on the stack,
// it needs to be popped off.
mv.visitInsn(POP);
}
}
if (this.member instanceof Method) {
mv.visitMethodInsn((isStatic ? INVOKESTATIC : INVOKEVIRTUAL), classDesc, this.member.getName(),
CodeFlow.createSignatureDescriptor((Method) this.member), false);
}
else {
mv.visitFieldInsn((isStatic ? GETSTATIC : GETFIELD), classDesc, this.member.getName(),
CodeFlow.toJvmDescriptor(((Field) this.member).getType()));
}
}