-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Closed
Labels
Description
Issue details
ClassReflection.isArray
returns false instead of expected true.
It could be possible that isEnum
also returns wrong values, but I didn't test that.
Reproduction steps/code
package com.badlogic.gdx.tests;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.tests.utils.GdxTest;
import com.badlogic.gdx.utils.reflect.ClassReflection;
import com.badlogic.gdx.utils.reflect.ReflectionException;
public class IsArrayIssueTest extends GdxTest {
public void create () {
testIsArray();
}
public void testIsArray () {
Class c = null;
try {
c = ClassReflection.forName("com.badlogic.gdx.math.Vector2[]");
} catch (ReflectionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
boolean isArray= c.isArray();
Gdx.app.log("ClassReflectionTest", "native is array: " + isArray);
boolean gdxIsArray= ClassReflection.isArray(c);
Gdx.app.log("ClassReflectionTest", "gdx is array: " + gdxIsArray);
}
}
Expected results are
native is array: true
gdx is array: true
Actual results are
native is array: true
gdx is array: false
Version of LibGDX and/or relevant dependencies
LibGdx 1.9.2 & Gwt 2.7.0
Suggested fix
Just use the isArray
method of Class
.
Where's the problem
The problem is that c
is always null
, when it's used to generate the reflection information for a foo[]
class, so https://github.com/libgdx/libgdx/blob/master/backends/gdx-backends-gwt/src/com/badlogic/gwtref/gen/ReflectionCacheSourceCreator.java#L537 will never be entered and isArray
will never be set to true
.
Instead, of using c
we should probably use t
which is of the type JArrayType
and t.isArray
is != null
, for foo[]
.
Please select the affected platforms
- Android
- iOS
- HTML/GWT
- Windows
- Linux
- MacOS