package java.lang {
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.io.InputStream;
import java.lang.Arguments;
import java.lang.JavaArray;
dynamic public class Class__ {
  private var name: String;

	  private static var classCache:Object = new Object();
	 
  public function getEnumConstants__(): JavaArray {
    return null;
  }
  public function Class____(): Object {
    return this;
  }
  public function Class____Ljava_lang_String_2(name: String): Object {
    this.name = name;
    return this;
  }
  public static function forName__Ljava_lang_String_2(str: String): Class__ {
    import flash.utils.*;
    if (str == null) throw new NullPointerException();
    if (str.length == 0) throw new ClassNotFoundException();
    var cls:Object = null;
    if (str.charAt(0) == "[") {
    cls = classCache[str];
    if (cls != null) return java.lang.Class__(cls);
    cls = java.lang.Class__.getArrayLeaf__Ljava_lang_String_2(str);
    cls = new java.lang.Class__();
    cls.name = str;
    classCache[str] = cls;
    return java.lang.Class__(cls);
    }
    if (str ==  "java.lang.Object") {
    cls = Object;
    } else if (str ==  "java.lang.String") {
    cls = String;
    } else {
    try {
    cls = getDefinitionByName(str);
    } catch (e:*) {}
    if (cls == null)
    throw new ClassNotFoundException(str);
    }
    if (cls.__javaClass__ == undefined) {
    var javaCls:java.lang.Class__ = new java.lang.Class__();
    javaCls.name = str;
    cls.__javaClass__  = javaCls;
    }
    return cls.__javaClass__;
  }
  public static function getArrayDepth__Ljava_lang_String_2(str: String): int {
    var start: int = 0;
    var end: int = Object(str).length__();
    for (; start < end; start++) {
      if (Object(str).charAt__I(start) != 91)
        break;
    }
    return start;
  }
  public static function getArrayLeaf__Ljava_lang_String_2(str: String): java.lang.Class__ {
    var start: int = 0;
    var end: int = Object(str).length__();
    for (; start < end; start++) {
      if (Object(str).charAt__I(start) != 91)
        break;
    }
    if (Object(str).charAt__I(start) == 76) {
      start++;
      end--;
    }
    str = Object(str).substring__II(start, end);
    if (str === "Z")
      return Boolean__.TYPE;
    if (str === "B")
      return Byte.TYPE;
    if (str === "C")
      return Character.TYPE;
    if (str === "S")
      return Short.TYPE;
    if (str === "I")
      return Integer.TYPE;
    if (str === "J")
      return Long.TYPE;
    if (str === "D")
      return Double.TYPE;
    if (str === "F")
      return Float.TYPE;
    if (str === "V")
      return Void.TYPE;
    return java.lang.Class__.forName__Ljava_lang_String_2(str);
  }
  public static function getClass__Ljava_lang_Object_2(obj: Object): java.lang.Class__ {
    import flash.utils.*;
    if (obj.constructor.__javaClass__ == undefined) {
    var name:String;
    if (obj.constructor == Object) {
    name = "java.lang.Object";
    } else if (obj.constructor == String) {
    name = "java.lang.String";
    } else {
    name = getQualifiedClassName(obj).replace("::", ".");
    }
    var cls:java.lang.Class__ = new java.lang.Class__();
    cls.name = name;
    obj.constructor.__javaClass__  = cls;
    }
    return obj.constructor.__javaClass__;
  }
  public function equals__Ljava_lang_Object_2(obj: Object): Boolean {
    return (obj is Boolean__) && ((java.lang.Class__(obj)).getName__() === this.getName__());
  }
  public function getComponentType__(): Class__ {
    if (!this.isArray__())
      return null;
    try {
      var str: String = Object(this.getName__()).substring__I(1);
      if (str === "Z")
        return Boolean__.TYPE;
      if (str === "B")
        return Byte.TYPE;
      if (str === "C")
        return Character.TYPE;
      if (str === "S")
        return Short.TYPE;
      if (str === "I")
        return Integer.TYPE;
      if (str === "J")
        return Long.TYPE;
      if (str === "D")
        return Double.TYPE;
      if (str === "F")
        return Float.TYPE;
      if (str === "V")
        return Void.TYPE;
      return java.lang.Class__.forName__Ljava_lang_String_2(str);
    } catch (e : ClassNotFoundException) {
      return null;
    }
    return null;
  }
  public function getField__Ljava_lang_String_2(fieldName: String): Field {
    import flash.utils.*;
    var cls:Object = null;
    if (name ==  "java.lang.Object") cls = Object;
    else if (name ==  "java.lang.String") cls = String;
    else cls = getDefinitionByName(name);
    var type:XML = describeType(cls);
    var field:XMLList = type.factory.variable.(@name == fieldName);
    if (field.length() == 0) {
    return null;
    //TODO throw NoSuchFieldException
    }
    var javaField:java.lang.reflect.Field = new java.lang.reflect.Field(fieldName, this);
    return javaField;
  }
  public function getFields__(): JavaArray {
    return new JavaArray("[Ljava/lang/reflect/Field;").lengths(0);
  }
  public function getInterfaces__(): JavaArray {
    import flash.utils.*;
    var cls:Object = null;
    if (name ==  "java.lang.Object") cls = Object;
    else if (name ==  "java.lang.String") cls = String;
    else cls = getDefinitionByName(name);
    var type:XML = describeType(cls);
    var i:int = 0;
    var list:XMLList = type.factory.implementsInterface.@type;
    var result:JavaArray = new JavaArray("java.lang.Class__").lengths(list.length);
    for each (var item:* in list) {
    result[i++] = java.lang.Class__.forName__Ljava_lang_String_2(item.toString().replace("::", "."));
    }
    return result;
  }
  public function getMethods__(): JavaArray {
    return new JavaArray("[Ljava/lang/reflect/Method;").lengths(0);
  }
  public function getMethod__Ljava_lang_String_2_3Ljava_lang_Class_2(name_1: String, parameterTypes: JavaArray): Method {
    return null;
  }
  public function getName__(): String {
    return name;
  }
  public function getSuperclass__(): Class__ {
    import flash.utils.*;
    if (isPrimitive__()) return null;
    if (this == java.lang.Void.TYPE) return null;
    if (name ==  "java.lang.Object") return null;
    if (this.isArray__() || name == "java.lang.String") {
    return java.lang.Class__.forName__Ljava_lang_String_2("java.lang.Object");
    }
    if (this.isInterface__()) return null;
    var str:String = getQualifiedSuperclassName(getDefinitionByName(name));
    return java.lang.Class__.forName__Ljava_lang_String_2(str);
  }
  public function getResourceAsStream__Ljava_lang_String_2(name_1: String): InputStream {
    if (name_1 === null)
      throw new NullPointerException(new Arguments(java.lang.NullPointerException.NullPointerException__, []));
    if (!Object(name_1).startsWith__Ljava_lang_String_2("/")) {
      var className: String = this.getName__();
      var index: int = Object(className).lastIndexOf__I(46);
      if (index != -1) {
        className = Object(className).substring__II(0, index + 1);
        className = Object(className).replace__CC(46, 47);
        name_1 = className + name_1;
      }
    }
    return ClassLoader.getSystemResourceAsStream__Ljava_lang_String_2(name_1);
  }
  public function isArray__(): Boolean {
    return Object(this.getName__()).charAt__I(0) == 91;
  }
  public function isAssignableFrom__Ljava_lang_Class_2(cls: Class__): Boolean {
    if (cls == null) throw new NullPointerException();
    if (this === cls) return true;
    if (isPrimitive__()) return false;
    if (isArray__()) {
    if (!cls.isArray__()) return false;
    if (java.lang.Class__.getArrayDepth__Ljava_lang_String_2(name) != java.lang.Class__.getArrayDepth__Ljava_lang_String_2(cls.name)) return false;
    return java.lang.Class__.getArrayLeaf__Ljava_lang_String_2(name).isAssignableFrom__Ljava_lang_Class_2(java.lang.Class__.getArrayLeaf__Ljava_lang_String_2(cls.name));
    }
    if (!isInterface__()) {
    cls = cls.getSuperclass__();
    while (cls != null) {
    if (this == cls) return true;
    cls = cls.getSuperclass__();
    }
    }
    var interfaces:JavaArray = cls.getInterfaces__();
    for (var i:int; i<interfaces.length; i++) {
    if (interfaces[i] == this) return true;
    }
    return false;
  }
  public function isInstance__Ljava_lang_Object_2(obj: Object): Boolean {
    import flash.utils.*;
    if (obj == null) return false;
    if (name ==  "java.lang.Object") return true;
    if (isArray__()) {
    if  (!(obj is JavaArray)) return false;
    return this.isAssignableFrom__Ljava_lang_Class_2(obj.getClass__())
    }
    var cls:Object = null;
    if (name ==  "java.lang.String") cls = String;
    else cls = getDefinitionByName(name);
    return obj is Class(cls);
  }
  public function isInterface__(): Boolean {
    import flash.utils.*;
    if (name == "java.lang.Object") return false;
    if (name == "java.lang.String") return false;
    if (isArray__()) return false;
    var type:XML = describeType(getDefinitionByName(name));
    return type.factory.extendsClass.length () == 0;
  }
  public function isPrimitive__(): Boolean {
    if (this === Boolean__.TYPE)
      return true;
    if (this === Byte.TYPE)
      return true;
    if (this === Character.TYPE)
      return true;
    if (this === Double.TYPE)
      return true;
    if (this === Float.TYPE)
      return true;
    if (this === Integer.TYPE)
      return true;
    if (this === Long.TYPE)
      return true;
    if (this === Short.TYPE)
      return true;
    return false;
  }
  public function newInstance__(): Object {
    import flash.utils.*;
    if (isInterface__() || isPrimitive__() || isArray__()) {
    throw new InstantiationException();
    }
    var cls:Object = null;
    if (name ==  "java.lang.Object") cls = Object;
    else if (name ==  "java.lang.String") cls = String;
    else cls = getDefinitionByName(name);
    return new cls();
  }
  public function toString__(): String {
    if (this.isPrimitive__())
      return this.getName__();
    return (this.isInterface__() ? "interface " : "class ") + this.getName__();
  }
  public function Class__(... vargs) {
    var args: Array;
    var id: int;
    if (vargs.length == 1 && vargs[0] is Arguments) {
      args = Arguments(vargs[0]).args;
      id = Arguments(vargs[0]).id;
    } else {
      if (vargs.length == 0) {
        id = 0;
      } else if (vargs.length == 1 && vargs[0] is String) {
        args = vargs;
        id = 1;
      }
    }
    switch (id) {
      case 0:
        break;
      case 1:
        var args1: Array = [args[0]];
        break;
    }
    super();
    switch (id) {
      case 0:
        Class____();
        break;
      case 1:
        Class____Ljava_lang_String_2(args1[0]);
        break;
    }
  }
  public static const Class____ : int = 0;
  public static const Class____Ljava_lang_String_2 : int = 1;
}
}
