Possibilities to invoke a method


You have several options to call a method with Jabaco. I'll explain the differents.


1) NormalCall - The fastest method is calling a known object:

   ' create the array list instance
   Dim realCol As New java#util#ArrayList
   ' invoke "add"
   realCol.add "value"
   ' validate
   MsgBox realCol.get(0)


2) UnknownCall - Using the Variant-Type to call a method. Internal it will use reflections so it is slightly slow:

   ' create the array list instance
   Dim col As Variant = New java#util#ArrayList
   ' invoke "add"
   col.add "value"
   ' validate
   MsgBox col.get(0)


3) CallByName - Same like the Variant-Method, but little verbosely:

   ' create the array list instance
   Dim realCol As New java#util#ArrayList
   ' create the anonym object and set the pointer to the array list
   Dim col As Object = realCol
   ' param for "add"-method
   Dim myArgs(0) As Variant
   myArgs(0) = "value"
   ' invoke "add"
   CallByName col, "add", myArgs
   ' validate
   MsgBox realCol.get(0)


4) Reflections - This is the background of 'CallByName'. More verbosely, but also more powerful:

// http://java.sun.com/docs/books/tutorial/reflect

Retrieved from "http://www.jabaco.org/wiki/Possibilities_to_invoke_a_method"

This page has been accessed 7,964 times. This page was last modified on 15 December 2008, at 09:54.



This page has been accessed 7,964 times. This page was last modified on 15 December 2008, at 09:54.