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


Java Attribute类代码示例

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


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

示例1: read

import jdk.internal.org.objectweb.asm.Attribute; //导入依赖的package包/类
@Override
protected Attribute read(ClassReader cr,
                         int off,
                         int len,
                         char[] buf,
                         int codeOff,
                         Label[] labels)
{
    // package count
    int package_count = cr.readUnsignedShort(off);
    off += 2;

    // packages
    Set<String> packages = new HashSet<>();
    for (int i=0; i<package_count; i++) {
        String pkg = cr.readPackage(off, buf).replace('/', '.');
        packages.add(pkg);
        off += 2;
    }

    return new ModulePackagesAttribute(packages);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:ClassFileAttributes.java

示例2: hasModulePackages

import jdk.internal.org.objectweb.asm.Attribute; //导入依赖的package包/类
boolean hasModulePackages() throws IOException {
    Set<String> attrTypes = new HashSet<>();
    ClassVisitor cv = new ClassVisitor(Opcodes.ASM5) {
        @Override
        public void visitAttribute(Attribute attr) {
            attrTypes.add(attr.type);
        }
    };

    // prototype of attributes that should be parsed
    Attribute[] attrs = new Attribute[] {
        new ClassFileAttributes.ModulePackagesAttribute()
    };

    try (InputStream in = getInputStream()) {
        // parse module-info.class
        ClassReader cr = new ClassReader(in);
        cr.accept(cv, attrs, 0);
        return attrTypes.contains(ClassFileConstants.MODULE_PACKAGES);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:SystemModulesPlugin.java

示例3: read

import jdk.internal.org.objectweb.asm.Attribute; //导入依赖的package包/类
public static ModuleTarget read(InputStream in) throws IOException {
    ModuleTargetAttribute[] modTargets = new ModuleTargetAttribute[1];
    ClassVisitor cv = new ClassVisitor(Opcodes.ASM5) {
        @Override
        public void visitAttribute(Attribute attr) {
            if (attr instanceof ModuleTargetAttribute) {
                modTargets[0] = (ModuleTargetAttribute)attr;
            }
        }
    };

    // prototype of attributes that should be parsed
    Attribute[] attrs = new Attribute[] {
        new ModuleTargetAttribute()
    };

    // parse module-info.class
    ClassReader cr = new ClassReader(in);
    cr.accept(cv, attrs, 0);
    if (modTargets[0] != null) {
        return new ModuleTarget(modTargets[0].targetPlatform());
    }

    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:ModuleTargetHelper.java

示例4: hasModuleTarget

import jdk.internal.org.objectweb.asm.Attribute; //导入依赖的package包/类
private static boolean hasModuleTarget(InputStream in) throws IOException {
    ModuleTargetAttribute[] modTargets = new ModuleTargetAttribute[1];
    ClassVisitor cv = new ClassVisitor(Opcodes.ASM5) {
        @Override
        public void visitAttribute(Attribute attr) {
            if (attr instanceof ModuleTargetAttribute) {
                modTargets[0] = (ModuleTargetAttribute)attr;
            }
        }
    };

    // prototype of attributes that should be parsed
    Attribute[] attrs = new Attribute[] {
        new ModuleTargetAttribute()
    };

    // parse module-info.class
    ClassReader cr = new ClassReader(in);
    cr.accept(cv, attrs, 0);
    return modTargets[0] != null && modTargets[0].targetPlatform() != null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:Main.java

示例5: read

import jdk.internal.org.objectweb.asm.Attribute; //导入依赖的package包/类
@Override
protected Attribute read(ClassReader cr,
                         int off,
                         int len,
                         char[] buf,
                         int codeOff,
                         Label[] labels)
{
    // package count
    int package_count = cr.readUnsignedShort(off);
    off += 2;

    // packages
    Set<String> packages = new HashSet<>();
    for (int i=0; i<package_count; i++) {
        String pkg = cr.readUTF8(off, buf).replace('/', '.');
        packages.add(pkg);
        off += 2;
    }

    return new ConcealedPackagesAttribute(packages);
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:23,代码来源:ClassFileAttributes.java

示例6: visitAttribute

import jdk.internal.org.objectweb.asm.Attribute; //导入依赖的package包/类
@Override
public void visitAttribute(final Attribute attr) {
    if (attrs == null) {
        attrs = new ArrayList<Attribute>(1);
    }
    attrs.add(attr);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:8,代码来源:FieldNode.java

示例7: visitAttribute

import jdk.internal.org.objectweb.asm.Attribute; //导入依赖的package包/类
@Override
public void visitAttribute(final Attribute attr) {
    checkEnd();
    if (attr == null) {
        throw new IllegalArgumentException(
                "Invalid attribute (must not be null)");
    }
    super.visitAttribute(attr);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:10,代码来源:CheckFieldAdapter.java

示例8: visitAttribute

import jdk.internal.org.objectweb.asm.Attribute; //导入依赖的package包/类
public void visitAttribute(final Attribute attr) {
    buf.setLength(0);
    buf.append("// ATTRIBUTE ").append(attr.type).append('\n');
    if (attr instanceof ASMifiable) {
        if (labelNames == null) {
            labelNames = new HashMap<Label, String>();
        }
        buf.append("{\n");
        ((ASMifiable) attr).asmify(buf, "attr", labelNames);
        buf.append(name).append(".visitAttribute(attr);\n");
        buf.append("}\n");
    }
    text.add(buf.toString());
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:15,代码来源:ASMifier.java

示例9: visitAttribute

import jdk.internal.org.objectweb.asm.Attribute; //导入依赖的package包/类
@Override
public void visitAttribute(final Attribute attr) {
    checkState();
    if (attr == null) {
        throw new IllegalArgumentException(
                "Invalid attribute (must not be null)");
    }
    super.visitAttribute(attr);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:10,代码来源:CheckClassAdapter.java

示例10: visitMethodAttribute

import jdk.internal.org.objectweb.asm.Attribute; //导入依赖的package包/类
@Override
public void visitMethodAttribute(final Attribute attr) {
    buf.setLength(0);
    buf.append(tab).append("ATTRIBUTE ");
    appendDescriptor(-1, attr.type);

    if (attr instanceof Textifiable) {
        ((Textifiable) attr).textify(buf, labelNames);
    } else {
        buf.append(" : unknown\n");
    }

    text.add(buf.toString());
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:15,代码来源:Textifier.java

示例11: visitAttribute

import jdk.internal.org.objectweb.asm.Attribute; //导入依赖的package包/类
/**
 * Prints a disassembled view of the given attribute.
 *
 * @param attr
 *            an attribute.
 */
public void visitAttribute(final Attribute attr) {
    buf.setLength(0);
    buf.append(tab).append("ATTRIBUTE ");
    appendDescriptor(-1, attr.type);

    if (attr instanceof Textifiable) {
        ((Textifiable) attr).textify(buf, null);
    } else {
        buf.append(" : unknown\n");
    }

    text.add(buf.toString());
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:Textifier.java

示例12: visitAttribute

import jdk.internal.org.objectweb.asm.Attribute; //导入依赖的package包/类
@Override
public void visitAttribute(final Attribute attr) {
    checkEndMethod();
    if (attr == null) {
        throw new IllegalArgumentException(
                "Invalid attribute (must not be null)");
    }
    super.visitAttribute(attr);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:10,代码来源:CheckMethodAdapter.java

示例13: visitField

import jdk.internal.org.objectweb.asm.Attribute; //导入依赖的package包/类
@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,代码行数:35,代码来源:ScriptClassInstrumentor.java

示例14: visitAttribute

import jdk.internal.org.objectweb.asm.Attribute; //导入依赖的package包/类
@Override
public void visitAttribute(Attribute attr) {
    String name = attr.type;
    Attribute replacement = attrs.get(name);
    if (replacement != null) {
        attr = replacement;
        attrs.remove(name);
    }
    super.visitAttribute(attr);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:ModuleInfoExtender.java

示例15: toByteArray

import jdk.internal.org.objectweb.asm.Attribute; //导入依赖的package包/类
/**
 * Returns the bytes of the modified module-info.class.
 * Once this method has been called then the Extender object should
 * be discarded.
 */
public byte[] toByteArray() throws IOException {
    ClassWriter cw
        = new ClassWriter(ClassWriter.COMPUTE_MAXS + ClassWriter.COMPUTE_FRAMES);

    AttributeAddingClassVisitor cv
        = new AttributeAddingClassVisitor(Opcodes.ASM5, cw);

    ClassReader cr = new ClassReader(in);

    if (packages != null)
        cv.addAttribute(new ModulePackagesAttribute(packages));
    if (mainClass != null)
        cv.addAttribute(new ModuleMainClassAttribute(mainClass));
    if (targetPlatform != null)
        cv.addAttribute(new ModuleTargetAttribute(targetPlatform));
    if (hashes != null)
        cv.addAttribute(new ModuleHashesAttribute(hashes));
    if (moduleResolution != null)
        cv.addAttribute(new ModuleResolutionAttribute(moduleResolution.value()));

    List<Attribute> attrs = new ArrayList<>();

    // prototypes of attributes that should be parsed
    attrs.add(new ModuleAttribute(version));
    attrs.add(new ModulePackagesAttribute());
    attrs.add(new ModuleMainClassAttribute());
    attrs.add(new ModuleTargetAttribute());
    attrs.add(new ModuleHashesAttribute());

    cr.accept(cv, attrs.toArray(new Attribute[0]), 0);

    // add any attributes that didn't replace previous attributes
    cv.finish();

    return cw.toByteArray();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:42,代码来源:ModuleInfoExtender.java


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