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


Java Opcodes.ASM4属性代码示例

本文整理汇总了Java中jdk.internal.org.objectweb.asm.Opcodes.ASM4属性的典型用法代码示例。如果您正苦于以下问题:Java Opcodes.ASM4属性的具体用法?Java Opcodes.ASM4怎么用?Java Opcodes.ASM4使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在jdk.internal.org.objectweb.asm.Opcodes的用法示例。


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

示例1: check

/**
 * Checks that this class node is compatible with the given ASM API version.
 * This methods checks that this node, and all its nodes recursively, do not
 * contain elements that were introduced in more recent versions of the ASM
 * API than the given version.
 *
 * @param api
 *            an ASM API version. Must be one of {@link Opcodes#ASM4} or
 *            {@link Opcodes#ASM5}.
 */
public void check(final int api) {
    if (api == Opcodes.ASM4) {
        if (visibleTypeAnnotations != null
                && visibleTypeAnnotations.size() > 0) {
            throw new RuntimeException();
        }
        if (invisibleTypeAnnotations != null
                && invisibleTypeAnnotations.size() > 0) {
            throw new RuntimeException();
        }
        for (FieldNode f : fields) {
            f.check(api);
        }
        for (MethodNode m : methods) {
            m.check(api);
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:28,代码来源:ClassNode.java

示例2: visitMethod

@Override
public MethodVisitor visitMethod(
    final int access,
    final String name,
    final String desc,
    final String signature,
    final String[] exceptions) {
    return new MethodVisitor(Opcodes.ASM4) {
        @Override
        public AnnotationVisitor visitAnnotationDefault() {
            return new NullAnnotationVisitor();
        }

        @Override
        public AnnotationVisitor visitAnnotation(final String descriptor, final boolean visible) {
            return new NullAnnotationVisitor();
        }
    };
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:NullVisitor.java

示例3: visitAnnotation

@Override
public AnnotationVisitor visitAnnotation(final String desc, final boolean visible) {
    final AnnotationVisitor delegateAV = super.visitAnnotation(desc, visible);
    if (SCRIPT_CLASS_ANNO_DESC.equals(desc)) {
        return new AnnotationVisitor(Opcodes.ASM4, delegateAV) {
            @Override
            public void visit(final String name, final Object value) {
                if ("value".equals(name)) {
                    scriptClassName = (String) value;
                }
                super.visit(name, value);
            }
        };
    }

    return delegateAV;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:ScriptClassInfoCollector.java

示例4: check

/**
 * Checks that this field node is compatible with the given ASM API version.
 * This methods checks that this node, and all its nodes recursively, do not
 * contain elements that were introduced in more recent versions of the ASM
 * API than the given version.
 *
 * @param api
 *            an ASM API version. Must be one of {@link Opcodes#ASM4} or
 *            {@link Opcodes#ASM5}.
 */
public void check(final int api) {
    if (api == Opcodes.ASM4) {
        if (visibleTypeAnnotations != null
                && visibleTypeAnnotations.size() > 0) {
            throw new RuntimeException();
        }
        if (invisibleTypeAnnotations != null
                && invisibleTypeAnnotations.size() > 0) {
            throw new RuntimeException();
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:22,代码来源:FieldNode.java

示例5: visitField

@Override
public FieldVisitor visitField(
    final int access,
    final String name,
    final String desc,
    final String signature,
    final Object value) {
    return new FieldVisitor(Opcodes.ASM4) {
        @Override
        public AnnotationVisitor visitAnnotation(final String descriptor, final boolean visible) {
            return new NullAnnotationVisitor();
        }
    };
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:14,代码来源:NullVisitor.java

示例6: ScriptClassInstrumentor

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();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:8,代码来源:ScriptClassInstrumentor.java

示例7: visitField

@Override
public FieldVisitor visitField(final int fieldAccess, final String fieldName,
        final String fieldDesc, final String signature, final Object value) {
    final MemberInfo memInfo = scriptClassInfo.find(fieldName, fieldDesc, fieldAccess);
    if (memInfo != null && memInfo.getKind() == Kind.PROPERTY &&
            memInfo.getWhere() != Where.INSTANCE && !memInfo.isStaticFinal()) {
        // non-instance @Property fields - these have to go elsewhere unless 'static final'
        return null;
    }

    final FieldVisitor delegateFV = super.visitField(fieldAccess, fieldName, fieldDesc,
            signature, value);
    return new FieldVisitor(Opcodes.ASM4, delegateFV) {
        @Override
        public AnnotationVisitor visitAnnotation(final String desc, final boolean visible) {
            if (ScriptClassInfo.annotations.containsKey(desc)) {
                // ignore script field annotations
                return null;
            }

            return fv.visitAnnotation(desc, visible);
        }

        @Override
        public void visitAttribute(final Attribute attr) {
            fv.visitAttribute(attr);
        }

        @Override
        public void visitEnd() {
            fv.visitEnd();
        }
    };
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:34,代码来源:ScriptClassInstrumentor.java

示例8: check

/**
 * Checks that this method node is compatible with the given ASM API
 * version. This methods checks that this node, and all its nodes
 * recursively, do not contain elements that were introduced in more recent
 * versions of the ASM API than the given version.
 *
 * @param api
 *            an ASM API version. Must be one of {@link Opcodes#ASM4} or
 *            {@link Opcodes#ASM5}.
 */
public void check(final int api) {
    if (api == Opcodes.ASM4) {
        if (visibleTypeAnnotations != null
                && visibleTypeAnnotations.size() > 0) {
            throw new RuntimeException();
        }
        if (invisibleTypeAnnotations != null
                && invisibleTypeAnnotations.size() > 0) {
            throw new RuntimeException();
        }
        int n = tryCatchBlocks == null ? 0 : tryCatchBlocks.size();
        for (int i = 0; i < n; ++i) {
            TryCatchBlockNode tcb = tryCatchBlocks.get(i);
            if (tcb.visibleTypeAnnotations != null
                    && tcb.visibleTypeAnnotations.size() > 0) {
                throw new RuntimeException();
            }
            if (tcb.invisibleTypeAnnotations != null
                    && tcb.invisibleTypeAnnotations.size() > 0) {
                throw new RuntimeException();
            }
        }
        for (int i = 0; i < instructions.size(); ++i) {
            AbstractInsnNode insn = instructions.get(i);
            if (insn.visibleTypeAnnotations != null
                    && insn.visibleTypeAnnotations.size() > 0) {
                throw new RuntimeException();
            }
            if (insn.invisibleTypeAnnotations != null
                    && insn.invisibleTypeAnnotations.size() > 0) {
                throw new RuntimeException();
            }
            if (insn instanceof MethodInsnNode) {
                boolean itf = ((MethodInsnNode) insn).itf;
                if (itf != (insn.opcode == Opcodes.INVOKEINTERFACE)) {
                    throw new RuntimeException();
                }
            }
        }
        if (visibleLocalVariableAnnotations != null
                && visibleLocalVariableAnnotations.size() > 0) {
            throw new RuntimeException();
        }
        if (invisibleLocalVariableAnnotations != null
                && invisibleLocalVariableAnnotations.size() > 0) {
            throw new RuntimeException();
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:59,代码来源:MethodNode.java

示例9: NullVisitor

NullVisitor() {
    super(Opcodes.ASM4);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:3,代码来源:NullVisitor.java

示例10: NullAnnotationVisitor

NullAnnotationVisitor() {
    super(Opcodes.ASM4);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:3,代码来源:NullVisitor.java

示例11: visitField

@Override
public FieldVisitor visitField(final int fieldAccess, final String fieldName, final String fieldDesc, final String signature, final Object value) {
    final FieldVisitor delegateFV = super.visitField(fieldAccess, fieldName, fieldDesc, signature, value);

    return new FieldVisitor(Opcodes.ASM4, delegateFV) {
        @Override
        public AnnotationVisitor visitAnnotation(final String descriptor, final boolean visible) {
            final AnnotationVisitor delegateAV = super.visitAnnotation(descriptor, visible);

            if (ScriptClassInfo.PROPERTY_ANNO_DESC.equals(descriptor)) {
                final MemberInfo memInfo = new MemberInfo();

                memInfo.setKind(Kind.PROPERTY);
                memInfo.setJavaName(fieldName);
                memInfo.setJavaDesc(fieldDesc);
                memInfo.setJavaAccess(fieldAccess);

                if ((fieldAccess & Opcodes.ACC_STATIC) != 0) {
                    memInfo.setValue(value);
                }

                addScriptMember(memInfo);

                return new AnnotationVisitor(Opcodes.ASM4, delegateAV) {
                    // These could be "null" if values are not suppiled,
                    // in which case we have to use the default values.
                    private String  name;
                    private Integer attributes;
                    private String  clazz = "";
                    private Where   where;

                    @Override
                    public void visit(final String annotationName, final Object annotationValue) {
                        switch (annotationName) {
                        case "name":
                            this.name = (String) annotationValue;
                            break;
                        case "attributes":
                            this.attributes = (Integer) annotationValue;
                            break;
                        case "clazz":
                            this.clazz = (annotationValue == null) ? "" : annotationValue.toString();
                            break;
                        default:
                            break;
                        }
                        super.visit(annotationName, annotationValue);
                    }

                    @Override
                    public void visitEnum(final String enumName, final String desc, final String enumValue) {
                        if ("where".equals(enumName) && WHERE_ENUM_DESC.equals(desc)) {
                            this.where = Where.valueOf(enumValue);
                        }
                        super.visitEnum(enumName, desc, enumValue);
                    }

                    @Override
                    public void visitEnd() {
                        super.visitEnd();
                        memInfo.setName(name == null ? fieldName : name);
                        memInfo.setAttributes(attributes == null
                                ? MemberInfo.DEFAULT_ATTRIBUTES : attributes);
                        clazz = clazz.replace('.', '/');
                        memInfo.setInitClass(clazz);
                        memInfo.setWhere(where == null? Where.INSTANCE : where);
                    }
                };
            }

            return delegateAV;
        }
    };
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:74,代码来源:ScriptClassInfoCollector.java

示例12: SignatureVisitor

/**
 * Constructs a new {@link SignatureVisitor}.
 *
 * @param api
 *            the ASM API version implemented by this visitor. Must be one
 *            of {@link Opcodes#ASM4} or {@link Opcodes#ASM5}.
 */
public SignatureVisitor(final int api) {
    if (api != Opcodes.ASM4 && api != Opcodes.ASM5) {
        throw new IllegalArgumentException();
    }
    this.api = api;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:13,代码来源:SignatureVisitor.java


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