Skip to content

Commit 8b56ff9

Browse files
bob0bobstephengold
andauthored
Fix issue #1687 (NPE in TestIssue1120) (#1697)
* When run from the test chooser, TestIssue1120 in jme3-examples crashes: Nov 28, 2021 1:10:12 AM com.jme3.app.LegacyApplication handleError SEVERE: Uncaught exception thrown in Thread[jME3 Main,6,main] java.lang.NullPointerException at jme3test.bullet.TestIssue1120.simpleInitApp(TestIssue1120.java:142) at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:240) at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:139) at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:221) at java.lang.Thread.run(Thread.java:748) The application's test field is null because it wasn't initialized. The initialization was placed in main(), which the test chooser never executes. * remove unwanted commented out code. Co-authored-by: Stephen Gold <[email protected]>
1 parent 3111535 commit 8b56ff9

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

jme3-examples/src/main/java/jme3test/bullet/TestIssue1120.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@
6565
*/
6666
public class TestIssue1120 extends SimpleApplication {
6767

68-
private static TestIssue1120 test;
6968
private BulletAppState bulletAppState;
7069
private final boolean physicsDebug = true;
7170
private BitmapText speedText;
@@ -74,7 +73,7 @@ public class TestIssue1120 extends SimpleApplication {
7473
private float bulletSpeed = 0.5f;
7574

7675
public static void main(String[] args) {
77-
test = new TestIssue1120();
76+
TestIssue1120 test = new TestIssue1120();
7877
test.setSettings(new AppSettings(true));
7978
test.settings.setFrameRate(60);
8079
if (SKIP_SETTINGS) {
@@ -139,10 +138,10 @@ public void simpleInitApp() {
139138

140139
float lineHeight = testInfo[0].getLineHeight();
141140
testInfo[0].setText("Camera move: W/A/S/D/Q/Z +/-: Increase/Decrease Speed");
142-
testInfo[0].setLocalTranslation(5, test.settings.getHeight(), 0);
141+
testInfo[0].setLocalTranslation(5, settings.getHeight(), 0);
143142
guiNode.attachChild(testInfo[0]);
144143
testInfo[1].setText("Left Click: Toggle pause Space: Restart test");
145-
testInfo[1].setLocalTranslation(5, test.settings.getHeight() - lineHeight, 0);
144+
testInfo[1].setLocalTranslation(5, settings.getHeight() - lineHeight, 0);
146145
guiNode.attachChild(testInfo[1]);
147146

148147
speedText.setLocalTranslation(202, lineHeight * 1, 0);

0 commit comments

Comments
 (0)