Esempio n. 1
0
  private Type getSootType(AnnotationElem e) {
    Type annotationType;
    switch (e.getKind()) {
      case '[': // array
        // Until now we only know it's some kind of array.
        annotationType = ARRAY_TYPE;
        AnnotationArrayElem array = (AnnotationArrayElem) e;
        if (array.getNumValues() > 0) {
          // Try to determine type of the array
          AnnotationElem firstElement = array.getValueAt(0);
          Type type = getSootType(firstElement);
          if (type == null) return null;

          if (type.equals(ARRAY_TYPE)) return ARRAY_TYPE;

          return ArrayType.v(type, 1);
        }
        break;
      case 's': // string
        annotationType = RefType.v("java.lang.String");
        break;
      case 'c': // class
        annotationType = RefType.v("java.lang.Class");
        break;
      case 'e': // enum
        AnnotationEnumElem enumElem = (AnnotationEnumElem) e;
        annotationType = Util.getType(enumElem.getTypeName());
        ;
        break;

      case 'L':
      case 'J':
      case 'S':
      case 'D':
      case 'I':
      case 'F':
      case 'B':
      case 'C':
      case 'V':
      case 'Z':
        annotationType = Util.getType(String.valueOf(e.getKind()));
        break;
      default:
        annotationType = null;
        break;
    }
    return annotationType;
  }