Browse Source

[jvm] don't do whatever genjava does

see #9225
Simon Krajewski 5 years ago
parent
commit
deb34f1204
2 changed files with 13 additions and 14 deletions
  1. 2 3
      src/generators/genjvm.ml
  2. 11 11
      std/haxe/Timer.hx

+ 2 - 3
src/generators/genjvm.ml

@@ -2519,9 +2519,8 @@ class tclass_to_jvm gctx c = object(self)
 		| Some e ->
 			self#generate_expr gctx jc jm e true SCNone MStatic
 		| None ->
-			()
-		end;
-		jm#return
+			jm#return
+		end
 
 	method private generate_fields =
 		let field mtype cf = match cf.cf_kind with

+ 11 - 11
std/haxe/Timer.hx

@@ -39,7 +39,7 @@ package haxe;
 class Timer {
 	#if (flash || js)
 	private var id:Null<Int>;
-	#elseif java
+	#elseif (java && !jvm)
 	private var timer:java.util.Timer;
 	private var task:java.util.TimerTask;
 	#else
@@ -66,7 +66,7 @@ class Timer {
 		#elseif js
 		var me = this;
 		id = untyped setInterval(function() me.run(), time_ms);
-		#elseif java
+		#elseif (java && !jvm)
 		timer = new java.util.Timer();
 		timer.scheduleAtFixedRate(task = new TimerTask(this), haxe.Int64.ofInt(time_ms), haxe.Int64.ofInt(time_ms));
 		#else
@@ -97,7 +97,7 @@ class Timer {
 		untyped clearInterval(id);
 		#end
 		id = null;
-		#elseif java
+		#elseif (java && !jvm)
 		if (timer != null) {
 			timer.cancel();
 			timer = null;
@@ -121,7 +121,7 @@ class Timer {
 		var timer = new haxe.Timer(1000); // 1000ms delay
 		timer.run = function() { ... }
 		```
-		
+
 		Once bound, it can still be rebound to different functions until `this`
 		Timer is stopped through a call to `this.stop`.
 	**/
@@ -175,12 +175,12 @@ class Timer {
 		#elseif (neko || php)
 		return Sys.time();
 		#elseif js
-			#if nodejs
-			var hrtime = js.Syntax.code('process.hrtime()'); // [seconds, remaining nanoseconds]
-			return hrtime[0] + hrtime[1] / 1e9;
-			#else
-			return @:privateAccess HxOverrides.now() / 1000;
-			#end
+		#if nodejs
+		var hrtime = js.Syntax.code('process.hrtime()'); // [seconds, remaining nanoseconds]
+		return hrtime[0] + hrtime[1] / 1e9;
+		#else
+		return @:privateAccess HxOverrides.now() / 1000;
+		#end
 		#elseif cpp
 		return untyped __global__.__time_stamp();
 		#elseif python
@@ -193,7 +193,7 @@ class Timer {
 	}
 }
 
-#if java
+#if (java && !jvm)
 @:nativeGen
 private class TimerTask extends java.util.TimerTask {
 	var timer:Timer;