2
0
Эх сурвалжийг харах

Java std cleanup (#11829)

* damage report

* unused, maybe

* more

* remove java.lang.String hacks

* remove java.NativeString

* restore CI

* Revert "remove java.NativeString"

This reverts commit fde3552f00b61a12a5b24596b0a450bf0f9b99fb.

* Revert "remove java.lang.String hacks"

This reverts commit 109a1167a69a528bf083266f5301e6fa620ff121.
Simon Krajewski 9 сар өмнө
parent
commit
b6b8925e43
83 өөрчлөгдсөн 433 нэмэгдсэн , 1536 устгасан
  1. 4 4
      src/codegen/javaModern.ml
  2. 1 1
      src/filters/capturedVars.ml
  3. 12 12
      src/generators/genjvm.ml
  4. 1 1
      src/optimization/inline.ml
  5. 1 1
      src/typing/strictMeta.ml
  6. 1 1
      std/StringTools.hx
  7. 2 2
      std/haxe/EnumTools.hx
  8. 2 2
      std/haxe/ds/Vector.hx
  9. 1 1
      std/haxe/io/BytesData.hx
  10. 1 10
      std/haxe/rtti/Meta.hx
  11. 0 44
      std/java/Boot.hx
  12. 0 33
      std/java/Init.hx
  13. 0 163
      std/java/Lib.hx
  14. 1 48
      std/java/NativeArray.hx
  15. 1 97
      std/java/NativeString.hx
  16. 0 523
      std/java/_std/haxe/ds/IntMap.hx
  17. 10 10
      std/java/lang/Byte.hx
  18. 110 110
      std/java/lang/Character.hx
  19. 11 11
      std/java/lang/Short.hx
  20. 0 25
      std/java/types/Char16.hx
  21. 0 25
      std/java/types/Int16.hx
  22. 0 25
      std/java/types/Int8.hx
  23. 0 83
      std/java/vm/AtomicList.hx
  24. 0 25
      std/java/vm/Deque.hx
  25. 0 25
      std/java/vm/Lock.hx
  26. 0 25
      std/java/vm/Mutex.hx
  27. 0 25
      std/java/vm/Thread.hx
  28. 0 25
      std/java/vm/Tls.hx
  29. 3 0
      std/jvm/Char16.hx
  30. 1 1
      std/jvm/Function.hx
  31. 3 0
      std/jvm/Int16.hx
  32. 1 27
      std/jvm/Int64.hx
  33. 3 0
      std/jvm/Int8.hx
  34. 23 6
      std/jvm/Jvm.hx
  35. 39 7
      std/jvm/NativeArray.hx
  36. 99 0
      std/jvm/NativeString.hx
  37. 8 26
      std/jvm/_std/Array.hx
  38. 0 0
      std/jvm/_std/Date.hx
  39. 0 0
      std/jvm/_std/Math.hx
  40. 2 2
      std/jvm/_std/String.hx
  41. 1 1
      std/jvm/_std/StringBuf.hx
  42. 6 5
      std/jvm/_std/Sys.hx
  43. 0 0
      std/jvm/_std/haxe/Exception.hx
  44. 7 5
      std/jvm/_std/haxe/Int64.hx
  45. 0 0
      std/jvm/_std/haxe/NativeStackTrace.hx
  46. 2 2
      std/jvm/_std/haxe/Resource.hx
  47. 1 1
      std/jvm/_std/haxe/Rest.hx
  48. 0 0
      std/jvm/_std/haxe/atomic/AtomicBool.hx
  49. 0 0
      std/jvm/_std/haxe/atomic/AtomicInt.hx
  50. 0 0
      std/jvm/_std/haxe/atomic/AtomicObject.hx
  51. 0 0
      std/jvm/_std/haxe/crypto/Md5.hx
  52. 0 0
      std/jvm/_std/haxe/crypto/Sha1.hx
  53. 0 0
      std/jvm/_std/haxe/crypto/Sha256.hx
  54. 0 0
      std/jvm/_std/haxe/ds/ObjectMap.hx
  55. 0 0
      std/jvm/_std/haxe/ds/WeakMap.hx
  56. 0 0
      std/jvm/_std/haxe/zip/Compress.hx
  57. 0 0
      std/jvm/_std/haxe/zip/Uncompress.hx
  58. 2 5
      std/jvm/_std/sys/FileSystem.hx
  59. 0 0
      std/jvm/_std/sys/io/File.hx
  60. 0 0
      std/jvm/_std/sys/io/FileInput.hx
  61. 0 0
      std/jvm/_std/sys/io/FileOutput.hx
  62. 4 5
      std/jvm/_std/sys/io/Process.hx
  63. 0 0
      std/jvm/_std/sys/net/Host.hx
  64. 4 4
      std/jvm/_std/sys/net/Socket.hx
  65. 0 0
      std/jvm/_std/sys/thread/Condition.hx
  66. 0 2
      std/jvm/_std/sys/thread/Deque.hx
  67. 0 0
      std/jvm/_std/sys/thread/Mutex.hx
  68. 0 0
      std/jvm/_std/sys/thread/Semaphore.hx
  69. 26 40
      std/jvm/_std/sys/thread/Thread.hx
  70. 0 0
      std/jvm/_std/sys/thread/Tls.hx
  71. 1 1
      std/jvm/annotation/EnumReflectionInformation.hx
  72. 1 1
      std/jvm/annotation/EnumValueReflectionInformation.hx
  73. 2 3
      std/jvm/io/NativeInput.hx
  74. 2 3
      std/jvm/io/NativeOutput.hx
  75. 1 1
      std/jvm/net/SslSocket.hx
  76. 1 1
      std/sys/Http.hx
  77. 7 5
      tests/unit/src/unit/TestJava.hx
  78. 3 1
      tests/unit/src/unit/TestNumericCasts.hx
  79. 1 1
      tests/unit/src/unit/issues/Issue10397.hx
  80. 2 3
      tests/unit/src/unit/issues/Issue2049.hx
  81. 2 2
      tests/unit/src/unit/issues/Issue2772.hx
  82. 15 17
      tests/unit/src/unit/issues/Issue2927.hx
  83. 1 1
      tests/unit/src/unit/issues/Issue9220.hx

+ 4 - 4
src/codegen/javaModern.ml

@@ -672,13 +672,13 @@ module SignatureConverter = struct
 
 	and convert_signature ctx p jsig =
 		match jsig with
-		| TByte -> mk_type_path (["java"; "types"], "Int8") [] p
-		| TChar -> mk_type_path (["java"; "types"], "Char16") [] p
+		| TByte -> mk_type_path (["jvm"], "Int8") [] p
+		| TChar -> mk_type_path (["jvm"], "Char16") [] p
 		| TDouble -> mk_type_path ([], "Float") [] p
 		| TFloat -> mk_type_path ([], "Single") [] p
 		| TInt -> mk_type_path ([], "Int") [] p
 		| TLong -> mk_type_path (["haxe"], "Int64") [] p
-		| TShort -> mk_type_path (["java"; "types"], "Int16") [] p
+		| TShort -> mk_type_path (["jvm"], "Int16") [] p
 		| TBool -> mk_type_path ([], "Bool") [] p
 		| TObject ( (["haxe";"root"], name), args ) -> mk_type_path ([], name) (List.map (convert_arg ctx p) args) p
 		| TObject ( (["java";"lang"], "Object"), [] ) -> mk_type_path ([], "Dynamic") [] p
@@ -693,7 +693,7 @@ module SignatureConverter = struct
 			| _ -> die "" __LOC__ in
 			mk_type_path (pack, name ^ "$" ^ String.concat "$" (List.map fst inners)) (List.map (fun param -> convert_arg ctx p param) actual_param) p
 		| TObjectInner (pack, inners) -> die "" __LOC__
-		| TArray (jsig, _) -> mk_type_path (["java"], "NativeArray") [ TPType (convert_signature ctx p jsig,p) ] p
+		| TArray (jsig, _) -> mk_type_path (["jvm"], "NativeArray") [ TPType (convert_signature ctx p jsig,p) ] p
 		| TMethod _ -> failwith "TMethod cannot be converted directly into Complex Type"
 		| TTypeParameter s ->
 			try

+ 1 - 1
src/filters/capturedVars.ml

@@ -47,7 +47,7 @@ let captured_vars com e =
 	| Jvm ->
 		let cnativearray =
 			match (List.find (fun md -> match md with
-					| TClassDecl ({ cl_path = ["java"],"NativeArray" }) -> true
+					| TClassDecl ({ cl_path = ["jvm"],"NativeArray" }) -> true
 					| _ -> false
 				) com.types)
 			with TClassDecl cl -> cl | _ -> die "" __LOC__

+ 12 - 12
src/generators/genjvm.ml

@@ -126,13 +126,13 @@ open NativeSignatures
 
 let jsignature_of_path path = match path with
 	| [],"Bool" -> TBool
-	| ["java"],"Int8" -> TByte
-	| ["java"],"Int16" -> TShort
+	| ["jvm"],"Int8" -> TByte
+	| ["jvm"],"Int16" -> TShort
 	| [],"Int" -> TInt
 	| ["haxe"],"Int32" -> TInt
 	| ["haxe"],"Int64" -> TLong
-	| ["java"],"Int64" -> TLong
-	| ["java"],"Char16" -> TChar
+	| ["jvm"],"Int64" -> TLong
+	| ["jvm"],"Char16" -> TChar
 	| [],"Single" -> TFloat
 	| [],"Float" -> TDouble
 	| [],"Dynamic" -> object_sig
@@ -183,7 +183,7 @@ let rec jsignature_of_type gctx stack t =
 	| TInst({cl_path = (["haxe";"root"],"Array")},[t]) ->
 		let t = get_boxed_type (jsignature_of_type t) in
 		TObject((["haxe";"root"],"Array"),[TType(WNone,t)])
-	| TInst({cl_path = (["java"],"NativeArray")},[t]) ->
+	| TInst({cl_path = (["jvm"],"NativeArray")},[t]) ->
 		TArray(jsignature_of_type t,None)
 	| TInst({cl_kind = KTypeParameter ttp; cl_path = (_,name)},_) ->
 		begin match get_constraints ttp with
@@ -745,7 +745,7 @@ class texpr_to_jvm
 		| FInstance({cl_path = (["java";"lang"],"String")},_,{cf_name = "length"}) ->
 			self#texpr rvalue_any e1;
 			jm#invokevirtual string_path "length" (method_sig [] (Some TInt))
-		| FInstance({cl_path = (["java"],"NativeArray")},_,{cf_name = "length"}) ->
+		| FInstance({cl_path = (["jvm"],"NativeArray")},_,{cf_name = "length"}) ->
 			self#texpr rvalue_any e1;
 			let vtobj = self#vtype e1.etype in
 			code#arraylength vtobj;
@@ -858,7 +858,7 @@ class texpr_to_jvm
 					apply (fun () -> code#dup_x2;);
 					jm#expect_reference_type;
 					jm#invokevirtual c.cl_path "__set" (method_sig [TInt;object_sig] None);
-				| TInst({cl_path = (["java"],"NativeArray")},[t]) ->
+				| TInst({cl_path = (["jvm"],"NativeArray")},[t]) ->
 					let vte = self#vtype t in
 					let vta = self#vtype e1.etype in
 					self#texpr rvalue_any e1;
@@ -1635,9 +1635,9 @@ class texpr_to_jvm
 			| _ ->
 				die "" __LOC__
 			end
-		| TIdent "__array__" | TField(_,FStatic({cl_path = (["java"],"NativeArray")},{cf_name = "make"})) ->
+		| TIdent "__array__" | TField(_,FStatic({cl_path = (["jvm"],"NativeArray")},{cf_name = "make"})) ->
 			begin match follow tr with
-			| TInst({cl_path = (["java"],"NativeArray")},[t]) ->
+			| TInst({cl_path = (["jvm"],"NativeArray")},[t]) ->
 				let jsig = self#vtype t in
 				self#new_native_array jsig el;
 				Some (array_sig jsig)
@@ -2047,7 +2047,7 @@ class texpr_to_jvm
 			else self#read (fun () -> self#cast_expect ret e.etype) e1 fa;
 		| TCall(e1,el) ->
 			self#call ret e.etype e1 el
-		| TNew({cl_path = (["java"],"NativeArray")},[t],[e1]) ->
+		| TNew({cl_path = (["jvm"],"NativeArray")},[t],[e1]) ->
 			self#texpr (if need_val ret then rvalue_any else RVoid) e1;
 			(* Technically this could throw... but whatever *)
 			if need_val ret then ignore(NativeArray.create jm#get_code jc#get_pool (jsignature_of_type gctx t))
@@ -2103,7 +2103,7 @@ class texpr_to_jvm
 				jm#cast TInt;
 				jm#invokevirtual c.cl_path "__get" (method_sig [TInt] (Some object_sig));
 				self#cast e.etype
-			| TInst({cl_path = (["java"],"NativeArray")},[t]) ->
+			| TInst({cl_path = (["jvm"],"NativeArray")},[t]) ->
 				self#texpr rvalue_any e1;
 				let vt = self#vtype e1.etype in
 				let vte = self#vtype t in
@@ -2648,7 +2648,7 @@ class tclass_to_jvm gctx c = object(self)
 			load();
 			jm#putstatic (["haxe";"root"],"Sys") "_args" (TArray(string_sig,None))
 		end;
-		jm#invokestatic (["haxe"; "java"], "Init") "init" (method_sig [] None);
+		jm#invokestatic (["haxe"; "jvm"], "Jvm") "init" (method_sig [] None);
 		self#generate_expr gctx None jc jm e SCNone MStatic;
 		if not jm#is_terminated then jm#return
 

+ 1 - 1
src/optimization/inline.ml

@@ -163,7 +163,7 @@ let api_inline ctx c field params p =
 			Some (Texpr.Builder.fcall (eJsSyntax()) "instanceof" [o;t] tbool p)
 	| (["haxe";"ds";"_Vector"],"Vector_Impl_"),("fromArrayCopy"),[{ eexpr = TArrayDecl args } as edecl] -> (try
 			let platf = match ctx.com.platform with
-				| Jvm -> "java"
+				| Jvm -> "jvm"
 				| _ -> raise Exit
 			in
 			let mpath = if field = "fromArrayCopy" then

+ 1 - 1
src/typing/strictMeta.ml

@@ -79,7 +79,7 @@ let rec kind_of_type_against ctx t_want e_have =
 				unify ctx e.etype t_want e.epos
 		end;
 		e
-	| TInst({cl_path = (["java"],"NativeArray")},[t1]) ->
+	| TInst({cl_path = (["jvm"],"NativeArray")},[t1]) ->
 		begin match fst e_have with
 			| EArrayDecl el ->
 				let el = List.map (kind_of_type_against ctx t1) el in

+ 1 - 1
std/StringTools.hx

@@ -594,7 +594,7 @@ class StringTools {
 	}
 
 	#if java
-	private static inline function _charAt(str:String, idx:Int):java.StdTypes.Char16
+	private static inline function _charAt(str:String, idx:Int):jvm.Char16
 		return (cast str : java.NativeString).charAt(idx);
 	#end
 

+ 2 - 2
std/haxe/EnumTools.hx

@@ -111,9 +111,9 @@ extern class EnumTools {
 		return Type.getEnumConstructs(e);
 	}
 
-	#if (java && jvm)
+	#if jvm
 	@:noCompletion
-	extern static function values<T>(en:Enum<T>):java.NativeArray<java.lang.Enum<T>>;
+	extern static function values<T>(en:Enum<T>):jvm.NativeArray<java.lang.Enum<T>>;
 	#end
 }
 

+ 2 - 2
std/haxe/ds/Vector.hx

@@ -32,7 +32,7 @@ private typedef VectorData<T> =
 	#elseif neko
 	neko.NativeArray<T>
 	#elseif java
-	java.NativeArray<T>
+	jvm.NativeArray<T>
 	#elseif lua
 	lua.Table<Int, T>
 	#elseif eval
@@ -280,7 +280,7 @@ abstract Vector<T>(VectorData<T>) {
 		#elseif flash10
 		return fromData(flash.Vector.ofArray(array));
 		#elseif java
-		return fromData(java.Lib.nativeArray(array, false));
+		return fromData(jvm.NativeArray.ofArray(array));
 		#elseif cpp
 		return cast array.copy();
 		#elseif js

+ 1 - 1
std/haxe/io/BytesData.hx

@@ -29,7 +29,7 @@ typedef BytesData = flash.utils.ByteArray;
 #elseif cpp
 typedef BytesData = Array<cpp.UInt8>;
 #elseif java
-typedef BytesData = java.NativeArray<java.StdTypes.Int8>;
+typedef BytesData = jvm.NativeArray<jvm.Int8>;
 #elseif python
 typedef BytesData = python.Bytearray;
 #elseif js

+ 1 - 10
std/haxe/rtti/Meta.hx

@@ -42,22 +42,13 @@ class Meta {
 		return (meta == null || meta.obj == null) ? {} : meta.obj;
 	}
 
-	// Could move this to Type.hx?
-	private static function isInterface(t:Dynamic):Bool {
-		#if java
-		return java.Lib.toNativeType(t).isInterface();
-		#else
-		throw "Something went wrong";
-		#end
-	}
-
 	private static function getMeta(t:Dynamic):MetaObject {
 		#if php
 		return php.Boot.getMeta(t.phpClassName);
 		#elseif java
 		var ret = Reflect.field(t, "__meta__");
 		if (ret == null && Std.isOfType(t, Class)) {
-			if (isInterface(t)) {
+			if (jvm.NativeTools.NativeClassTools.native(t).isInterface()) {
 				var name = Type.getClassName(t),
 					cls = Type.resolveClass(name + '_HxMeta');
 				if (cls != null)

+ 0 - 44
std/java/Boot.hx

@@ -1,44 +0,0 @@
-/*
- * Copyright (C)2005-2019 Haxe Foundation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-package java;
-
-import java.Lib;
-import java.Init;
-import java.StdTypes;
-import Reflect;
-import Map;
-import haxe.ds.StringMap;
-import java.lang.Boolean;
-import java.lang.Character;
-import java.lang.Class;
-import java.lang.Number;
-import java.lang.Byte;
-import java.lang.Double;
-import java.lang.Float;
-import java.lang.Integer;
-import java.lang.Long;
-import java.lang.Short;
-import java.lang.Throwable;
-
-@:dox(hide)
-extern class Boot {}

+ 0 - 33
std/java/Init.hx

@@ -1,33 +0,0 @@
-/*
- * Copyright (C)2005-2019 Haxe Foundation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-package java;
-
-@:native("haxe.java.Init") @:keep class Init {
-	public static function init():Void {
-		#if std_encoding_utf8
-		try {
-			java.lang.System.setOut(new java.io.PrintStream(java.lang.System.out, true, "utf-8"));
-			java.lang.System.setErr(new java.io.PrintStream(java.lang.System.err, true, "utf-8"));
-		} catch (e:java.io.UnsupportedEncodingException) {}
-		#end
-	}
-}

+ 0 - 163
std/java/Lib.hx

@@ -1,163 +0,0 @@
-/*
- * Copyright (C)2005-2019 Haxe Foundation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-package java;
-
-/**
-	Platform-specific Java Library. Provides some platform-specific functions for the Java target,
-	such as conversion from Haxe types to native types and vice-versa.
-**/
-// we cannot use the java package for custom classes, so we're redefining it as "haxe.java.Lib"
-@:native('haxe.java.Lib') class Lib {
-	/**
-		Print the specified value on the default output.
-	**/
-	inline public static function print(v:Dynamic):Void {
-		Sys.print(v);
-	}
-
-	/**
-		Print the specified value on the default output followed by a newline character.
-	**/
-	inline public static function println(v:Dynamic):Void {
-		Sys.println(v);
-	}
-
-	/**
-		Returns a native array from the supplied Array. This native array is unsafe to be written on,
-		as it may or may not be linked to the actual Array implementation.
-
-		If `equalLengthRequired` is true, the result might be a copy of an array with the correct size.
-	**/
-	inline public static function nativeArray<T>(arr:Array<T>, equalLengthRequired:Bool):NativeArray<T> {
-		var ret = new NativeArray(arr.length);
-		for (i in 0...arr.length) {
-			ret[i] = arr[i];
-		}
-		return ret;
-	}
-
-	/**
-		Gets the native `java.lang.Class` from the supplied object. Will throw an exception in case of null being passed.
-		[deprecated] - use `getNativeType` instead
-	**/
-	@:deprecated('The function `nativeType` is deprecated and will be removed in later versions. Please use `getNativeType` instead')
-	inline public static function nativeType<T>(obj:T):java.lang.Class<T> {
-		return untyped obj.getClass();
-	}
-
-	/**
-		Gets the native `java.lang.Class` from the supplied object. Will throw an exception in case of null being passed.
-	**/
-	inline public static function getNativeType<T>(obj:T):java.lang.Class<T> {
-		return untyped obj.getClass();
-	}
-
-	/**
-		Returns a Class<> equivalent to the native java.lang.Class type.
-	**/
-	public static inline function fromNativeType<T>(t:java.lang.Class<T>):Class<T> {
-		return untyped t;
-	}
-
-	/**
-		Returns a java.lang.Class equivalent to the Haxe Class<> type.
-	**/
-	public static inline function toNativeType<T>(cl:Class<T>):java.lang.Class<T> {
-		return untyped cl;
-	}
-
-	/**
-		Returns a java.lang.Class equivalent to the Haxe Enum<> type.
-	**/
-	public static inline function toNativeEnum<T>(cl:Enum<T>):java.lang.Class<T> {
-		return untyped cl;
-	}
-
-	/**
-		Returns a Haxe Array of a native Array.
-		Unless `copy` is true, it won't copy the contents of the native array,
-		so unless any operation triggers an array resize, all changes made to the Haxe array will affect the native array argument.
-	**/
-	@:generic public static function array<T>(native:java.NativeArray<T>):Array<T> {
-		return untyped Array.ofNative(native);
-	}
-
-	extern inline private static function doArray<T>(native:java.NativeArray<T>):Array<T> {
-		var ret:NativeArray<Dynamic> = new NativeArray(native.length);
-		for (i in 0...native.length) {
-			ret[i] = native[i];
-		}
-		return untyped Array.ofNative(ret);
-	}
-
-	public static function array_Int(native:java.NativeArray<Int>):Array<Int> {
-		return doArray(native);
-	}
-
-	public static function array_Float(native:java.NativeArray<Float>):Array<Float> {
-		return doArray(native);
-	}
-
-	public static function array_Bool(native:java.NativeArray<Bool>):Array<Bool> {
-		return doArray(native);
-	}
-
-	public static function array_java_Int8(native:java.NativeArray<java.StdTypes.Int8>):Array<java.StdTypes.Int8> {
-		return doArray(native);
-	}
-
-	public static function array_java_Int16(native:java.NativeArray<java.StdTypes.Int16>):Array<java.StdTypes.Int16> {
-		return doArray(native);
-	}
-
-	public static function array_java_Char16(native:java.NativeArray<java.StdTypes.Char16>):Array<java.StdTypes.Char16> {
-		return doArray(native);
-	}
-
-	public static function array_Single(native:java.NativeArray<Single>):Array<Single> {
-		return doArray(native);
-	}
-
-	public static function array_haxe_Int64(native:java.NativeArray<haxe.Int64>):Array<haxe.Int64> {
-		return doArray(native);
-	}
-
-	/**
-		Allocates a new Haxe Array with a predetermined size
-	**/
-	public static function arrayAlloc<T>(size:Int):Array<T> {
-		return untyped Array.alloc(size);
-	}
-
-	/**
-		Ensures that one thread does not enter a critical section of code while another thread
-		is in the critical section. If another thread attempts to enter a locked code, it
-		will wait, block, until the object is released.
-		This is the equivalent to "synchronized" in java code.
-
-		This method only exists at compile-time, so it can't be called via reflection.
-	**/
-	extern public static inline function lock<T>(obj:Dynamic, block:T):Void {
-		untyped __lock__(obj, block);
-	}
-}

+ 1 - 48
std/java/NativeArray.hx

@@ -1,50 +1,3 @@
-/*
- * Copyright (C)2005-2019 Haxe Foundation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
 package java;
 
-import haxe.extern.Rest;
-
-/**
-	Represents a java fixed-size Array (`T[]`)
-**/
-@:nativeGen extern class NativeArray<T> implements ArrayAccess<T> {
-	/**
-		Creates a new array with the specified elements.
-
-		Usage:
-		```haxe
-		var elements = NativeArray.make(1,2,3,4,5,6);
-		```
-	**/
-	static function make<T>(elements:Rest<T>):NativeArray<T>;
-
-	/**
-		The length of the array
-	**/
-	var length(default, null):Int;
-
-	/**
-		Allocates a new array with size `len`
-	**/
-	function new(len:Int):Void;
-}
+typedef NativeArray<T> = jvm.NativeArray<T>;

+ 1 - 97
std/java/NativeString.hx

@@ -1,99 +1,3 @@
-/*
- * Copyright (C)2005-2019 Haxe Foundation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
 package java;
 
-import haxe.Int64;
-import haxe.extern.Rest;
-import java.StdTypes.Int8;
-import java.StdTypes.Char16;
-import java.lang.CharSequence;
-import java.util.Locale;
-
-@:native("java.lang.String")
-extern class NativeString {
-	function charAt(index:Int):Char16;
-	function codePointAt(index:Int):Int;
-	function codePointBefore(index:Int):Int;
-	function codePointCount(beginIndex:Int, endIndex:Int):Int;
-	function compareTo(anotherString:String):Int;
-	function compareToIgnoreCase(str:String):Int;
-	function concat(str:String):String;
-	function contains(s:CharSequence):Bool;
-	@:overload function contentEquals(cs:CharSequence):Bool;
-	@:overload function contentEquals(sb:java.lang.StringBuffer):Bool;
-	@:overload static function copyValueOf(data:NativeArray<Char16>):String;
-	@:overload static function copyValueOf(data:NativeArray<Char16>, offset:Int, count:Int):String;
-	function endsWith(suffix:String):Bool;
-	function equals(anObject:Dynamic):Bool;
-	function equalsIgnoreCase(anotherString:String):Bool;
-	@:overload static function format(l:Locale, format:String, args:Rest<Dynamic>):String;
-	@:overload static function format(format:String, args:Rest<Dynamic>):String;
-	@:overload function getBytes():NativeArray<Int8>;
-	@:overload function getBytes(charset:java.nio.charset.Charset):NativeArray<Int8>;
-	@:deprecated @:overload function getBytes(srcBegin:Int, srcEnd:Int, dst:NativeArray<Int8>, dstBegin:Int):Void;
-	@:overload function getBytes(charsetName:String):NativeArray<Int8>;
-	function getChars(srcBegin:Int, srcEnd:Int, dst:NativeArray<Char16>, dstBegin:Int):Void;
-	function hashCode():Int;
-	@:overload function indexOf(ch:Int):Int;
-	@:overload function indexOf(ch:Int, fromIndex:Int):Int;
-	@:overload function indexOf(str:String):Int;
-	@:overload function indexOf(str:String, fromIndex:Int):Int;
-	function intern():String;
-	function isEmpty():Bool;
-	@:overload function lastIndexOf(ch:Int):Int;
-	@:overload function lastIndexOf(ch:Int, fromIndex:Int):Int;
-	@:overload function lastIndexOf(str:String):Int;
-	@:overload function lastIndexOf(str:String, fromIndex:Int):Int;
-	function length():Int;
-	function matches(regex:String):Bool;
-	function offsetByCodePoints(index:Int, codePointOffset:Int):Int;
-	@:overload function regionMatches(ignoreCase:Bool, toffset:Int, other:String, ooffset:Int, len:Int):Bool;
-	@:overload function regionMatches(toffset:Int, other:String, ooffset:Int, len:Int):Bool;
-	@:overload function replace(oldChar:Char16, newChar:Char16):String;
-	@:overload function replace(target:CharSequence, replacement:CharSequence):String;
-	function replaceAll(regex:String, replacement:String):String;
-	function replaceFirst(regex:String, replacement:String):String;
-	@:overload function split(regex:String):NativeArray<String>;
-	@:overload function split(regex:String, limit:Int):NativeArray<String>;
-	@:overload function startsWith(prefix:String):Bool;
-	@:overload function startsWith(prefix:String, toffset:Int):Bool;
-	function subSequence(beginIndex:Int, endIndex:Int):CharSequence;
-	@:overload function substring(beginIndex:Int):String;
-	@:overload function substring(beginIndex:Int, endIndex:Int):String;
-	function toCharArray():NativeArray<Char16>;
-	@:overload function toLowerCase():String;
-	@:overload function toLowerCase(locale:Locale):String;
-	function toString():String;
-	@:overload function toUpperCase():String;
-	@:overload function toUpperCase(locale:Locale):String;
-	function trim():String;
-	@:overload static function valueOf(b:Bool):String;
-	@:overload static function valueOf(c:Char16):String;
-	@:overload static function valueOf(data:NativeArray<Char16>):String;
-	@:overload static function valueOf(data:NativeArray<Char16>, offset:Int, count:Int):String;
-	@:overload static function valueOf(d:Float):String;
-	@:overload static function valueOf(f:String):String;
-	@:overload static function valueOf(i:Int):String;
-	@:overload static function valueOf(l:haxe.Int64):String;
-	@:overload static function valueOf(obj:java.lang.Object):String;
-}
+typedef NativeString = jvm.NativeString;

+ 0 - 523
std/java/_std/haxe/ds/IntMap.hx

@@ -1,523 +0,0 @@
-/*
- * Copyright (C)2005-2019 Haxe Foundation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-package haxe.ds;
-
-import java.NativeArray;
-
-/*
- * This IntMap implementation is based on khash (https://github.com/attractivechaos/klib/blob/master/khash.h)
- * Copyright goes to Attractive Chaos <[email protected]> and his contributors
- *
- * Thanks also to Jonas Malaco Filho for his Haxe-written IntMap code inspired by Python tables.
- * (https://jonasmalaco.com/fossil/test/jonas-haxe/artifact/887b53126e237d6c68951111d594033403889304)
- */
-@:coreApi class IntMap<T> implements haxe.Constraints.IMap<Int, T> {
-	private static inline var HASH_UPPER = 0.7;
-
-	private var flags:NativeArray<Int>;
-	private var _keys:NativeArray<Int>;
-	private var vals:NativeArray<T>;
-
-	private var nBuckets:Int;
-	private var size:Int;
-	private var nOccupied:Int;
-	private var upperBound:Int;
-
-	#if !no_map_cache
-	private var cachedKey:Int;
-	private var cachedIndex:Int;
-	#end
-
-	public function new():Void {
-		#if !no_map_cache
-		cachedIndex = -1;
-		#end
-	}
-
-	public function set(key:Int, value:T):Void {
-		var targetIndex:Int;
-		if (nOccupied >= upperBound) {
-			if (nBuckets > (size << 1)) {
-				resize(nBuckets - 1); // clear "deleted" elements
-			} else {
-				resize(nBuckets + 1);
-			}
-		}
-
-		var flags = flags, _keys = _keys;
-		{
-			var mask = nBuckets - 1,
-				hashedKey = hash(key),
-				curIndex = hashedKey & mask;
-
-			var delKey = -1, curFlag = 0;
-			// to speed things up, don't loop if the first bucket is already free
-			if (isEmpty(getFlag(flags, curIndex))) {
-				targetIndex = curIndex;
-			} else {
-				var inc = getInc(hashedKey, mask), last = curIndex;
-				while (!(_keys[curIndex] == key || isEmpty(curFlag = getFlag(flags, curIndex)))) {
-					if (delKey == -1 && isDel(curFlag)) {
-						delKey = curIndex;
-					}
-					curIndex = (curIndex + inc) & mask;
-					#if debug
-					assert(curIndex != last);
-					#end
-				}
-
-				if (delKey != -1 && isEmpty(getFlag(flags, curIndex))) {
-					targetIndex = delKey;
-				} else {
-					targetIndex = curIndex;
-				}
-			}
-		}
-
-		var flag = getFlag(flags, targetIndex);
-		if (isEmpty(flag)) {
-			_keys[targetIndex] = key;
-			vals[targetIndex] = value;
-			setIsBothFalse(flags, targetIndex);
-			size++;
-			nOccupied++;
-		} else if (isDel(flag)) {
-			_keys[targetIndex] = key;
-			vals[targetIndex] = value;
-			setIsBothFalse(flags, targetIndex);
-			size++;
-		} else {
-			#if debug
-			assert(_keys[targetIndex] == key);
-			#end
-			vals[targetIndex] = value;
-		}
-	}
-
-	private final function lookup(key:Int):Int {
-		if (nBuckets != 0) {
-			var flags = flags, _keys = _keys;
-
-			var mask = nBuckets - 1,
-				k = hash(key),
-				index = k & mask,
-				curFlag = -1,
-				inc = getInc(k, mask), /* inc == 1 for linear probing */
-				last = index;
-			do {
-				if (_keys[index] == key) {
-					if (isEmpty(curFlag = getFlag(flags, index))) {
-						index = (index + inc) & mask;
-						continue;
-					} else if (isDel(curFlag)) {
-						return -1;
-					} else {
-						return index;
-					}
-				} else {
-					index = (index + inc) & mask;
-				}
-			} while (index != last);
-		}
-
-		return -1;
-	}
-
-	public function get(key:Int):Null<T> {
-		var idx = -1;
-		#if !no_map_cache
-		if (cachedKey == key && ((idx = cachedIndex) != -1)) {
-			return vals[idx];
-		}
-		#end
-
-		idx = lookup(key);
-		if (idx != -1) {
-			#if !no_map_cache
-			cachedKey = key;
-			cachedIndex = idx;
-			#end
-			return vals[idx];
-		}
-
-		return null;
-	}
-
-	private function getDefault(key:Int, def:T):T {
-		var idx = -1;
-		#if !no_map_cache
-		if (cachedKey == key && ((idx = cachedIndex) != -1)) {
-			return vals[idx];
-		}
-		#end
-
-		idx = lookup(key);
-		if (idx != -1) {
-			#if !no_map_cache
-			cachedKey = key;
-			cachedIndex = idx;
-			#end
-			return vals[idx];
-		}
-
-		return def;
-	}
-
-	public function exists(key:Int):Bool {
-		var idx = -1;
-		#if !no_map_cache
-		if (cachedKey == key && ((idx = cachedIndex) != -1)) {
-			return true;
-		}
-		#end
-
-		idx = lookup(key);
-		if (idx != -1) {
-			#if !no_map_cache
-			cachedKey = key;
-			cachedIndex = idx;
-			#end
-
-			return true;
-		}
-
-		return false;
-	}
-
-	public function remove(key:Int):Bool {
-		var idx = -1;
-		#if !no_map_cache
-		if (!(cachedKey == key && ((idx = cachedIndex) != -1)))
-		#end
-		{
-			idx = lookup(key);
-		}
-
-		if (idx == -1) {
-			return false;
-		} else {
-			#if !no_map_cache
-			if (cachedKey == key) {
-				cachedIndex = -1;
-			}
-			#end
-			if (!isEither(getFlag(flags, idx))) {
-				setIsDelTrue(flags, idx);
-				--size;
-
-				vals[idx] = null;
-				// we do NOT reset the keys here, as unlike StringMap, we check for keys equality
-				// and stop if we find a key that is equal to the one we're looking for
-				// setting this to 0 will allow the hash to contain duplicate `0` keys
-				// (see #6457)
-				// _keys[idx] = 0;
-			}
-
-			return true;
-		}
-	}
-
-	private final function resize(newNBuckets:Int):Void {
-		// This function uses 0.25*n_bucktes bytes of working space instead of [sizeof(key_t+val_t)+.25]*n_buckets.
-		var newFlags = null;
-		var j = 1;
-		{
-			newNBuckets = roundUp(newNBuckets);
-			if (newNBuckets < 4)
-				newNBuckets = 4;
-			if (size >= (newNBuckets * HASH_UPPER + 0.5))
-				/* requested size is too small */ {
-				j = 0;
-			} else { /* hash table size to be changed (shrink or expand); rehash */
-				var nfSize = flagsSize(newNBuckets);
-				newFlags = new NativeArray(nfSize);
-				for (i in 0...nfSize) {
-					newFlags[i] = 0xaaaaaaaa; // isEmpty = true; isDel = false
-				}
-				if (nBuckets < newNBuckets) // expand
-				{
-					var k = new NativeArray(newNBuckets);
-					if (_keys != null) {
-						arrayCopy(_keys, 0, k, 0, nBuckets);
-					}
-					_keys = k;
-
-					var v = new NativeArray(newNBuckets);
-					if (vals != null) {
-						arrayCopy(vals, 0, v, 0, nBuckets);
-					}
-					vals = v;
-				} // otherwise shrink
-			}
-		}
-
-		if (j != 0) { // rehashing is required
-			#if !no_map_cache
-			// resetting cache
-			cachedKey = 0;
-			cachedIndex = -1;
-			#end
-
-			j = -1;
-			var nBuckets = nBuckets, _keys = _keys, vals = vals, flags = flags;
-
-			var newMask = newNBuckets - 1;
-			while (++j < nBuckets) {
-				if (!isEither(getFlag(flags, j))) {
-					var key = _keys[j];
-					var val = vals[j];
-
-					// do not set keys as 0 - see comment about #6457
-					// _keys[j] = 0;
-					vals[j] = cast null;
-					setIsDelTrue(flags, j);
-					while (true)
-						/* kick-out process; sort of like in Cuckoo hashing */ {
-						var k = hash(key);
-						var inc = getInc(k, newMask);
-						var i = k & newMask;
-						while (!isEmpty(getFlag(newFlags, i))) {
-							i = (i + inc) & newMask;
-						}
-						setIsEmptyFalse(newFlags, i);
-
-						if (i < nBuckets && !isEither(getFlag(flags, i)))
-							/* kick out the existing element */ {
-							{
-								var tmp = _keys[i];
-								_keys[i] = key;
-								key = tmp;
-							} {
-								var tmp = vals[i];
-								vals[i] = val;
-								val = tmp;
-							}
-
-							setIsDelTrue(flags, i); /* mark it as deleted in the old hash table */
-						} else { /* write the element and jump out of the loop */
-							_keys[i] = key;
-							vals[i] = val;
-							break;
-						}
-					}
-				}
-			}
-
-			if (nBuckets > newNBuckets)
-				/* shrink the hash table */ {
-				{
-					var k = new NativeArray(newNBuckets);
-					arrayCopy(_keys, 0, k, 0, newNBuckets);
-					this._keys = k;
-				} {
-					var v = new NativeArray(newNBuckets);
-					arrayCopy(vals, 0, v, 0, newNBuckets);
-					this.vals = v;
-				}
-			}
-
-			this.flags = newFlags;
-			this.nBuckets = newNBuckets;
-			this.nOccupied = size;
-			this.upperBound = Std.int(newNBuckets * HASH_UPPER + .5);
-		}
-	}
-
-	public inline function keys():Iterator<Int> {
-		return new IntMapKeyIterator(this);
-	}
-
-	public inline function iterator():Iterator<T> {
-		return new IntMapValueIterator(this);
-	}
-
-	@:runtime public inline function keyValueIterator():KeyValueIterator<Int, T> {
-		return new haxe.iterators.MapKeyValueIterator(this);
-	}
-
-	public function copy():IntMap<T> {
-		var copied = new IntMap();
-		for (key in keys())
-			copied.set(key, get(key));
-		return copied;
-	}
-
-	public function toString():String {
-		var s = new StringBuf();
-		s.add("[");
-		var it = keys();
-		for (i in it) {
-			s.add(i);
-			s.add(" => ");
-			s.add(Std.string(get(i)));
-			if (it.hasNext())
-				s.add(", ");
-		}
-		s.add("]");
-		return s.toString();
-	}
-
-	public function clear():Void {
-		flags = null;
-		_keys = null;
-		vals = null;
-		nBuckets = 0;
-		size = 0;
-		nOccupied = 0;
-		upperBound = 0;
-		#if !no_map_cache
-		cachedKey = 0;
-		cachedIndex = -1;
-		#end
-	}
-
-	private static inline function assert(x:Bool):Void {
-		#if debug
-		if (!x)
-			throw "assert failed";
-		#end
-	}
-
-	private static inline function defaultK():Int
-		return 0;
-
-	private static inline function arrayCopy(sourceArray:Dynamic, sourceIndex:Int, destinationArray:Dynamic, destinationIndex:Int, length:Int):Void
-		java.lang.System.arraycopy(sourceArray, sourceIndex, destinationArray, destinationIndex, length);
-
-	private static inline function getInc(k:Int, mask:Int):Int
-		return (((k) >> 3 ^ (k) << 3) | 1) & (mask);
-
-	private static inline function hash(i:Int):Int
-		return i;
-
-	// flags represents a bit array with 2 significant bits for each index
-	// one bit for deleted (1), one for empty (2)
-	// so what this function does is:
-	//  * gets the integer with (flags / 16)
-	//  * shifts those bits to the right ((flags % 16) * 2) places
-	//  * masks it with 0b11
-	private static inline function getFlag(flags:NativeArray<Int>, i:Int):Int {
-		return ((flags[i >> 4] >>> ((i & 0xf) << 1)) & 3);
-	}
-
-	private static inline function isDel(flag:Int):Bool {
-		return (flag & 1) != 0;
-	}
-
-	private static inline function isEmpty(flag:Int):Bool {
-		return (flag & 2) != 0;
-	}
-
-	private static inline function isEither(flag:Int):Bool {
-		return flag != 0;
-	}
-
-	private static inline function setIsDelFalse(flags:NativeArray<Int>, i:Int):Void {
-		flags[i >> 4] &= ~(1 << ((i & 0xf) << 1));
-	}
-
-	private static inline function setIsEmptyFalse(flags:NativeArray<Int>, i:Int):Void {
-		flags[i >> 4] &= ~(2 << ((i & 0xf) << 1));
-	}
-
-	private static inline function setIsBothFalse(flags:NativeArray<Int>, i:Int):Void {
-		flags[i >> 4] &= ~(3 << ((i & 0xf) << 1));
-	}
-
-	private static inline function setIsDelTrue(flags:NativeArray<Int>, i:Int):Void {
-		flags[i >> 4] |= 1 << ((i & 0xf) << 1);
-	}
-
-	private static inline function roundUp(x:Int):Int {
-		--x;
-		x |= (x) >>> 1;
-		x |= (x) >>> 2;
-		x |= (x) >>> 4;
-		x |= (x) >>> 8;
-		x |= (x) >>> 16;
-		return ++x;
-	}
-
-	private static inline function flagsSize(m:Int):Int
-		return ((m) < 16 ? 1 : (m) >> 4);
-}
-
-@:access(haxe.ds.IntMap)
-private final class IntMapKeyIterator<T> {
-	var m:IntMap<T>;
-	var i:Int;
-	var len:Int;
-
-	public function new(m:IntMap<T>) {
-		this.i = 0;
-		this.m = m;
-		this.len = m.nBuckets;
-	}
-
-	public function hasNext():Bool {
-		for (j in i...len) {
-			if (!IntMap.isEither(IntMap.getFlag(m.flags, j))) {
-				i = j;
-				return true;
-			}
-		}
-		return false;
-	}
-
-	public function next():Int {
-		var ret = m._keys[i];
-		#if !no_map_cache
-		m.cachedIndex = i;
-		m.cachedKey = ret;
-		#end
-		i++;
-		return ret;
-	}
-}
-
-@:access(haxe.ds.IntMap)
-private final class IntMapValueIterator<T> {
-	var m:IntMap<T>;
-	var i:Int;
-	var len:Int;
-
-	public function new(m:IntMap<T>) {
-		this.i = 0;
-		this.m = m;
-		this.len = m.nBuckets;
-	}
-
-	public function hasNext():Bool {
-		for (j in i...len) {
-			if (!IntMap.isEither(IntMap.getFlag(m.flags, j))) {
-				i = j;
-				return true;
-			}
-		}
-		return false;
-	}
-
-	public inline function next():T {
-		return m.vals[i++];
-	}
-}

+ 10 - 10
std/java/lang/Byte.hx

@@ -26,31 +26,31 @@ package java.lang;
 @:transitive
 @:forwardStatics
 @:forward abstract Byte(ByteClass) from ByteClass to ByteClass {
-	@:to extern inline public function toByte():java.types.Int8
+	@:to extern inline public function toByte():jvm.Int8
 		return this.byteValue();
 
-	@:from extern inline public static function fromByte(b:java.types.Int8):Byte
+	@:from extern inline public static function fromByte(b:jvm.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 function new(param1:jvm.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;
-	static final MAX_VALUE:java.types.Int8;
-	static final MIN_VALUE:java.types.Int8;
+	static final MAX_VALUE:jvm.Int8;
+	static final MIN_VALUE:jvm.Int8;
 	static final SIZE:Int;
 	static final TYPE:Class<Byte>;
-	@:overload static function compare(param1:java.types.Int8, param2:java.types.Int8):Int;
+	@:overload static function compare(param1:jvm.Int8, param2:jvm.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 parseByte(param1:String, param2:Int):jvm.Int8;
+	@:overload @:throws("java.lang.NumberFormatException") static function parseByte(param1:String):jvm.Int8;
+	@:native("toString") @:overload static function _toString(param1:jvm.Int8):String;
+	@:overload static function valueOf(param1:jvm.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;
 

+ 110 - 110
std/java/lang/Character.hx

@@ -26,166 +26,166 @@ package java.lang;
 @:transitive
 @:forwardStatics
 @:forward abstract Character(CharacterClass) from CharacterClass to CharacterClass {
-	@:to extern inline public function toCharacter():java.types.Char16
+	@:to extern inline public function toCharacter():jvm.Char16
 		return this.charValue();
 
-	@:from extern inline public static function fromCharacter(b:java.types.Char16):Character
+	@:from extern inline public static function fromCharacter(b:jvm.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 new(param1:jvm.Char16):Void;
+	@:overload function charValue():jvm.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;
-	static final COMBINING_SPACING_MARK:java.types.Char16;
-	static final CONNECTOR_PUNCTUATION:java.types.Char16;
-	static final CONTROL:java.types.Char16;
-	static final CURRENCY_SYMBOL:java.types.Char16;
-	static final DASH_PUNCTUATION:java.types.Char16;
-	static final DECIMAL_DIGIT_NUMBER:java.types.Char16;
-	static final DIRECTIONALITY_ARABIC_NUMBER:java.types.Char16;
-	static final DIRECTIONALITY_BOUNDARY_NEUTRAL:java.types.Char16;
-	static final DIRECTIONALITY_COMMON_NUMBER_SEPARATOR:java.types.Char16;
-	static final DIRECTIONALITY_EUROPEAN_NUMBER:java.types.Char16;
-	static final DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR:java.types.Char16;
-	static final DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR:java.types.Char16;
-	static final DIRECTIONALITY_LEFT_TO_RIGHT:java.types.Char16;
-	static final DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING:java.types.Char16;
-	static final DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE:java.types.Char16;
-	static final DIRECTIONALITY_NONSPACING_MARK:java.types.Char16;
-	static final DIRECTIONALITY_OTHER_NEUTRALS:java.types.Char16;
-	static final DIRECTIONALITY_PARAGRAPH_SEPARATOR:java.types.Char16;
-	static final DIRECTIONALITY_POP_DIRECTIONAL_FORMAT:java.types.Char16;
-	static final DIRECTIONALITY_RIGHT_TO_LEFT:java.types.Char16;
-	static final DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC:java.types.Char16;
-	static final DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING:java.types.Char16;
-	static final DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE:java.types.Char16;
-	static final DIRECTIONALITY_SEGMENT_SEPARATOR:java.types.Char16;
-	static final DIRECTIONALITY_UNDEFINED:java.types.Char16;
-	static final DIRECTIONALITY_WHITESPACE:java.types.Char16;
-	static final ENCLOSING_MARK:java.types.Char16;
-	static final END_PUNCTUATION:java.types.Char16;
-	static final FINAL_QUOTE_PUNCTUATION:java.types.Char16;
-	static final FORMAT:java.types.Char16;
-	static final INITIAL_QUOTE_PUNCTUATION:java.types.Char16;
-	static final LETTER_NUMBER:java.types.Char16;
-	static final LINE_SEPARATOR:java.types.Char16;
-	static final LOWERCASE_LETTER:java.types.Char16;
-	static final MATH_SYMBOL:java.types.Char16;
+	static final COMBINING_SPACING_MARK:jvm.Char16;
+	static final CONNECTOR_PUNCTUATION:jvm.Char16;
+	static final CONTROL:jvm.Char16;
+	static final CURRENCY_SYMBOL:jvm.Char16;
+	static final DASH_PUNCTUATION:jvm.Char16;
+	static final DECIMAL_DIGIT_NUMBER:jvm.Char16;
+	static final DIRECTIONALITY_ARABIC_NUMBER:jvm.Char16;
+	static final DIRECTIONALITY_BOUNDARY_NEUTRAL:jvm.Char16;
+	static final DIRECTIONALITY_COMMON_NUMBER_SEPARATOR:jvm.Char16;
+	static final DIRECTIONALITY_EUROPEAN_NUMBER:jvm.Char16;
+	static final DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR:jvm.Char16;
+	static final DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR:jvm.Char16;
+	static final DIRECTIONALITY_LEFT_TO_RIGHT:jvm.Char16;
+	static final DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING:jvm.Char16;
+	static final DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE:jvm.Char16;
+	static final DIRECTIONALITY_NONSPACING_MARK:jvm.Char16;
+	static final DIRECTIONALITY_OTHER_NEUTRALS:jvm.Char16;
+	static final DIRECTIONALITY_PARAGRAPH_SEPARATOR:jvm.Char16;
+	static final DIRECTIONALITY_POP_DIRECTIONAL_FORMAT:jvm.Char16;
+	static final DIRECTIONALITY_RIGHT_TO_LEFT:jvm.Char16;
+	static final DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC:jvm.Char16;
+	static final DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING:jvm.Char16;
+	static final DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE:jvm.Char16;
+	static final DIRECTIONALITY_SEGMENT_SEPARATOR:jvm.Char16;
+	static final DIRECTIONALITY_UNDEFINED:jvm.Char16;
+	static final DIRECTIONALITY_WHITESPACE:jvm.Char16;
+	static final ENCLOSING_MARK:jvm.Char16;
+	static final END_PUNCTUATION:jvm.Char16;
+	static final FINAL_QUOTE_PUNCTUATION:jvm.Char16;
+	static final FORMAT:jvm.Char16;
+	static final INITIAL_QUOTE_PUNCTUATION:jvm.Char16;
+	static final LETTER_NUMBER:jvm.Char16;
+	static final LINE_SEPARATOR:jvm.Char16;
+	static final LOWERCASE_LETTER:jvm.Char16;
+	static final MATH_SYMBOL:jvm.Char16;
 	static final MAX_CODE_POINT:Int;
-	static final MAX_HIGH_SURROGATE:java.types.Char16;
-	static final MAX_LOW_SURROGATE:java.types.Char16;
+	static final MAX_HIGH_SURROGATE:jvm.Char16;
+	static final MAX_LOW_SURROGATE:jvm.Char16;
 	static final MAX_RADIX:Int;
-	static final MAX_SURROGATE:java.types.Char16;
-	static final MAX_VALUE:java.types.Char16;
+	static final MAX_SURROGATE:jvm.Char16;
+	static final MAX_VALUE:jvm.Char16;
 	static final MIN_CODE_POINT:Int;
-	static final MIN_HIGH_SURROGATE:java.types.Char16;
-	static final MIN_LOW_SURROGATE:java.types.Char16;
+	static final MIN_HIGH_SURROGATE:jvm.Char16;
+	static final MIN_LOW_SURROGATE:jvm.Char16;
 	static final MIN_RADIX:Int;
 	static final MIN_SUPPLEMENTARY_CODE_POINT:Int;
-	static final MIN_SURROGATE:java.types.Char16;
-	static final MIN_VALUE:java.types.Char16;
-	static final MODIFIER_LETTER:java.types.Char16;
-	static final MODIFIER_SYMBOL:java.types.Char16;
-	static final NON_SPACING_MARK:java.types.Char16;
-	static final OTHER_LETTER:java.types.Char16;
-	static final OTHER_NUMBER:java.types.Char16;
-	static final OTHER_PUNCTUATION:java.types.Char16;
-	static final OTHER_SYMBOL:java.types.Char16;
-	static final PARAGRAPH_SEPARATOR:java.types.Char16;
-	static final PRIVATE_USE:java.types.Char16;
+	static final MIN_SURROGATE:jvm.Char16;
+	static final MIN_VALUE:jvm.Char16;
+	static final MODIFIER_LETTER:jvm.Char16;
+	static final MODIFIER_SYMBOL:jvm.Char16;
+	static final NON_SPACING_MARK:jvm.Char16;
+	static final OTHER_LETTER:jvm.Char16;
+	static final OTHER_NUMBER:jvm.Char16;
+	static final OTHER_PUNCTUATION:jvm.Char16;
+	static final OTHER_SYMBOL:jvm.Char16;
+	static final PARAGRAPH_SEPARATOR:jvm.Char16;
+	static final PRIVATE_USE:jvm.Char16;
 	static final SIZE:Int;
-	static final SPACE_SEPARATOR:java.types.Char16;
-	static final START_PUNCTUATION:java.types.Char16;
-	static final SURROGATE:java.types.Char16;
-	static final TITLECASE_LETTER:java.types.Char16;
+	static final SPACE_SEPARATOR:jvm.Char16;
+	static final START_PUNCTUATION:jvm.Char16;
+	static final SURROGATE:jvm.Char16;
+	static final TITLECASE_LETTER:jvm.Char16;
 	static final TYPE:Class<Character>;
-	static final UNASSIGNED:java.types.Char16;
-	static final UPPERCASE_LETTER:java.types.Char16;
+	static final UNASSIGNED:jvm.Char16;
+	static final UPPERCASE_LETTER:jvm.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 codePointAt(param1:java.NativeArray<jvm.Char16>, param2:Int, param3:Int):Int;
+	@:overload static function codePointAt(param1:java.NativeArray<jvm.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 codePointBefore(param1:java.NativeArray<jvm.Char16>, param2:Int, param3:Int):Int;
+	@:overload static function codePointBefore(param1:java.NativeArray<jvm.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 codePointCount(param1:java.NativeArray<jvm.Char16>, param2:Int, param3:Int):Int;
+	@:overload static function compare(param1:jvm.Char16, param2:jvm.Char16):Int;
+	@:overload static function digit(param1:jvm.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 forDigit(param1:Int, param2:Int):jvm.Char16;
+	@:overload static function getDirectionality(param1:jvm.Char16):jvm.Char16;
+	@:overload static function getDirectionality(param1:Int):jvm.Char16;
 	@:overload static function getName(param1:Int):String;
-	@:overload static function getNumericValue(param1:java.types.Char16):Int;
+	@:overload static function getNumericValue(param1:jvm.Char16):Int;
 	@:overload static function getNumericValue(param1:Int):Int;
-	@:overload static function getType(param1:java.types.Char16):Int;
+	@:overload static function getType(param1:jvm.Char16):Int;
 	@:overload static function getType(param1:Int):Int;
-	@:overload static function highSurrogate(param1:Int):java.types.Char16;
+	@:overload static function highSurrogate(param1:Int):jvm.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:jvm.Char16):Bool;
 	@:overload static function isDefined(param1:Int):Bool;
-	@:overload static function isDigit(param1:java.types.Char16):Bool;
+	@:overload static function isDigit(param1:jvm.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 isHighSurrogate(param1:jvm.Char16):Bool;
+	@:overload static function isISOControl(param1:jvm.Char16):Bool;
 	@:overload static function isISOControl(param1:Int):Bool;
-	@:overload static function isIdentifierIgnorable(param1:java.types.Char16):Bool;
+	@:overload static function isIdentifierIgnorable(param1:jvm.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:jvm.Char16):Bool;
 	@:overload static function isJavaIdentifierPart(param1:Int):Bool;
-	@:overload static function isJavaIdentifierStart(param1:java.types.Char16):Bool;
+	@:overload static function isJavaIdentifierStart(param1:jvm.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 @:deprecated static function isJavaLetter(param1:jvm.Char16):Bool;
+	@:overload @:deprecated static function isJavaLetterOrDigit(param1:jvm.Char16):Bool;
+	@:overload static function isLetter(param1:jvm.Char16):Bool;
 	@:overload static function isLetter(param1:Int):Bool;
-	@:overload static function isLetterOrDigit(param1:java.types.Char16):Bool;
+	@:overload static function isLetterOrDigit(param1:jvm.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 isLowSurrogate(param1:jvm.Char16):Bool;
+	@:overload static function isLowerCase(param1:jvm.Char16):Bool;
 	@:overload static function isLowerCase(param1:Int):Bool;
-	@:overload static function isMirrored(param1:java.types.Char16):Bool;
+	@:overload static function isMirrored(param1:jvm.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 @:deprecated static function isSpace(param1:jvm.Char16):Bool;
+	@:overload static function isSpaceChar(param1:jvm.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 isSurrogate(param1:jvm.Char16):Bool;
+	@:overload static function isSurrogatePair(param1:jvm.Char16, param2:jvm.Char16):Bool;
+	@:overload static function isTitleCase(param1:jvm.Char16):Bool;
 	@:overload static function isTitleCase(param1:Int):Bool;
-	@:overload static function isUnicodeIdentifierPart(param1:java.types.Char16):Bool;
+	@:overload static function isUnicodeIdentifierPart(param1:jvm.Char16):Bool;
 	@:overload static function isUnicodeIdentifierPart(param1:Int):Bool;
-	@:overload static function isUnicodeIdentifierStart(param1:java.types.Char16):Bool;
+	@:overload static function isUnicodeIdentifierStart(param1:jvm.Char16):Bool;
 	@:overload static function isUnicodeIdentifierStart(param1:Int):Bool;
-	@:overload static function isUpperCase(param1:java.types.Char16):Bool;
+	@:overload static function isUpperCase(param1:jvm.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:jvm.Char16):Bool;
 	@:overload static function isWhitespace(param1:Int):Bool;
-	@:overload static function lowSurrogate(param1:Int):java.types.Char16;
+	@:overload static function lowSurrogate(param1:Int):jvm.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 offsetByCodePoints(param1:java.NativeArray<jvm.Char16>, param2:Int, param3:Int, param4:Int, param5:Int):Int;
+	@:overload static function reverseBytes(param1:jvm.Char16):jvm.Char16;
+	@:overload static function toChars(param1:Int, param2:java.NativeArray<jvm.Char16>, param3:Int):Int;
+	@:overload static function toChars(param1:Int):java.NativeArray<jvm.Char16>;
+	@:overload static function toCodePoint(param1:jvm.Char16, param2:jvm.Char16):Int;
+	@:overload static function toLowerCase(param1:jvm.Char16):jvm.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;
+	@:native("toString") @:overload static function _toString(param1:jvm.Char16):String;
+	@:overload static function toTitleCase(param1:jvm.Char16):jvm.Char16;
 	@:overload static function toTitleCase(param1:Int):Int;
-	@:overload static function toUpperCase(param1:java.types.Char16):java.types.Char16;
+	@:overload static function toUpperCase(param1:jvm.Char16):jvm.Char16;
 	@:overload static function toUpperCase(param1:Int):Int;
-	@:overload static function valueOf(param1:java.types.Char16):Character;
+	@:overload static function valueOf(param1:jvm.Char16):Character;
 }
 
 @:realPath("java.lang.Character_CharacterCache") @:javaNative @:native("java.lang.Character$CharacterCache") @:javaCanonical("java.lang",
@@ -411,7 +411,7 @@ package java.lang;
 	static final YI_RADICALS:Character_UnicodeBlock;
 	static final YI_SYLLABLES:Character_UnicodeBlock;
 	@:overload final static function forName(param1:String):Character_UnicodeBlock;
-	@:overload static function of(param1:java.types.Char16):Character_UnicodeBlock;
+	@:overload static function of(param1:jvm.Char16):Character_UnicodeBlock;
 	@:overload static function of(param1:Int):Character_UnicodeBlock;
 }
 

+ 11 - 11
std/java/lang/Short.hx

@@ -26,32 +26,32 @@ package java.lang;
 @:transitive
 @:forwardStatics
 @:forward abstract Short(ShortClass) from ShortClass to ShortClass {
-	@:to extern inline public function toShort():java.types.Int16
+	@:to extern inline public function toShort():jvm.Int16
 		return this.shortValue();
 
-	@:from extern inline public static function fromShort(b:java.types.Int16):Short
+	@:from extern inline public static function fromShort(b:jvm.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 function new(param1:jvm.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;
-	static final MAX_VALUE:java.types.Int16;
-	static final MIN_VALUE:java.types.Int16;
+	static final MAX_VALUE:jvm.Int16;
+	static final MIN_VALUE:jvm.Int16;
 	static final SIZE:Int;
 	static final TYPE:Class<Short>;
-	@:overload static function compare(param1:java.types.Int16, param2:java.types.Int16):Int;
+	@:overload static function compare(param1:jvm.Int16, param2:jvm.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 static function valueOf(param1:java.types.Int16):Short;
+	@:overload @:throws("java.lang.NumberFormatException") static function parseShort(param1:String, param2:Int):jvm.Int16;
+	@:overload @:throws("java.lang.NumberFormatException") static function parseShort(param1:String):jvm.Int16;
+	@:overload static function reverseBytes(param1:jvm.Int16):jvm.Int16;
+	@:native("toString") @:overload static function _toString(param1:jvm.Int16):String;
+	@:overload static function valueOf(param1:jvm.Int16):Short;
 	@:overload @:throws("java.lang.NumberFormatException") static function valueOf(param1:String, param2:Int):Short;
 	@:overload @:throws("java.lang.NumberFormatException") static function valueOf(param1:String):Short;
 

+ 0 - 25
std/java/types/Char16.hx

@@ -1,25 +0,0 @@
-/*
- * Copyright (C)2005-2019 Haxe Foundation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-package java.types;
-
-typedef Char16 = java.StdTypes.Char16;

+ 0 - 25
std/java/types/Int16.hx

@@ -1,25 +0,0 @@
-/*
- * Copyright (C)2005-2019 Haxe Foundation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-package java.types;
-
-typedef Int16 = java.StdTypes.Int16;

+ 0 - 25
std/java/types/Int8.hx

@@ -1,25 +0,0 @@
-/*
- * Copyright (C)2005-2019 Haxe Foundation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-package java.types;
-
-typedef Int8 = java.StdTypes.Int8;

+ 0 - 83
std/java/vm/AtomicList.hx

@@ -1,83 +0,0 @@
-/*
- * Copyright (C)2005-2019 Haxe Foundation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-package java.vm;
-
-import java.util.concurrent.atomic.AtomicReference;
-
-/**
-	A lock-free queue implementation
-**/
-@:native('haxe.java.vm.AtomicList')
-@:nativeGen class AtomicList<T> {
-	@:volatile @:private var head:AtomicNode<T>;
-	@:volatile @:private var tail:AtomicReference<AtomicNode<T>>;
-
-	public function new() {
-		this.head = new AtomicNode(null);
-		this.head.set(new AtomicNode(null));
-		this.tail = new AtomicReference(head);
-	}
-
-	public function add(v:T) {
-		var n = new AtomicNode(v), tail = this.tail;
-		var p = null;
-		while (!((p = tail.get()).compareAndSet(null, n))) {
-			tail.compareAndSet(p, p.get());
-		}
-		tail.compareAndSet(p, n);
-	}
-
-	public function pop():Null<T> {
-		var p = null, pget = null, head = head;
-		do {
-			p = head.get();
-			if ((pget = p.get()) == null)
-				return null; // empty
-		} while (!head.compareAndSet(p, pget));
-
-		var ret = pget.value;
-		pget.value = null;
-		return ret;
-	}
-
-	public function peek() {
-		var ret = head.get();
-		if (ret == null)
-			return null; // empty
-		return ret.value;
-	}
-
-	public function peekLast() {
-		return tail.get().value;
-	}
-}
-
-@:native('haxe.java.vm.AtomicNode')
-@:nativeGen class AtomicNode<T> extends AtomicReference<AtomicNode<T>> {
-	public var value:T;
-
-	public function new(value) {
-		super();
-		this.value = value;
-	}
-}

+ 0 - 25
std/java/vm/Deque.hx

@@ -1,25 +0,0 @@
-/*
- * Copyright (C)2005-2019 Haxe Foundation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-package java.vm;
-
-@:deprecated typedef Deque<T> = sys.thread.Deque<T>;

+ 0 - 25
std/java/vm/Lock.hx

@@ -1,25 +0,0 @@
-/*
- * Copyright (C)2005-2019 Haxe Foundation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-package java.vm;
-
-@:deprecated typedef Lock = sys.thread.Lock;

+ 0 - 25
std/java/vm/Mutex.hx

@@ -1,25 +0,0 @@
-/*
- * Copyright (C)2005-2019 Haxe Foundation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-package java.vm;
-
-@:deprecated typedef Mutex = sys.thread.Mutex;

+ 0 - 25
std/java/vm/Thread.hx

@@ -1,25 +0,0 @@
-/*
- * Copyright (C)2005-2019 Haxe Foundation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-package java.vm;
-
-@:deprecated typedef Thread = sys.thread.Thread;

+ 0 - 25
std/java/vm/Tls.hx

@@ -1,25 +0,0 @@
-/*
- * Copyright (C)2005-2019 Haxe Foundation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-package java.vm;
-
-@:deprecated typedef Tls<T> = sys.thread.Tls<T>;

+ 3 - 0
std/jvm/Char16.hx

@@ -0,0 +1,3 @@
+package jvm;
+
+@:notNull @:runtimeValue @:coreType extern abstract Char16 from Int {}

+ 1 - 1
std/jvm/Function.hx

@@ -1,6 +1,6 @@
 package jvm;
 
-import java.NativeArray;
+import jvm.NativeArray;
 
 @:native("haxe.jvm.Function")
 @:nativeGen

+ 3 - 0
std/jvm/Int16.hx

@@ -0,0 +1,3 @@
+package jvm;
+
+@:notNull @:runtimeValue @:coreType extern abstract Int16 from Int {}

+ 1 - 27
std/java/StdTypes.hx → std/jvm/Int64.hx

@@ -1,30 +1,4 @@
-/*
- * Copyright (C)2005-2019 Haxe Foundation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-package java;
-
-@:notNull @:runtimeValue @:coreType extern abstract Int8 from Int {}
-@:notNull @:runtimeValue @:coreType extern abstract Int16 from Int {}
-@:notNull @:runtimeValue @:coreType extern abstract Char16 from Int {}
+package jvm;
 
 @:notNull @:runtimeValue @:coreType extern abstract Int64 from Int from Float {
 	@:op(A + B) public static function addI(lhs:Int64, rhs:Int):Int64;

+ 3 - 0
std/jvm/Int8.hx

@@ -0,0 +1,3 @@
+package jvm;
+
+@:notNull @:runtimeValue @:coreType extern abstract Int8 from Int {}

+ 23 - 6
std/jvm/Jvm.hx

@@ -27,11 +27,10 @@ import haxe.Constraints;
 import haxe.ds.Option;
 import haxe.ds.Vector;
 import haxe.extern.Rest;
-import java.Init;
-import java.NativeArray;
 import java.lang.NullPointerException;
 import jvm.DynamicObject;
 import jvm.EmptyConstructor;
+import jvm.NativeArray;
 import jvm.Object;
 import jvm.annotation.ClassReflectionInformation;
 import jvm.annotation.EnumReflectionInformation;
@@ -40,6 +39,20 @@ import jvm.annotation.EnumValueReflectionInformation;
 @:keep
 @:native('haxe.jvm.Jvm')
 class Jvm {
+	public static function init():Void {
+		#if std_encoding_utf8
+		try {
+			java.lang.System.setOut(new java.io.PrintStream(java.lang.System.out, true, "utf-8"));
+			java.lang.System.setErr(new java.io.PrintStream(java.lang.System.err, true, "utf-8"));
+		} catch (e:java.io.UnsupportedEncodingException) {}
+		#end
+	}
+
+	static public function getNativeType<T>(obj:T):java.lang.Class<T> {
+		var obj:java.lang.Object = (cast obj : java.lang.Object);
+		return cast obj.getClass();
+	}
+
 	extern static public function instanceof<S, T>(obj:S, type:T):Bool;
 
 	extern static public function referenceEquals<T>(v1:T, v2:T):Bool;
@@ -137,7 +150,7 @@ class Jvm {
 				}
 				continue;
 			};
-			var argType = (argValue : java.lang.Object).getClass();
+			var argType = getNativeType(argValue);
 			var arg = getWrapperClass(paramType);
 			if (arg.isAssignableFrom(argType)) {
 				callArgs[i] = args[i];
@@ -290,7 +303,7 @@ class Jvm {
 	}
 
 	static public function readFieldClosure(obj:Dynamic, name:String, parameterTypes:NativeArray<java.lang.Class<Dynamic>>):Dynamic {
-		var cl = (obj : java.lang.Object).getClass();
+		var cl = getNativeType(obj);
 		var method = cl.getMethod(name, ...parameterTypes);
 		if (method.isBridge()) {
 			/* This is probably not what we want... go through all methods and see if we find one that
@@ -323,7 +336,7 @@ class Jvm {
 	}
 
 	static public function readFieldNoObject(obj:Dynamic, name:String):Dynamic {
-		var cl = (obj : java.lang.Object).getClass();
+		var cl = getNativeType(obj);
 		try {
 			var field = cl.getField(name);
 			field.setAccessible(true);
@@ -388,7 +401,7 @@ class Jvm {
 
 	static public function writeFieldNoObject<T>(obj:Dynamic, name:String, value:T) {
 		try {
-			var cl = (obj : java.lang.Object).getClass();
+			var cl = getNativeType(obj);
 			var field = cl.getField(name);
 			field.setAccessible(true);
 			try {
@@ -614,4 +627,8 @@ class Jvm {
 		}
 		throw "Invalid operation";
 	}
+
+	extern public static inline function lock<T>(obj:Dynamic, block:T):Void {
+		untyped __lock__(obj, block);
+	}
 }

+ 39 - 7
std/java/vm/Gc.hx → std/jvm/NativeArray.hx

@@ -20,15 +20,47 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
-package java.vm;
+package jvm;
 
-@:native('haxe.java.vm.Gc') class Gc {
-	public static function run(major:Bool) {
-		java.lang.System.gc();
+import haxe.extern.Rest;
+
+/**
+	Represents a java fixed-size Array (`T[]`)
+**/
+@:nativeGen extern class NativeArray<T> implements ArrayAccess<T> {
+	/**
+		Creates a new array with the specified elements.
+
+		Usage:
+		```haxe
+		var elements = NativeArray.make(1,2,3,4,5,6);
+		```
+	**/
+	static function make<T>(elements:Rest<T>):NativeArray<T>;
+
+	static inline function ofArray<T>(arr:Array<T>) {
+		var ret = new NativeArray(arr.length);
+		for (i in 0...arr.length) {
+			ret[i] = arr[i];
+		}
+		return ret;
 	}
 
-	public static function stats():{heap:Int, free:Int} {
-		var r = java.lang.Runtime.getRuntime();
-		return {heap: cast r.totalMemory(), free: cast r.freeMemory()};
+	inline function toArray<T>() {
+		var a = [];
+		for (i in 0...length) {
+			a[i] = this[i];
+		}
+		return a;
 	}
+
+	/**
+		The length of the array
+	**/
+	var length(default, null):Int;
+
+	/**
+		Allocates a new array with size `len`
+	**/
+	function new(len:Int):Void;
 }

+ 99 - 0
std/jvm/NativeString.hx

@@ -0,0 +1,99 @@
+/*
+ * Copyright (C)2005-2019 Haxe Foundation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+package jvm;
+
+import haxe.Int64;
+import haxe.extern.Rest;
+import java.lang.CharSequence;
+import java.util.Locale;
+import jvm.Char16;
+import jvm.Int8;
+
+@:native("java.lang.String")
+extern class NativeString {
+	function charAt(index:Int):Char16;
+	function codePointAt(index:Int):Int;
+	function codePointBefore(index:Int):Int;
+	function codePointCount(beginIndex:Int, endIndex:Int):Int;
+	function compareTo(anotherString:String):Int;
+	function compareToIgnoreCase(str:String):Int;
+	function concat(str:String):String;
+	function contains(s:CharSequence):Bool;
+	@:overload function contentEquals(cs:CharSequence):Bool;
+	@:overload function contentEquals(sb:java.lang.StringBuffer):Bool;
+	@:overload static function copyValueOf(data:NativeArray<Char16>):String;
+	@:overload static function copyValueOf(data:NativeArray<Char16>, offset:Int, count:Int):String;
+	function endsWith(suffix:String):Bool;
+	function equals(anObject:Dynamic):Bool;
+	function equalsIgnoreCase(anotherString:String):Bool;
+	@:overload static function format(l:Locale, format:String, args:Rest<Dynamic>):String;
+	@:overload static function format(format:String, args:Rest<Dynamic>):String;
+	@:overload function getBytes():NativeArray<Int8>;
+	@:overload function getBytes(charset:java.nio.charset.Charset):NativeArray<Int8>;
+	@:deprecated @:overload function getBytes(srcBegin:Int, srcEnd:Int, dst:NativeArray<Int8>, dstBegin:Int):Void;
+	@:overload function getBytes(charsetName:String):NativeArray<Int8>;
+	function getChars(srcBegin:Int, srcEnd:Int, dst:NativeArray<Char16>, dstBegin:Int):Void;
+	function hashCode():Int;
+	@:overload function indexOf(ch:Int):Int;
+	@:overload function indexOf(ch:Int, fromIndex:Int):Int;
+	@:overload function indexOf(str:String):Int;
+	@:overload function indexOf(str:String, fromIndex:Int):Int;
+	function intern():String;
+	function isEmpty():Bool;
+	@:overload function lastIndexOf(ch:Int):Int;
+	@:overload function lastIndexOf(ch:Int, fromIndex:Int):Int;
+	@:overload function lastIndexOf(str:String):Int;
+	@:overload function lastIndexOf(str:String, fromIndex:Int):Int;
+	function length():Int;
+	function matches(regex:String):Bool;
+	function offsetByCodePoints(index:Int, codePointOffset:Int):Int;
+	@:overload function regionMatches(ignoreCase:Bool, toffset:Int, other:String, ooffset:Int, len:Int):Bool;
+	@:overload function regionMatches(toffset:Int, other:String, ooffset:Int, len:Int):Bool;
+	@:overload function replace(oldChar:Char16, newChar:Char16):String;
+	@:overload function replace(target:CharSequence, replacement:CharSequence):String;
+	function replaceAll(regex:String, replacement:String):String;
+	function replaceFirst(regex:String, replacement:String):String;
+	@:overload function split(regex:String):NativeArray<String>;
+	@:overload function split(regex:String, limit:Int):NativeArray<String>;
+	@:overload function startsWith(prefix:String):Bool;
+	@:overload function startsWith(prefix:String, toffset:Int):Bool;
+	function subSequence(beginIndex:Int, endIndex:Int):CharSequence;
+	@:overload function substring(beginIndex:Int):String;
+	@:overload function substring(beginIndex:Int, endIndex:Int):String;
+	function toCharArray():NativeArray<Char16>;
+	@:overload function toLowerCase():String;
+	@:overload function toLowerCase(locale:Locale):String;
+	function toString():String;
+	@:overload function toUpperCase():String;
+	@:overload function toUpperCase(locale:Locale):String;
+	function trim():String;
+	@:overload static function valueOf(b:Bool):String;
+	@:overload static function valueOf(c:Char16):String;
+	@:overload static function valueOf(data:NativeArray<Char16>):String;
+	@:overload static function valueOf(data:NativeArray<Char16>, offset:Int, count:Int):String;
+	@:overload static function valueOf(d:Float):String;
+	@:overload static function valueOf(f:String):String;
+	@:overload static function valueOf(i:Int):String;
+	@:overload static function valueOf(l:haxe.Int64):String;
+	@:overload static function valueOf(obj:java.lang.Object):String;
+}

+ 8 - 26
std/java/_std/Array.hx → std/jvm/_std/Array.hx

@@ -20,17 +20,10 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
-import java.lang.System;
-import java.NativeArray;
 import haxe.iterators.ArrayKeyValueIterator;
+import java.NativeArray;
+import java.lang.System;
 
-@:classCode('
-	public Array(T[] _native)
-	{
-		this.__a = _native;
-		this.length = _native.length;
-	}
-')
 @:coreApi final class Array<T> implements ArrayAccess<T> {
 	public var length(default, null):Int;
 
@@ -39,9 +32,6 @@ import haxe.iterators.ArrayKeyValueIterator;
 	@:skipReflection static var __hx_toString_depth = 0;
 	@:skipReflection static inline final __hx_defaultCapacity = 4;
 
-	@:functionCode('
-			return new Array<X>(_native);
-	')
 	private static function ofNative<X>(native:NativeArray<X>):Array<X> {
 		var a = new Array();
 		a.length = native.length;
@@ -49,9 +39,6 @@ import haxe.iterators.ArrayKeyValueIterator;
 		return a;
 	}
 
-	@:functionCode('
-			return new Array<Y>((Y[]) ((java.lang.Object)new java.lang.Object[size]));
-	')
 	private static function alloc<Y>(size:Int):Array<Y> {
 		var a = new Array();
 		a.length = size;
@@ -59,13 +46,11 @@ import haxe.iterators.ArrayKeyValueIterator;
 		return a;
 	}
 
-	#if jvm
 	function getNative():NativeArray<T> {
 		var a = new NativeArray(length);
 		System.arraycopy(__a, 0, a, 0, length);
 		return a;
 	}
-	#end
 
 	public function new():Void {
 		this.length = 0;
@@ -386,7 +371,7 @@ import haxe.iterators.ArrayKeyValueIterator;
 		}
 		return false;
 	}
-		
+
 	public function indexOf(x:T, ?fromIndex:Int):Int {
 		var len = length, a = __a, i:Int = (fromIndex == null) ? 0 : fromIndex;
 		if (i < 0) {
@@ -403,9 +388,7 @@ import haxe.iterators.ArrayKeyValueIterator;
 	}
 
 	public function lastIndexOf(x:T, ?fromIndex:Int):Int {
-		var len = length,
-			a = __a,
-			i:Int = (fromIndex == null) ? len - 1 : fromIndex;
+		var len = length, a = __a, i:Int = (fromIndex == null) ? len - 1 : fromIndex;
 		if (i >= len)
 			i = len - 1;
 		else if (i < 0)
@@ -430,7 +413,7 @@ import haxe.iterators.ArrayKeyValueIterator;
 		return new haxe.iterators.ArrayIterator(this);
 	}
 
-	public inline function keyValueIterator() : ArrayKeyValueIterator<T> {
+	public inline function keyValueIterator():ArrayKeyValueIterator<T> {
 		return new ArrayKeyValueIterator(this);
 	}
 
@@ -473,8 +456,7 @@ import haxe.iterators.ArrayKeyValueIterator;
 		return __a[idx];
 	}
 
-	private function __set(idx:Int, v:T):#if jvm Void #else T #end
-	{
+	private function __set(idx:Int, v:T):Void {
 		var __a = __a;
 		if (idx >= __a.length) {
 			var newl = idx + 1;
@@ -489,7 +471,7 @@ import haxe.iterators.ArrayKeyValueIterator;
 		if (idx >= length)
 			this.length = idx + 1;
 
-		#if !jvm return #end __a[idx] = v;
+		__a[idx] = v;
 	}
 
 	private inline function __unsafe_get(idx:Int):T {
@@ -499,4 +481,4 @@ import haxe.iterators.ArrayKeyValueIterator;
 	private inline function __unsafe_set(idx:Int, val:T):T {
 		return __a[idx] = val;
 	}
-}
+}

+ 0 - 0
std/java/_std/Date.hx → std/jvm/_std/Date.hx


+ 0 - 0
std/java/_std/Math.hx → std/jvm/_std/Math.hx


+ 2 - 2
std/jvm/_std/String.hx

@@ -26,8 +26,8 @@ extern class String implements java.lang.CharSequence {
 
 	@:overload(function(b:haxe.io.BytesData, offset:Int, length:Int, charsetName:String):Void {})
 	@:overload(function(b:haxe.io.BytesData, offset:Int, length:Int):Void {})
-	@:overload(function(b:java.NativeArray<java.StdTypes.Char16>):Void {})
-	@:overload(function(b:java.NativeArray<Int>, offset:Int, count:Int):Void {})
+	@:overload(function(b:jvm.NativeArray<jvm.Char16>):Void {})
+	@:overload(function(b:jvm.NativeArray<Int>, offset:Int, count:Int):Void {})
 	function new(string:String):Void;
 
 	function toUpperCase():String;

+ 1 - 1
std/jvm/_std/StringBuf.hx

@@ -51,7 +51,7 @@ class StringBuf {
 	@:overload
 	@:native("add")
 	@:ifFeature("StringBuf.add")
-	function addOpt(v:java.types.Char16):Void {
+	function addOpt(v:jvm.Char16):Void {
 		b.append(v);
 	}
 

+ 6 - 5
std/java/_std/Sys.hx → std/jvm/_std/Sys.hx

@@ -26,6 +26,7 @@ import java.nio.file.Paths;
 import sys.io.Process;
 
 using haxe.Int64;
+using jvm.NativeTools;
 
 @:coreApi class Sys {
 	private static var _args:java.NativeArray<String>;
@@ -43,7 +44,7 @@ using haxe.Int64;
 	public static function args():Array<String> {
 		if (_args == null)
 			return [];
-		return java.Lib.array(_args);
+		return @:privateAccess Array.ofNative(_args);
 	}
 
 	public static function getEnv(s:String):String {
@@ -142,7 +143,7 @@ using haxe.Int64;
 	}
 
 	public static function programPath():String {
-		final uri:URI = java.Lib.toNativeType(Sys).getProtectionDomain().getCodeSource().getLocation().toURI();
+		final uri:URI = Sys.native().getProtectionDomain().getCodeSource().getLocation().toURI();
 		return Std.string(Paths.get(uri));
 	}
 
@@ -153,14 +154,14 @@ using haxe.Int64;
 
 	public static function stdin():haxe.io.Input {
 		var _in:java.io.InputStream = Reflect.field(System, "in");
-		return new java.io.NativeInput(_in);
+		return new jvm.io.NativeInput(_in);
 	}
 
 	public static function stdout():haxe.io.Output {
-		return new java.io.NativeOutput(System.out);
+		return new jvm.io.NativeOutput(System.out);
 	}
 
 	public static function stderr():haxe.io.Output {
-		return new java.io.NativeOutput(System.err);
+		return new jvm.io.NativeOutput(System.err);
 	}
 }

+ 0 - 0
std/java/_std/haxe/Exception.hx → std/jvm/_std/haxe/Exception.hx


+ 7 - 5
std/java/_std/haxe/Int64.hx → std/jvm/_std/haxe/Int64.hx

@@ -22,11 +22,11 @@
 
 package haxe;
 
-using haxe.Int64;
-
 import haxe.Int64Helper;
 
-private typedef __Int64 = java.StdTypes.Int64;
+using haxe.Int64;
+
+private typedef __Int64 = jvm.Int64;
 
 @:coreApi
 @:transitive
@@ -129,14 +129,16 @@ abstract Int64(__Int64) from __Int64 to __Int64 {
 		return ++this;
 
 	@:op(A++) private inline function postIncrement():Int64
-		return this++;
+		return this
 
+	++;
 	@:op(--A) private inline function preDecrement():Int64
 		return --this;
 
 	@:op(A--) private inline function postDecrement():Int64
-		return this--;
+		return this
 
+	--;
 	@:op(A + B) public static inline function add(a:Int64, b:Int64):Int64
 		return a.val + b.val;
 

+ 0 - 0
std/java/_std/haxe/NativeStackTrace.hx → std/jvm/_std/haxe/NativeStackTrace.hx


+ 2 - 2
std/java/_std/haxe/Resource.hx → std/jvm/_std/haxe/Resource.hx

@@ -35,7 +35,7 @@ package haxe;
 		var stream = cast(Resource, java.lang.Class<Dynamic>).getResourceAsStream("/" + name);
 		if (stream == null)
 			return null;
-		var stream = new java.io.NativeInput(stream);
+		var stream = new jvm.io.NativeInput(stream);
 		return stream.readAll().toString();
 	}
 
@@ -45,7 +45,7 @@ package haxe;
 		var stream = cast(Resource, java.lang.Class<Dynamic>).getResourceAsStream("/" + name);
 		if (stream == null)
 			return null;
-		var stream = new java.io.NativeInput(stream);
+		var stream = new jvm.io.NativeInput(stream);
 		return stream.readAll();
 	}
 }

+ 1 - 1
std/jvm/_std/haxe/Rest.hx

@@ -28,7 +28,7 @@ abstract Rest<T>(NativeRest<T>) {
 	}
 
 	@:noDoc
-	@:from extern inline static function fromNative<T>(a:java.NativeArray<T>):Rest<T> {
+	@:from extern inline static function fromNative<T>(a:jvm.NativeArray<T>):Rest<T> {
 		return new Rest(Vector.fromData(a));
 	}
 

+ 0 - 0
std/java/_std/haxe/atomic/AtomicBool.hx → std/jvm/_std/haxe/atomic/AtomicBool.hx


+ 0 - 0
std/java/_std/haxe/atomic/AtomicInt.hx → std/jvm/_std/haxe/atomic/AtomicInt.hx


+ 0 - 0
std/java/_std/haxe/atomic/AtomicObject.hx → std/jvm/_std/haxe/atomic/AtomicObject.hx


+ 0 - 0
std/java/_std/haxe/crypto/Md5.hx → std/jvm/_std/haxe/crypto/Md5.hx


+ 0 - 0
std/java/_std/haxe/crypto/Sha1.hx → std/jvm/_std/haxe/crypto/Sha1.hx


+ 0 - 0
std/java/_std/haxe/crypto/Sha256.hx → std/jvm/_std/haxe/crypto/Sha256.hx


+ 0 - 0
std/java/_std/haxe/ds/ObjectMap.hx → std/jvm/_std/haxe/ds/ObjectMap.hx


+ 0 - 0
std/java/_std/haxe/ds/WeakMap.hx → std/jvm/_std/haxe/ds/WeakMap.hx


+ 0 - 0
std/java/_std/haxe/zip/Compress.hx → std/jvm/_std/haxe/zip/Compress.hx


+ 0 - 0
std/java/_std/haxe/zip/Uncompress.hx → std/jvm/_std/haxe/zip/Uncompress.hx


+ 2 - 5
std/java/_std/sys/FileSystem.hx → std/jvm/_std/sys/FileSystem.hx

@@ -23,7 +23,6 @@
 package sys;
 
 import java.io.File;
-import java.Lib;
 
 @:coreApi
 class FileSystem {
@@ -59,9 +58,7 @@ class FileSystem {
 				size: cast(attributes.get("size"), Int),
 				uid: attributes.get("uid"),
 			};
-		}
-
-		catch (e) {
+		} catch (e) {
 			return {
 				gid: 0, // java doesn't let you get this info
 				uid: 0, // same
@@ -119,6 +116,6 @@ class FileSystem {
 		var f = new File(path);
 		if (!f.exists())
 			throw "Path " + path + " doesn't exist";
-		return Lib.array(f.list());
+		return @:privateAccess Array.ofNative(f.list());
 	}
 }

+ 0 - 0
std/java/_std/sys/io/File.hx → std/jvm/_std/sys/io/File.hx


+ 0 - 0
std/java/_std/sys/io/FileInput.hx → std/jvm/_std/sys/io/FileInput.hx


+ 0 - 0
std/java/_std/sys/io/FileOutput.hx → std/jvm/_std/sys/io/FileOutput.hx


+ 4 - 5
std/java/_std/sys/io/Process.hx → std/jvm/_std/sys/io/Process.hx

@@ -26,9 +26,9 @@ import haxe.SysTools;
 import haxe.io.Bytes;
 import haxe.io.BytesInput;
 import haxe.io.Eof;
-import java.io.IOException;
-import java.io.EOFException;
 import java.NativeArray;
+import java.io.EOFException;
+import java.io.IOException;
 
 @:coreApi
 class Process {
@@ -84,7 +84,7 @@ class Process {
 		var p = proc = createProcessBuilder(cmd, args).start();
 		stderr = new ProcessInput(p.getErrorStream());
 		stdout = new ProcessInput(p.getInputStream());
-		stdin = new java.io.NativeOutput(p.getOutputStream());
+		stdin = new jvm.io.NativeOutput(p.getOutputStream());
 	}
 
 	public function getPid():Int {
@@ -121,7 +121,7 @@ class Process {
 	}
 }
 
-private class ProcessInput extends java.io.NativeInput {
+private class ProcessInput extends jvm.io.NativeInput {
 	private var chained:BytesInput;
 
 	public function bufferContents():Void {
@@ -153,7 +153,6 @@ private class ProcessInput extends java.io.NativeInput {
 		try {
 			ret = stream.read(s.getData(), pos, len);
 		} catch (e:EOFException) {
-
 			throw new Eof();
 		} catch (e:IOException) {
 			throw haxe.io.Error.Custom(e);

+ 0 - 0
std/java/_std/sys/net/Host.hx → std/jvm/_std/sys/net/Host.hx


+ 4 - 4
std/java/_std/sys/net/Socket.hx → std/jvm/_std/sys/net/Socket.hx

@@ -68,8 +68,8 @@ class Socket {
 	public function connect(host:Host, port:Int):Void {
 		try {
 			sock.connect(new InetSocketAddress(host.wrapped, port));
-			this.output = new java.io.NativeOutput(sock.getOutputStream());
-			this.input = new java.io.NativeInput(sock.getInputStream());
+			this.output = new jvm.io.NativeOutput(sock.getOutputStream());
+			this.input = new jvm.io.NativeInput(sock.getInputStream());
 		} catch (e:Dynamic)
 			throw e;
 	}
@@ -106,8 +106,8 @@ class Socket {
 
 		var s = new Socket();
 		s.sock = ret;
-		s.output = new java.io.NativeOutput(ret.getOutputStream());
-		s.input = new java.io.NativeInput(ret.getInputStream());
+		s.output = new jvm.io.NativeOutput(ret.getOutputStream());
+		s.input = new jvm.io.NativeInput(ret.getInputStream());
 
 		return s;
 	}

+ 0 - 0
std/java/_std/sys/thread/Condition.hx → std/jvm/_std/sys/thread/Condition.hx


+ 0 - 2
std/java/_std/sys/thread/Deque.hx → std/jvm/_std/sys/thread/Deque.hx

@@ -22,8 +22,6 @@
 
 package sys.thread;
 
-import java.Lib;
-
 @:coreApi
 @:native('haxe.java.vm.Deque')
 @:nativeGen class Deque<T> {

+ 0 - 0
std/java/_std/sys/thread/Mutex.hx → std/jvm/_std/sys/thread/Mutex.hx


+ 0 - 0
std/java/_std/sys/thread/Semaphore.hx → std/jvm/_std/sys/thread/Semaphore.hx


+ 26 - 40
std/java/_std/sys/thread/Thread.hx → std/jvm/_std/sys/thread/Thread.hx

@@ -22,26 +22,25 @@
 
 package sys.thread;
 
-import java.Lib;
 import java.lang.Runnable;
-import java.util.WeakHashMap;
-import java.util.Collections;
-import java.lang.Thread as JavaThread;
 import java.lang.System;
-import java.StdTypes.Int64 as Long;
-import java.util.concurrent.atomic.AtomicInteger;
+import java.lang.Thread as JavaThread;
+import java.util.Collections;
+import java.util.WeakHashMap;
 import java.util.concurrent.LinkedBlockingDeque;
+import java.util.concurrent.atomic.AtomicInteger;
+import jvm.Int64 as Long;
 
 private typedef ThreadImpl = HaxeThread;
 
 abstract Thread(ThreadImpl) from ThreadImpl {
-	public var events(get,never):EventLoop;
+	public var events(get, never):EventLoop;
 
 	inline function new(t:HaxeThread) {
 		this = t;
 	}
 
-	public static inline function create(job:()->Void):Thread {
+	public static inline function create(job:() -> Void):Thread {
 		return HaxeThread.create(job, false);
 	}
 
@@ -49,11 +48,11 @@ abstract Thread(ThreadImpl) from ThreadImpl {
 		return HaxeThread.get(JavaThread.currentThread());
 	}
 
-	public static inline function runWithEventLoop(job:()->Void):Void {
+	public static inline function runWithEventLoop(job:() -> Void):Void {
 		HaxeThread.runWithEventLoop(job);
 	}
 
-	public static inline function createWithEventLoop(job:()->Void):Thread {
+	public static inline function createWithEventLoop(job:() -> Void):Thread {
 		return HaxeThread.create(job, true);
 	}
 
@@ -70,24 +69,24 @@ abstract Thread(ThreadImpl) from ThreadImpl {
 	}
 
 	function get_events():EventLoop {
-		if(this.events == null)
+		if (this.events == null)
 			throw new NoEventLoopException();
 		return this.events;
 	}
 
-	@:keep //TODO: keep only if events are actually used
+	@:keep // TODO: keep only if events are actually used
 	static function processEvents():Void {
 		current().getHandle().events.loop();
 	}
 }
 
 private class HaxeThread {
-	static var nativeThreads:java.util.Map<JavaThread,HaxeThread>;
+	static var nativeThreads:java.util.Map<JavaThread, HaxeThread>;
 	static var mainJavaThread:JavaThread;
 	static var mainHaxeThread:HaxeThread;
 
 	static function __init__() {
-		nativeThreads = Collections.synchronizedMap(new WeakHashMap<JavaThread,HaxeThread>());
+		nativeThreads = Collections.synchronizedMap(new WeakHashMap<JavaThread, HaxeThread>());
 		mainJavaThread = JavaThread.currentThread();
 		mainHaxeThread = new HaxeThread();
 		mainHaxeThread.events = new EventLoop();
@@ -95,11 +94,11 @@ private class HaxeThread {
 
 	public final messages = new LinkedBlockingDeque<Dynamic>();
 
-	public var events(default,null):Null<EventLoop>;
+	public var events(default, null):Null<EventLoop>;
 
-	public static function create(job:()->Void, withEventLoop:Bool):HaxeThread {
+	public static function create(job:() -> Void, withEventLoop:Bool):HaxeThread {
 		var hx = new HaxeThread();
-		if(withEventLoop)
+		if (withEventLoop)
 			hx.events = new EventLoop();
 		var thread = new NativeHaxeThread(hx, job, withEventLoop);
 		thread.setDaemon(true);
@@ -108,10 +107,10 @@ private class HaxeThread {
 	}
 
 	public static function get(javaThread:JavaThread):HaxeThread {
-		if(javaThread == mainJavaThread) {
+		if (javaThread == mainJavaThread) {
 			return mainHaxeThread;
-		} else if(javaThread is NativeHaxeThread) {
-			return (cast javaThread:NativeHaxeThread).haxeThread;
+		} else if (javaThread is NativeHaxeThread) {
+			return (cast javaThread : NativeHaxeThread).haxeThread;
 		} else {
 			switch nativeThreads.get(javaThread) {
 				case null:
@@ -124,15 +123,15 @@ private class HaxeThread {
 		}
 	}
 
-	public static function runWithEventLoop(job:()->Void):Void {
+	public static function runWithEventLoop(job:() -> Void):Void {
 		var thread = get(JavaThread.currentThread());
-		if(thread.events == null) {
+		if (thread.events == null) {
 			thread.events = new EventLoop();
 			try {
 				job();
 				thread.events.loop();
 				thread.events = null;
-			} catch(e) {
+			} catch (e) {
 				thread.events = null;
 				throw e;
 			}
@@ -154,9 +153,10 @@ private class HaxeThread {
 
 private class NativeHaxeThread extends java.lang.Thread {
 	public final haxeThread:HaxeThread;
+
 	final withEventLoop:Bool;
 
-	public function new(haxeThread:HaxeThread, job:()->Void, withEventLoop:Bool) {
+	public function new(haxeThread:HaxeThread, job:() -> Void, withEventLoop:Bool) {
 		super(new Job(job));
 		this.haxeThread = haxeThread;
 		this.withEventLoop = withEventLoop;
@@ -164,27 +164,13 @@ private class NativeHaxeThread extends java.lang.Thread {
 
 	override overload public function run() {
 		super.run();
-		if(withEventLoop)
+		if (withEventLoop)
 			haxeThread.events.loop();
 	}
 }
 
-#if jvm
 private abstract Job(Runnable) from Runnable to Runnable {
-	public inline function new(job:()->Void) {
+	public inline function new(job:() -> Void) {
 		this = cast job;
 	}
 }
-#else
-private class Job implements Runnable {
-	final job:()->Void;
-
-	public function new(job:()->Void) {
-		this.job = job;
-	}
-
-	public function run() {
-		job();
-	}
-}
-#end

+ 0 - 0
std/java/_std/sys/thread/Tls.hx → std/jvm/_std/sys/thread/Tls.hx


+ 1 - 1
std/jvm/annotation/EnumReflectionInformation.hx

@@ -26,5 +26,5 @@ package jvm.annotation;
 @:native("haxe.jvm.annotation.EnumReflectionInformation")
 @:keep
 interface EnumReflectionInformation extends java.lang.annotation.Annotation {
-	function constructorNames():java.NativeArray<String>;
+	function constructorNames():jvm.NativeArray<String>;
 }

+ 1 - 1
std/jvm/annotation/EnumValueReflectionInformation.hx

@@ -26,5 +26,5 @@ package jvm.annotation;
 @:native("haxe.jvm.annotation.EnumValueReflectionInformation")
 @:keep
 interface EnumValueReflectionInformation extends java.lang.annotation.Annotation {
-	function argumentNames():java.NativeArray<String>;
+	function argumentNames():jvm.NativeArray<String>;
 }

+ 2 - 3
std/java/io/NativeInput.hx → std/jvm/io/NativeInput.hx

@@ -20,14 +20,14 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
-package java.io;
+package jvm.io;
 
 import haxe.Int64;
 import haxe.io.Bytes;
 import haxe.io.Eof;
 import haxe.io.Input;
-import java.io.IOException;
 import java.io.EOFException;
+import java.io.IOException;
 
 @:native('haxe.java.io.NativeInput') class NativeInput extends Input {
 	var stream:java.io.InputStream;
@@ -53,7 +53,6 @@ import java.io.EOFException;
 		try {
 			ret = stream.read(s.getData(), pos, len);
 		} catch (e:EOFException) {
-
 			throw new Eof();
 		} catch (e:IOException) {
 			throw haxe.io.Error.Custom(e);

+ 2 - 3
std/java/io/NativeOutput.hx → std/jvm/io/NativeOutput.hx

@@ -20,14 +20,14 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
-package java.io;
+package jvm.io;
 
 import haxe.Int64;
 import haxe.io.Bytes;
 import haxe.io.Eof;
 import haxe.io.Output;
-import java.io.IOException;
 import java.io.EOFException;
+import java.io.IOException;
 
 @:native('haxe.java.io.NativeOutput') class NativeOutput extends Output {
 	var stream:java.io.OutputStream;
@@ -40,7 +40,6 @@ import java.io.EOFException;
 		try {
 			stream.write(c);
 		} catch (e:EOFException) {
-
 			throw new Eof();
 		} catch (e:IOException) {
 			throw haxe.io.Error.Custom(e);

+ 1 - 1
std/java/net/SslSocket.hx → std/jvm/net/SslSocket.hx

@@ -20,7 +20,7 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
-package java.net;
+package jvm.net;
 
 @:native('haxe.java.net.SslSocket') class SslSocket extends sys.net.Socket {
 	override private function create():Void {

+ 1 - 1
std/sys/Http.hx

@@ -103,7 +103,7 @@ class Http extends haxe.http.HttpBase {
 				#if php
 				sock = new php.net.SslSocket();
 				#elseif java
-				sock = new java.net.SslSocket();
+				sock = new jvm.net.SslSocket();
 				#elseif python
 				sock = new python.net.SslSocket();
 				#elseif (!no_ssl && (hxssl || hl || cpp || (neko && !(macro || interp) || eval) || (lua && !lua_vanilla)))

+ 7 - 5
tests/unit/src/unit/TestJava.hx

@@ -13,6 +13,8 @@ import haxe.test.TEnum;
 import java.util.EnumSet;
 import java.vm.*;
 
+using jvm.NativeTools;
+
 #if jvm
 @:strict(haxe.test.MyClass.MyClass_MyAnnotation({author: "John Doe", someEnum: TB}))
 @:strict(MyClass_ParameterLessAnnotation)
@@ -84,15 +86,15 @@ class TestJava extends Test {
 
 	@:strict(MyClass_MyAnnotation({author: "author", currentRevision: 2}))
 	public function testAnnotations() {
-		var cl = java.Lib.toNativeType(TestJava);
-		var a = cl.getAnnotation(java.Lib.toNativeType(MyClass_MyAnnotation));
+		var cl = TestJava.native();
+		var a = cl.getAnnotation(MyClass_MyAnnotation.native());
 		t(a != null);
 		eq(a.author(), "John Doe");
 		eq(a.someEnum(), TB);
 		eq(a.currentRevision(), 1);
-		t(cl.getAnnotation(java.Lib.toNativeType(MyClass_ParameterLessAnnotation)) != null);
+		t(cl.getAnnotation(MyClass_ParameterLessAnnotation.native()) != null);
 		var m = cl.getMethod("testAnnotations");
-		a = m.getAnnotation(java.Lib.toNativeType(MyClass_MyAnnotation));
+		a = m.getAnnotation(MyClass_MyAnnotation.native());
 		t(a != null);
 		eq(a.author(), "author");
 		eq(a.someEnum(), TC);
@@ -110,7 +112,7 @@ class TestJava extends Test {
 	}
 
 	function testEnumSet() {
-		var es1:EnumSet<TEnum> = EnumSet.noneOf(java.Lib.toNativeEnum(TEnum));
+		var es1:EnumSet<TEnum> = EnumSet.noneOf(TEnum.native());
 		f(es1.contains(TA));
 		es1.add(TA);
 		t(es1.contains(TA));

+ 3 - 1
tests/unit/src/unit/TestNumericCasts.hx

@@ -1,8 +1,10 @@
 // This file is auto-generated from RunCastGenerator.hx - do not edit!
 package unit;
 #if jvm
-import java.StdTypes;
+import jvm.Int16;
+import jvm.Int8;
 private typedef Int32 = Int;
+private typedef Int64 = haxe.Int64;
 private typedef Float32 = Single;
 private typedef Float64 = Float;
 #else

+ 1 - 1
tests/unit/src/unit/issues/Issue10397.hx

@@ -8,7 +8,7 @@ private class NotMain {
 	static public function gather() {
 		final main = new NotMain();
 
-		final cls = java.Lib.getNativeType(main);
+		final cls = jvm.Jvm.getNativeType(main);
 
 		final classAnnotations = [];
 		final methods = new Map();

+ 2 - 3
tests/unit/src/unit/issues/Issue2049.hx

@@ -1,7 +1,6 @@
 package unit.issues;
 #if jvm
-import java.NativeArray;
-import java.Lib;
+import jvm.NativeArray;
 #end
 
 class Issue2049 extends unit.Test
@@ -10,7 +9,7 @@ class Issue2049 extends unit.Test
 	public function test()
 	{
 		var arr = [ 1., 1., 1., 0.5 ].map( function( n: Float ): Single { return n; });
-		var scaleFactors:NativeArray<Single> = Lib.nativeArray( arr, true );
+		var scaleFactors = haxe.ds.Vector.fromArrayCopy( arr);
 		eq(1.,scaleFactors[0]);
 		eq(1.,scaleFactors[1]);
 		eq(1.,scaleFactors[2]);

+ 2 - 2
tests/unit/src/unit/issues/Issue2772.hx

@@ -6,9 +6,9 @@ class Issue2772 extends Test
 	public function test()
 	{
 		var f = false;
-		java.Lib.lock(Issue2772, f = true);
+		jvm.Jvm.lock(Issue2772, f = true);
 		t(f);
-		java.Lib.lock(this, f = false);
+		jvm.Jvm.lock(this, f = false);
 		this.f(f);
 	}
 #end

+ 15 - 17
tests/unit/src/unit/issues/Issue2927.hx

@@ -1,24 +1,22 @@
 package unit.issues;
+
 #if jvm
-import java.Lib;
-import java.NativeArray;
+import jvm.NativeArray;
 #end
 
 class Issue2927 extends Test {
-#if jvm
-	public function test()
-	{
-		var arr = Lib.array(new NativeArray<Int>(1));
-		eq(arr.length,1);
-		var arr = Lib.array(new NativeArray<Float>(1));
-		eq(arr.length,1);
-		var arr = Lib.array(new NativeArray<Single>(1));
-		eq(arr.length,1);
-		var arr = Lib.array(new NativeArray<haxe.io.Bytes>(1));
-		eq(arr.length,1);
-		var arr = Lib.array(new NativeArray<haxe.Int64>(1));
-		eq(arr.length,1);
+	#if jvm
+	public function test() {
+		var arr = new NativeArray<Int>(1).toArray();
+		eq(arr.length, 1);
+		var arr = new NativeArray<Float>(1).toArray();
+		eq(arr.length, 1);
+		var arr = new NativeArray<Single>(1).toArray();
+		eq(arr.length, 1);
+		var arr = new NativeArray<haxe.io.Bytes>(1).toArray();
+		eq(arr.length, 1);
+		var arr = new NativeArray<haxe.Int64>(1).toArray();
+		eq(arr.length, 1);
 	}
-#end
+	#end
 }
-

+ 1 - 1
tests/unit/src/unit/issues/Issue9220.hx

@@ -5,7 +5,7 @@ import unit.Test;
 class Issue9220 extends Test {
 	#if jvm
 	public function test() {
-		eq("12.200", java.NativeString.format(java.util.Locale.US, '%.3f', 12.2));
+		eq("12.200", jvm.NativeString.format(java.util.Locale.US, '%.3f', 12.2));
 	}
 	#end
 }