Jelajahi Sumber

[java] Make java.lang primitive boxed types as abstracts instead of
Null<Type>

Related to #2738

Cauê Waneck 10 tahun lalu
induk
melakukan
1585b9b001

+ 24 - 9
genjava.ml

@@ -40,6 +40,13 @@ let is_boxed_type t = match follow t with
 	| TInst ({ cl_path = (["java";"lang"], "Short") }, [])
 	| TInst ({ cl_path = (["java";"lang"], "Character") }, [])
 	| TInst ({ cl_path = (["java";"lang"], "Float") }, []) -> true
+	| TAbstract ({ a_path = (["java";"lang"], "Boolean") }, [])
+	| TAbstract ({ a_path = (["java";"lang"], "Double") }, [])
+	| TAbstract ({ a_path = (["java";"lang"], "Integer") }, [])
+	| TAbstract ({ a_path = (["java";"lang"], "Byte") }, [])
+	| TAbstract ({ a_path = (["java";"lang"], "Short") }, [])
+	| TAbstract ({ a_path = (["java";"lang"], "Character") }, [])
+	| TAbstract ({ a_path = (["java";"lang"], "Float") }, []) -> true
 	| _ -> false
 
 let unboxed_type gen t tbyte tshort tchar tfloat = match follow t with
@@ -50,6 +57,13 @@ let unboxed_type gen t tbyte tshort tchar tfloat = match follow t with
 	| TInst ({ cl_path = (["java";"lang"], "Short") }, []) -> tshort
 	| TInst ({ cl_path = (["java";"lang"], "Character") }, []) -> tchar
 	| TInst ({ cl_path = (["java";"lang"], "Float") }, []) -> tfloat
+	| TAbstract ({ a_path = (["java";"lang"], "Boolean") }, []) -> gen.gcon.basic.tbool
+	| TAbstract ({ a_path = (["java";"lang"], "Double") }, []) -> gen.gcon.basic.tfloat
+	| TAbstract ({ a_path = (["java";"lang"], "Integer") }, []) -> gen.gcon.basic.tint
+	| TAbstract ({ a_path = (["java";"lang"], "Byte") }, []) -> tbyte
+	| TAbstract ({ a_path = (["java";"lang"], "Short") }, []) -> tshort
+	| TAbstract ({ a_path = (["java";"lang"], "Character") }, []) -> tchar
+	| TAbstract ({ a_path = (["java";"lang"], "Float") }, []) -> tfloat
 	| _ -> assert false
 
 let rec t_has_type_param t = match follow t with
@@ -2533,14 +2547,15 @@ and convert_signature ctx p jsig =
 	| TBool -> mk_type_path ctx ([], "Bool") []
 	| TObject ( (["haxe";"root"], name), args ) -> mk_type_path ctx ([], name) (List.map (convert_arg ctx p) args)
 	(** nullable types *)
-	| TObject ( (["java";"lang"], "Integer"), [] ) -> mk_type_path ctx ([], "Null") [ TPType (mk_type_path ctx ([], "Int") []) ]
-	| TObject ( (["java";"lang"], "Double"), [] ) -> mk_type_path ctx ([], "Null") [ TPType (mk_type_path ctx ([], "Float") []) ]
-	| TObject ( (["java";"lang"], "Single"), [] ) -> mk_type_path ctx ([], "Null") [ TPType (mk_type_path ctx ([], "Single") []) ]
-	| TObject ( (["java";"lang"], "Boolean"), [] ) -> mk_type_path ctx ([], "Null") [ TPType (mk_type_path ctx ([], "Bool") []) ]
-	| TObject ( (["java";"lang"], "Byte"), [] ) -> mk_type_path ctx ([], "Null") [ TPType (mk_type_path ctx (["java";"types"], "Int8") []) ]
-	| TObject ( (["java";"lang"], "Character"), [] ) -> mk_type_path ctx ([], "Null") [ TPType (mk_type_path ctx (["java";"types"], "Char16") []) ]
-	| TObject ( (["java";"lang"], "Short"), [] ) -> mk_type_path ctx ([], "Null") [ TPType (mk_type_path ctx (["java";"types"], "Int16") []) ]
-	| TObject ( (["java";"lang"], "Long"), [] ) -> mk_type_path ctx ([], "Null") [ TPType (mk_type_path ctx (["haxe"], "Int64") []) ]
+	(* replaced from Null<Type> to the actual abstract type to fix #2738 *)
+	(* | TObject ( (["java";"lang"], "Integer"), [] ) -> mk_type_path ctx ([], "Null") [ TPType (mk_type_path ctx ([], "Int") []) ] *)
+	(* | TObject ( (["java";"lang"], "Double"), [] ) -> mk_type_path ctx ([], "Null") [ TPType (mk_type_path ctx ([], "Float") []) ] *)
+	(* | TObject ( (["java";"lang"], "Float"), [] ) -> mk_type_path ctx ([], "Null") [ TPType (mk_type_path ctx ([], "Single") []) ] *)
+	(* | TObject ( (["java";"lang"], "Boolean"), [] ) -> mk_type_path ctx ([], "Null") [ TPType (mk_type_path ctx ([], "Bool") []) ] *)
+	(* | TObject ( (["java";"lang"], "Byte"), [] ) -> mk_type_path ctx ([], "Null") [ TPType (mk_type_path ctx (["java";"types"], "Int8") []) ] *)
+	(* | TObject ( (["java";"lang"], "Character"), [] ) -> mk_type_path ctx ([], "Null") [ TPType (mk_type_path ctx (["java";"types"], "Char16") []) ] *)
+	(* | TObject ( (["java";"lang"], "Short"), [] ) -> mk_type_path ctx ([], "Null") [ TPType (mk_type_path ctx (["java";"types"], "Int16") []) ] *)
+	(* | TObject ( (["java";"lang"], "Long"), [] ) -> mk_type_path ctx ([], "Null") [ TPType (mk_type_path ctx (["haxe"], "Int64") []) ] *)
 	(** other std types *)
 	| TObject ( (["java";"lang"], "Object"), [] ) -> mk_type_path ctx ([], "Dynamic") []
 	| TObject ( (["java";"lang"], "String"), [] ) -> mk_type_path ctx ([], "String") []
@@ -3468,7 +3483,7 @@ let add_java_lib com file std =
 			end
 		with
 		| JReader.Error_message msg ->
-			if com.verbose then prerr_endline ("Class reader failed: " ^ msg);
+			prerr_endline ("Class reader failed: " ^ msg);
 			None
 		| e ->
 			if com.verbose then begin

+ 1 - 1
libs

@@ -1 +1 @@
-Subproject commit 7a767563347f00ad32da8f9fa6a35462874ec12a
+Subproject commit 4aec2aa934e90db8950d2c6b36c666018ba101a3

+ 1 - 1
std/java/_std/Reflect.hx

@@ -118,7 +118,7 @@ import java.Boot;
 
 	public static function isObject( v : Dynamic ) : Bool
 	{
-		return v != null && !(Std.is(v, HxEnum) || Std.is(v, Function) || Std.is(v, java.lang.Enum) || Std.is(v, java.lang.Number) || Std.is(v, java.lang.Boolean));
+		return v != null && !(Std.is(v, HxEnum) || Std.is(v, Function) || Std.is(v, java.lang.Enum) || Std.is(v, java.lang.Number) || Std.is(v, java.lang.Boolean.BooleanClass));
 	}
 
 	public static function isEnumValue( v : Dynamic ) : Bool {

+ 1 - 1
std/java/internal/Runtime.hx

@@ -575,7 +575,7 @@ package java.internal;
 
 	public static function isFinite(v:Float):Bool
 	{
-		return (v == v) && !java.lang.Double._isInfinite(v);
+		return (v == v) && !java.lang.Double.DoubleClass._isInfinite(v);
 	}
 }
 

+ 30 - 0
std/java/lang/Boolean.hx

@@ -0,0 +1,30 @@
+package java.lang;
+
+@:forward abstract Boolean(BooleanClass) from BooleanClass to BooleanClass
+{
+	@:to @:extern inline public function toBool():Bool
+		return this.booleanValue();
+	@:from @:extern inline public static function fromBool(b:Bool):Boolean
+		return BooleanClass.valueOf(b);
+}
+
+@:native("java.lang.Boolean") extern class BooleanClass extends Number implements Comparable<Boolean>
+{
+	@:overload public function new(bool:Bool):Void;
+	@:overload public function new(string:String):Void;
+	@:overload public function booleanValue() : Bool;
+	@:overload public function compareTo(param1 : Boolean) : Int;
+	@:overload public function compareTo(param1 : Dynamic) : Int;
+	@:overload public function equals(param1 : Dynamic) : Bool;
+	@:overload public function hashCode() : Int;
+	@:overload public function toString() : String;
+	@:final public static var FALSE : Boolean;
+	@:final public static var TRUE : Boolean;
+	@:final public static var TYPE : Class<Boolean>;
+	@:overload public static function compare(param1 : Bool, param2 : Bool) : Int;
+	@:overload public static function getBoolean(param1 : String) : Bool;
+	@:overload public static function parseBoolean(param1 : String) : Bool;
+	@:native("toString") @:overload public static function _toString(param1 : Bool) : String;
+	@:overload public static function valueOf(param1 : Bool) : Boolean;
+	@:overload public static function valueOf(param1 : String) : Boolean;
+}

+ 32 - 0
std/java/lang/Byte.hx

@@ -0,0 +1,32 @@
+package java.lang;
+
+@:forward abstract Byte(ByteClass) from ByteClass to ByteClass
+{
+	@:to @:extern inline public function toByte():java.types.Int8
+		return this.byteValue();
+	@:from @:extern inline public static function fromByte(b:java.types.Int8):Byte
+		return ByteClass.valueOf(b);
+}
+
+@:native("java.lang.Byte") extern class ByteClass extends Number implements Comparable<Byte>
+{
+	@:overload function new(param1 : java.types.Int8) : Void;
+	@:overload @:throws("java.lang.NumberFormatException") function new(param1 : String) : Void;
+	@:overload function compareTo(param1 : Byte) : Int;
+	@:overload function compareTo(param1 : Dynamic) : Int;
+	@:overload function equals(param1 : Dynamic) : Bool;
+	@:overload function hashCode() : Int;
+	@:overload function toString() : String;
+	@:final static var MAX_VALUE(default,null) : java.types.Int8;
+	@:final static var MIN_VALUE(default,null) : java.types.Int8;
+	@:final static var SIZE(default,null) : Int;
+	@:final static var TYPE : Class<Byte>;
+	@:overload static function compare(param1 : java.types.Int8, param2 : java.types.Int8) : Int;
+	@:overload @:throws("java.lang.NumberFormatException") static function decode(param1 : String) : Byte;
+	@:overload @:throws("java.lang.NumberFormatException") static function parseByte(param1 : String, param2 : Int) : java.types.Int8;
+	@:overload @:throws("java.lang.NumberFormatException") static function parseByte(param1 : String) : java.types.Int8;
+	@:native("toString") @:overload static function _toString(param1 : java.types.Int8) : String;
+	@:overload static function valueOf(param1 : java.types.Int8) : Byte;
+	@:overload @:throws("java.lang.NumberFormatException") static function valueOf(param1 : String) : Byte;
+	@:overload @:throws("java.lang.NumberFormatException") static function valueOf(param1 : String, param2 : Int) : Byte;
+}

+ 167 - 0
std/java/lang/Character.hx

@@ -0,0 +1,167 @@
+package java.lang;
+
+@:forward abstract Character(CharacterClass) from CharacterClass to CharacterClass
+{
+	@:to @:extern inline public function toCharacter():java.types.Char16
+		return this.charValue();
+	@:from @:extern inline public static function fromCharacter(b:java.types.Char16):Character
+		return CharacterClass.valueOf(b);
+}
+
+@:native("java.lang.Character") extern class CharacterClass implements Comparable<Character>
+{
+	@:overload function new(param1 : java.types.Char16) : Void;
+	@:overload function charValue() : java.types.Char16;
+	@:overload function compareTo(param1 : Character) : Int;
+	@:overload function compareTo(param1 : Dynamic) : Int;
+	@:overload function equals(param1 : Dynamic) : Bool;
+	@:overload function hashCode() : Int;
+	@:overload function toString() : String;
+	@:final static var COMBINING_SPACING_MARK(default,null) : java.types.Char16;
+	@:final static var CONNECTOR_PUNCTUATION(default,null) : java.types.Char16;
+	@:final static var CONTROL(default,null) : java.types.Char16;
+	@:final static var CURRENCY_SYMBOL(default,null) : java.types.Char16;
+	@:final static var DASH_PUNCTUATION(default,null) : java.types.Char16;
+	@:final static var DECIMAL_DIGIT_NUMBER(default,null) : java.types.Char16;
+	@:final static var DIRECTIONALITY_ARABIC_NUMBER(default,null) : java.types.Char16;
+	@:final static var DIRECTIONALITY_BOUNDARY_NEUTRAL(default,null) : java.types.Char16;
+	@:final static var DIRECTIONALITY_COMMON_NUMBER_SEPARATOR(default,null) : java.types.Char16;
+	@:final static var DIRECTIONALITY_EUROPEAN_NUMBER(default,null) : java.types.Char16;
+	@:final static var DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR(default,null) : java.types.Char16;
+	@:final static var DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR(default,null) : java.types.Char16;
+	@:final static var DIRECTIONALITY_LEFT_TO_RIGHT(default,null) : java.types.Char16;
+	@:final static var DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING(default,null) : java.types.Char16;
+	@:final static var DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE(default,null) : java.types.Char16;
+	@:final static var DIRECTIONALITY_NONSPACING_MARK(default,null) : java.types.Char16;
+	@:final static var DIRECTIONALITY_OTHER_NEUTRALS(default,null) : java.types.Char16;
+	@:final static var DIRECTIONALITY_PARAGRAPH_SEPARATOR(default,null) : java.types.Char16;
+	@:final static var DIRECTIONALITY_POP_DIRECTIONAL_FORMAT(default,null) : java.types.Char16;
+	@:final static var DIRECTIONALITY_RIGHT_TO_LEFT(default,null) : java.types.Char16;
+	@:final static var DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC(default,null) : java.types.Char16;
+	@:final static var DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING(default,null) : java.types.Char16;
+	@:final static var DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE(default,null) : java.types.Char16;
+	@:final static var DIRECTIONALITY_SEGMENT_SEPARATOR(default,null) : java.types.Char16;
+	@:final static var DIRECTIONALITY_UNDEFINED(default,null) : java.types.Char16;
+	@:final static var DIRECTIONALITY_WHITESPACE(default,null) : java.types.Char16;
+	@:final static var ENCLOSING_MARK(default,null) : java.types.Char16;
+	@:final static var END_PUNCTUATION(default,null) : java.types.Char16;
+	@:final static var FINAL_QUOTE_PUNCTUATION(default,null) : java.types.Char16;
+	@:final static var FORMAT(default,null) : java.types.Char16;
+	@:final static var INITIAL_QUOTE_PUNCTUATION(default,null) : java.types.Char16;
+	@:final static var LETTER_NUMBER(default,null) : java.types.Char16;
+	@:final static var LINE_SEPARATOR(default,null) : java.types.Char16;
+	@:final static var LOWERCASE_LETTER(default,null) : java.types.Char16;
+	@:final static var MATH_SYMBOL(default,null) : java.types.Char16;
+	@:final static var MAX_CODE_POINT(default,null) : Int;
+	@:final static var MAX_HIGH_SURROGATE(default,null) : java.types.Char16;
+	@:final static var MAX_LOW_SURROGATE(default,null) : java.types.Char16;
+	@:final static var MAX_RADIX(default,null) : Int;
+	@:final static var MAX_SURROGATE(default,null) : java.types.Char16;
+	@:final static var MAX_VALUE(default,null) : java.types.Char16;
+	@:final static var MIN_CODE_POINT(default,null) : Int;
+	@:final static var MIN_HIGH_SURROGATE(default,null) : java.types.Char16;
+	@:final static var MIN_LOW_SURROGATE(default,null) : java.types.Char16;
+	@:final static var MIN_RADIX(default,null) : Int;
+	@:final static var MIN_SUPPLEMENTARY_CODE_POINT(default,null) : Int;
+	@:final static var MIN_SURROGATE(default,null) : java.types.Char16;
+	@:final static var MIN_VALUE(default,null) : java.types.Char16;
+	@:final static var MODIFIER_LETTER(default,null) : java.types.Char16;
+	@:final static var MODIFIER_SYMBOL(default,null) : java.types.Char16;
+	@:final static var NON_SPACING_MARK(default,null) : java.types.Char16;
+	@:final static var OTHER_LETTER(default,null) : java.types.Char16;
+	@:final static var OTHER_NUMBER(default,null) : java.types.Char16;
+	@:final static var OTHER_PUNCTUATION(default,null) : java.types.Char16;
+	@:final static var OTHER_SYMBOL(default,null) : java.types.Char16;
+	@:final static var PARAGRAPH_SEPARATOR(default,null) : java.types.Char16;
+	@:final static var PRIVATE_USE(default,null) : java.types.Char16;
+	@:final static var SIZE(default,null) : Int;
+	@:final static var SPACE_SEPARATOR(default,null) : java.types.Char16;
+	@:final static var START_PUNCTUATION(default,null) : java.types.Char16;
+	@:final static var SURROGATE(default,null) : java.types.Char16;
+	@:final static var TITLECASE_LETTER(default,null) : java.types.Char16;
+	@:final static var TYPE : Class<Character>;
+	@:final static var UNASSIGNED(default,null) : java.types.Char16;
+	@:final static var UPPERCASE_LETTER(default,null) : java.types.Char16;
+	@:overload static function charCount(param1 : Int) : Int;
+	@:overload static function codePointAt(param1 : CharSequence, param2 : Int) : Int;
+	@:overload static function codePointAt(param1 : java.NativeArray<java.types.Char16>, param2 : Int, param3 : Int) : Int;
+	@:overload static function codePointAt(param1 : java.NativeArray<java.types.Char16>, param2 : Int) : Int;
+	@:overload static function codePointBefore(param1 : CharSequence, param2 : Int) : Int;
+	@:overload static function codePointBefore(param1 : java.NativeArray<java.types.Char16>, param2 : Int, param3 : Int) : Int;
+	@:overload static function codePointBefore(param1 : java.NativeArray<java.types.Char16>, param2 : Int) : Int;
+	@:overload static function codePointCount(param1 : CharSequence, param2 : Int, param3 : Int) : Int;
+	@:overload static function codePointCount(param1 : java.NativeArray<java.types.Char16>, param2 : Int, param3 : Int) : Int;
+	@:overload static function compare(param1 : java.types.Char16, param2 : java.types.Char16) : Int;
+	@:overload static function digit(param1 : java.types.Char16, param2 : Int) : Int;
+	@:overload static function digit(param1 : Int, param2 : Int) : Int;
+	@:overload static function forDigit(param1 : Int, param2 : Int) : java.types.Char16;
+	@:overload static function getDirectionality(param1 : java.types.Char16) : java.types.Char16;
+	@:overload static function getDirectionality(param1 : Int) : java.types.Char16;
+	@:overload static function getName(param1 : Int) : String;
+	@:overload static function getNumericValue(param1 : java.types.Char16) : Int;
+	@:overload static function getNumericValue(param1 : Int) : Int;
+	@:overload static function getType(param1 : java.types.Char16) : Int;
+	@:overload static function getType(param1 : Int) : Int;
+	@:overload static function highSurrogate(param1 : Int) : java.types.Char16;
+	@:overload static function isAlphabetic(param1 : Int) : Bool;
+	@:overload static function isBmpCodePoint(param1 : Int) : Bool;
+	@:overload static function isDefined(param1 : java.types.Char16) : Bool;
+	@:overload static function isDefined(param1 : Int) : Bool;
+	@:overload static function isDigit(param1 : java.types.Char16) : Bool;
+	@:overload static function isDigit(param1 : Int) : Bool;
+	@:overload static function isHighSurrogate(param1 : java.types.Char16) : Bool;
+	@:overload static function isISOControl(param1 : java.types.Char16) : Bool;
+	@:overload static function isISOControl(param1 : Int) : Bool;
+	@:overload static function isIdentifierIgnorable(param1 : java.types.Char16) : Bool;
+	@:overload static function isIdentifierIgnorable(param1 : Int) : Bool;
+	@:overload static function isIdeographic(param1 : Int) : Bool;
+	@:overload static function isJavaIdentifierPart(param1 : java.types.Char16) : Bool;
+	@:overload static function isJavaIdentifierPart(param1 : Int) : Bool;
+	@:overload static function isJavaIdentifierStart(param1 : java.types.Char16) : Bool;
+	@:overload static function isJavaIdentifierStart(param1 : Int) : Bool;
+	@:overload @:deprecated static function isJavaLetter(param1 : java.types.Char16) : Bool;
+	@:overload @:deprecated static function isJavaLetterOrDigit(param1 : java.types.Char16) : Bool;
+	@:overload static function isLetter(param1 : java.types.Char16) : Bool;
+	@:overload static function isLetter(param1 : Int) : Bool;
+	@:overload static function isLetterOrDigit(param1 : java.types.Char16) : Bool;
+	@:overload static function isLetterOrDigit(param1 : Int) : Bool;
+	@:overload static function isLowSurrogate(param1 : java.types.Char16) : Bool;
+	@:overload static function isLowerCase(param1 : java.types.Char16) : Bool;
+	@:overload static function isLowerCase(param1 : Int) : Bool;
+	@:overload static function isMirrored(param1 : java.types.Char16) : Bool;
+	@:overload static function isMirrored(param1 : Int) : Bool;
+	@:overload @:deprecated static function isSpace(param1 : java.types.Char16) : Bool;
+	@:overload static function isSpaceChar(param1 : java.types.Char16) : Bool;
+	@:overload static function isSpaceChar(param1 : Int) : Bool;
+	@:overload static function isSupplementaryCodePoint(param1 : Int) : Bool;
+	@:overload static function isSurrogate(param1 : java.types.Char16) : Bool;
+	@:overload static function isSurrogatePair(param1 : java.types.Char16, param2 : java.types.Char16) : Bool;
+	@:overload static function isTitleCase(param1 : java.types.Char16) : Bool;
+	@:overload static function isTitleCase(param1 : Int) : Bool;
+	@:overload static function isUnicodeIdentifierPart(param1 : java.types.Char16) : Bool;
+	@:overload static function isUnicodeIdentifierPart(param1 : Int) : Bool;
+	@:overload static function isUnicodeIdentifierStart(param1 : java.types.Char16) : Bool;
+	@:overload static function isUnicodeIdentifierStart(param1 : Int) : Bool;
+	@:overload static function isUpperCase(param1 : java.types.Char16) : Bool;
+	@:overload static function isUpperCase(param1 : Int) : Bool;
+	@:overload static function isValidCodePoint(param1 : Int) : Bool;
+	@:overload static function isWhitespace(param1 : java.types.Char16) : Bool;
+	@:overload static function isWhitespace(param1 : Int) : Bool;
+	@:overload static function lowSurrogate(param1 : Int) : java.types.Char16;
+	@:overload static function offsetByCodePoints(param1 : CharSequence, param2 : Int, param3 : Int) : Int;
+	@:overload static function offsetByCodePoints(param1 : java.NativeArray<java.types.Char16>, param2 : Int, param3 : Int, param4 : Int, param5 : Int) : Int;
+	@:overload static function reverseBytes(param1 : java.types.Char16) : java.types.Char16;
+	@:overload static function toChars(param1 : Int, param2 : java.NativeArray<java.types.Char16>, param3 : Int) : Int;
+	@:overload static function toChars(param1 : Int) : java.NativeArray<java.types.Char16>;
+	@:overload static function toCodePoint(param1 : java.types.Char16, param2 : java.types.Char16) : Int;
+	@:overload static function toLowerCase(param1 : java.types.Char16) : java.types.Char16;
+	@:overload static function toLowerCase(param1 : Int) : Int;
+	@:native("toString") @:overload static function _toString(param1 : java.types.Char16) : String;
+	@:overload static function toTitleCase(param1 : java.types.Char16) : java.types.Char16;
+	@:overload static function toTitleCase(param1 : Int) : Int;
+	@:overload static function toUpperCase(param1 : java.types.Char16) : java.types.Char16;
+	@:overload static function toUpperCase(param1 : Int) : Int;
+	@:overload static function valueOf(param1 : java.types.Char16) : Character;
+
+}
+

+ 43 - 0
std/java/lang/Double.hx

@@ -0,0 +1,43 @@
+package java.lang;
+
+@:forward abstract Double(DoubleClass) from DoubleClass to DoubleClass
+{
+	@:to @:extern inline public function toFloat():Float
+		return this.doubleValue();
+	@:from @:extern inline public static function fromFloat(b:Float):Double
+		return DoubleClass.valueOf(b);
+}
+
+@:native("java.lang.Double") extern class DoubleClass extends Number implements Comparable<Double>
+{
+	@:overload function new(param1 : Float) : Void;
+	@:overload @:throws("java.lang.NumberFormatException") function new(param1 : String) : Void;
+	@:overload function compareTo(param1 : Double) : Int;
+	@:overload function compareTo(param1 : Dynamic) : Int;
+	@:overload function equals(param1 : Dynamic) : Bool;
+	@:overload function hashCode() : Int;
+	@:overload function isInfinite() : Bool;
+	@:overload function isNaN() : Bool;
+	@:overload function toString() : String;
+	@:final static var MAX_EXPONENT(default,null) : Int;
+	@:final static var MAX_VALUE(default,null) : Float;
+	@:final static var MIN_EXPONENT(default,null) : Int;
+	@:final static var MIN_NORMAL(default,null) : Float;
+	@:final static var MIN_VALUE(default,null) : Float;
+	@:final static var NEGATIVE_INFINITY(default,null) : Float;
+	@:final static var NaN(default,null) : Float;
+	@:final static var POSITIVE_INFINITY(default,null) : Float;
+	@:final static var SIZE(default,null) : Int;
+	@:final static var TYPE : Class<Double>;
+	@:overload static function compare(param1 : Float, param2 : Float) : Int;
+	@:overload static function doubleToLongBits(param1 : Float) : haxe.Int64;
+	@:overload static function doubleToRawLongBits(param1 : Float) : haxe.Int64;
+	@:native("isInfinite") @:overload static function _isInfinite(param1 : Float) : Bool;
+	@:native("isNaN") @:overload static function _isNaN(param1 : Float) : Bool;
+	@:overload static function longBitsToDouble(param1 : haxe.Int64) : Float;
+	@:overload @:throws("java.lang.NumberFormatException") static function parseDouble(param1 : String) : Float;
+	@:overload static function toHexString(param1 : Float) : String;
+	@:native("toString") @:overload static function _toString(param1 : Float) : String;
+	@:overload @:throws("java.lang.NumberFormatException") static function valueOf(param1 : String) : Double;
+	@:overload static function valueOf(param1 : Float) : Double;
+}

+ 46 - 0
std/java/lang/Float.hx

@@ -0,0 +1,46 @@
+package java.lang;
+
+@:forward abstract Float(FloatClass) from FloatClass to FloatClass
+{
+	@:to @:extern inline public function toFloat():std.StdTypes.Float
+		return this.floatValue();
+	@:from @:extern inline public static function fromFloat(b:std.StdTypes.Single):Float
+		return FloatClass.valueOf(b);
+}
+
+@:native("java.lang.Float") extern class FloatClass extends Number implements Comparable<Float>
+{
+	@:overload function new(param1 : Single) : Void;
+	@:overload @:throws("java.lang.NumberFormatException") function new(param1 : String) : Void;
+	@:overload function new(param1 : std.StdTypes.Float) : Void;
+	@:overload function compareTo(param1 : Float) : Int;
+	@:overload function compareTo(param1 : Dynamic) : Int;
+	@:overload function equals(param1 : Dynamic) : Bool;
+	@:overload function hashCode() : Int;
+	@:overload function isInfinite() : Bool;
+	@:overload function isNaN() : Bool;
+	@:overload function toString() : String;
+	@:final static var MAX_EXPONENT(default,null) : Int;
+	@:final static var MAX_VALUE(default,null) : Single;
+	@:final static var MIN_EXPONENT(default,null) : Int;
+	@:final static var MIN_NORMAL(default,null) : Single;
+	@:final static var MIN_VALUE(default,null) : Single;
+	@:final static var NEGATIVE_INFINITY(default,null) : Single;
+	@:final static var NaN(default,null) : Single;
+	@:final static var POSITIVE_INFINITY(default,null) : Single;
+	@:final static var SIZE(default,null) : Int;
+	@:final static var TYPE : Class<std.StdTypes.Float>;
+	@:overload static function compare(param1 : Single, param2 : Single) : Int;
+	@:overload static function floatToIntBits(param1 : Single) : Int;
+	@:overload static function floatToRawIntBits(param1 : Single) : Int;
+	@:overload static function intBitsToFloat(param1 : Int) : Single;
+	@:native("isInfinite") @:overload static function _isInfinite(param1 : Single) : Bool;
+	@:native("isNaN") @:overload static function _isNaN(param1 : Single) : Bool;
+	@:overload @:throws("java.lang.NumberFormatException") static function parseFloat(param1 : String) : Single;
+	@:overload static function toHexString(param1 : Single) : String;
+	@:native("toString") @:overload static function _toString(param1 : Single) : String;
+	@:overload @:throws("java.lang.NumberFormatException") static function valueOf(param1 : String) : Float;
+	@:overload static function valueOf(param1 : Single) : Float;
+
+}
+

+ 50 - 0
std/java/lang/Integer.hx

@@ -0,0 +1,50 @@
+package java.lang;
+
+@:forward abstract Integer(IntegerClass) from IntegerClass to IntegerClass
+{
+	@:to @:extern inline public function toInt():Int
+		return this.intValue();
+	@:from @:extern inline public static function fromInt(b:Int):Integer
+		return IntegerClass.valueOf(b);
+}
+
+@:native("java.lang.Integer") extern class IntegerClass extends Number implements Comparable<Integer>
+{
+	@:overload function new(param1 : Int) : Void;
+	@:overload @:throws("java.lang.NumberFormatException") function new(param1 : String) : Void;
+	@:overload function compareTo(param1 : Integer) : Int;
+	@:overload function compareTo(param1 : Dynamic) : Int;
+	@:overload function equals(param1 : Dynamic) : Bool;
+	@:overload function hashCode() : Int;
+	@:overload function toString() : String;
+	@:final static var MAX_VALUE(default,null) : Int;
+	@:final static var MIN_VALUE(default,null) : Int;
+	@:final static var SIZE(default,null) : Int;
+	@:final static var TYPE : Class<Integer>;
+	@:overload static function bitCount(param1 : Int) : Int;
+	@:overload static function compare(param1 : Int, param2 : Int) : Int;
+	@:overload @:throws("java.lang.NumberFormatException") static function decode(param1 : String) : Integer;
+	@:overload static function getInteger(param1 : String) : Integer;
+	@:overload static function getInteger(param1 : String, param2 : Integer) : Integer;
+	@:overload static function getInteger(param1 : String, param2 : Int) : Integer;
+	@:overload static function highestOneBit(param1 : Int) : Int;
+	@:overload static function lowestOneBit(param1 : Int) : Int;
+	@:overload static function numberOfLeadingZeros(param1 : Int) : Int;
+	@:overload static function numberOfTrailingZeros(param1 : Int) : Int;
+	@:overload @:throws("java.lang.NumberFormatException") static function parseInt(param1 : String, param2 : Int) : Int;
+	@:overload @:throws("java.lang.NumberFormatException") static function parseInt(param1 : String) : Int;
+	@:overload static function reverse(param1 : Int) : Int;
+	@:overload static function reverseBytes(param1 : Int) : Int;
+	@:overload static function rotateLeft(param1 : Int, param2 : Int) : Int;
+	@:overload static function rotateRight(param1 : Int, param2 : Int) : Int;
+	@:overload static function signum(param1 : Int) : Int;
+	@:overload static function toBinaryString(param1 : Int) : String;
+	@:overload static function toHexString(param1 : Int) : String;
+	@:overload static function toOctalString(param1 : Int) : String;
+	@:native("toString") @:overload static function _toString(param1 : Int, param2 : Int) : String;
+	@:native("toString") @:overload static function _toString(param1 : Int) : String;
+	@:overload @:throws("java.lang.NumberFormatException") static function valueOf(param1 : String, param2 : Int) : Integer;
+	@:overload static function valueOf(param1 : Int) : Integer;
+	@:overload @:throws("java.lang.NumberFormatException") static function valueOf(param1 : String) : Integer;
+}
+

+ 34 - 0
std/java/lang/Short.hx

@@ -0,0 +1,34 @@
+package java.lang;
+
+@:forward abstract Short(ShortClass) from ShortClass to ShortClass
+{
+	@:to @:extern inline public function toShort():java.types.Int16
+		return this.shortValue();
+	@:from @:extern inline public static function fromShort(b:java.types.Int16):Short
+		return ShortClass.valueOf(b);
+}
+
+@:native("java.lang.Short") extern class ShortClass extends Number implements Comparable<Short>
+{
+	@:overload function new(param1 : java.types.Int16) : Void;
+	@:overload @:throws("java.lang.NumberFormatException") function new(param1 : String) : Void;
+	@:overload function compareTo(param1 : Short) : Int;
+	@:overload function compareTo(param1 : Dynamic) : Int;
+	@:overload function equals(param1 : Dynamic) : Bool;
+	@:overload function hashCode() : Int;
+	@:overload function toString() : String;
+	@:final static var MAX_VALUE(default,null) : java.types.Int16;
+	@:final static var MIN_VALUE(default,null) : java.types.Int16;
+	@:final static var SIZE(default,null) : Int;
+	@:final static var TYPE : Class<Short>;
+	@:overload static function compare(param1 : java.types.Int16, param2 : java.types.Int16) : Int;
+	@:overload @:throws("java.lang.NumberFormatException") static function decode(param1 : String) : Short;
+	@:overload @:throws("java.lang.NumberFormatException") static function parseShort(param1 : String, param2 : Int) : java.types.Int16;
+	@:overload @:throws("java.lang.NumberFormatException") static function parseShort(param1 : String) : java.types.Int16;
+	@:overload static function reverseBytes(param1 : java.types.Int16) : java.types.Int16;
+	@:native("toString") @:overload static function _toString(param1 : java.types.Int16) : String;
+	@:overload @:throws("java.lang.NumberFormatException") static function valueOf(param1 : String, param2 : Int) : Short;
+	@:overload static function valueOf(param1 : java.types.Int16) : Short;
+	@:overload @:throws("java.lang.NumberFormatException") static function valueOf(param1 : String) : Short;
+
+}

+ 1 - 1
typeload.ml

@@ -861,7 +861,7 @@ let check_overriding ctx c =
 				if ctx.com.config.pf_overload && (Meta.has Meta.Overload f2.cf_meta && not (Meta.has Meta.Overload f.cf_meta)) then
 					display_error ctx ("Field " ^ i ^ " should be declared with @:overload since it was already declared as @:overload in superclass") p
 				else if not (List.memq f c.cl_overrides) then
-					display_error ctx ("Field " ^ i ^ " should be declared with 'override' since it is inherited from superclass") p
+					display_error ctx ("Field " ^ i ^ " should be declared with 'override' since it is inherited from superclass " ^ Ast.s_type_path csup.cl_path) p
 				else if not f.cf_public && f2.cf_public then
 					display_error ctx ("Field " ^ i ^ " has less visibility (public/private) than superclass one") p
 				else (match f.cf_kind, f2.cf_kind with