Explorar el Código

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]>
bob0bob hace 3 años
padre
commit
8b56ff9221

+ 3 - 4
jme3-examples/src/main/java/jme3test/bullet/TestIssue1120.java

@@ -65,7 +65,6 @@ import java.util.List;
  */
 public class TestIssue1120 extends SimpleApplication {
 
-    private static TestIssue1120 test;
     private BulletAppState bulletAppState;
     private final boolean physicsDebug = true;
     private BitmapText speedText;
@@ -74,7 +73,7 @@ public class TestIssue1120 extends SimpleApplication {
     private float bulletSpeed = 0.5f;
 
     public static void main(String[] args) {
-        test = new TestIssue1120();
+        TestIssue1120 test = new TestIssue1120();
         test.setSettings(new AppSettings(true));
         test.settings.setFrameRate(60);
         if (SKIP_SETTINGS) {
@@ -139,10 +138,10 @@ public class TestIssue1120 extends SimpleApplication {
 
         float lineHeight = testInfo[0].getLineHeight();
         testInfo[0].setText("Camera move: W/A/S/D/Q/Z     +/-: Increase/Decrease Speed");
-        testInfo[0].setLocalTranslation(5, test.settings.getHeight(), 0);
+        testInfo[0].setLocalTranslation(5, settings.getHeight(), 0);
         guiNode.attachChild(testInfo[0]);
         testInfo[1].setText("Left Click: Toggle pause            Space: Restart test");
-        testInfo[1].setLocalTranslation(5, test.settings.getHeight() - lineHeight, 0);
+        testInfo[1].setLocalTranslation(5, settings.getHeight() - lineHeight, 0);
         guiNode.attachChild(testInfo[1]);
 
         speedText.setLocalTranslation(202, lineHeight * 1, 0);