本文整理汇总了Java中com.sun.tools.classfile.Descriptor类的典型用法代码示例。如果您正苦于以下问题:Java Descriptor类的具体用法?Java Descriptor怎么用?Java Descriptor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Descriptor类属于com.sun.tools.classfile包,在下文中一共展示了Descriptor类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: check
import com.sun.tools.classfile.Descriptor; //导入依赖的package包/类
void check(String dir, String... fileNames)
throws
IOException,
ConstantPoolException,
Descriptor.InvalidDescriptor {
for (String fileName : fileNames) {
ClassFile classFileToCheck = ClassFile.read(new File(dir, fileName));
for (Method method : classFileToCheck.methods) {
if ((method.access_flags.flags & ACC_STRICT) == 0) {
errors.add(String.format(offendingMethodErrorMessage,
method.getName(classFileToCheck.constant_pool),
classFileToCheck.getName()));
}
}
}
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:CheckACC_STRICTFlagOnclinitTest.java
示例2: getValue
import com.sun.tools.classfile.Descriptor; //导入依赖的package包/类
String getValue(Descriptor d) {
try {
return d.getValue(constant_pool);
} catch (ConstantPoolException e) {
return report(e);
}
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:8,代码来源:ClassWriter.java
示例3: setStackMap
import com.sun.tools.classfile.Descriptor; //导入依赖的package包/类
void setStackMap(StackMapTable_attribute attr) {
if (attr == null) {
map = null;
return;
}
Method m = classWriter.getMethod();
Descriptor d = m.descriptor;
String[] args;
try {
ConstantPool cp = classWriter.getClassFile().constant_pool;
String argString = d.getParameterTypes(cp);
args = argString.substring(1, argString.length() - 1).split("[, ]+");
} catch (ConstantPoolException | InvalidDescriptor e) {
return;
}
boolean isStatic = m.access_flags.is(AccessFlags.ACC_STATIC);
verification_type_info[] initialLocals = new verification_type_info[(isStatic ? 0 : 1) + args.length];
if (!isStatic)
initialLocals[0] = new CustomVerificationTypeInfo("this");
for (int i = 0; i < args.length; i++) {
initialLocals[(isStatic ? 0 : 1) + i] =
new CustomVerificationTypeInfo(args[i].replace(".", "/"));
}
map = new HashMap<>();
StackMapBuilder builder = new StackMapBuilder();
// using -1 as the pc for the initial frame effectively compensates for
// the difference in behavior for the first stack map frame (where the
// pc offset is just offset_delta) compared to subsequent frames (where
// the pc offset is always offset_delta+1).
int pc = -1;
map.put(pc, new StackMap(initialLocals, empty));
for (int i = 0; i < attr.entries.length; i++)
pc = attr.entries[i].accept(builder, pc);
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:41,代码来源:StackMapWriter.java
示例4: writeDescriptor
import com.sun.tools.classfile.Descriptor; //导入依赖的package包/类
private void writeDescriptor(int index, boolean resolveIndices) {
if (resolveIndices) {
try {
ConstantPool constant_pool = classWriter.getClassFile().constant_pool;
Descriptor d = new Descriptor(index);
print(d.getFieldType(constant_pool));
return;
} catch (ConstantPoolException | InvalidDescriptor ignore) {
}
}
print("#" + index);
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:AnnotationWriter.java
示例5: check
import com.sun.tools.classfile.Descriptor; //导入依赖的package包/类
void check()
throws
IOException,
ConstantPoolException,
Descriptor.InvalidDescriptor {
ClassFile classFileToCheck = ClassFile.read(new File("Test.class"));
for (Method method : classFileToCheck.methods) {
if ((method.access_flags.flags & ACC_STRICT) == 0) {
errors.add(String.format(offendingMethodErrorMessage,
method.getName(classFileToCheck.constant_pool),
classFileToCheck.getName()));
}
}
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:CheckACC_STRICTFlagOnPkgAccessClassTest.java
示例6: analyzeClassFile
import com.sun.tools.classfile.Descriptor; //导入依赖的package包/类
void analyzeClassFile(ClassFile classFileToCheck)
throws
IOException,
ConstantPoolException,
Descriptor.InvalidDescriptor {
boolean enumClass =
(classFileToCheck.access_flags.flags & ACC_ENUM) != 0;
boolean nonFinalStaticEnumField;
boolean nonFinalStaticField;
currentFieldsToIgnore =
classFieldsToIgnoreMap.get(classFileToCheck.getName());
for (Field field : classFileToCheck.fields) {
if (ignoreField(field.getName(classFileToCheck.constant_pool))) {
continue;
}
nonFinalStaticEnumField =
(field.access_flags.flags & (ACC_ENUM | ACC_FINAL)) == 0;
nonFinalStaticField =
(field.access_flags.flags & ACC_STATIC) != 0 &&
(field.access_flags.flags & ACC_FINAL) == 0;
if (enumClass ? nonFinalStaticEnumField : nonFinalStaticField) {
errors.add("There is a mutable field named " +
field.getName(classFileToCheck.constant_pool) +
", at class " +
classFileToCheck.getName());
}
}
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:31,代码来源:DetectMutableStaticFields.java
示例7: MethodInfo
import com.sun.tools.classfile.Descriptor; //导入依赖的package包/类
MethodInfo(ClassFile cf, Method m) {
this.method = m;
String name;
String paramTypes;
String returnType;
LineNumberTable_attribute.Entry[] lineNumberTable;
try {
// method name
name = m.getName(cf.constant_pool);
// signature
paramTypes = m.descriptor.getParameterTypes(cf.constant_pool);
returnType = m.descriptor.getReturnType(cf.constant_pool);
Code_attribute codeAttr = (Code_attribute)
m.attributes.get(Attribute.Code);
lineNumberTable = ((LineNumberTable_attribute)
codeAttr.attributes.get(Attribute.LineNumberTable)).line_number_table;
} catch (ConstantPoolException|Descriptor.InvalidDescriptor e) {
throw new RuntimeException(e);
}
this.name = name;
this.paramTypes = paramTypes;
this.returnType = returnType;
Arrays.stream(lineNumberTable).forEach(entry ->
bciToLineNumbers.computeIfAbsent(entry.start_pc, _n -> new TreeSet<>())
.add(entry.line_number));
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:28,代码来源:TestBCI.java
注:本文中的com.sun.tools.classfile.Descriptor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论