本文整理汇总了Java中com.sun.tools.classfile.ConstantPool.CPInfo.size方法的典型用法代码示例。如果您正苦于以下问题:Java CPInfo.size方法的具体用法?Java CPInfo.size怎么用?Java CPInfo.size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.tools.classfile.ConstantPool.CPInfo
的用法示例。
在下文中一共展示了CPInfo.size方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkReferences
import com.sun.tools.classfile.ConstantPool.CPInfo; //导入方法依赖的package包/类
void checkReferences() throws IOException, ConstantPoolException {
File testClasses = new File(System.getProperty("test.classes"));
File file = new File(testClasses,
CPoolRefClassContainingInlinedCts.class.getName() + ".class");
ClassFile classFile = ClassFile.read(file);
int i = 1;
CPInfo cpInfo;
while (i < classFile.constant_pool.size()) {
cpInfo = classFile.constant_pool.get(i);
if (cpInfo instanceof CONSTANT_Class_info) {
checkClassName(((CONSTANT_Class_info)cpInfo).getName());
}
i += cpInfo.size();
}
if (numberOfReferencedClassesToBeChecked != 16) {
throw new AssertionError("Class reference missing in the constant pool");
}
}
示例2: checkReferences
import com.sun.tools.classfile.ConstantPool.CPInfo; //导入方法依赖的package包/类
void checkReferences() throws IOException, ConstantPoolException {
File testClasses = new File(System.getProperty("test.classes"));
File file = new File(testClasses,
CPoolRefClassContainingInlinedCts.class.getName() + ".class");
ClassFile classFile = ClassFile.read(file);
int i = 1;
CPInfo cpInfo;
while (i < classFile.constant_pool.size()) {
cpInfo = classFile.constant_pool.get(i);
if (cpInfo instanceof CONSTANT_Class_info) {
checkClassName(((CONSTANT_Class_info)cpInfo).getName());
}
i += cpInfo.size();
}
if (numberOfReferencedClassesToBeChecked != 8) {
throw new AssertionError("Class reference missing in the constant pool");
}
}
示例3: addToCP
import com.sun.tools.classfile.ConstantPool.CPInfo; //导入方法依赖的package包/类
private static int addToCP(List<CPInfo> constantPool, CPInfo entry) {
int result = constantPool.size();
constantPool.add(entry);
if (entry.size() > 1) {
constantPool.add(null);
}
return result;
}
示例4: addModuleResolutionAttribute
import com.sun.tools.classfile.ConstantPool.CPInfo; //导入方法依赖的package包/类
private void addModuleResolutionAttribute(Path classfile, int resolution_flags) throws Exception {
ClassFile cf = ClassFile.read(classfile);
Attributes attrs = cf.attributes;
List<CPInfo> cpData = new ArrayList<>();
cpData.add(null);
for (CPInfo info : cf.constant_pool.entries()) {
cpData.add(info);
if (info.size() == 2)
cpData.add(null);
}
cpData.add(new CONSTANT_Utf8_info(Attribute.ModuleResolution));
ConstantPool newCP = new ConstantPool(cpData.toArray(new CPInfo[0]));
ModuleResolution_attribute res = new ModuleResolution_attribute(newCP, resolution_flags);
Map<String, Attribute> newAttributeMap = new HashMap<>(attrs.map);
newAttributeMap.put(Attribute.ModuleResolution, res);
Attributes newAttrs = new Attributes(newAttributeMap);
ClassFile newCF = new ClassFile(cf.magic,
cf.minor_version,
cf.major_version,
newCP,
cf.access_flags,
cf.this_class,
cf.super_class,
cf.interfaces,
cf.fields,
cf.methods,
newAttrs);
try (OutputStream out = Files.newOutputStream(classfile)) {
new ClassWriter().write(newCF, out);
}
}