NOTES LS2J QUICK TIP: Function for collecting method signatures

When using LS2J to utilize Java classes from within LotusScript, you may be faced with needing to declare and bind to a method explicitly using its JNI signature. A common case where this is necesary is when your Java class has multiple overridden methods and you need to explicitly use one of them. Instead of wrestling with the JNI syntax, you can use this handy function to bind to the object and print out the signatures for you to copy:

  1. Function getMethodSignatures(jClass As Javaclass, l As noteslog)
  2. Dim msg$
  3. Dim methods As JavaMethodCollection
  4. Set methods = jclass.Getclassmethods()
  5. ForAll meth In methods
  6. msg$ = meth.Methodname & " - SIG: " & meth.Signature
  7. If Not(l Is Nothing) Then Call l.logaction(msg$)
  8. Print msg$
  9. End ForAll
  10.  
  11. End Function

A sample output from the NotesLog looks like this:

  1. Started running agent 'LS Method Enumerator Test' on 01/21/2010 03:25:25 PM
  2. 01/21/2010 03:25:26 PM: equals - SIG: (Ljava/lang/Object;)Z
  3. 01/21/2010 03:25:26 PM: hashCode - SIG: ()I
  4. 01/21/2010 03:25:26 PM: toString - SIG: ()Ljava/lang/String;
  5. 01/21/2010 03:25:26 PM: generate - SIG: (Ljava/lang/String;Ljava/lang/String;Ljava/util/HashMap;)V
  6. 01/21/2010 03:25:26 PM: setPageOrientation - SIG: (Z)V
  7. 01/21/2010 03:25:26 PM: generate - SIG: (Ljava/lang/String;Ljava/lang/String;)V
  8. 01/21/2010 03:25:26 PM: addToRoot - SIG: (Ljava/lang/String;Ljava/lang/Object;)V
  9. 01/21/2010 03:25:26 PM: removeFromRoot - SIG: (Ljava/lang/String;)V
  10. 01/21/2010 03:25:26 PM: resetRoot - SIG: ()V
  11. 01/21/2010 03:25:26 PM: getClass - SIG: ()Ljava/lang/Class;
  12. 01/21/2010 03:25:26 PM: notify - SIG: ()V
  13. 01/21/2010 03:25:26 PM: notifyAll - SIG: ()V
  14. 01/21/2010 03:25:26 PM: wait - SIG: ()V
  15. 01/21/2010 03:25:26 PM: wait - SIG: (J)V
  16. 01/21/2010 03:25:26 PM: wait - SIG: (JI)V
  17. 01/21/2010 03:25:26 PM: main - SIG: ([Ljava/lang/String;)V
  18. Ran LotusScript code
  19. Done running agent 'LS Method Enumerator Test' on 01/21/2010 03:25:26 PM

Kindly rate this post using the star system below and/or rate my authoring abilities on Scribnia.

SHAMELESS PLUG: Like what you see? Hire Me! Contact [email protected] or use the contact page to learn more about engaging Jake Ochs for your development needs.