jMonkeyEngine / jMonkeyEngine/jmonkeyengine
IllegalArgumentException in registerObject()
Nobody has claimed this yet.
- #2051 by @andygibson — closed without merging
- Dominant language
- Java
- Stars
- 4.3k
- Forks
- 1.2k
- Avg merge
- 4d 7h
- Merged PRs (30d)
- 14
Description
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
While JME specifically reserves the value -1 for invalid IDs:
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:
- https://registry.khronos.org/OpenGL-Refpages/gl4/html/glGenBuffers.xhtml
- https://registry.khronos.org/OpenGL-Refpages/gl4/html/glGenTextures.xhtml
According to the OpenGL spec, GLuint is at least 32 bits, so values > 0x7fffffff will produce negative values in a Java int.
I think the tests in lines 105 and 132 should be specifically for == INVALID_ID instead of <= 0.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with jme3-core/src/main/java/com/jme3/util/NativeObjectManager.java at the checks around lines 105 and 132, then read NativeObject.java around the INVALID_ID definition. Confirm how OpenGL GLuint values are represented as Java ints and update the behavior so only the reserved invalid ID is rejected. Run the relevant jme3-core tests and verify valid negative IDs no longer trigger the exception.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100