diff --git a/代码/workspace_robo4/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/dotnet/host/Module.java b/代码/workspace_robo4/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/dotnet/host/Module.java index 2867a6f..e538d7a 100644 --- a/代码/workspace_robo4/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/dotnet/host/Module.java +++ b/代码/workspace_robo4/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/dotnet/host/Module.java @@ -65,7 +65,7 @@ public class Module extends BaseModule { Container.cache.addComponent("robocode.host.vb", DotNetHost.class); Container.cache.addComponent("robocode.host.dotnet", DotNetHost.class); - } catch (Throwable e) { + } catch (RuntimeException e) { Logger.logError(e); throw new Error("Can't initialize .NET Robocode", e); } diff --git a/代码/workspace_robo4/plugins/dotnet/robocode.dotnet.installer/src/main/java/net/sf/robocode/installer/AutoExtract.java b/代码/workspace_robo4/plugins/dotnet/robocode.dotnet.installer/src/main/java/net/sf/robocode/installer/AutoExtract.java index eaba300..852475f 100644 --- a/代码/workspace_robo4/plugins/dotnet/robocode.dotnet.installer/src/main/java/net/sf/robocode/installer/AutoExtract.java +++ b/代码/workspace_robo4/plugins/dotnet/robocode.dotnet.installer/src/main/java/net/sf/robocode/installer/AutoExtract.java @@ -240,7 +240,7 @@ public class AutoExtract implements ActionListener { // Set native look and feel try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); - } catch (Throwable t) {// For some reason Ubuntu 7 can cause a NullPointerException when trying to getting the LAF + } catch (RuntimeException t) {// For some reason Ubuntu 7 can cause a NullPointerException when trying to getting the LAF } File suggestedDir; diff --git a/代码/workspace_robo4/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestMaxTurnRate.java b/代码/workspace_robo4/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestMaxTurnRate.java index 551fac3..5507bb1 100644 --- a/代码/workspace_robo4/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestMaxTurnRate.java +++ b/代码/workspace_robo4/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestMaxTurnRate.java @@ -40,33 +40,33 @@ public class TestMaxTurnRate extends RobocodeTestBed { if (event.getTurnSnapshot().getTurn() == 26) { final String out = buf.toString(); - Assert.assertTrue(out.contains("1: 0.0, 0.0") | out.contains("1: 0.0, -0.0")); - Assert.assertTrue(out.contains("2: 0.0, -1.0") | out.contains("2: 0.0, -0.999999999")); - Assert.assertTrue(out.contains("3: 0.0, -2.0") | out.contains("3: 0.0, -1.999999999")); - Assert.assertTrue(out.contains("4: 0.0, -3.0") | out.contains("4: 0.0, -2.999999999")); - Assert.assertTrue(out.contains("5: 0.0, -4.0") | out.contains("5: 0.0, -3.999999999")); - Assert.assertTrue(out.contains("6: 0.0, -5.0") | out.contains("6: 0.0, -4.999999999")); - Assert.assertTrue(out.contains("7: 0.0, -6.0") | out.contains("7: 0.0, -5.999999999")); - Assert.assertTrue(out.contains("8: 0.0, -7.0") | out.contains("8: 0.0, -6.999999999")); - Assert.assertTrue(out.contains("9: 0.0, -8.0") | out.contains("9: 0.0, -7.999999999")); - Assert.assertTrue(out.contains("10: 0.0, -9.0") | out.contains("10: 0.0, -8.999999999")); - Assert.assertTrue(out.contains("11: 0.0, -10.0") | out.contains("11: 0.0, -9.999999999")); - Assert.assertTrue(out.contains("12: 0.0, -10.0") | out.contains("12: 0.0, -9.999999999")); - Assert.assertTrue(out.contains("13: 0.0, -10.0") | out.contains("13: 0.0, -9.999999999")); + Assert.assertTrue(out.contains("1: 0.0, 0.0") || out.contains("1: 0.0, -0.0")); + Assert.assertTrue(out.contains("2: 0.0, -1.0") || out.contains("2: 0.0, -0.999999999")); + Assert.assertTrue(out.contains("3: 0.0, -2.0") || out.contains("3: 0.0, -1.999999999")); + Assert.assertTrue(out.contains("4: 0.0, -3.0") || out.contains("4: 0.0, -2.999999999")); + Assert.assertTrue(out.contains("5: 0.0, -4.0") || out.contains("5: 0.0, -3.999999999")); + Assert.assertTrue(out.contains("6: 0.0, -5.0") || out.contains("6: 0.0, -4.999999999")); + Assert.assertTrue(out.contains("7: 0.0, -6.0") || out.contains("7: 0.0, -5.999999999")); + Assert.assertTrue(out.contains("8: 0.0, -7.0") || out.contains("8: 0.0, -6.999999999")); + Assert.assertTrue(out.contains("9: 0.0, -8.0") || out.contains("9: 0.0, -7.999999999")); + Assert.assertTrue(out.contains("10: 0.0, -9.0") || out.contains("10: 0.0, -8.999999999")); + Assert.assertTrue(out.contains("11: 0.0, -10.0") || out.contains("11: 0.0, -9.999999999")); + Assert.assertTrue(out.contains("12: 0.0, -10.0") || out.contains("12: 0.0, -9.999999999")); + Assert.assertTrue(out.contains("13: 0.0, -10.0") || out.contains("13: 0.0, -9.999999999")); - Assert.assertTrue(out.contains("14: 0.0, 0.0") | out.contains("14: 0.0, -0.0")); - Assert.assertTrue(out.contains("15: 0.0, 1.0") | out.contains("15: 0.0, 0.999999999")); - Assert.assertTrue(out.contains("16: 0.0, 2.0") | out.contains("16: 0.0, 1.999999999")); - Assert.assertTrue(out.contains("17: 0.0, 3.0") | out.contains("17: 0.0, 2.999999999")); - Assert.assertTrue(out.contains("18: 0.0, 4.0") | out.contains("18: 0.0, 3.999999999")); - Assert.assertTrue(out.contains("19: 0.0, 5.0") | out.contains("19: 0.0, 4.999999999")); - Assert.assertTrue(out.contains("20: 0.0, 6.0") | out.contains("20: 0.0, 5.999999999")); - Assert.assertTrue(out.contains("21: 0.0, 7.0") | out.contains("21: 0.0, 6.999999999")); - Assert.assertTrue(out.contains("22: 0.0, 8.0") | out.contains("22: 0.0, 7.999999999")); - Assert.assertTrue(out.contains("23: 0.0, 9.0") | out.contains("23: 0.0, 8.999999999")); - Assert.assertTrue(out.contains("24: 0.0, 10.0") | out.contains("24: 0.0, 9.999999999")); - Assert.assertTrue(out.contains("25: 0.0, 10.0") | out.contains("25: 0.0, 9.999999999")); - Assert.assertTrue(out.contains("26: 0.0, 10.0") | out.contains("26: 0.0, 9.999999999")); + Assert.assertTrue(out.contains("14: 0.0, 0.0") || out.contains("14: 0.0, -0.0")); + Assert.assertTrue(out.contains("15: 0.0, 1.0") || out.contains("15: 0.0, 0.999999999")); + Assert.assertTrue(out.contains("16: 0.0, 2.0") || out.contains("16: 0.0, 1.999999999")); + Assert.assertTrue(out.contains("17: 0.0, 3.0") || out.contains("17: 0.0, 2.999999999")); + Assert.assertTrue(out.contains("18: 0.0, 4.0") || out.contains("18: 0.0, 3.999999999")); + Assert.assertTrue(out.contains("19: 0.0, 5.0") || out.contains("19: 0.0, 4.999999999")); + Assert.assertTrue(out.contains("20: 0.0, 6.0") || out.contains("20: 0.0, 5.999999999")); + Assert.assertTrue(out.contains("21: 0.0, 7.0") || out.contains("21: 0.0, 6.999999999")); + Assert.assertTrue(out.contains("22: 0.0, 8.0") || out.contains("22: 0.0, 7.999999999")); + Assert.assertTrue(out.contains("23: 0.0, 9.0") || out.contains("23: 0.0, 8.999999999")); + Assert.assertTrue(out.contains("24: 0.0, 10.0") || out.contains("24: 0.0, 9.999999999")); + Assert.assertTrue(out.contains("25: 0.0, 10.0") || out.contains("25: 0.0, 9.999999999")); + Assert.assertTrue(out.contains("26: 0.0, 10.0") || out.contains("26: 0.0, 9.999999999")); } } } diff --git a/代码/workspace_robo4/plugins/testing/robocode.testing.installer/src/main/java/net/sf/robocode/installer/AutoExtract.java b/代码/workspace_robo4/plugins/testing/robocode.testing.installer/src/main/java/net/sf/robocode/installer/AutoExtract.java index c7825a0..e993cf8 100644 --- a/代码/workspace_robo4/plugins/testing/robocode.testing.installer/src/main/java/net/sf/robocode/installer/AutoExtract.java +++ b/代码/workspace_robo4/plugins/testing/robocode.testing.installer/src/main/java/net/sf/robocode/installer/AutoExtract.java @@ -246,7 +246,7 @@ public class AutoExtract implements ActionListener { // Set native look and feel try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); - } catch (Throwable t) {// For some reason Ubuntu 7 can cause a NullPointerException when trying to getting the LAF + } catch (RuntimeException t) {// For some reason Ubuntu 7 can cause a NullPointerException when trying to getting the LAF } File installDir = null; diff --git a/代码/workspace_robo4/robocode.api/src/main/java/net/sf/robocode/security/HiddenAccess.java b/代码/workspace_robo4/robocode.api/src/main/java/net/sf/robocode/security/HiddenAccess.java index 2616238..184001c 100644 --- a/代码/workspace_robo4/robocode.api/src/main/java/net/sf/robocode/security/HiddenAccess.java +++ b/代码/workspace_robo4/robocode.api/src/main/java/net/sf/robocode/security/HiddenAccess.java @@ -113,7 +113,7 @@ public class HiddenAccess { System.exit(-1); } catch (MalformedURLException e) { Logger.logError(e); - } catch (Error e) { + } catch (MyException e) { Logger.logError(e); throw e; } diff --git a/代码/workspace_robo4/robocode.core/src/main/java/net/sf/robocode/battle/events/BattleEventDispatcher.java b/代码/workspace_robo4/robocode.core/src/main/java/net/sf/robocode/battle/events/BattleEventDispatcher.java index c6a146f..9155e67 100644 --- a/代码/workspace_robo4/robocode.core/src/main/java/net/sf/robocode/battle/events/BattleEventDispatcher.java +++ b/代码/workspace_robo4/robocode.core/src/main/java/net/sf/robocode/battle/events/BattleEventDispatcher.java @@ -46,7 +46,7 @@ public class BattleEventDispatcher implements IBattleListener { for (IBattleListener listener : listeners) { try { listener.onBattleStarted(event); - } catch (Throwable ex) { + } catch (RuntimeException ex) { logError("onBattleStarted " + listener.getClass(), ex); } } @@ -56,7 +56,7 @@ public class BattleEventDispatcher implements IBattleListener { for (IBattleListener listener : listeners) { try { listener.onBattleCompleted(event); - } catch (Throwable ex) { + } catch (RuntimeException ex) { logError("onBattleCompleted " + listener.getClass(), ex); } } @@ -66,7 +66,7 @@ public class BattleEventDispatcher implements IBattleListener { for (IBattleListener listener : listeners) { try { listener.onBattleFinished(event); - } catch (Throwable ex) { + } catch (RuntimeException ex) { logError("onBattleFinished " + listener.getClass(), ex); } } @@ -76,7 +76,7 @@ public class BattleEventDispatcher implements IBattleListener { for (IBattleListener listener : listeners) { try { listener.onBattlePaused(event); - } catch (Throwable ex) { + } catch (RuntimeException ex) { logError("onBattlePaused " + listener.getClass(), ex); } } @@ -86,7 +86,7 @@ public class BattleEventDispatcher implements IBattleListener { for (IBattleListener listener : listeners) { try { listener.onBattleResumed(event); - } catch (Throwable ex) { + } catch (RuntimeException ex) { logError("onBattleResumed " + listener.getClass(), ex); } } @@ -96,7 +96,7 @@ public class BattleEventDispatcher implements IBattleListener { for (IBattleListener listener : listeners) { try { listener.onRoundStarted(event); - } catch (Throwable ex) { + } catch (RuntimeException ex) { logError("onRoundStarted " + listener.getClass(), ex); } } @@ -106,7 +106,7 @@ public class BattleEventDispatcher implements IBattleListener { for (IBattleListener listener : listeners) { try { listener.onRoundEnded(event); - } catch (Throwable ex) { + } catch (RuntimeException ex) { logError("onRoundEnded " + listener.getClass(), ex); } } @@ -116,7 +116,7 @@ public class BattleEventDispatcher implements IBattleListener { for (IBattleListener listener : listeners) { try { listener.onTurnStarted(event); - } catch (Throwable ex) { + } catch (RuntimeException ex) { logError("onTurnStarted " + listener.getClass(), ex); } } @@ -126,7 +126,7 @@ public class BattleEventDispatcher implements IBattleListener { for (IBattleListener listener : listeners) { try { listener.onTurnEnded(event); - } catch (Throwable ex) { + } catch (RuntimeException ex) { logError("onTurnEnded " + listener.getClass(), ex); } } @@ -136,7 +136,7 @@ public class BattleEventDispatcher implements IBattleListener { for (IBattleListener listener : listeners) { try { listener.onBattleMessage(event); - } catch (Throwable ex) { + } catch (RuntimeException ex) { logError("onBattleMessage " + listener.getClass(), ex); } } @@ -146,7 +146,7 @@ public class BattleEventDispatcher implements IBattleListener { for (IBattleListener listener : listeners) { try { listener.onBattleError(event); - } catch (Throwable ex) { + } catch (RuntimeException ex) { Logger.realErr.println(listener.getClass() + " " + ex.getMessage()); } } diff --git a/代码/workspace_robo4/robocode.core/src/main/java/net/sf/robocode/core/RobocodeMain.java b/代码/workspace_robo4/robocode.core/src/main/java/net/sf/robocode/core/RobocodeMain.java index 24c831b..3ba5a93 100644 --- a/代码/workspace_robo4/robocode.core/src/main/java/net/sf/robocode/core/RobocodeMain.java +++ b/代码/workspace_robo4/robocode.core/src/main/java/net/sf/robocode/core/RobocodeMain.java @@ -171,7 +171,7 @@ public final class RobocodeMain extends RobocodeMainBase { System.exit(8); } } - } catch (Throwable e) { + } catch (RuntimeException e) { Logger.logError(e); } } diff --git a/代码/workspace_robo4/robocode.host/src/main/java/net/sf/robocode/host/JavaHost.java b/代码/workspace_robo4/robocode.host/src/main/java/net/sf/robocode/host/JavaHost.java index 3540256..7dde1e9 100644 --- a/代码/workspace_robo4/robocode.host/src/main/java/net/sf/robocode/host/JavaHost.java +++ b/代码/workspace_robo4/robocode.host/src/main/java/net/sf/robocode/host/JavaHost.java @@ -88,7 +88,7 @@ public class JavaHost implements IHost { } return checkInterfaces(robotClass, robotItem); - } catch (Throwable t) { + } catch (RuntimeException t) { if (message) { logError("Got an error with " + robotItem.getFullClassName() + ": " + t); // just message here if (t.getMessage() != null && t.getMessage().contains("Bad version number in .class file")) { diff --git a/代码/workspace_robo4/robocode.host/src/main/java/net/sf/robocode/host/events/EventManager.java b/代码/workspace_robo4/robocode.host/src/main/java/net/sf/robocode/host/events/EventManager.java index 0024a6b..5621c87 100644 --- a/代码/workspace_robo4/robocode.host/src/main/java/net/sf/robocode/host/events/EventManager.java +++ b/代码/workspace_robo4/robocode.host/src/main/java/net/sf/robocode/host/events/EventManager.java @@ -382,7 +382,7 @@ public final class EventManager implements IEventManager { } catch (RuntimeException e) { currentTopEvent = null; throw e; - } catch (Error e) { + } catch (MyException e) { currentTopEvent = null; throw e; } finally { diff --git a/代码/workspace_robo4/robocode.host/src/main/java/net/sf/robocode/host/proxies/HostingRobotProxy.java b/代码/workspace_robo4/robocode.host/src/main/java/net/sf/robocode/host/proxies/HostingRobotProxy.java index df5d591..9fdb31e 100644 --- a/代码/workspace_robo4/robocode.host/src/main/java/net/sf/robocode/host/proxies/HostingRobotProxy.java +++ b/代码/workspace_robo4/robocode.host/src/main/java/net/sf/robocode/host/proxies/HostingRobotProxy.java @@ -157,7 +157,7 @@ abstract class HostingRobotProxy implements IHostingRobotProxy, IHostedThread { private void loadClassBattle() { try { robotClassLoader.loadRobotMainClass(true); - } catch (Throwable e) { + } catch (RuntimeException e) { println("SYSTEM: Could not load " + statics.getName() + " : "); println(e); drainEnergy(); @@ -183,7 +183,7 @@ abstract class HostingRobotProxy implements IHostingRobotProxy, IHostedThread { robot = null; logError(e); return false; - } catch (Throwable e) { + } catch (RuntimeException e) { println("SYSTEM: An error occurred during initialization of " + statics.getName()); println("SYSTEM: " + e); println(e); @@ -247,7 +247,7 @@ abstract class HostingRobotProxy implements IHostingRobotProxy, IHostedThread { println(e); logMessage(statics.getName() + " stopped successfully."); throw e; // must be re-thrown in order to stop the thread - } catch (Throwable t) { + } catch (RuntimeException t) { drainEnergy(); println(t); logMessage(statics.getName() + ": Throwable: " + t); // without stack here diff --git a/代码/workspace_robo4/robocode.host/src/main/java/net/sf/robocode/host/security/RobotClassLoader.java b/代码/workspace_robo4/robocode.host/src/main/java/net/sf/robocode/host/security/RobotClassLoader.java index 69dad86..0993839 100644 --- a/代码/workspace_robo4/robocode.host/src/main/java/net/sf/robocode/host/security/RobotClassLoader.java +++ b/代码/workspace_robo4/robocode.host/src/main/java/net/sf/robocode/host/security/RobotClassLoader.java @@ -244,7 +244,7 @@ public class RobotClassLoader extends URLClassLoader implements IRobotClassLoade } else { warnIfStaticRobotInstanceFields(); } - } catch (Throwable e) { + } catch (RuntimeException e) { robotClass = null; throw new ClassNotFoundException(e.getMessage(), e); } @@ -289,7 +289,7 @@ public class RobotClassLoader extends URLClassLoader implements IRobotClassLoade } } } - } catch (Throwable t) { + } catch (RuntimeException t) { Logger.logError(t); } } @@ -305,7 +305,7 @@ public class RobotClassLoader extends URLClassLoader implements IRobotClassLoade Class type = null; try { type = loadRobotClassLocaly(className, false); - } catch (Throwable t) { + } catch (RuntimeException t) { continue; } if (type != null) { @@ -366,7 +366,7 @@ public class RobotClassLoader extends URLClassLoader implements IRobotClassLoade modifiersField.setInt(field, modifiers & ~Modifier.FINAL); // Remove the FINAL modifier field.set(null, null); - } catch (Throwable ignore) {} + } catch (RuntimeException ignore) {} } /** @@ -383,7 +383,7 @@ public class RobotClassLoader extends URLClassLoader implements IRobotClassLoade for (Field field: type.getDeclaredFields()) { fields.add(field); } - } catch (Throwable ignore) {// NoClassDefFoundError does occur with some robots, e.g. sgp.Drunken [1.12] + } catch (RuntimeException ignore) {// NoClassDefFoundError does occur with some robots, e.g. sgp.Drunken [1.12] // We ignore all exceptions and errors here so we can proceed to retrieve // field from super classes. } diff --git a/代码/workspace_robo4/robocode.installer/src/main/java/net/sf/robocode/installer/AutoExtract.java b/代码/workspace_robo4/robocode.installer/src/main/java/net/sf/robocode/installer/AutoExtract.java index 581a88e..e4c6d0a 100644 --- a/代码/workspace_robo4/robocode.installer/src/main/java/net/sf/robocode/installer/AutoExtract.java +++ b/代码/workspace_robo4/robocode.installer/src/main/java/net/sf/robocode/installer/AutoExtract.java @@ -337,7 +337,7 @@ public class AutoExtract implements ActionListener { // Set native look and feel try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); - } catch (Throwable t) {// For some reason Ubuntu 7 can cause a NullPointerException when trying to getting the LAF + } catch (RuntimeException t) {// For some reason Ubuntu 7 can cause a NullPointerException when trying to getting the LAF } AutoExtract extractor = new AutoExtract(); diff --git a/代码/workspace_robo4/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/netengine/FileTransfer.java b/代码/workspace_robo4/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/netengine/FileTransfer.java index c686e5a..09004c4 100644 --- a/代码/workspace_robo4/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/netengine/FileTransfer.java +++ b/代码/workspace_robo4/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/netengine/FileTransfer.java @@ -204,7 +204,7 @@ public class FileTransfer { if (conn != null) { conn.disconnect(); } - } catch (Throwable ignore) {// we expect this, right ? + } catch (RuntimeException ignore) {// we expect this, right ? } } } diff --git a/代码/workspace_robo4/robocode.tests.robots/src/main/java/tested/robots/AwtAttack.java b/代码/workspace_robo4/robocode.tests.robots/src/main/java/tested/robots/AwtAttack.java index 35c4ff8..5722779 100644 --- a/代码/workspace_robo4/robocode.tests.robots/src/main/java/tested/robots/AwtAttack.java +++ b/代码/workspace_robo4/robocode.tests.robots/src/main/java/tested/robots/AwtAttack.java @@ -54,7 +54,7 @@ public class AwtAttack extends AdvancedRobot { }; javax.swing.SwingUtilities.invokeLater(doHack); - } catch (Throwable e) { + } catch (RuntimeException e) { // swalow security exception e.printStackTrace(out); } @@ -75,7 +75,7 @@ public class AwtAttack extends AdvancedRobot { e.printStackTrace(out); } catch (IOException e) { e.printStackTrace(out); - } catch (Throwable e) { + } catch (RuntimeException e) { // swalow security exception e.printStackTrace(out); } diff --git a/代码/workspace_robo4/robocode.tests.robots/src/main/java/tested/robots/ConstructorAwtAttack.java b/代码/workspace_robo4/robocode.tests.robots/src/main/java/tested/robots/ConstructorAwtAttack.java index 97bc321..47ae244 100644 --- a/代码/workspace_robo4/robocode.tests.robots/src/main/java/tested/robots/ConstructorAwtAttack.java +++ b/代码/workspace_robo4/robocode.tests.robots/src/main/java/tested/robots/ConstructorAwtAttack.java @@ -39,7 +39,7 @@ public class ConstructorAwtAttack extends robocode.AdvancedRobot { }; javax.swing.SwingUtilities.invokeLater(doHack); - } catch (Throwable e) { + } catch (RuntimeException e) { // swallow security exception e.printStackTrace(out); } @@ -60,7 +60,7 @@ public class ConstructorAwtAttack extends robocode.AdvancedRobot { e.printStackTrace(out); } catch (IOException e) { e.printStackTrace(out); - } catch (Throwable e) { + } catch (RuntimeException e) { // swallow security exception e.printStackTrace(out); } diff --git a/代码/workspace_robo4/robocode.tests.robots/src/main/java/tested/robots/ConstructorThreadAttack.java b/代码/workspace_robo4/robocode.tests.robots/src/main/java/tested/robots/ConstructorThreadAttack.java index a0c1e4a..0c5a0f8 100644 --- a/代码/workspace_robo4/robocode.tests.robots/src/main/java/tested/robots/ConstructorThreadAttack.java +++ b/代码/workspace_robo4/robocode.tests.robots/src/main/java/tested/robots/ConstructorThreadAttack.java @@ -24,7 +24,7 @@ public class ConstructorThreadAttack extends robocode.AdvancedRobot { Thread t = new Thread(a); t.start(); - } catch (Throwable e) { + } catch (RuntimeException e) { // swallow security exception e.printStackTrace(out); } @@ -39,7 +39,7 @@ public class ConstructorThreadAttack extends robocode.AdvancedRobot { Thread t = new Thread(tg, a); t.start(); - } catch (Throwable e) { + } catch (RuntimeException e) { // swallow security exception e.printStackTrace(out); } diff --git a/代码/workspace_robo4/robocode.tests.robots/src/main/java/tested/robots/FileAttack.java b/代码/workspace_robo4/robocode.tests.robots/src/main/java/tested/robots/FileAttack.java index 3a35cec..9f76ccf 100644 --- a/代码/workspace_robo4/robocode.tests.robots/src/main/java/tested/robots/FileAttack.java +++ b/代码/workspace_robo4/robocode.tests.robots/src/main/java/tested/robots/FileAttack.java @@ -52,7 +52,7 @@ public class FileAttack extends AdvancedRobot { e.printStackTrace(out); } catch (IOException e) { e.printStackTrace(out); - } catch (Throwable e) { + } catch (RuntimeException e) { // swalow security exception e.printStackTrace(out); } @@ -72,7 +72,7 @@ public class FileAttack extends AdvancedRobot { e.printStackTrace(out); } catch (IOException e) { e.printStackTrace(out); - } catch (Throwable e) { + } catch (RuntimeException e) { // swalow security exception e.printStackTrace(out); } diff --git a/代码/workspace_robo4/robocode.tests.robots/src/main/java/tested/robots/IncludeNamespaceAttack.java b/代码/workspace_robo4/robocode.tests.robots/src/main/java/tested/robots/IncludeNamespaceAttack.java index d2cb8e1..c5ecdb9 100644 --- a/代码/workspace_robo4/robocode.tests.robots/src/main/java/tested/robots/IncludeNamespaceAttack.java +++ b/代码/workspace_robo4/robocode.tests.robots/src/main/java/tested/robots/IncludeNamespaceAttack.java @@ -37,7 +37,7 @@ public class IncludeNamespaceAttack extends AdvancedRobot { private void namespaceAttack() { try { HiddenAccess.createRules(10, 10, 10, 10, 1, false, 100); - } catch (Throwable e) { + } catch (RuntimeException e) { // Swallow security exception e.printStackTrace(out); } diff --git a/代码/workspace_robo4/robocode.tests.robots/src/main/java/tested/robots/ThreadAttack.java b/代码/workspace_robo4/robocode.tests.robots/src/main/java/tested/robots/ThreadAttack.java index 84cd88f..bb21f8c 100644 --- a/代码/workspace_robo4/robocode.tests.robots/src/main/java/tested/robots/ThreadAttack.java +++ b/代码/workspace_robo4/robocode.tests.robots/src/main/java/tested/robots/ThreadAttack.java @@ -42,7 +42,7 @@ public class ThreadAttack extends AdvancedRobot { Thread t = new Thread(a); t.start(); - } catch (Throwable e) { + } catch (RuntimeException e) { // swallow security exception e.printStackTrace(out); } @@ -57,7 +57,7 @@ public class ThreadAttack extends AdvancedRobot { Thread t = new Thread(tg, a); t.start(); - } catch (Throwable e) { + } catch (RuntimeException e) { // swallow security exception e.printStackTrace(out); } diff --git a/代码/workspace_robo4/robocode.tests.robots/src/main/java/tested/robots/ThreadGroupAttack.java b/代码/workspace_robo4/robocode.tests.robots/src/main/java/tested/robots/ThreadGroupAttack.java index dbf59ec..963b549 100644 --- a/代码/workspace_robo4/robocode.tests.robots/src/main/java/tested/robots/ThreadGroupAttack.java +++ b/代码/workspace_robo4/robocode.tests.robots/src/main/java/tested/robots/ThreadGroupAttack.java @@ -51,7 +51,7 @@ public class ThreadGroupAttack extends Robot { } } }).start(); - } catch (Throwable t) { + } catch (RuntimeException t) { t.printStackTrace(out); } } diff --git a/代码/workspace_robo4/robocode.tests.robots/src/main/java/tested/robots/UndeadThread.java b/代码/workspace_robo4/robocode.tests.robots/src/main/java/tested/robots/UndeadThread.java index 94b042c..75fcbfa 100644 --- a/代码/workspace_robo4/robocode.tests.robots/src/main/java/tested/robots/UndeadThread.java +++ b/代码/workspace_robo4/robocode.tests.robots/src/main/java/tested/robots/UndeadThread.java @@ -23,7 +23,7 @@ public class UndeadThread extends AdvancedRobot { while (true) { try { body(); - } catch (Throwable t) { + } catch (RuntimeException t) { // spamming the console out.println("Swalowed it, HA HA HA HA HAAAAA !!!!!"); out.println(t); diff --git a/代码/workspace_robo4/robocode.tests/src/main/java/net/sf/robocode/test/helpers/Assert.java b/代码/workspace_robo4/robocode.tests/src/main/java/net/sf/robocode/test/helpers/Assert.java index 6f5fded..27c29dd 100644 --- a/代码/workspace_robo4/robocode.tests/src/main/java/net/sf/robocode/test/helpers/Assert.java +++ b/代码/workspace_robo4/robocode.tests/src/main/java/net/sf/robocode/test/helpers/Assert.java @@ -22,7 +22,7 @@ public class Assert extends org.junit.Assert { public static void allAssertNear(double v1, double v2) { try { assertNear(v1, v2); - } catch (Throwable ex) { + } catch (RuntimeException ex) { ex.printStackTrace(System.err); } } @@ -30,7 +30,7 @@ public class Assert extends org.junit.Assert { public static void allAssertThat(T t, org.hamcrest.Matcher tMatcher) { try { org.junit.Assert.assertThat(t, tMatcher); - } catch (Throwable ex) { + } catch (RuntimeException ex) { ex.printStackTrace(System.err); } } diff --git a/代码/workspace_robo4/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/EditWindow.java b/代码/workspace_robo4/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/EditWindow.java index 4986b8b..a0f8e9b 100644 --- a/代码/workspace_robo4/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/EditWindow.java +++ b/代码/workspace_robo4/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/EditWindow.java @@ -146,7 +146,7 @@ public class EditWindow extends JInternalFrame { setModified(editorPanel.getEditorPane().isModified()); } }); - } catch (Throwable e) { + } catch (RuntimeException e) { Logger.logError(e); } } diff --git a/代码/workspace_robo4/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/WindowMenuItem.java b/代码/workspace_robo4/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/WindowMenuItem.java index 1baec07..bda1627 100644 --- a/代码/workspace_robo4/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/WindowMenuItem.java +++ b/代码/workspace_robo4/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/WindowMenuItem.java @@ -74,7 +74,7 @@ public class WindowMenuItem extends JCheckBoxMenuItem implements ActionListener if (window.isIcon()) { try { window.setIcon(false); - } catch (Throwable ignored) {} + } catch (RuntimeException ignored) {} } if (window.getDesktopPane() != null) { window.getDesktopPane().setSelectedFrame(window); @@ -83,7 +83,7 @@ public class WindowMenuItem extends JCheckBoxMenuItem implements ActionListener window.grabFocus(); try { window.setSelected(true); - } catch (Throwable ignored) {} + } catch (RuntimeException ignored) {} } /** diff --git a/代码/workspace_robo4/robocode.ui/src/main/java/net/sf/robocode/ui/WindowManager.java b/代码/workspace_robo4/robocode.ui/src/main/java/net/sf/robocode/ui/WindowManager.java index 476bc5b..bbdae95 100644 --- a/代码/workspace_robo4/robocode.ui/src/main/java/net/sf/robocode/ui/WindowManager.java +++ b/代码/workspace_robo4/robocode.ui/src/main/java/net/sf/robocode/ui/WindowManager.java @@ -574,14 +574,14 @@ public class WindowManager implements IWindowManagerExt { private void setLookAndFeel() { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); - } catch (Throwable t) { + } catch (RuntimeException t) { // Work-around for problems with setting Look and Feel described here: // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6468089 Locale.setDefault(Locale.US); try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); - } catch (Throwable t2) { + } catch (RuntimeException t2) { // For some reason Ubuntu 7 can cause a NullPointerException when trying to getting the LAF System.err.println("Could not set the Look and Feel (LAF). The default LAF is used instead"); } diff --git a/代码/workspace_robo4/robocode.ui/src/main/java/net/sf/robocode/ui/battle/AwtBattleAdaptor.java b/代码/workspace_robo4/robocode.ui/src/main/java/net/sf/robocode/ui/battle/AwtBattleAdaptor.java index bfb479c..11436ae 100644 --- a/代码/workspace_robo4/robocode.ui/src/main/java/net/sf/robocode/ui/battle/AwtBattleAdaptor.java +++ b/代码/workspace_robo4/robocode.ui/src/main/java/net/sf/robocode/ui/battle/AwtBattleAdaptor.java @@ -132,7 +132,7 @@ public final class AwtBattleAdaptor { calculateFPS(); } } - } catch (Throwable t) { + } catch (RuntimeException t) { Logger.logError(t); } } diff --git a/代码/workspace_robo4/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/TeamCreator.java b/代码/workspace_robo4/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/TeamCreator.java index dbaabb4..b3e10d6 100644 --- a/代码/workspace_robo4/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/TeamCreator.java +++ b/代码/workspace_robo4/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/TeamCreator.java @@ -1,4 +1,3 @@ - package net.sf.robocode.ui.dialog; @@ -32,17 +31,14 @@ public class TeamCreator extends JDialog implements WizardListener { private RobotSelectionPanel robotSelectionPanel; private TeamCreatorOptionsPanel teamCreatorOptionsPanel; - private final int minRobots = 2;//ÿ - private final int maxRobots = 10;//ÿ10 + private final int minRobots = 2; + private final int maxRobots = 10; private final EventHandler eventHandler = new EventHandler(); - //EventHandlerʵActionListenerӿڣʵֶļ class EventHandler implements ActionListener { public void actionPerformed(ActionEvent e) { - //eΪIJʱeΪActionEvent if (e.getActionCommand().equals("Refresh")) { - //ִи² getRobotSelectionPanel().refreshRobotList(true); } } @@ -63,12 +59,9 @@ public class TeamCreator extends JDialog implements WizardListener { return teamCreatorOptionsPanel; } - //ȡǶе private JPanel getTeamCreatorContentPane() { if (teamCreatorContentPane == null) { - //ǶΪ teamCreatorContentPane = new JPanel(); - //½Ƕ teamCreatorContentPane.setLayout(new BorderLayout()); teamCreatorContentPane.add(getWizardController(), BorderLayout.SOUTH); teamCreatorContentPane.add(getWizardPanel(), BorderLayout.CENTER); @@ -82,12 +75,8 @@ public class TeamCreator extends JDialog implements WizardListener { return teamCreatorContentPane; } - //ѡɱ - protected RobotSelectionPanel getRobotSelectionPanel() - { - //ǰѡΪ - if (robotSelectionPanel == null) - { + protected RobotSelectionPanel getRobotSelectionPanel() { + if (robotSelectionPanel == null) { robotSelectionPanel = net.sf.robocode.core.Container.createComponent(RobotSelectionPanel.class); robotSelectionPanel.setup(minRobots, maxRobots, false, "Select the robots for this team.", false, true, true, false, false, false, null); @@ -95,11 +84,8 @@ public class TeamCreator extends JDialog implements WizardListener { return robotSelectionPanel; } - //½һǶ - private WizardCardPanel getWizardPanel() - { - if (wizardPanel == null) - { + private WizardCardPanel getWizardPanel() { + if (wizardPanel == null) { wizardPanel = new WizardCardPanel(this); wizardPanel.add(getRobotSelectionPanel(), "Select robots"); wizardPanel.add(getTeamCreatorOptionsPanel(), "Select options"); @@ -107,27 +93,23 @@ public class TeamCreator extends JDialog implements WizardListener { return wizardPanel; } - //ڳʼ - public void initialize() - { + public void initialize() { setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); setTitle("Create a team"); setContentPane(getTeamCreatorContentPane()); } private WizardController getWizardController() { - if (wizardController == null) - { + if (wizardController == null) { wizardController = getWizardPanel().getWizardController(); } return wizardController; } - //ȡ + public void cancelButtonActionPerformed() { dispose(); } - - //ɼ + public void finishButtonActionPerformed() { try { int rc = createTeam(); @@ -145,14 +127,12 @@ public class TeamCreator extends JDialog implements WizardListener { } } - //ıдݿ public int createTeam() throws IOException { File file = new File(repositoryManager.getRobotsDirectory(), teamCreatorOptionsPanel.getTeamPackage().replace('.', File.separatorChar) + teamCreatorOptionsPanel.getTeamNameField().getText() + ".team"); if (file.exists()) { - //ǰѾ int ok = JOptionPane.showConfirmDialog(this, file + " already exists. Are you sure you want to replace it?", "Warning", JOptionPane.YES_NO_CANCEL_OPTION); @@ -170,13 +150,10 @@ public class TeamCreator extends JDialog implements WizardListener { String webPageFieldString = teamCreatorOptionsPanel.getWebpageField().getText(); if (webPageFieldString != null && webPageFieldString.length() > 0) { - try - { + try { webPageUrl = new URL(webPageFieldString); - } catch (MalformedURLException e) - { - try - { + } catch (MalformedURLException e) { + try { webPageUrl = new URL("http://" + webPageFieldString); teamCreatorOptionsPanel.getWebpageField().setText(webPageUrl.toString()); } catch (MalformedURLException ignored) {} diff --git a/代码/workspace_robo4/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/TeamCreatorOptionsPanel.java b/代码/workspace_robo4/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/TeamCreatorOptionsPanel.java index 345c874..7d4dc12 100644 --- a/代码/workspace_robo4/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/TeamCreatorOptionsPanel.java +++ b/代码/workspace_robo4/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/TeamCreatorOptionsPanel.java @@ -1,4 +1,3 @@ - package net.sf.robocode.ui.dialog; @@ -18,7 +17,6 @@ import java.net.URL; import java.util.List; - @SuppressWarnings("serial") public class TeamCreatorOptionsPanel extends WizardPanel { private TeamCreator teamCreator; @@ -41,20 +39,16 @@ public class TeamCreatorOptionsPanel extends WizardPanel { private String teamPackage; - private class EventHandler implements ComponentListener, DocumentListener - { - public void insertUpdate(DocumentEvent e) - { + private class EventHandler implements ComponentListener, DocumentListener { + public void insertUpdate(DocumentEvent e) { fireStateChanged(); } - public void changedUpdate(DocumentEvent e) - { + public void changedUpdate(DocumentEvent e) { fireStateChanged(); } - public void removeUpdate(DocumentEvent e) - { + public void removeUpdate(DocumentEvent e) { fireStateChanged(); } @@ -65,38 +59,32 @@ public class TeamCreatorOptionsPanel extends WizardPanel { public void componentShown(ComponentEvent e) { List selectedRobots; - if (teamCreator != null) - { + if (teamCreator != null) { selectedRobots = teamCreator.getRobotSelectionPanel().getSelectedRobots(); - } else - { + } else { selectedRobots = teamPackager.getRobotSelectionPanel().getSelectedRobots(); } - if (selectedRobots != null) - { + if (selectedRobots != null) { IRobotSpecItem robotSpecification = selectedRobots.get(0); getTeamNameLabel().setText("Please choose a name for your team: (Must be a valid Java classname)"); getTeamNameField().setText(robotSpecification.getShortClassName() + "Team"); getTeamPackageLabel().setText(robotSpecification.getFullPackage() + "."); teamPackage = robotSpecification.getFullPackage(); - if (teamPackage != null) - { + if (teamPackage != null) { teamPackage += "."; } String d = robotSpecification.getDescription(); - if (d == null) - { + if (d == null) { d = ""; } getDescriptionArea().setText(d); String a = robotSpecification.getAuthorName(); - if (a == null) - { + if (a == null) { a = ""; } getAuthorField().setText(a); @@ -315,7 +303,11 @@ public class TeamCreatorOptionsPanel extends WizardPanel { return teamPackageLabel; } - + /** + * õ + * + * @return һַ + */ public String getTeamPackage() { return (teamPackage != null) ? teamPackage : "."; }