Creating instance and calling instance method

This article provides an introduction to cross-technology invocation of instance methods when calling a instance method from any runtime using any language. The article explains how to create instance of class and invoke any instance method, pass arguments and retrieve the results.

With Javonet you can interact with classes from any runtime like they were available in any language but invocation must be performed through Javonet SDK API, passing type and method name as string.

Javonet allows you to pass any any language value type as argument to instance method from any runtime. In example: int, float, string, char, long and other. For reference type arguments (instances of other classes) you can create such instance with Javonet and pass the Invocation Context variable referencing that object as argument of static method invocation.

Creating instance and calling instance method from custom any runtime

With Javonet it is possible to reference any custom any runtime and interact with public methods declared on types defined within that module almost the same as with any other any language library.

This section present sample custom any runtime with class declaring methods and Javonet SDK syntax required to create object and invoke that methods and consume the results in any language.

Code example below represents sample code from any runtime that will be used in following sections:

It is possible to invoke one of the declared instance methods from any runtime using following any language code. This uses in memory runtime bridging to load the any runtime, and next retrieves reference to specific type, creates object of the type, and invokes the instance method passing value type arguments. Result of the invocation is returned as regular any language value and can be used for further processing.

Select technology of module you want to use:

Standard any runtime

The same steps are required to use types and methods from standard any runtime:

Select technology of module you want to use: