From fb4d24c684c27747563820c4114d235ca1e75604 Mon Sep 17 00:00:00 2001 From: mlhpdx Date: Fri, 13 May 2022 13:35:19 -0700 Subject: [PATCH 1/2] Fix null reference due to unassigned field The code was previously declaring and assigning a local variable instead of the field by the same name. --- java_client_src/src/ihs/apcs/spacebattle/GraphicalClient.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java_client_src/src/ihs/apcs/spacebattle/GraphicalClient.java b/java_client_src/src/ihs/apcs/spacebattle/GraphicalClient.java index 23c12ef..5487e85 100644 --- a/java_client_src/src/ihs/apcs/spacebattle/GraphicalClient.java +++ b/java_client_src/src/ihs/apcs/spacebattle/GraphicalClient.java @@ -72,7 +72,7 @@ public void run() { // Create ship this.shipClassname = args[1]; - Class shipType = Class.forName(this.shipClassname); + shipType = Class.forName(this.shipClassname); this.logMessage("Creating new " + shipType.getName()); this.ship = (Spaceship)shipType.getConstructor().newInstance(); From 4b3715bf0ba325c0a0e4524d53e4dcf3b8d3abd4 Mon Sep 17 00:00:00 2001 From: mlhpdx Date: Sat, 14 May 2022 18:06:05 -0700 Subject: [PATCH 2/2] Update java_client_src/src/ihs/apcs/spacebattle/GraphicalClient.java Co-authored-by: Michael A. Hawker --- java_client_src/src/ihs/apcs/spacebattle/GraphicalClient.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java_client_src/src/ihs/apcs/spacebattle/GraphicalClient.java b/java_client_src/src/ihs/apcs/spacebattle/GraphicalClient.java index 5487e85..65c0e2c 100644 --- a/java_client_src/src/ihs/apcs/spacebattle/GraphicalClient.java +++ b/java_client_src/src/ihs/apcs/spacebattle/GraphicalClient.java @@ -72,7 +72,7 @@ public void run() { // Create ship this.shipClassname = args[1]; - shipType = Class.forName(this.shipClassname); + this.shipType = Class.forName(this.shipClassname); this.logMessage("Creating new " + shipType.getName()); this.ship = (Spaceship)shipType.getConstructor().newInstance();