当前位置: 首页>>代码示例>>Java>>正文


Java FieldVisitor类代码示例

本文整理汇总了Java中org.objectweb.asm.FieldVisitor的典型用法代码示例。如果您正苦于以下问题:Java FieldVisitor类的具体用法?Java FieldVisitor怎么用?Java FieldVisitor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FieldVisitor类属于org.objectweb.asm包,在下文中一共展示了FieldVisitor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: begin

import org.objectweb.asm.FieldVisitor; //导入依赖的package包/类
@Override
public void begin(final String name, final Attributes attrs) {
    String desc = attrs.getValue("desc");
    boolean visible = Boolean.valueOf(attrs.getValue("visible"))
            .booleanValue();
    int typeRef = Integer.parseInt(attrs.getValue("typeRef"));
    TypePath typePath = TypePath.fromString(attrs.getValue("typePath"));

    Object v = peek();
    if (v instanceof ClassVisitor) {
        push(((ClassVisitor) v).visitTypeAnnotation(typeRef, typePath,
                desc, visible));
    } else if (v instanceof FieldVisitor) {
        push(((FieldVisitor) v).visitTypeAnnotation(typeRef, typePath,
                desc, visible));
    } else if (v instanceof MethodVisitor) {
        push(((MethodVisitor) v).visitTypeAnnotation(typeRef, typePath,
                desc, visible));
    }
}
 
开发者ID:ItzSomebody,项目名称:DirectLeaks-AntiReleak-Remover,代码行数:21,代码来源:ASMContentHandler.java

示例2: visitField

import org.objectweb.asm.FieldVisitor; //导入依赖的package包/类
@Override
public FieldVisitor visitField(final int access, final String name,
        final String desc, final String signature, final Object value) {
    StringBuilder sb = new StringBuilder();
    appendAccess(access | ACCESS_FIELD, sb);

    AttributesImpl att = new AttributesImpl();
    att.addAttribute("", "access", "access", "", sb.toString());
    att.addAttribute("", "name", "name", "", name);
    att.addAttribute("", "desc", "desc", "", desc);
    if (signature != null) {
        att.addAttribute("", "signature", "signature", "",
                encode(signature));
    }
    if (value != null) {
        att.addAttribute("", "value", "value", "", encode(value.toString()));
    }

    return new SAXFieldAdapter(sa, att);
}
 
开发者ID:ItzSomebody,项目名称:DirectLeaks-AntiReleak-Remover,代码行数:21,代码来源:SAXClassAdapter.java

示例3: visitField

import org.objectweb.asm.FieldVisitor; //导入依赖的package包/类
@Override
public FieldVisitor visitField(final int access, final String name,
        final String desc, final String signature, final Object value) {
    checkState();
    checkAccess(access, Opcodes.ACC_PUBLIC + Opcodes.ACC_PRIVATE
            + Opcodes.ACC_PROTECTED + Opcodes.ACC_STATIC
            + Opcodes.ACC_FINAL + Opcodes.ACC_VOLATILE
            + Opcodes.ACC_TRANSIENT + Opcodes.ACC_SYNTHETIC
            + Opcodes.ACC_ENUM + Opcodes.ACC_DEPRECATED + 0x40000); // ClassWriter.ACC_SYNTHETIC_ATTRIBUTE
    CheckMethodAdapter.checkUnqualifiedName(version, name, "field name");
    CheckMethodAdapter.checkDesc(desc, false);
    if (signature != null) {
        checkFieldSignature(signature);
    }
    if (value != null) {
        CheckMethodAdapter.checkConstant(value);
    }
    FieldVisitor av = super
            .visitField(access, name, desc, signature, value);
    return new CheckFieldAdapter(av);
}
 
开发者ID:ItzSomebody,项目名称:DirectLeaks-AntiReleak-Remover,代码行数:22,代码来源:CheckClassAdapter.java

示例4: assertFiledTypes

import org.objectweb.asm.FieldVisitor; //导入依赖的package包/类
private void assertFiledTypes(final Class<?> type, String... expected)
        throws IOException {
    final ClassReader reader = new ClassReader(type.getName());
    final Set<String> actual = new HashSet<String>();
    reader.accept(new ClassVisitor(Opcodes.ASM5) {
        @Override
        public FieldVisitor visitField(int access, String name,
                String desc, String signature, Object value) {
            if ((access & Opcodes.ACC_SYNTHETIC) == 0) {
                if (signature == null) {
                    signature = desc;
                }
                cyclicRefsTest.getTypesFromSignature(signature, actual);
            }
            return null;
        }
    }, 0);
    assertEquals(new HashSet<String>(Arrays.asList(expected)), actual);
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:20,代码来源:CyclicReferencesTestTest.java

示例5: generate

import org.objectweb.asm.FieldVisitor; //导入依赖的package包/类
public byte[] generate(){
    String className = "eu.mikroskeem.test.shuriken.common.classtools.gen.GeneratedClass";
    String classNameInternal = className.replaceAll("\\.", "/");

    ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS + ClassWriter.COMPUTE_FRAMES);
    cw.visit(
            V1_8,
            ACC_PUBLIC + ACC_SUPER,
            classNameInternal,
            null,
            Type.getInternalName(Object.class),
            null);
    FieldVisitor fv = cw.visitField(ACC_PRIVATE + ACC_STATIC, "test", Type.getDescriptor(String.class), null, "hey");
    fv.visitEnd();
    MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
    mv.visitVarInsn(ALOAD, 0);
    mv.visitMethodInsn(INVOKESPECIAL, Type.getInternalName(Object.class), "<init>", "()V", false);
    mv.visitInsn(RETURN);
    mv.visitMaxs(0, 0);
    mv.visitEnd();
    cw.visitEnd();
    return cw.toByteArray();
}
 
开发者ID:mikroskeem,项目名称:Shuriken,代码行数:24,代码来源:ValidatorTester.java

示例6: visitField

import org.objectweb.asm.FieldVisitor; //导入依赖的package包/类
@Override
public FieldVisitor visitField(final int access,
    final String name, final String desc,
    final String signature, final Object value) {
    this.dirs.addIf("attributes")
        .add("attribute")
        .set(name)
        .attr("type", desc.replaceAll(";$", ""))
        .attr(
            "public",
            (access & Opcodes.ACC_PUBLIC) == Opcodes.ACC_PUBLIC
        )
        .attr(
            "static",
            (access & Opcodes.ACC_STATIC) == Opcodes.ACC_STATIC
        )
        .up().up();
    return super.visitField(
        access, name, desc, signature, value
    );
}
 
开发者ID:yegor256,项目名称:jpeek,代码行数:22,代码来源:Skeleton.java

示例7: visitField

import org.objectweb.asm.FieldVisitor; //导入依赖的package包/类
@Override
public FieldVisitor visitField(final int access, final String name,
        final String desc, final String signature, final Object value) {
    if ((access & Opcodes.ACC_SYNTHETIC) != 0) {
        cp.newUTF8("Synthetic");
    }
    if ((access & Opcodes.ACC_DEPRECATED) != 0) {
        cp.newUTF8("Deprecated");
    }
    cp.newUTF8(name);
    cp.newUTF8(desc);
    if (signature != null) {
        cp.newUTF8("Signature");
        cp.newUTF8(signature);
    }
    if (value != null) {
        cp.newConst(value);
    }
    return new FieldConstantsCollector(cv.visitField(access, name, desc,
            signature, value), cp);
}
 
开发者ID:acmerli,项目名称:fastAOP,代码行数:22,代码来源:ClassConstantsCollector.java

示例8: visitLdcInsn

import org.objectweb.asm.FieldVisitor; //导入依赖的package包/类
@Override
public void visitLdcInsn(Object cst) {
    if (!(cst instanceof Type)) {
        super.visitLdcInsn(cst);
        return;
    }

    // transform Foo.class for 1.2 compatibility
    String ldcName = ((Type) cst).getInternalName();
    String fieldName = "class$" + ldcName.replace('/', '$');
    if (!classOptimizer.syntheticClassFields.contains(ldcName)) {
        classOptimizer.syntheticClassFields.add(ldcName);
        FieldVisitor fv = classOptimizer.syntheticFieldVisitor(ACC_STATIC
                | ACC_SYNTHETIC, fieldName, "Ljava/lang/Class;");
        fv.visitEnd();
    }

    String clsName = classOptimizer.clsName;
    mv.visitFieldInsn(GETSTATIC, clsName, fieldName, "Ljava/lang/Class;");
}
 
开发者ID:acmerli,项目名称:fastAOP,代码行数:21,代码来源:MethodOptimizer.java

示例9: visitField

import org.objectweb.asm.FieldVisitor; //导入依赖的package包/类
@Override
public FieldVisitor visitField(final int access, final String name,
        final String desc, final String signature, final Object value) {
    String s = remapper.mapFieldName(className, name, desc);
    if ("-".equals(s)) {
        return null;
    }
    if ((access & (Opcodes.ACC_PUBLIC | Opcodes.ACC_PROTECTED)) == 0) {
        if ((access & Opcodes.ACC_FINAL) != 0
                && (access & Opcodes.ACC_STATIC) != 0 && desc.length() == 1) {
            return null;
        }
        if ("org/objectweb/asm".equals(pkgName) && s.equals(name)) {
            System.out.println("INFO: " + clsName + "." + s
                    + " could be renamed");
        }
        super.visitField(access, name, desc, null, value);
    } else {
        if (!s.equals(name)) {
            throw new RuntimeException("The public or protected field "
                    + className + '.' + name + " must not be renamed.");
        }
        super.visitField(access, name, desc, null, value);
    }
    return null; // remove debug info
}
 
开发者ID:acmerli,项目名称:fastAOP,代码行数:27,代码来源:ClassOptimizer.java

示例10: visitField

import org.objectweb.asm.FieldVisitor; //导入依赖的package包/类
@Override
public FieldVisitor visitField(
       final int access,
       final String name,
       final String desc,
       final String signature,
       final Object value)
   {
   	if ((access & ACC_SYNTHETIC) == 0) {
        JvmFieldBuilder fieldBuilder = new JvmFieldBuilder(
        		result,
        		(access & ACC_STATIC) == 0 ? typeParameters : null,
        		proxies,
   				access,
        		name,
        		desc,
        		signature,
        		value);
        return fieldBuilder;
   	}
   	return null;
   }
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:23,代码来源:JvmDeclaredTypeBuilder.java

示例11: visitField

import org.objectweb.asm.FieldVisitor; //导入依赖的package包/类
@Override
public FieldVisitor visitField(int access, String name, String desc, String sig, Object o) {
  if (this.classOnly) {
    return super.visitField(access, name, desc, sig, o);
  }
  if (name.startsWith("$") || name.startsWith("this$")) {
    return super.visitField(access, name, desc, sig, o);
  }
  if (includePrivate) {
    return new FieldAnalyzeVisitor(this, access, name, desc, sig)
        .setTypeMap(this.getTypeMap())
        .parseSignature();
  }
  // log.debug("Field Name:{}", name);
  if ((Opcodes.ACC_PRIVATE & access) == 0) {
    return new FieldAnalyzeVisitor(this, access, name, desc, sig)
        .setTypeMap(this.getTypeMap())
        .parseSignature();
  }
  return super.visitField(access, name, desc, sig, o);
}
 
开发者ID:mopemope,项目名称:meghanada-server,代码行数:22,代码来源:ClassAnalyzeVisitor.java

示例12: generateFields

import org.objectweb.asm.FieldVisitor; //导入依赖的package包/类
/**
 * Emits the bytecode for all fields of the class
 */
protected void generateFields() {
       for (SootField f : sc.getFields()) {
           String name = f.getName();
           String desc = toTypeDesc(f.getType());
           String sig = null;
           if (f.hasTag("SignatureTag")) {
               SignatureTag genericSignature = (SignatureTag) f
                       .getTag("SignatureTag");
               sig = genericSignature.getSignature();
           }
           Object value = getDefaultValue(f);
           int access = getModifiers(f.getModifiers(), f);
           FieldVisitor fv = cv.visitField(access, name, desc, sig, value);
           if (fv != null) {
               generateAnnotations(fv, f);
               generateAttributes(fv, f);
               fv.visitEnd();
           }
       }
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:24,代码来源:AbstractASMBackend.java

示例13: visitField

import org.objectweb.asm.FieldVisitor; //导入依赖的package包/类
@Override
public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) {
    if ("$VALUES".equals(name) && classStack.peek().isEnum()) {
        return null;
    }

    String signatureDesc = signature != null ? signature : desc;
    SignatureReader r = new SignatureReader(signatureDesc);
    CustomTraceSignatureVisitor sv = new CustomTraceSignatureVisitor(Opcodes.ACC_PUBLIC);
    r.accept(sv);

    FieldInfo field = FieldInfo.fieldInfo()
        .name(name)
        .modifiers(access)
        .type(sv.getTypeOrSuperclass())
        .value(value)
        .build();
    classStack.peek().addToFields(field);
    return new FieldProcessor(field);
}
 
开发者ID:aalmiray,项目名称:naum,代码行数:21,代码来源:ClassProcessor.java

示例14: visitField

import org.objectweb.asm.FieldVisitor; //导入依赖的package包/类
public FieldVisitor visitField(
    final int access,
    final String name,
    final String desc,
    final String signature,
    final Object value)
{
    checkState();
    checkAccess(access, Opcodes.ACC_PUBLIC + Opcodes.ACC_PRIVATE
            + Opcodes.ACC_PROTECTED + Opcodes.ACC_STATIC
            + Opcodes.ACC_FINAL + Opcodes.ACC_VOLATILE
            + Opcodes.ACC_TRANSIENT + Opcodes.ACC_SYNTHETIC
            + Opcodes.ACC_ENUM + Opcodes.ACC_DEPRECATED);
    CheckMethodAdapter.checkIdentifier(name, "field name");
    CheckMethodAdapter.checkDesc(desc, false);
    if (signature != null) {
        // TODO
    }
    if (value != null) {
        CheckMethodAdapter.checkConstant(value);
    }
    FieldVisitor av = cv.visitField(access, name, desc, signature, value);
    return new CheckFieldAdapter(av);
}
 
开发者ID:vilie,项目名称:javify,代码行数:25,代码来源:CheckClassAdapter.java

示例15: visitField

import org.objectweb.asm.FieldVisitor; //导入依赖的package包/类
public FieldVisitor visitField(
    final int access,
    final String name,
    final String desc,
    final String signature,
    final Object value)
{
    buf.setLength(0);
    buf.append("{\n");
    buf.append("fv = cw.visitField(");
    appendAccess(access | ACCESS_FIELD);
    buf.append(", ");
    appendConstant(name);
    buf.append(", ");
    appendConstant(desc);
    buf.append(", ");
    appendConstant(signature);
    buf.append(", ");
    appendConstant(value);
    buf.append(");\n");
    text.add(buf.toString());
    ASMifierFieldVisitor aav = new ASMifierFieldVisitor();
    text.add(aav.getText());
    text.add("}\n");
    return aav;
}
 
开发者ID:vilie,项目名称:javify,代码行数:27,代码来源:ASMifierClassVisitor.java


注:本文中的org.objectweb.asm.FieldVisitor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。