-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IllegalArgumentException in registerObject() #1982
Comments
The
|
re: "While JME specifically reserves the value -1 for invalid IDs:" ...and that might actually be a valid ID also. Maybe JME should track invalid IDs in a different way. |
We could store IDs as |
It appears that |
Or Integer (capital 'i') so that it could be nullable. |
I will try this locally and see how it works both on linux and try to test it on mac as well. Thanks for looking into this. |
Got some more info from the modified build. App now loads but window is black. It seems the assertion was legit in this case:
And then
But I guess that is due to the first exception. The graphics card info makes me believe this is maybe related to Radeon cards, and not Macs:
Would it be worth downgrading lwjgl to 2.9? |
This warning can be resolved by adding the
Just in case, I am using an AMD ATI Radeon graphics card on Linux and do not have such issue. |
One thing I notice is that |
I think the jmonkeyengine/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java Lines 533 to 555 in a0c2c5e
|
More evidence that JME requires native-object IDs to be non-negative: jmonkeyengine/jme3-core/src/main/java/com/jme3/audio/AudioBuffer.java Lines 133 to 136 in cef0d3b
If the ID were negative, sign extension during the conversion to |
Might the answer here be encapsulation? Exposing the id and using it to indicate both the id of the object and the validity of it seems to be the root of the problem. Since -1 (or other negative numbers) can be a valid ID but also a signal for an invalid ID/Object, it is contradictory. We can encapsulate the id, and provide separate methods to indicate object validity. By removing access to Behind the scenes, we can either use a separate I've put in PR: #2051 as a prototype for what I mean. Perhaps anyone who can reproduce the problem can see if it fixes it. |
Encapsulation can be a breaking change for older code.
Assuming most code uses setId(INVALID_ID) and not setId(-1), this shouldn't cause any issue, and if it doesn't then there is the warning that gives a chance to figure out that there is something wrong and how to fix it. Pseudo code: public static final **long** INVALID_ID=-1;
private **long** id;
public long getId(){
return id;
}
@Deprecated
public void setId(int id){
if(id==-1){
warn("ID was set to -1. Note: this is a valid ID now, please use setId(INVALID_ID) to reset the id to the invalid ID");
}
this.id=toUnsignedInt(id);
}
public void setId(**long** id){
this.id=id;
}
|
This issue was reported at the Discourse hub/forum: https://hub.jmonkeyengine.org/t/java-lang-illegalargumentexception-object-id-must-be-greater-than-zero-on-mac/46559
jmonkeyengine/jme3-core/src/main/java/com/jme3/util/NativeObjectManager.java
Lines 104 to 107 in 44a50de
While JME specifically reserves the value
-1
for invalid IDs:jmonkeyengine/jme3-core/src/main/java/com/jme3/util/NativeObject.java
Line 47 in 44a50de
I believe negative IDs in general don't justify throwing an exception.
The OpenGL documentation doesn't specify range of values for a texture name, only that they are
GLuint
:According to the OpenGL spec,
GLuint
is at least 32 bits, so values > 0x7fffffff will produce negative values in a Javaint
.I think the tests in lines 105 and 132 should be specifically for
== INVALID_ID
instead of<= 0
.The text was updated successfully, but these errors were encountered: