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


Java ClsUtil.readU2方法代码示例

本文整理汇总了Java中com.intellij.util.cls.ClsUtil.readU2方法的典型用法代码示例。如果您正苦于以下问题:Java ClsUtil.readU2方法的具体用法?Java ClsUtil.readU2怎么用?Java ClsUtil.readU2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.util.cls.ClsUtil的用法示例。


在下文中一共展示了ClsUtil.readU2方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readConstant

import com.intellij.util.cls.ClsUtil; //导入方法依赖的package包/类
private ConstantValue readConstant(final BytePointer ptr) throws ClsFormatException {
  final int tag = ClsUtil.readU1(ptr);
  switch (tag) {
    case ClsUtil.CONSTANT_Integer :
      int value = ClsUtil.readU4(ptr);
      return new IntegerConstantValue(value);
    case ClsUtil.CONSTANT_Float:
      float floatValue = ClsUtil.readFloat(ptr);
      return new FloatConstantValue(floatValue);
    case ClsUtil.CONSTANT_Long :
      int high = ClsUtil.readU4(ptr);
      int low = ClsUtil.readU4(ptr);
      long v = ((long)high << 32) | (low & 0xFFFFFFFFL);
      return new LongConstantValue(v);
    case ClsUtil.CONSTANT_Double :
      double doubleValue = ClsUtil.readDouble(ptr);
      return new DoubleConstantValue(doubleValue);
    case ClsUtil.CONSTANT_String :
      int stringIndex = ClsUtil.readU2(ptr);
      ptr.offset = getOffsetInConstantPool(stringIndex);
      return new StringConstantValue(ClsUtil.readUtf8Info(ptr));
    default : throw new ClsFormatException();
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:25,代码来源:ClassFileReader.java

示例2: ConstantPoolIterator

import com.intellij.util.cls.ClsUtil; //导入方法依赖的package包/类
public ConstantPoolIterator(BytePointer ptr) throws ClsFormatException {
  myPtr = ptr;
  myPtr.offset = 0;
  int magic = ClsUtil.readU4(myPtr);
  if (magic != ClsUtil.MAGIC){
    throw new ClsFormatException();
  }
  myPtr.offset += 2; // minor version
  myPtr.offset += 2; // major version
  myEntryCount = ClsUtil.readU2(myPtr);
  if (myEntryCount < 1){
    throw new ClsFormatException();
  }
  myCurrentEntryIndex = 1; // Entry at index 0 is included in the count but is not present in the constant pool
  myCurrentOffset = myPtr.offset;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:17,代码来源:ClassFileReader.java

示例3: getSuperClass

import com.intellij.util.cls.ClsUtil; //导入方法依赖的package包/类
/**
 * @return fully qualified name of the class' superclass. In case there is no super return ""
 */
public String getSuperClass() throws ClsFormatException {
  if (mySuperClassName == null) {
    BytePointer ptr = new BytePointer(getData(), getConstantPoolEnd() + 4);
    int index = ClsUtil.readU2(ptr);
    if (index == 0) {
      if (CommonClassNames.JAVA_LANG_OBJECT.equals(getQualifiedName())) {
        mySuperClassName = "";
      }
      else {
        throw new ClsFormatException();
      }
    }
    else {
      ptr.offset = getOffsetInConstantPool(index);
      mySuperClassName = readClassInfo(ptr); // keep '$' in the name for anonymous classes
      if (isInterface()) {
        if (!CommonClassNames.JAVA_LANG_OBJECT.equals(mySuperClassName)) {
          throw new ClsFormatException();
        }
      }
      /*
      else {
        if (!MakeUtil.isAnonymous(mySuperClassName)) {
          mySuperClassName = mySuperClassName.replace('$', '.');
        }
      }
      */
    }
  }
  return mySuperClassName;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:35,代码来源:ClassFileReader.java

示例4: getSuperInterfaces

import com.intellij.util.cls.ClsUtil; //导入方法依赖的package包/类
public String[] getSuperInterfaces() throws ClsFormatException {
  if (mySuperInterfaces == null) {
    BytePointer ptr = new BytePointer(getData(), getConstantPoolEnd() + 6);
    int count = ClsUtil.readU2(ptr);
    mySuperInterfaces = ArrayUtil.newStringArray(count);
    BytePointer auxPtr = new BytePointer(ptr.bytes, 0);
    for (int idx = 0; idx < mySuperInterfaces.length; idx++) {
      auxPtr.offset = getOffsetInConstantPool(ClsUtil.readU2(ptr));
      mySuperInterfaces[idx] = readClassInfo(auxPtr);
    }
  }
  return mySuperInterfaces;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:14,代码来源:ClassFileReader.java

示例5: readRefStructure

import com.intellij.util.cls.ClsUtil; //导入方法依赖的package包/类
private MemberReferenceInfo readRefStructure(int tag, BytePointer ptr) throws ClsFormatException {
  /*
  if (tag != ClsUtil.CONSTANT_Fieldref && tag != ClsUtil.CONSTANT_Methodref && tag != ClsUtil.CONSTANT_InterfaceMethodref) {
    throw new ClsFormatException();
  }
  */
  int classInfoIndex = ClsUtil.readU2(ptr);
  int nameTypeInfoIndex = ClsUtil.readU2(ptr);

  ptr.offset = getOffsetInConstantPool(classInfoIndex);
  if (ClsUtil.CONSTANT_Class != ClsUtil.readU1(ptr)) {
    throw new ClsFormatException();
  }
  ptr.offset = getOffsetInConstantPool(ClsUtil.readU2(ptr));
  String className = ClsUtil.readUtf8Info(ptr, '/', '.'); // keep '$' in names

  ptr.offset = getOffsetInConstantPool(nameTypeInfoIndex);
  if (ClsUtil.CONSTANT_NameAndType != ClsUtil.readU1(ptr)) {
    throw new ClsFormatException();
  }
  int memberNameIndex = ClsUtil.readU2(ptr);
  int descriptorIndex = ClsUtil.readU2(ptr);

  ptr.offset = getOffsetInConstantPool(memberNameIndex);
  String memberName = ClsUtil.readUtf8Info(ptr);

  if ((memberName.indexOf('$') >= 0 || memberName.indexOf('<') >= 0) && !CONSTRUCTOR_NAME.equals(memberName)) { // skip refs to synthetic members
    return null;
  }

  ptr.offset = getOffsetInConstantPool(descriptorIndex);
  String descriptor = ClsUtil.readUtf8Info(ptr);

  MemberInfo info = ClsUtil.CONSTANT_Fieldref == tag? new FieldInfo(getSymbolId(memberName), getSymbolId(descriptor)) : new MethodInfo(getSymbolId(memberName), getSymbolId(descriptor), CONSTRUCTOR_NAME.equals(memberName));
  return new MemberReferenceInfo(getSymbolId(className), info);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:37,代码来源:ClassFileReader.java

示例6: readClassInfo

import com.intellij.util.cls.ClsUtil; //导入方法依赖的package包/类
private String readClassInfo(BytePointer ptr) throws ClsFormatException{
  final int tag = ClsUtil.readU1(ptr);
  if (tag != ClsUtil.CONSTANT_Class){
    throw new ClsFormatException(CompilerBundle.message("class.parsing.error.wrong.record.tag.expected.another", tag, ClsUtil.CONSTANT_Class));
  }
  int index = ClsUtil.readU2(ptr);
  return ClsUtil.readUtf8Info(new BytePointer(ptr.bytes, getOffsetInConstantPool(index)), '/', '.');
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:9,代码来源:ClassFileReader.java

示例7: readAttributes

import com.intellij.util.cls.ClsUtil; //导入方法依赖的package包/类
@SuppressWarnings({"HardCodedStringLiteral"})
private ClsAttributeTable readAttributes(BytePointer ptr) throws ClsFormatException {
  int count = ClsUtil.readU2(ptr); // attributeCount
  final ClsAttributeTable attributes = new ClsAttributeTable();
  while (count-- > 0) {
    final String attrName = readAttributeName(ptr);
    if ("Exceptions".equals(attrName)) {
      attributes.exceptions = readExceptions(ptr);
    }
    else if ("Signature".equals(attrName)) {
      attributes.genericSignature = readSignatureAttribute(ptr);
    }
    else if ("SourceFile".equals(attrName)) {
      attributes.sourceFile = readSourceFileAttribute(ptr);
    }
    else if ("ConstantValue".equals(attrName)){
      attributes.constantValue = readFieldConstantValue(ptr);
    }
    else if ("RuntimeVisibleAnnotations".equals(attrName)) {
      attributes.runtimeVisibleAnnotations = readAnnotations(ptr);
    }
    else if ("RuntimeInvisibleAnnotations".equals(attrName)) {
      attributes.runtimeInvisibleAnnotations = readAnnotations(ptr);
    }
    else if ("RuntimeVisibleParameterAnnotations".equals(attrName)) {
      attributes.runtimeVisibleParameterAnnotations = readParameterAnnotations(ptr);
    }
    else if ("RuntimeInvisibleParameterAnnotations".equals(attrName)) {
      attributes.runtimeInvisibleParameterAnnotations = readParameterAnnotations(ptr);
    }
    else if ("AnnotationDefault".equals(attrName)) {
      attributes.annotationDefault = readAnnotationMemberValue(new BytePointer(ptr.bytes, ptr.offset + 6));
    }
    gotoNextAttribute(ptr);
  }
  return attributes;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:38,代码来源:ClassFileReader.java

示例8: readExceptions

import com.intellij.util.cls.ClsUtil; //导入方法依赖的package包/类
private String[] readExceptions(BytePointer p) throws ClsFormatException{
  final BytePointer ptr = new BytePointer(p.bytes, p.offset + 6); // position to the count of exceptions
  int count = ClsUtil.readU2(ptr);
  final ArrayList<String> array = new ArrayList<String>(count);
  while (count-- > 0) {
    int idx = ClsUtil.readU2(ptr);
    if (idx != 0) {
      final String exceptionClass = readClassInfo(new BytePointer(ptr.bytes, getOffsetInConstantPool(idx)));
      array.add(exceptionClass);
    }
  }
  return ArrayUtil.toStringArray(array);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:14,代码来源:ClassFileReader.java

示例9: readFieldConstantValue

import com.intellij.util.cls.ClsUtil; //导入方法依赖的package包/类
private ConstantValue readFieldConstantValue(BytePointer p) throws ClsFormatException{
  final BytePointer ptr = new BytePointer(p.bytes, p.offset + 2);
  if (ClsUtil.readU4(ptr) != 2) {
    throw new ClsFormatException(); // attribute length must be 2
  }
  int valueIndex = ClsUtil.readU2(ptr);
  ptr.offset = getOffsetInConstantPool(valueIndex);
  return readConstant(ptr);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:10,代码来源:ClassFileReader.java

示例10: readAnnotationsArray

import com.intellij.util.cls.ClsUtil; //导入方法依赖的package包/类
private AnnotationConstantValue[] readAnnotationsArray(BytePointer ptr) throws ClsFormatException {
  final int numberOfAnnotations = ClsUtil.readU2(ptr);
  if (numberOfAnnotations == 0) {
    return AnnotationConstantValue.EMPTY_ARRAY;
  }
  AnnotationConstantValue[] annotations = new AnnotationConstantValue[numberOfAnnotations];
  for (int attributeIndex = 0; attributeIndex < numberOfAnnotations; attributeIndex++) {
    annotations[attributeIndex] = readAnnotation(ptr);
  }
  return annotations;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:12,代码来源:ClassFileReader.java

示例11: readAnnotation

import com.intellij.util.cls.ClsUtil; //导入方法依赖的package包/类
private AnnotationConstantValue readAnnotation(BytePointer ptr) throws ClsFormatException {
  final int classInfoIndex = ClsUtil.readU2(ptr);
  final String qName = readAnnotationClassName(new BytePointer(ptr.bytes, getOffsetInConstantPool(classInfoIndex)));
  final List<AnnotationNameValuePair> memberValues = new ArrayList<AnnotationNameValuePair>();
  final int numberOfPairs = ClsUtil.readU2(ptr);
  for (int idx = 0; idx < numberOfPairs; idx++) {
    final int memberNameIndex = ClsUtil.readU2(ptr);
    final String memberName = ClsUtil.readUtf8Info(ptr.bytes, getOffsetInConstantPool(memberNameIndex));
    final ConstantValue memberValue = readAnnotationMemberValue(ptr);
    memberValues.add(new AnnotationNameValuePair(getSymbolId(memberName), memberValue));
  }
  return new AnnotationConstantValue(getSymbolId(qName), memberValues.toArray(new AnnotationNameValuePair[memberValues.size()]));
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:14,代码来源:ClassFileReader.java

示例12: readAttributeName

import com.intellij.util.cls.ClsUtil; //导入方法依赖的package包/类
private String readAttributeName(BytePointer p) throws ClsFormatException {
  final BytePointer ptr = new BytePointer(p.bytes, p.offset);
  final int nameIndex = ClsUtil.readU2(ptr);
  ptr.offset = getOffsetInConstantPool(nameIndex);
  return ClsUtil.readUtf8Info(ptr);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:7,代码来源:ClassFileReader.java

示例13: next

import com.intellij.util.cls.ClsUtil; //导入方法依赖的package包/类
/**
 * Positions the pointer to the next entry
 */
public void next() throws ClsFormatException {
  myPtr.offset = myCurrentOffset;
  int tag = ClsUtil.readU1(myPtr);
  switch(tag){
    default:
      throw new ClsFormatException();

    case ClsUtil.CONSTANT_Class:
    case ClsUtil.CONSTANT_String:
      myPtr.offset += 2;
    break;

    case ClsUtil.CONSTANT_Fieldref:
    case ClsUtil.CONSTANT_Methodref:
    case ClsUtil.CONSTANT_InterfaceMethodref:
    case ClsUtil.CONSTANT_Integer:
    case ClsUtil.CONSTANT_Float:
    case ClsUtil.CONSTANT_NameAndType:
      myPtr.offset += 4;
    break;

    case ClsUtil.CONSTANT_Long:
    case ClsUtil.CONSTANT_Double:
      myPtr.offset += 8;
      myCurrentEntryIndex++; // takes 2 entries
    break;

    case ClsUtil.CONSTANT_Utf8:
      int length = ClsUtil.readU2(myPtr);
      myPtr.offset += length;
    break;

    case ClsUtil.CONSTANT_MethodHandle:
      myPtr.offset += 3;
      break;
    case ClsUtil.CONSTANT_MethodType:
      myPtr.offset += 2;
      break;
    case ClsUtil.CONSTANT_InvokeDynamic:
      myPtr.offset += 4;
      break;
  }
  myCurrentEntryIndex++;
  myCurrentOffset = myPtr.offset;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:49,代码来源:ClassFileReader.java

示例14: next

import com.intellij.util.cls.ClsUtil; //导入方法依赖的package包/类
/**
 * Positions the pointer to the next entry
 */
public void next() throws ClsFormatException {
  myPtr.offset = myCurrentOffset;
  int tag = ClsUtil.readU1(myPtr);
  switch(tag){
    default:
      throw new ClsFormatException();

    case ClsUtil.CONSTANT_Class:
    case ClsUtil.CONSTANT_String:
      myPtr.offset += 2;
      break;

    case ClsUtil.CONSTANT_Fieldref:
    case ClsUtil.CONSTANT_Methodref:
    case ClsUtil.CONSTANT_InterfaceMethodref:
    case ClsUtil.CONSTANT_Integer:
    case ClsUtil.CONSTANT_Float:
    case ClsUtil.CONSTANT_NameAndType:
      myPtr.offset += 4;
      break;

    case ClsUtil.CONSTANT_Long:
    case ClsUtil.CONSTANT_Double:
      myPtr.offset += 8;
      myCurrentEntryIndex++; // takes 2 entries
      break;

    case ClsUtil.CONSTANT_Utf8:
      int length = ClsUtil.readU2(myPtr);
      myPtr.offset += length;
      break;

    case ClsUtil.CONSTANT_MethodHandle:
      myPtr.offset += 3;
      break;
    case ClsUtil.CONSTANT_MethodType:
      myPtr.offset += 2;
      break;
    case ClsUtil.CONSTANT_InvokeDynamic:
      myPtr.offset += 4;
      break;
  }
  myCurrentEntryIndex++;
  myCurrentOffset = myPtr.offset;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:49,代码来源:ClassFileReader.java


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