本文整理汇总了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);
}
示例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);
}
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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());
}
示例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);
}
示例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());
}
示例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());
}
示例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);
}
示例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();
}
};
}
示例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);
}
示例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();
}