jMonkeyEngine / jMonkeyEngine/jmonkeyengine

IllegalArgumentException in registerObject()

Open
#1,982 13 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

  • #2051 by @andygibson — closed without merging
bug
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

https://github.com/jMonkeyEngine/jmonkeyengine/blob/44a50de4d7797dc3dd8d46cd1f51308e9a05d627/jme3-core/src/main/java/com/jme3/util/NativeObjectManager.java#L104-L107

While JME specifically reserves the value -1 for invalid IDs:

https://github.com/jMonkeyEngine/jmonkeyengine/blob/44a50de4d7797dc3dd8d46cd1f51308e9a05d627/jme3-core/src/main/java/com/jme3/util/NativeObject.java#L47

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 Java int.

I think the tests in lines 105 and 132 should be specifically for == INVALID_ID instead of <= 0.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.