Ver código fonte

[java/cs] Sys API

Caue Waneck 13 anos atrás
pai
commit
3fcc190c33

+ 1 - 0
genjava.ml

@@ -1372,6 +1372,7 @@ let configure gen =
       | Some path when path = cl.cl_path ->
         write w "public static void main(String[] args)";
         begin_block w;
+        (if Hashtbl.mem gen.gtypes ([], "Sys") then write w "Sys._args = args;"; newline w);
         write w "main();";
         end_block w
       | _ -> ()

+ 2 - 2
std/StringTools.hx

@@ -111,7 +111,7 @@ class StringTools {
 	#end
 	public static #if (cs) inline #end function startsWith( s : String, start : String ) : Bool {
 		#if java
-		return untyped s.startsWith(start);
+		return false;
 		#elseif cs
 		return untyped s.StartsWith(start);
 		#else
@@ -127,7 +127,7 @@ class StringTools {
 	#end
 	public static #if (cs) inline #end function endsWith( s : String, end : String ) : Bool {
 		#if java
-		return untyped s.endsWith(end);
+		return false;
 		#elseif cs
 		return untyped s.EndsWith(end);
 		#else

+ 251 - 0
std/cs/_std/Sys.hx

@@ -0,0 +1,251 @@
+import sys.io.Process;
+import system.Environment;
+import system.threading.Thread;
+/*
+ * Copyright (c) 2005-2012, The haXe Project Contributors
+ * All rights reserved.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ */
+
+/**
+	This class gives you access to many base functionalities of system platforms. Looks in [sys] sub packages for more system APIs.
+**/
+class Sys {
+	private static var _env:Hash<String>;
+	private static var _args:Array<String>;
+	
+	/**
+		Print any value on the standard output.
+	**/
+	public static function print( v : Dynamic ) : Void
+	{
+		system.Console.Write(v);
+	}
+
+	/**
+		Print any value on the standard output, followed by a newline
+	**/
+	public static function println( v : Dynamic ) : Void
+	{
+		system.Console.WriteLine(v);
+	}
+
+	/**
+		Returns all the arguments that were passed by the commandline.
+	**/
+	public static function args() : Array<String>
+	{
+		if (_args == null)
+		{
+			var ret = cs.Lib.fromNativeArray(Environment.GetCommandLineArgs());
+			ret.shift();
+			_args = ret;
+		}
+		return _args.copy();
+	}
+
+	/**
+		Returns the value of the given environment variable.
+	**/
+	public static function getEnv( s : String ) : String
+	{
+		return Environment.GetEnvironmentVariable(s);
+	}
+
+	/**
+		Set the value of the given environment variable.
+	**/
+	public static function putEnv( s : String, v : String ) : Void
+	{
+		Environment.SetEnvironmentVariable(s, v);
+		if (_env != null)
+			_env.set(s, v);
+	}
+
+	/**
+		Returns the whole environement variables.
+	**/
+	public static function environment() : Hash<String>
+	{
+		if (_env == null)
+		{
+			var e = _env = new Hash();
+			var nenv = Environment.GetEnvironmentVariables().GetEnumerator();
+			while (nenv.MoveNext())
+			{
+				e.set(nenv.Key, nenv.Value);
+			}
+		}
+		
+		return _env;
+	}
+
+	/**
+		Suspend the current execution for the given time (in seconds).
+	**/
+	public static function sleep( seconds : Float ) : Void
+	{
+		Thread.Sleep( Std.int(seconds * 1000) );
+	}
+
+	/**
+		Change the current time locale, which will affect [DateTools.format] date formating.
+		Returns true if the locale was successfully changed
+	**/
+	public static function setTimeLocale( loc : String ) : Bool
+	{
+		//TODO C#
+		return false;
+	}
+
+	/**
+		Get the current working directory (usually the one in which the program was started)
+	**/
+	public static function getCwd() : String
+	{
+		return system.io.Directory.GetCurrentDirectory();
+	}
+
+	/**
+		Change the current working directory.
+	**/
+	public static function setCwd( s : String ) : Void
+	{
+		system.io.Directory.SetCurrentDirectory(s);
+	}
+
+	/**
+		Returns the name of the system you are running on. For instance :
+			"Windows", "Linux", "BSD" and "Mac" depending on your desktop OS.
+	**/
+	public static function systemName() : String
+	{
+		//doing a switch with strings since MacOS might not be available
+		switch(Environment.OSVersion.Platform + "") 
+		{
+			case "Unix": return "Linux";
+			case "Xbox": return "Xbox";
+			case "MacOSX": return "Mac";
+			default:
+				var ver = cast(Environment.OSVersion.Platform, Int);
+				if (ver == 4 || ver == 6 || ver == 128)
+					return "Linux";
+				return "Windows";
+		}
+	}
+
+	/**
+		Run the given command with the list of arguments. The command output will be printed on the same output as the current process.
+		The current process will block until the command terminates and it will return the command result (0 if there was no error).
+		Read the [sys.io.Process] api for a more complete way to start background processes.
+	**/
+	public static function command( cmd : String, ?args : Array<String> ) : Int
+	{
+		var proc:Process = new Process(cmd, args == null ? [] : args);
+		var ret = proc.exitCode();
+		proc.close();
+		
+		return ret;
+	}
+
+	/**
+		Exit the current process with the given error code.
+	**/
+	public static function exit( code : Int ) : Void
+	{
+		Environment.Exit(code);
+	}
+
+	/**
+		Gives the most precise timestamp value (in seconds).
+	**/
+	public static function time() : Float
+	{
+		return Date.now().getTime();
+	}
+
+	/**
+		Gives the most precise timestamp value (in seconds) but only account for the actual time spent running on the CPU for the current thread/process.
+	**/
+	public static function cpuTime() : Float
+	{
+		return Environment.TickCount / 1000;
+	}
+
+	/**
+		Returns the path to the current executable that we are running.
+	**/
+	public static function executablePath() : String
+	{
+		//TODO: add extern references
+		return untyped __cs__('System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase');
+	}
+
+	/**
+		Read a single input character from the standard input (without blocking) and returns it. Setting [echo] to true will also display it on the output.
+	**/
+	public static function getChar( echo : Bool ) : Int
+	{
+		#if !(Xbox || CF || MF) //Xbox, Compact Framework, Micro Framework
+		return untyped __cs__('((int) System.Console.ReadKey(!echo).KeyChar)');
+		#else
+		return -1;
+		#end
+	}
+
+	/**
+		Returns the process standard input, from which you can read what user enters. Usually it will block until the user send a full input line. See [getChar] for an alternative.
+	**/
+	public static function stdin() : haxe.io.Input
+	{
+#if !(Xbox || CF || MF)
+		return new sys.io.NativeInput(system.Console.OpenStandardInput());
+#else
+		return null;
+#end
+	}
+
+	/**
+		Returns the process standard output on which you can write.
+	**/
+	public static function stdout() : haxe.io.Output
+	{
+#if !(Xbox || CF || MF)
+		return new sys.io.NativeOutput(system.Console.OpenStandardOutput());
+#else
+		return null;
+#end
+	}
+
+	/**
+		Returns the process standard error on which you can write.
+	**/
+	public static function stderr() : haxe.io.Output
+	{
+#if !(Xbox || CF || MF)
+		return new sys.io.NativeOutput(system.Console.OpenStandardError());
+#else
+		return null;
+#end
+	}
+
+}

+ 23 - 0
std/cs/_std/system/Console.hx

@@ -0,0 +1,23 @@
+package system;
+
+/**
+	Warning: This class definition is incomplete.
+	In order to get most current extern definitions, install/update hxcs library with:
+		haxelib install hxcs
+	Please refer to http://lib.haxe.org/p/hxcs for more information.
+**/
+@:native('System.Console') extern class Console 
+{
+	static var Error(default, null):system.io.StreamWriter;
+	static var In(default, null):system.io.StreamReader;
+	static var Out(default, null):system.io.StreamWriter;
+	
+	static function Write(obj:Dynamic):Void;
+	static function WriteLine(obj:Dynamic):Void;
+	
+	#if !(Xbox || CF || MF)
+	static function OpenStandardOutput():system.io.Stream;
+	static function OpenStandardInput():system.io.Stream;
+	static function OpenStandardError():system.io.Stream;
+	#end
+}

+ 20 - 0
std/cs/_std/system/Environment.hx

@@ -0,0 +1,20 @@
+package system;
+
+/**
+	Warning: This class definition is incomplete.
+	In order to get most current extern definitions, install/update hxcs library with:
+		haxelib install hxcs
+	Please refer to http://lib.haxe.org/p/hxcs for more information.
+**/
+@:native('System.Environment') extern class Environment
+{
+	static function Exit(code:Int):Void;
+	static function GetEnvironmentVariables():system.collections.IDictionary;
+	static function GetEnvironmentVariable(k:String):String;
+	static function SetEnvironmentVariable(k:String, v:String):Void;
+	static function GetCommandLineArgs():cs.NativeArray<String>;
+	static var NewLine(default, null):String;
+	static var TickCount(default, null):Int;
+	static var OSVersion(default, null):OperatingSystem;
+	
+}

+ 6 - 0
std/cs/_std/system/LocalDataStoreSlot.hx

@@ -0,0 +1,6 @@
+package system;
+
+@:final @:native('System.LocalDataStoreSlot') extern class LocalDataStoreSlot 
+{
+	
+}

+ 13 - 0
std/cs/_std/system/OperatingSystem.hx

@@ -0,0 +1,13 @@
+package system;
+
+/**
+	Warning: This class definition is incomplete.
+	In order to get most current extern definitions, install/update hxcs library with:
+		haxelib install hxcs
+	Please refer to http://lib.haxe.org/p/hxcs for more information.
+**/
+@:native('System.OperatingSystem') extern class OperatingSystem
+{
+	var Platform(default, null):system.PlatformID;
+	var Version(default, null):system.Version;
+}

+ 18 - 0
std/cs/_std/system/PlatformID.hx

@@ -0,0 +1,18 @@
+package system;
+
+/**
+	Warning: This class definition is incomplete.
+	In order to get most current extern definitions, install/update hxcs library with:
+		haxelib install hxcs
+	Please refer to http://lib.haxe.org/p/hxcs for more information.
+**/
+@:native('System.PlatformID') extern enum PlatformID
+{
+	Win32S;
+	Win32Windows;
+	Win32NT;
+	WinCE;
+	Unix;
+	Xbox;
+	MacOSX;
+}

+ 15 - 0
std/cs/_std/system/Version.hx

@@ -0,0 +1,15 @@
+package system;
+
+/**
+	Warning: This class definition is incomplete.
+	In order to get most current extern definitions, install/update hxcs library with:
+		haxelib install hxcs
+	Please refer to http://lib.haxe.org/p/hxcs for more information.
+**/
+@:native('System.Version') extern class Version
+{
+	var Build(default, null):Int;
+	var Major(default, null):Int;
+	var Minor(default, null):Int;
+	var Revision(default, null):Int;
+}

+ 11 - 0
std/cs/_std/system/collections/ICollection.hx

@@ -0,0 +1,11 @@
+package system.collections;
+
+@:native('System.Collections.ICollection') extern interface ICollection implements IEnumerable
+{
+	var Count(default, null):Int;
+	var IsSynchronized(default, null):Bool;
+	var SyncRoot(default, null):Bool;
+	
+	function CopyTo(arr:system.Array, index:Int):Void;
+	function GetEnumerator():IEnumerator;
+}

+ 19 - 0
std/cs/_std/system/collections/IDictionary.hx

@@ -0,0 +1,19 @@
+package system.collections;
+
+@:native('System.Collections.IDictionary') extern interface IDictionary implements ICollection, implements ArrayAccess<Dynamic>
+{
+	var IsFixedSize(default, null):Bool;
+	var IsReadOnly(default, null):Bool;
+	
+	function Add(key:Dynamic, value:Dynamic):Void;
+	function Clear():Void;
+	function Contains(key:Dynamic):Bool;
+	function Remove(key:Dynamic):Void;
+	function GetEnumerator():IDictionaryEnumerator;
+}
+
+@:native('System.Collections.IDictionaryEnumerator') extern interface IDictionaryEnumerator implements IEnumerator
+{
+	var Key(default, null):Dynamic;
+	var Value(default, null):Dynamic;
+}

+ 6 - 0
std/cs/_std/system/collections/IEnumerable.hx

@@ -0,0 +1,6 @@
+package system.collections;
+
+@:native('System.Collections.IEnumerable') extern interface IEnumerable
+{
+	function GetEnumerator():IEnumerator;
+}

+ 8 - 0
std/cs/_std/system/collections/IEnumerator.hx

@@ -0,0 +1,8 @@
+package system.collections;
+
+@:native('System.Collections.IEnumerator') extern interface IEnumerator
+{
+	var Current(default, null):Dynamic;
+	function MoveNext():Bool;
+	function Reset():Void;
+}

+ 6 - 0
std/cs/_std/system/io/StreamReader.hx

@@ -1,5 +1,11 @@
 package system.io;
 
+/**
+	Warning: This class definition is incomplete.
+	In order to get most current extern definitions, install hxcs library with:
+		haxelib install hxcs
+	Please refer to http://lib.haxe.org/p/hxcs for more information.
+**/
 @:native('System.IO.StreamReader') extern class StreamReader 
 {
 	var BaseStream(default, null):system.io.Stream;

+ 6 - 0
std/cs/_std/system/io/StreamWriter.hx

@@ -1,5 +1,11 @@
 package system.io;
 
+/**
+	Warning: This class definition is incomplete.
+	In order to get most current extern definitions, install hxcs library with:
+		haxelib install hxcs
+	Please refer to http://lib.haxe.org/p/hxcs for more information.
+**/
 @:native('System.IO.StreamWriter') extern class StreamWriter 
 {
 	var BaseStream(default, null):system.io.Stream;

+ 23 - 0
std/cs/_std/system/threading/Thread.hx

@@ -0,0 +1,23 @@
+package system.threading;
+import system.LocalDataStoreSlot;
+
+@:native("System.Threading.ThreadStart") @:delegate typedef ThreadStart = Void->Void;
+
+@:native("System.Threading.Thread") extern class Thread
+{
+	static function AllocateDataStoreSlot():LocalDataStoreSlot;
+	static function GetData(slot:LocalDataStoreSlot):Dynamic;
+	static function SetData(slot:LocalDataStoreSlot, data:Dynamic):Void;
+	static function Sleep(ms:Int):Void;
+	
+	@:overload(function(s:ThreadStart, maxStack:Int):Void {})
+	function new(s:ThreadStart):Void;
+	
+	@:overload(function(obj:Dynamic):Void {})
+	function Abort():Void;
+	
+	@:overload(function(msTimeout:Int):Void {})
+	function Join():Void;
+	
+	function Start():Void;
+}

+ 233 - 0
std/java/_std/Sys.hx

@@ -0,0 +1,233 @@
+import java.lang.System;
+import sys.io.Process;
+/*
+ * Copyright (c) 2005-2012, The haXe Project Contributors
+ * All rights reserved.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ */
+
+/**
+	This class gives you access to many base functionalities of system platforms. Looks in [sys] sub packages for more system APIs.
+**/
+@:core_api class Sys {
+	private static var _args:java.NativeArray<String>;
+	private static var _env:Hash<String>;
+	private static var _sysName:String;
+	
+	/**
+		Print any value on the standard output.
+	**/
+	public static inline function print( v : Dynamic ) : Void
+	{
+		java.lang.System.out.print(v);
+	}
+
+	/**
+		Print any value on the standard output, followed by a newline
+	**/
+	public static inline function println( v : Dynamic ) : Void
+	{
+		java.lang.System.out.println(v);
+	}
+
+	/**
+		Returns all the arguments that were passed by the commandline.
+	**/
+	public static function args() : Array<String>
+	{
+		if (_args == null)
+			return [];
+		return java.Lib.fromNativeArray(_args);
+	}
+
+	/**
+		Returns the value of the given environment variable.
+	**/
+	public static function getEnv( s : String ) : String
+	{
+		return java.lang.System.getenv(s);
+	}
+
+	/**
+		Set the value of the given environment variable.
+		Warning: It is not implemented in Java
+	**/
+	public static function putEnv( s : String, v : String ) : Void
+	{
+		//java offers no support for it (!)
+		throw "Not implemented in this platform";
+	}
+
+	/**
+		Returns the whole environement variables.
+	**/
+	public static function environment() : Hash<String>
+	{
+		if (_env != null)
+			return _env;
+		var _env = _env = new Hash();
+		for (mv in java.lang.System.getenv().entrySet())
+		{
+			_env.set(mv.getKey(), mv.getValue());
+		}
+		
+		return _env;
+	}
+
+	/**
+		Suspend the current execution for the given time (in seconds).
+	**/
+	public static function sleep( seconds : Float ) : Void
+	{
+		try
+			java.lang.Thread.sleep(cast seconds * 1000)
+		catch (e:Dynamic) 
+			throw e;
+	}
+
+	/**
+		Change the current time locale, which will affect [DateTools.format] date formating.
+		Returns true if the locale was successfully changed
+	**/
+	public static function setTimeLocale( loc : String ) : Bool
+	{
+		return false;
+	}
+
+	/**
+		Get the current working directory (usually the one in which the program was started)
+	**/
+	public static function getCwd() : String
+	{
+		return new java.io.File(".").getAbsolutePath().substr(0,-1);
+	}
+
+	/**
+		Change the current working directory.
+	**/
+	public static function setCwd( s : String ) : Void
+	{
+		//java offers no support for it (!)
+		throw "not implemented";
+	}
+
+	/**
+		Returns the name of the system you are running on. For instance :
+			"Windows", "Linux", "BSD" and "Mac" depending on your desktop OS.
+	**/
+	public static function systemName() : String
+	{
+		if (_sysName != null) return _sysName;
+		var sname = System.getProperty("os.name").toLowerCase();
+		if (sname.indexOf("win") >= 0)
+			return _sysName = "Windows";
+		if (sname.indexOf("mac") >= 0)
+			return _sysName = "Mac";
+		if (sname.indexOf("nux") >= 0)
+			return _sysName = "Linux";
+		if (sname.indexOf("nix") >= 0)
+			return _sysName = "BSD";
+		
+		return _sysName = System.getProperty("os.name");
+	}
+
+	/**
+		Run the given command with the list of arguments. The command output will be printed on the same output as the current process.
+		The current process will block until the command terminates and it will return the command result (0 if there was no error).
+		Read the [sys.io.Process] api for a more complete way to start background processes.
+	**/
+	public static function command( cmd : String, ?args : Array<String> ) : Int
+	{
+		var proc:Process = new Process(cmd, args == null ? [] : args);
+		var ret = proc.exitCode();
+		proc.close();
+		
+		return ret;
+	}
+
+	/**
+		Exit the current process with the given error code.
+	**/
+	public static function exit( code : Int ) : Void
+	{
+		System.exit(code);
+	}
+
+	/**
+		Gives the most precise timestamp value (in seconds).
+	**/
+	public static function time() : Float
+	{
+		return cast(System.currentTimeMillis(), Float) / 1000;
+	}
+
+	/**
+		Gives the most precise timestamp value (in seconds) but only account for the actual time spent running on the CPU for the current thread/process.
+	**/
+	public static function cpuTime() : Float
+	{
+		return cast(System.nanoTime(), Float) / 1000;
+	}
+
+	/**
+		Returns the path to the current executable that we are running.
+	**/
+	public static function executablePath() : String
+	{
+		return getCwd();
+	}
+
+	/**
+		Read a single input character from the standard input (without blocking) and returns it. Setting [echo] to true will also display it on the output.
+	**/
+	public static function getChar( echo : Bool ) : Int
+	{
+		//TODO
+		return throw "Not implemented";
+	}
+
+	/**
+		Returns the process standard input, from which you can read what user enters. Usually it will block until the user send a full input line. See [getChar] for an alternative.
+	**/
+	public static function stdin() : haxe.io.Input
+	{
+		var _in:java.io.InputStream = Reflect.field(System, "in");
+		return new sys.io.NativeInput(_in);
+	}
+
+	/**
+		Returns the process standard output on which you can write.
+	**/
+	public static function stdout() : haxe.io.Output
+	{
+		return new sys.io.NativeOutput(System.out);
+	}
+
+	/**
+		Returns the process standard error on which you can write.
+	**/
+	public static function stderr() : haxe.io.Output
+	{
+		return new sys.io.NativeOutput(System.err);
+	}
+
+}

+ 13 - 0
std/java/io/PrintStream.hx

@@ -0,0 +1,13 @@
+package java.io;
+
+extern class PrintStream extends OutputStream
+{
+	@:overload(function(out:OutputStream, autoFlush:Bool):Void {})
+	function new(file:File):Void;
+	
+	function append(s:String):PrintStream;
+	function format(s:String, args:java.NativeArray<Dynamic>):PrintStream;
+	function printf(s:String, args:java.NativeArray<Dynamic>):PrintStream;
+	function print(obj:Dynamic):Void;
+	function println(obj:Dynamic):Void;
+}

+ 8 - 0
std/java/lang/Runnable.hx

@@ -0,0 +1,8 @@
+package java.lang;
+
+interface Runnable 
+{
+
+	function run():Void;
+	
+}

+ 13 - 7
std/java/lang/System.hx

@@ -1,23 +1,29 @@
 package java.lang;
 import haxe.Int64;
 
-/**
- * ...
- * @author waneck
- */
-
 extern class System 
 {
+	static var err(default, null):java.io.PrintStream;
+	static var out(default, null):java.io.PrintStream;
+	//static var in(default, null):java.io.InputStream; //collision
+	
 	static function arraycopy(src:Dynamic, srcPos:Int, dest:Dynamic, destPos:Int, length:Int):Void;
+	static function clearProperty(key:String):String;
 	static function currentTimeMillis():Int64;
 	static function exit(status:Int):Void;
+	@:overload(function():java.util.Map<String,String> {})
 	static function getenv(name:String):String;
-	static function getProperty(key:String, def:String):String;
-	static function setProperty(key:String, value:String):String;
+	static function getProperty(key:String, ?def:String):String;
+	static function identityHashCode(x:Dynamic):Int;
 	static function load(filename:String):Void;
 	static function loadLibrary(libname:String):Void;
 	static function mapLibraryName(libname:String):String;
+	static function nanoTime():Int64;
 	static function gc():Void;
 	static function runFinalization():Void;
+	static function setErr(err:java.io.PrintStream):Void;
+	static function setOut(out:java.io.PrintStream):Void;
+	static function setIn(v:java.io.InputStream):Void;
+	static function setProperty(key:String, value:String):String;
 	
 }

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

@@ -0,0 +1,32 @@
+package java.lang;
+import haxe.Int64;
+
+extern class Thread 
+{
+	static function activeCount():Int;
+	static function currentThread():Thread;
+	static function dumpStack():Void;
+	static function enumerate(tarray:java.NativeArray<Thread>):Int;
+	static function interrupted():Bool;
+	@:overload(function(ms:Int64, nano:Int):Void {})
+	static function sleep(ms:Int64):Void;
+	static function yield():Void;
+	
+	function new(target:Runnable):Void;
+	
+	function destroy():Void;
+	function getName():String;
+	function getPriority():Int;
+	function interrupt():Void;
+	function isAlive():Bool;
+	function isDaemon():Bool;
+	function isInterrupted():Bool;
+	
+	@:overload(function(ms:Int64):Void {})
+	@:overload(function(ms:Int64, nanos:Int):Void {})
+	function join():Void;
+	
+	function run():Void; //should call start(), not run()
+	function setPriority(newPriority:Int):Void;
+	function start():Void;
+}

+ 15 - 0
std/java/util/Collection.hx

@@ -0,0 +1,15 @@
+package java.util;
+
+extern interface Collection<E> implements java.util.Iterable<E>
+{
+	function add(o:E):Bool;
+	function addAll(c:Collection<E>):Bool;
+	function clear():Void;
+	function contains(o:Dynamic):Bool;
+	function containsAll(c:Collection<Dynamic>):Bool;
+	function isEmpty():Bool;
+	function iterator():Iterator<E>;
+	function remove(o:Dynamic):Bool;
+	function size():Int;
+	function toArray():java.NativeArray<Dynamic>;
+}

+ 6 - 0
std/java/util/Iterable.hx

@@ -0,0 +1,6 @@
+package java.util;
+
+extern interface Iterable<T>
+{
+	function iterator():Iterator<T>;
+}

+ 8 - 0
std/java/util/Iterator.hx

@@ -0,0 +1,8 @@
+package java.util;
+
+extern interface Iterator<T>
+{
+	function hasNext():Bool;
+	function next():T;
+	function remove():Void;
+}

+ 22 - 0
std/java/util/Map.hx

@@ -0,0 +1,22 @@
+package java.util;
+
+extern interface Map<K,V>
+{
+	function clear():Void;
+	function containsKey(obj:Dynamic):Bool;
+	function containsValue(obj:Dynamic):Bool;
+	function entrySet():java.util.Set<MapEntry<K,V>>;
+	function get(k:Dynamic):V;
+	function keySet():java.util.Set<K>;
+	function put(key:K, value:V):V;
+	function remove(key:Dynamic):V;
+	function size():Int;
+	function values():Collection<V>;
+}
+
+@:native('java.util.Map.Entry') extern interface MapEntry<K,V>
+{
+	function getKey():K;
+	function getValue():V;
+	function setValue(v:V):V;
+}

+ 6 - 0
std/java/util/Set.hx

@@ -0,0 +1,6 @@
+package java.util;
+
+extern interface Set<E> implements Collection<E>
+{
+	
+}