protected String llniType(Type t, boolean handleize, boolean longDoubleOK) {
   String res = null;
   String elmt = t.typeName();
   if (t.dimension().indexOf("[]") != -1) {
     if ((t.dimension().indexOf("[][]") != -1) || (t.asClassDoc() != null)) res = "IArrayOfRef";
     else if (elmt.equals("boolean")) res = "IArrayOfBoolean";
     else if (elmt.equals("byte")) res = "IArrayOfByte";
     else if (elmt.equals("char")) res = "IArrayOfChar";
     else if (elmt.equals("int")) res = "IArrayOfInt";
     else if (elmt.equals("long")) res = "IArrayOfLong";
     else if (elmt.equals("float")) res = "IArrayOfFloat";
     else if (elmt.equals("double")) res = "IArrayOfDouble";
     if (!handleize) res = "DEREFERENCED_" + res;
   } else {
     if (elmt.equals("void")) res = "void";
     else if ((elmt.equals("boolean"))
         || (elmt.equals("byte"))
         || (elmt.equals("char"))
         || (elmt.equals("short"))
         || (elmt.equals("int"))) res = "java_int";
     else if (elmt.equals("long")) res = longDoubleOK ? "java_long" : "val32 /* java_long */";
     else if (elmt.equals("float")) res = "java_float";
     else if (elmt.equals("double"))
       res = res = longDoubleOK ? "java_double" : "val32 /* java_double */";
     else if (t.asClassDoc() != null) {
       res = "I" + mangleClassName(t.asClassDoc().qualifiedName());
       if (!handleize) res = "DEREFERENCED_" + res;
     }
   }
   return res;
 }
 protected final String jniType(Type t) {
   String elmT = t.typeName();
   if (t.dimension().indexOf("[]") != -1) {
     if (elmT.equals("boolean")) return "jbooleanArray";
     else if (elmT.equals("byte")) return "jbyteArray";
     else if (elmT.equals("char")) return "jcharArray";
     else if (elmT.equals("short")) return "jshortArray";
     else if (elmT.equals("int")) return "jintArray";
     else if (elmT.equals("long")) return "jlongArray";
     else if (elmT.equals("float")) return "jfloatArray";
     else if (elmT.equals("double")) return "jdoubleArray";
     else if ((t.dimension().indexOf("[][]") != -1) || (t.asClassDoc() != null))
       return "jobjectArray";
   } else {
     if (elmT.equals("void")) return "void";
     else if (elmT.equals("boolean")) return "jboolean";
     else if (elmT.equals("byte")) return "jbyte";
     else if (elmT.equals("char")) return "jchar";
     else if (elmT.equals("short")) return "jshort";
     else if (elmT.equals("int")) return "jint";
     else if (elmT.equals("long")) return "jlong";
     else if (elmT.equals("float")) return "jfloat";
     else if (elmT.equals("double")) return "jdouble";
     else if (t.asClassDoc() != null) {
       if (elmT.equals("String")) return "jstring";
       else if (t.asClassDoc().subclassOf(root.classNamed("java.lang.Class"))) return "jclass";
       else return "jobject";
     }
   }
   Util.bug("jni.unknown.type");
   return null; /* dead code. */
 }
 /**
  * Parses a type definition
  *
  * @param type
  * @return
  */
 protected static TypeInfo ParseType(Type type) {
   TypeInfo typeInfo = new TypeInfo();
   typeInfo.qualifiedName = type.qualifiedTypeName();
   typeInfo.dimension = type.dimension();
   typeInfo.wildcard = ParseWildCard(type.asWildcardType());
   typeInfo.generics = ParseGenerics(type.asParameterizedType());
   return typeInfo;
 }
  /**
   * Parses annotation instances from the javadoc annotation instance type
   *
   * @param annotationDocs Annotations decorated on some type
   * @return Serializable representation of annotations
   */
  protected static AnnotationInstance[] ParseAnnotationInstances(
      AnnotationDesc[] annotationDocs, String origin) {
    AnnotationInstance[] annotations = null;

    if (annotationDocs != null && annotationDocs.length > 0) {
      ArrayList<AnnotationInstance> list = new ArrayList<AnnotationInstance>();

      for (AnnotationDesc annot : annotationDocs) {
        AnnotationInstance instance = new AnnotationInstance();

        AnnotationTypeDoc annotTypeInfo = null;
        try {
          annotTypeInfo = annot.annotationType();
          instance.name = annot.annotationType().name();
          instance.qualifiedName = annot.annotationType().qualifiedTypeName();

        } catch (ClassCastException castException) {
          log.error("Unable to obtain type data about an annotation found on: " + origin);
          log.error("Add to the -cp parameter the class/jar that defines this annotation.");
          instance.name = null;
          instance.qualifiedName = null;
        }

        AnnotationDesc.ElementValuePair[] arguments = annot.elementValues();
        if (arguments != null && arguments.length > 0) {
          ArrayList<AnnotationArgument> argumentList = new ArrayList<AnnotationArgument>();

          for (AnnotationDesc.ElementValuePair pair : arguments) {
            AnnotationArgument annotationArgument = new AnnotationArgument();
            annotationArgument.name = pair.element().name();

            Type annotationArgumentType = pair.element().returnType();
            annotationArgument.type = annotationArgumentType.qualifiedTypeName();
            annotationArgument.isPrimitive = annotationArgumentType.isPrimitive();
            annotationArgument.isArray = annotationArgumentType.dimension().length() > 0;

            Object objValue = pair.value().value();
            if (objValue instanceof AnnotationValue[]) {
              AnnotationValue[] realValues = (AnnotationValue[]) objValue;
              String[] values = new String[realValues.length];

              for (int i = 0; i < realValues.length; i++) {
                values[i] = realValues[i].value().toString();
              }
              annotationArgument.value = values;
            } else if (objValue instanceof Number) {
              Number number = (Number) objValue;
              annotationArgument.value = new String[] {number.toString()};
            } else if (objValue instanceof Character) {
              Character character = (Character) objValue;
              annotationArgument.value = new String[] {character.toString()};
            } else if (objValue instanceof Boolean) {
              Boolean booleanValue = (Boolean) objValue;
              annotationArgument.value = new String[] {booleanValue.toString()};
            } else if (objValue instanceof String) {
              String stringValue = (String) objValue;
              annotationArgument.value = new String[] {stringValue};
            } else if (objValue instanceof FieldDoc) {
              FieldDoc field = (FieldDoc) objValue;
              annotationArgument.value = new String[] {field.name()};
            } else if (objValue instanceof ClassDoc) {
              ClassDoc classDoc = (ClassDoc) objValue;
              annotationArgument.value = new String[] {classDoc.qualifiedTypeName()};
            }
            argumentList.add(annotationArgument);
          }

          instance.arguments = argumentList.toArray(new AnnotationArgument[] {});
        }

        list.add(instance);
      }

      annotations = list.toArray(new AnnotationInstance[] {});
    }

    return annotations;
  }