Skip to content

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

Closed

Description

@masesdevelopers
          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)

Activity

  1. added
    enhancementNew feature or request
    JNetJNet related issue
    .NETPull requests that update .net code
    JNetReflectorJNetReflector related issue
    on Feb 23, 2024
  2. masesdevelopers commented on Feb 24, 2024

    @masesdevelopers
    ContributorAuthor

    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

Metadata

Metadata

Labels

.NETPull requests that update .net codeJNetJNet related issueJNetReflectorJNetReflector related issueenhancementNew feature or request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions