本文整理汇总了Java中org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader.u1At方法的典型用法代码示例。如果您正苦于以下问题:Java ClassFileReader.u1At方法的具体用法?Java ClassFileReader.u1At怎么用?Java ClassFileReader.u1At使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader
的用法示例。
在下文中一共展示了ClassFileReader.u1At方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildImports
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader; //导入方法依赖的package包/类
public ImportReference[] buildImports(ClassFileReader reader) {
// add remaining references to the list of type names
// (code extracted from BinaryIndexer#extractReferenceFromConstantPool(...))
int[] constantPoolOffsets = reader.getConstantPoolOffsets();
int constantPoolCount = constantPoolOffsets.length;
for (int i = 0; i < constantPoolCount; i++) {
int tag = reader.u1At(constantPoolOffsets[i]);
char[] name = null;
switch (tag) {
case ClassFileConstants.MethodRefTag :
case ClassFileConstants.InterfaceMethodRefTag :
int constantPoolIndex = reader.u2At(constantPoolOffsets[i] + 3);
int utf8Offset = constantPoolOffsets[reader.u2At(constantPoolOffsets[constantPoolIndex] + 3)];
name = reader.utf8At(utf8Offset + 3, reader.u2At(utf8Offset + 1));
break;
case ClassFileConstants.ClassTag :
utf8Offset = constantPoolOffsets[reader.u2At(constantPoolOffsets[i] + 1)];
name = reader.utf8At(utf8Offset + 3, reader.u2At(utf8Offset + 1));
break;
}
if (name == null || (name.length > 0 && name[0] == '['))
break; // skip over array references
this.typeNames.add(CharOperation.splitOn('/', name));
}
// convert type names into import references
int typeNamesLength = this.typeNames.size();
ImportReference[] imports = new ImportReference[typeNamesLength];
char[][][] set = this.typeNames.set;
int index = 0;
for (int i = 0, length = set.length; i < length; i++) {
char[][] typeName = set[i];
if (typeName != null) {
imports[index++] = new ImportReference(typeName, new long[typeName.length]/*dummy positions*/, false/*not on demand*/, 0);
}
}
return imports;
}
示例2: extractReferenceFromConstantPool
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader; //导入方法依赖的package包/类
/**
* Extract all type, method, field and interface method references from the constant pool
*/
private void extractReferenceFromConstantPool(byte[] contents, ClassFileReader reader) throws ClassFormatException {
int[] constantPoolOffsets = reader.getConstantPoolOffsets();
int constantPoolCount = constantPoolOffsets.length;
for (int i = 1; i < constantPoolCount; i++) {
int tag = reader.u1At(constantPoolOffsets[i]);
/**
* u1 tag
* u2 class_index
* u2 name_and_type_index
*/
char[] name = null;
char[] type = null;
switch (tag) {
case ClassFileConstants.FieldRefTag :
// add reference to the class/interface and field name and type
name = extractName(constantPoolOffsets, reader, i);
addFieldReference(name);
break;
case ClassFileConstants.MethodRefTag :
// add reference to the class and method name and type
case ClassFileConstants.InterfaceMethodRefTag :
// add reference to the interface and method name and type
name = extractName(constantPoolOffsets, reader, i);
type = extractType(constantPoolOffsets, reader, i);
if (CharOperation.equals(INIT, name)) {
// get class name and see if it's a local type or not
char[] className = extractClassName(constantPoolOffsets, reader, i);
boolean localType = false;
if (className != null) {
for (int c = 0, max = className.length; c < max; c++) {
switch (className[c]) {
case '/':
className[c] = '.';
break;
case '$':
localType = true;
break;
}
}
}
// add a constructor reference, use class name to extract arg count if it's a local type to remove synthetic parameter
addConstructorReference(className, extractArgCount(type, localType?className:null));
} else {
// add a method reference
addMethodReference(name, extractArgCount(type, null));
}
break;
case ClassFileConstants.ClassTag :
// add a type reference
name = extractClassReference(constantPoolOffsets, reader, i);
if (name.length > 0 && name[0] == '[')
break; // skip over array references
name = replace('/', '.', name); // so that it looks like java.lang.String
addTypeReference(name);
// also add a simple reference on each segment of the qualification (see http://bugs.eclipse.org/bugs/show_bug.cgi?id=24741)
char[][] qualification = CharOperation.splitOn('.', name);
for (int j = 0, length = qualification.length; j < length; j++) {
addNameReference(qualification[j]);
}
break;
}
}
}