Skip to content

IllegalArgumentException in registerObject() #1982

Open
@stephengold

Description

@stephengold

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

public void registerObject(NativeObject obj) {
if (obj.getId() <= 0) {
throw new IllegalArgumentException("object id must be greater than zero");
}

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

public static final int INVALID_ID = -1;

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething that is supposed to work, but doesn't. More severe than a "defect".

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions