Skip to content

Commit a7643e7

Browse files
committed
#2562 Prompt users to turn on asserts (if they haven't already)
1 parent 2a0a746 commit a7643e7

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

jme3-core/src/main/java/com/jme3/scene/Spatial.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,8 @@ public boolean checkCulling(Camera cam) {
369369
throw new IllegalStateException("Scene graph is not properly updated for rendering.\n"
370370
+ "State was changed after rootNode.updateGeometricState() call. \n"
371371
+ "Make sure you do not modify the scene from another thread!\n"
372-
+ "Problem spatial name: " + getName());
372+
+ "Problem spatial name: " + getName() + "\n" +
373+
SceneGraphThreadWarden.getTurnOnAssertsPrompt());
373374
}
374375

375376
CullHint cm = getCullHint();

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,5 +135,13 @@ public static boolean assertOnCorrectThread(Spatial spatial){
135135
return true; // return true so can be a "side effect" of an assert
136136
}
137137

138+
public static String getTurnOnAssertsPrompt(){
139+
if(ASSERTS_ENABLED){
140+
return "";
141+
} else{
142+
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.";
143+
}
144+
}
145+
138146
}
139147

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public static void setupClass() {
3333
// Make sure assertions are enabled
3434
boolean assertsEnabled = false;
3535
assert assertsEnabled = true;
36+
//noinspection ConstantValue
3637
if (!assertsEnabled) {
3738
throw new RuntimeException("WARNING: Assertions are not enabled! Tests may not work correctly.");
3839
}

0 commit comments

Comments
 (0)