Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

This issue can extended using native types only when JVM counter-part is a native type, otherwise use the JVM class. #371

Closed
masesdevelopers opened this issue Feb 23, 2024 · 1 comment · Fixed by #372 or #373
Assignees
Labels
enhancement New feature or request JNet JNet related issue JNetReflector JNetReflector related issue .NET Pull requests that update .net code

Comments

@masesdevelopers
Copy link
Contributor

          This issue can extended using native types only when JVM counter-part is a native type, otherwise use the JVM class.

Some examples are:

  • bool when there is a JVM boolean, otherwise use Java.Lang.Boolean which can be managed like a Nullable type in .NET withbool?
  • int when there is a JVM int, otherwise use Java.Lang.Integer which can be managed like a Nullable type in .NET withint?

Originally posted by @masesdevelopers in #363 (comment)

@masesdevelopers
Copy link
Contributor Author

The following snippet of code does not work as expected:

        static void TestSimpleOperatorsExtension<TJVM, TNet>(params TNet[] dataInput)
            where TJVM : INativeConvertible<TJVM, TNet>, new()
        {
            var jvmArray = dataInput.ToJVMArray<TJVM, TNet>();

            var jvmIterable = dataInput.ToJVMCollectionType<ArrayList<TJVM>, TJVM, TNet>();

            var netList = jvmArray.ToNetCollectionType<System.Collections.Generic.List<TNet>, TNet, TJVM>(); // raise exception

            TNet[] arrayNet = jvmIterable.ToNetArray<TNet, TJVM>();

            if (!dataInput.SequenceEqual(arrayNet)) throw new System.InvalidOperationException();
        }

The main reason is that, currently, JCOBridge assumes, by default, to convert types like "java.lang.String" into native .NET types (string). JCOBridge needs an update to distinguish raw native types from convertible native types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment