[Git][java-team/robocode][upstream] New upstream version 1.9.3.3

Markus Koschany gitlab at salsa.debian.org
Thu Sep 13 17:48:33 BST 2018


Markus Koschany pushed to branch upstream at Debian Java Maintainers / robocode


Commits:
65892b20 by Markus Koschany at 2018-09-13T11:50:31Z
New upstream version 1.9.3.3
- - - - -


10 changed files:

- + .gitignore
- plugins/dotnet/ReadMe.txt
- robocode.api/src/main/java/robocode/control/RandomFactory.java
- robocode.battle/src/main/java/net/sf/robocode/battle/BattleManager.java
- robocode.core/src/main/java/net/sf/robocode/battle/BattleProperties.java
- robocode.repository/src/main/java/net/sf/robocode/repository/Repository.java
- robocode.roborumble/src/main/java/net/sf/robocode/roborumble/netengine/ResultsUpload.java
- robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/RobocodeCompilerFactory.java
- super-pom/pom.xml
- versions.md


Changes:

=====================================
.gitignore
=====================================
@@ -0,0 +1,12 @@
+.metadata
+target
+build.xml
+maven-build.xml
+maven-build.properties
+/plugins/dotnet/robocode.dotnet.samples/src/robocode.dotnet.samples.sln
+/plugins/dotnet/robocode.dotnet.samples/src/robocode.dotnet.samples.suo
+ucdetector_reports
+/plugins/dotnet/*.suo
+*.class
+.recommenders
+.sonarlint


=====================================
plugins/dotnet/ReadMe.txt
=====================================
@@ -84,4 +84,26 @@ NOTE: You might need to remove the 'rem' and change the following lines inside
 	  correct Java version:
 
 rem set JAVA_HOME=%JDK6_HOME%
-rem set PATH=%JAVA_HOME%\bin;%PATH%
\ No newline at end of file
+rem set PATH=%JAVA_HOME%\bin;%PATH%
+
+
+INSTALL LIBRARIES INTO THE LOCAL MAVEN REPOSITORY
+=================================================
+Robocode will give compiler error when running mvnassembly the first time or if the jni4net version is rolled.
+Make sure to run these commands:
+
+mvn install:install-file -DgroupId=net.sf.jni4net -DartifactId=jni4net.n -Dversion=0.8.7.0 -Dpackaging=dotnet:library -Dfile=<robocode-work-dir>\plugins\dotnet\tools\lib\jni4net.n-0.8.7.0.dll
+
+mvn install:install-file -DgroupId=net.sf.jni4net -DartifactId=jni4net.j -Dversion=0.8.7.0 -Dpackaging=jar -Dfile=<robocode-work-dir>\plugins\dotnet\tools\lib\jni4net.j-0.8.7.0.jar
+
+mvn install:install-file -DgroupId=net.sf.jni4net -DartifactId=jni4net.n.w32.v20 -Dversion=0.8.7.0 -Dpackaging=dotnet:library -Dfile=<robocode-work-dir>\plugins\dotnet\tools\lib\jni4net.n.w32.v20-0.8.7.0.dll
+
+mvn install:install-file -DgroupId=net.sf.jni4net -DartifactId=jni4net.n.w32.v40 -Dversion=0.8.7.0 -Dpackaging=dotnet:library -Dfile=<robocode-work-dir>\plugins\dotnet\tools\lib\jni4net.n.w32.v40-0.8.7.0.dll
+
+mvn install:install-file -DgroupId=net.sf.jni4net -DartifactId=jni4net.n.w64.v20 -Dversion=0.8.7.0 -Dpackaging=dotnet:library -Dfile=<robocode-work-dir>\plugins\dotnet\tools\lib\jni4net.n.w64.v20-0.8.7.0.dll
+
+mvn install:install-file -DgroupId=net.sf.jni4net -DartifactId=jni4net.n.w64.v40 -Dversion=0.8.7.0 -Dpackaging=dotnet:library -Dfile=<robocode-work-dir>\plugins\dotnet\tools\lib\jni4net.n.w64.v40-0.8.7.0.dll
+
+mvn install:install-file -DgroupId=org.nunit -DartifactId=nunit.framework -Dversion=2.4.3.0 -Dpackaging=dotnet:library -Dfile=<robocode-work-dir>\plugins\dotnet\tools\lib\nunit.framework-2.4.3.0.dll
+
+Where <robocode-work-dir> is the directory containing your Robocode sources, e.g. D:\robocode-work
\ No newline at end of file


=====================================
robocode.api/src/main/java/robocode/control/RandomFactory.java
=====================================
@@ -7,96 +7,139 @@
  */
 package robocode.control;
 
-
-import static net.sf.robocode.io.Logger.logError;
 import static net.sf.robocode.io.Logger.logWarning;
 
 import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
 import java.util.Random;
 
-
 /**
  * The RandomFactory is used for controlling the generation of random numbers,
  * and supports generating random numbers that are deterministic, which is
  * useful for testing purposes.
  *
  * @author Pavel Savara (original)
+ * @author Xor (fixed for Java 8)
+ * @author Flemming N. Larsen (fixed for Java 8)
  *
  * @since 1.6.1
  */
 public class RandomFactory {
-	private static Random randomNumberGenerator;
+	private static Random randomNumberGenerator = new Random();
 
 	private static boolean warningNotSupportedLogged;
 	private static boolean isDeterministic;
 
-	static {
-		randomNumberGenerator = new Random();
-	}
-
 	public boolean isDeterministic() {
 		return isDeterministic;
 	}
 
 	/**
-	 * Returns the random number generator used for generating a stream of
-	 * random numbers.
+	 * Returns the random number generator used for generating a stream of random
+	 * numbers.
 	 *
 	 * @return a {@link java.util.Random} instance.
 	 * @see java.util.Random
 	 */
 	public static Random getRandom() {
 		if (randomNumberGenerator == null) {
-			try {
-				Math.random();
-				final Field field = Math.class.getDeclaredField("randomNumberGenerator");
-				final boolean savedFieldAccessible = field.isAccessible();
-
-				field.setAccessible(true);
-				randomNumberGenerator = (Random) field.get(null);
-				field.setAccessible(savedFieldAccessible);
-			} catch (NoSuchFieldException e) {
+			Field field = getRandomNumberGeneratorField();
+			if (field != null) {
+				try {
+					randomNumberGenerator = getRandomNumberGenerator(field);
+				} catch (IllegalAccessException e) {
+					logWarningNotSupported();
+				}
+			}
+			if (randomNumberGenerator == null) {
 				logWarningNotSupported();
 				randomNumberGenerator = new Random();
-			} catch (IllegalAccessException e) {
-				logError(e);
-				randomNumberGenerator = new Random();
 			}
 		}
 		return randomNumberGenerator;
 	}
 
+	private static Field getRandomNumberGeneratorField() {
+		try {
+			return Math.class.getDeclaredField("randomNumberGenerator");
+		} catch (NoSuchFieldException e) {
+			try {
+				final Class<?> clazz = Class.forName("java.lang.Math$RandomNumberGeneratorHolder");
+				return clazz.getDeclaredField("randomNumberGenerator");
+			} catch (NoSuchFieldException e1) {
+				logWarningNotSupported();
+			} catch (ClassNotFoundException e1) {
+				logWarningNotSupported();
+			}
+		}
+		return null;
+	}
+
+	private static Random getRandomNumberGenerator(Field field) throws IllegalAccessException {
+		Math.random();
+		final boolean savedFieldAccessible = field.isAccessible();
+
+		field.setAccessible(true);
+		randomNumberGenerator = (Random) field.get(null);
+		field.setAccessible(savedFieldAccessible);
+
+		return randomNumberGenerator;
+	}
+
 	/**
-	 * Sets the random number generator instance used for generating a
-	 * stream of random numbers.
+	 * Sets the random number generator instance used for generating a stream of
+	 * random numbers.
 	 *
-	 * @param random a {@link java.util.Random} instance.
+	 * @param random
+	 *            a {@link java.util.Random} instance.
 	 * @see java.util.Random
 	 */
 	public static void setRandom(Random random) {
 		randomNumberGenerator = random;
-		try {
-			Math.random();
-			final Field field = Math.class.getDeclaredField("randomNumberGenerator");
-			final boolean savedFieldAccessible = field.isAccessible();
 
-			field.setAccessible(true);
-			field.set(null, randomNumberGenerator);
-			field.setAccessible(savedFieldAccessible);
-		} catch (NoSuchFieldException e) {
+		Field field = getRandomNumberGeneratorField();
+		if (field != null) {
+			try {
+				setRandomNumberGenerator(field);
+			} catch (Exception e) {
+				logWarningNotSupported();
+			}
+		} else {
 			logWarningNotSupported();
-		} catch (IllegalAccessException e) {
-			logError(e);
+		}
+	}
+
+	private static void setRandomNumberGenerator(Field field) throws IllegalAccessException, NoSuchFieldException {
+		Math.random();
+		final boolean savedFieldAccessible = field.isAccessible();
+		field.setAccessible(true);
+
+		Field modifiersField = Field.class.getDeclaredField("modifiers");
+
+		final boolean savedModifiersAccessible = modifiersField.isAccessible();
+		modifiersField.setAccessible(true);
+		try {
+			int oldModifiers = field.getModifiers();
+			try {
+				modifiersField.setInt(field, oldModifiers & ~Modifier.FINAL);
+
+				field.set(null, randomNumberGenerator);
+			} finally {
+				modifiersField.setInt(field, oldModifiers);
+			}
+		} finally {
+			modifiersField.setAccessible(savedModifiersAccessible);
 		}
 
-		// TODO ZAMO using Robot classloader inject seed also for all instances being created by robots
+		field.setAccessible(savedFieldAccessible);
 	}
 
 	/**
 	 * Resets the random number generator instance to be deterministic when
 	 * generating random numbers.
 	 *
-	 * @param seed the seed to use for the new deterministic random generator.
+	 * @param seed
+	 *            the seed to use for the new deterministic random generator.
 	 */
 	public static void resetDeterministic(long seed) {
 		setRandom(new Random(seed));
@@ -104,14 +147,14 @@ public class RandomFactory {
 	}
 
 	/**
-	 * Logs a warning that the deterministic random feature is not supported by the JVM.
+	 * Logs a warning that the deterministic random feature is not supported by the
+	 * JVM.
 	 */
 	private static void logWarningNotSupported() {
 		if (!(warningNotSupportedLogged || System.getProperty("RANDOMSEED", "none").equals("none"))) {
-			logWarning(
-					"The deterministic random generator feature is not supported by this JVM:\n"
-							+ System.getProperty("java.vm.vendor") + " " + System.getProperty("java.vm.name") + " "
-							+ System.getProperty("java.vm.version"));
+			logWarning("The deterministic random generator feature is not supported by this JVM:\n"
+					+ System.getProperty("java.vm.vendor") + " " + System.getProperty("java.vm.name") + " "
+					+ System.getProperty("java.vm.version"));
 
 			warningNotSupportedLogged = true;
 		}


=====================================
robocode.battle/src/main/java/net/sf/robocode/battle/BattleManager.java
=====================================
@@ -51,7 +51,7 @@ public class BattleManager implements IBattleManager {
 
 	private volatile IBattle battle;
 	private Thread battleThread;
-	private BattleProperties battleProperties = new BattleProperties();
+	private BattleProperties battleProperties;
 
 	private final BattleEventDispatcher battleEventDispatcher;
 
@@ -69,6 +69,7 @@ public class BattleManager implements IBattleManager {
 		this.hostManager = hostManager;
 		this.battleEventDispatcher = battleEventDispatcher;
 		Logger.setLogListener(battleEventDispatcher);
+		battleProperties = new BattleProperties(properties);
 	}
 
 	public synchronized void cleanup() {


=====================================
robocode.core/src/main/java/net/sf/robocode/battle/BattleProperties.java
=====================================
@@ -8,6 +8,7 @@
 package net.sf.robocode.battle;
 
 
+import net.sf.robocode.settings.ISettingsManager;
 import robocode.AdvancedRobot;
 import robocode.Robot;
 import robocode.control.RobotSetup;
@@ -51,6 +52,19 @@ public class BattleProperties implements Serializable {
 
 	private final Properties props = new Properties();
 
+	public BattleProperties() {
+	}
+
+	public BattleProperties(ISettingsManager properties) {
+		battlefieldWidth = properties.getBattleDefaultBattlefieldWidth();
+		battlefieldHeight = properties.getBattleDefaultBattlefieldHeight();
+		numRounds = properties.getBattleDefaultNumberOfRounds();
+		gunCoolingRate = properties.getBattleDefaultGunCoolingRate();
+		inactivityTime = properties.getBattleDefaultInactivityTime();
+		hideEnemyNames = properties.getBattleDefaultHideEnemyNames();
+		sentryBorderSize = properties.getBattleDefaultSentryBorderSize();
+	}
+
 	/**
 	 * Gets the battlefieldWidth.
 	 *


=====================================
robocode.repository/src/main/java/net/sf/robocode/repository/Repository.java
=====================================
@@ -127,15 +127,21 @@ class Repository implements IRepository {
 	 * {@inheritDoc}
 	 */
 	public IRepositoryItem getItem(String friendlyUrl) {
-		// Friendly urls containing ending asterix like "test.Robot* must be changed into "test.Robot".
-		// That is, contain no ending asterix.
-		if (friendlyUrl.endsWith("*")) {
-			friendlyUrl = friendlyUrl.substring(0, friendlyUrl.length() - 1);
-		}
 		IRepositoryItem repositoryItem = repositoryItems.get(friendlyUrl);
 		if (repositoryItem == null) {
 			repositoryItem = removedItems.get(friendlyUrl);
 		}
+		if (repositoryItem == null) {			
+			// Friendly urls containing ending asterix like "test.Robot* must be changed into "test.Robot".
+			// That is, contain no ending asterix.
+			if (friendlyUrl.endsWith("*")) {
+				friendlyUrl = friendlyUrl.substring(0, friendlyUrl.length() - 1);
+			}
+			repositoryItem = repositoryItems.get(friendlyUrl);
+			if (repositoryItem == null) {
+				repositoryItem = removedItems.get(friendlyUrl);
+			}
+		}
 		return repositoryItem;
 	}
 


=====================================
robocode.roborumble/src/main/java/net/sf/robocode/roborumble/netengine/ResultsUpload.java
=====================================
@@ -180,29 +180,32 @@ public class ResultsUpload {
 
 			String data = "game=" + game + commonData;
 
+			boolean errsaved = false;
+
 			if (matchtype.equals("GENERAL") || matchtype.equals("SERVER")) {
-				errorsfound = errorsfound | senddata(game, data, outtxt, true, results, i, battlesnum, prioritybattles);
+				errsaved = senddata(game, data, outtxt, true, results, i, battlesnum, prioritybattles);
 			}
 
 			if (sizesfile.length() != 0) { // upload also related competitions
 				if (minibots.length() != 0 && !matchtype.equals("NANO") && !matchtype.equals("MICRO")
 						&& size.checkCompetitorsForSize(first[0], second[0], 1500)) {
 					data = "game=" + minibots + commonData;
-					errorsfound = errorsfound
-							| senddata(minibots, data, outtxt, true, results, i, battlesnum, prioritybattles);
+					errsaved = errsaved
+							| senddata(minibots, data, outtxt, !errsaved, results, i, battlesnum, prioritybattles);
 				}
 				if (microbots.length() != 0 && !matchtype.equals("NANO")
 						&& size.checkCompetitorsForSize(first[0], second[0], 750)) {
 					data = "game=" + microbots + commonData;
-					errorsfound = errorsfound
-							| senddata(microbots, data, outtxt, true, results, i, battlesnum, prioritybattles);
+					errsaved = errsaved
+							| senddata(microbots, data, outtxt, !errsaved, results, i, battlesnum, prioritybattles);
 				}
 				if (nanobots.length() != 0 && size.checkCompetitorsForSize(first[0], second[0], 250)) {
 					data = "game=" + nanobots + commonData;
-					errorsfound = errorsfound
-							| senddata(nanobots, data, outtxt, true, results, i, battlesnum, prioritybattles);
+					errsaved = errsaved
+							| senddata(nanobots, data, outtxt, !errsaved, results, i, battlesnum, prioritybattles);
 				}
 			}
+			errorsfound = errorsfound || errsaved;
 		}
 
 		// close files


=====================================
robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/RobocodeCompilerFactory.java
=====================================
@@ -114,7 +114,7 @@ public class RobocodeCompilerFactory {
 
 		String compilerName = "Java Compiler (javac)";
 		String compilerBinary = "javac";
-		String compilerOptions = "-deprecation -g -source 1.6 -encoding UTF-8";
+		String compilerOptions = "-version";
 
 		boolean javacOK = testCompiler(compilerName, compilerBinary, console);
 		boolean ecjOK = false;


=====================================
super-pom/pom.xml
=====================================
@@ -13,8 +13,8 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xs
 	</organization>
 	<properties>
 		<project.build.sourceEncoding>cp1252</project.build.sourceEncoding>
-		<robocode.version>1.9.3.2</robocode.version> <!-- Any string, but no spaces (use '-' instead of space) -->
-		<robocode.dotnet.version>1.9.3.2</robocode.dotnet.version> <!-- Only X.X.X.X format -->
+		<robocode.version>1.9.3.3</robocode.version> <!-- Any string, but no spaces (use '-' instead of space) -->
+		<robocode.dotnet.version>1.9.3.3</robocode.dotnet.version> <!-- Only X.X.X.X format -->
 		<javadoc.additionalparam/>
 	</properties>
 	<repositories>


=====================================
versions.md
=====================================
@@ -1,7 +1,13 @@
-## Version 1.9.3.3 (09-04-2018)
+## Version 1.9.3.3 (10-09-2018)
 
 ## Bug fix
 * Fixed issue with the RobocodeEngine, which could not read robots in "developer mode" (marked with a asterix '*' character)
+* [Bug-395][]: Roborumble client duplicates battle results on network error.
+* [Bug-397][]: Robocode UI cannot remember battle settings upon restart.
+* [Bug-399][]: RANDOMSEED option does not support Java 8.
+	* Thanks goes to bumfod for all 3 fixes above. :-)
+* [Bug-400][]: Problem to compile Robot.
+    * The compiler options have been cut down to include only the -verbose option per default.
 
 ## Version 1.9.3.2 (04-04-2018) The Java 10 support release
 
@@ -3057,6 +3063,10 @@ Currently, there is one known issue, which will be fixed with the next Beta or i
 [Bug-392]: http://sourceforge.net/p/robocode/bugs/392/  (Bullets of the same bot collide at low bullet powers and high gun-cooling rate)
 [Bug-393]: http://sourceforge.net/p/robocode/bugs/393/  (More frequent roborumble server checks)
 [Bug-394]: http://sourceforge.net/p/robocode/bugs/394/  (HiDPI scaling causes visual glitches)
+[Bug-395]: http://sourceforge.net/p/robocode/bugs/395/	(Roborumble client duplicates battle results on network error)
+[Bug-397]: http://sourceforge.net/p/robocode/bugs/397/  (Robocode UI cannot remember battle settings upon restart)
+[Bug-399]: http://sourceforge.net/p/robocode/bugs/399/  (RANDOMSEED option does not support Java 8)
+[Bug-400]: http://sourceforge.net/p/robocode/bugs/400/  (Problem to compile Robot)
 
 [Req-1]:   http://sourceforge.net/p/robocode/feature-requests/1/    (Multiple or hyperthreading CPUs (most P4s) hangs Robocode)
 [Req-2]:   http://sourceforge.net/p/robocode/feature-requests/2/    (Keep window size of "New battle" window)



View it on GitLab: https://salsa.debian.org/java-team/robocode/commit/65892b20cdf501c297d073ae4cebc266cb2891d6

-- 
View it on GitLab: https://salsa.debian.org/java-team/robocode/commit/65892b20cdf501c297d073ae4cebc266cb2891d6
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20180913/cad242e7/attachment.html>


More information about the pkg-java-commits mailing list