Android Question [SOLVED] Reflection and template argument

Discussion in 'Android Questions' started by wonder, May 24, 2019.

  1. wonder

    wonder Expert Licensed User



    This is a Reflection question, so please read-on even if you're not familiar with LibGDX.

    With regards to LibGDX, I'm trying to access (with reflection) the "derivativeAt" method of the CatmullRomSpline class, but I'm unfortunately getting a NoSuchMethod exception.


    LibGDX CatmullRomSpline Source code:

    For reference, I tried to access "valueAt", which I'm sure it works:
    Dim out As lgMathVector2

    'This works!!
    preview_spline.ValueAt(out, 0.5)

    'This doesn't work!!
    Dim r As Reflector
    r.Target = preview_spline
    "valueAt"Array(out, 0.5), Array As String("com.badlogic.gdx.math.Vector2""java.lang.float"))

    'java.lang.NoSuchMethodException: valueAt [interface com.badlogic.gdx.math.Vector, float]
    '    at java.lang.Class.getMethod(
    '    at java.lang.Class.getDeclaredMethod(
    '    at anywheresoftware.b4a.agraham.reflection.Reflection.runmethod(
    '    at anywheresoftware.b4a.agraham.reflection.Reflection.RunMethod4(
    '    at com.ninjadynamics.mangamotion.mangapage._drawpathpreview(
    '    at com.ninjadynamics.mangamotion.mangapage._drawmotionpaths(
    '    at com.ninjadynamics.mangamotion.main._lgs1_render(
    '    at java.lang.reflect.Method.invoke(Native Method)
    '    at anywheresoftware.b4a.BA.raiseEvent2(
    '    at anywheresoftware.b4a.libgdx.lgScreenManager$lgScreen.render(SourceFile:125)
    '    at anywheresoftware.b4a.libgdx.lgScreenManager.Render(SourceFile:75)
    '    at anywheresoftware.b4a.libgdx.LibGDX$b.render(SourceFile:156)
    '    at
    '    at android.opengl.GLSurfaceView$GLThread.guardedRun(
    '    at android.opengl.GLSurfaceView$
    '** Activity (main) Pause, UserClosed = true **
    'waiting for pause synchronization took too long; assuming deadlock and killing
    Can anyone please help or point me in the right direction? Many thanks in advance!
    Last edited: May 24, 2019
  2. Informatix

    Informatix Expert Licensed User

    r.Target = preview_spline.InternalObject
    Peter Simpson likes this.
  3. wonder

    wonder Expert Licensed User

    Hi! Thanks for the quick reply!

    Dim r As Reflector
    r.Target = preview_spline.InternalObject
    "valueAt"Array(out, 0.5), Array As String("com.badlogic.gdx.math.Vector2""java.lang.float"))
    java.lang.NoSuchMethodException: valueAt [class com.badlogic.gdx.math.Vector2, float]

    Still the same... :(
  4. wonder

    wonder Expert Licensed User

    I found the solution! :) :D

    It seems that for a template type argument, "java.lang.Object" can be used.
    Also, for LibGDX the InternalObject member has to be used as well.

    Dim out as lgMathVector2
    Dim r As Reflector
    r.Target = preview_spline.InternalObject
    Dim f = 0.5 As Float
    "valueAt"Array(out, f), Array As String("java.lang.Object""java.lang.float"))
    Peter Simpson and Informatix like this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice