Using Value-Type and Reference-Type Arrays

You are browsing legacy Javonet 1.5 (Java<>.NET bridge for Windows) documentation. Use the left side menu or click here to switch to latest Javonet 2.0 documentation. Javonet 2.0 allows you to use any module from JVM, CLR, Netcore, Python, Ruby, Perl, NodeJS on Windows, Linux and MacOs from any application created in Java, Clojure, Groovy, Kotlin, C#, F#, J#, VB.NET, Python, Perl, Ruby, JavaScript, TypeScript, C++ and GoLang

With Javonet, you can use any value-type or reference-type arrays. Arrays can be retrieved from field or property values, returned as method invocation results, or passed as arguments or set to fields and properties. All array operations can be performed both on instance and static elements.

Using arrays is very simple. Value-typed arrays are translated into regular arrays of corresponding Java types. Reference-typed arrays are represented as array of NObject/JObject objects.

Assuming we have a custom JAR library with the following class inside:

This snippet doesn't support selected combination of technologies.

To use method from this class in Java:

I code in:

This snippet doesn't support selected combination of technologies.

Java

Starting with version 1.4hf34 you can also retrieve a mixed arrays of value and reference types. In such case you will received on Java side an Object[] which will consist of NObject items and Java value types like (float, double, int, etc..).

See Live Example!