Răsfoiți Sursa

#2562 Prompt users to turn on asserts (if they haven't already)

Richard Tingle 2 luni în urmă
părinte
comite
a7643e7bc3

+ 2 - 1
jme3-core/src/main/java/com/jme3/scene/Spatial.java

@@ -369,7 +369,8 @@ public abstract class Spatial implements Savable, Cloneable, Collidable,
             throw new IllegalStateException("Scene graph is not properly updated for rendering.\n"
                     + "State was changed after rootNode.updateGeometricState() call. \n"
                     + "Make sure you do not modify the scene from another thread!\n"
-                    + "Problem spatial name: " + getName());
+                    + "Problem spatial name: " + getName() + "\n" +
+                    SceneGraphThreadWarden.getTurnOnAssertsPrompt());
         }
 
         CullHint cm = getCullHint();

+ 8 - 0
jme3-core/src/main/java/com/jme3/scene/threadwarden/SceneGraphThreadWarden.java

@@ -135,5 +135,13 @@ public class SceneGraphThreadWarden {
         return true; // return true so can be a "side effect" of an assert
     }
 
+    public static String getTurnOnAssertsPrompt(){
+        if(ASSERTS_ENABLED){
+            return "";
+        } else{
+            return "To get more accurate debug consider turning on asserts. This will allow JME to do additional checks which *may* find the source of the problem. To do so, add -ea to the JVM arguments.";
+        }
+    }
+
 }
 

+ 1 - 0
jme3-core/src/test/java/com/jme3/scene/threadwarden/SceneGraphThreadWardenTest.java

@@ -33,6 +33,7 @@ public class SceneGraphThreadWardenTest {
         // Make sure assertions are enabled
         boolean assertsEnabled = false;
         assert assertsEnabled = true;
+        //noinspection ConstantValue
         if (!assertsEnabled) {
             throw new RuntimeException("WARNING: Assertions are not enabled! Tests may not work correctly.");
         }