Esempio n. 1
0
  /** Convert Java class to Fantom type. */
  public static Type toFanType(Class cls, boolean checked) {
    // try a predefined mapping
    String name = cls.getName();
    Type t = (Type) javaToFanTypes.get(name);
    if (t != null) return t;

    // if class name starts with "fan."
    if (name.startsWith("fan.")) {
      int dot = name.lastIndexOf('.');
      String podName = name.substring(4, dot);
      String typeName = name.substring(dot + 1);
      Pod pod = Pod.find(podName, checked);
      if (pod == null) return null;
      return pod.type(typeName, checked);
    }

    // map to a FFI Java class
    return Env.cur().loadJavaType(cls);
  }
Esempio n. 2
0
 /** Return if the specified Java class represents an immutable type. */
 public static boolean isJavaImmutable(Class cls) {
   return javaImmutables.get(cls.getName()) != null;
 }