Binding Library - *.jna namespace missed

zerokewl88zerokewl88 Member ✭✭
edited October 8 in Xamarin.Android

I have noticed that a namespace is missed out for some reason when attempting to bind a binding library.

Do the Binding Library Project's skip anything with a namespace including .jna ?

In this screenshot, all the other namespaces have been reoslved, and i can bind them, except these are simply missing ?

I am attempting to bind quite a large library, and we have to use a specific version of the JNA, which I have already added as a EmbeddedReferenceJar - it just seems to not pick this namespace up and add it to the assembly when it's create.

Thank You.

Added:

Further more, i can see that the com.sun.jna namespace is also not added for some reason, and alot of my bindings are complaining because of these default types that it can not find.

BINDINGSGENERATOR : warning BG8102: Class Com.[obfuscated].Jna.HNObject has unknown base type com.sun.jna.PointerType.
BINDINGSGENERATOR : warning BG8102: Class Com.[obfuscated].Jna.NativeSize has unknown base type com.sun.jna.IntegerType.

1> BINDINGSGENERATOR : warning BG8102: Class Com.[obfuscated].Jna.NMemory has unknown base type com.sun.jna.Memory.
1> BINDINGSGENERATOR : warning BG8103: Class Com.[obfuscated].Jna.NativeArray has invalid base type com.[obfuscated].jna.NMemory.
1> BINDINGSGENERATOR : warning BG8103: Class Com.[obfuscated].Jna.NObjectArrayBase has invalid base type com.[obfuscated].jna.NativeArray.
1> BINDINGSGENERATOR : warning BG8103: Class Com.[obfuscated].Jna.ArrayArray has invalid base type com.[obfuscated].jna.NObjectArrayBase.
1> BINDINGSGENERATOR : warning BG8103: Class Com.[obfuscated].Jna.ByteBufferArray has invalid base type com.[obfuscated].jna.NativeArray.
1> BINDINGSGENERATOR : warning BG8103: Class Com.[obfuscated].Jna.ByteOrderArray has invalid base type com.[obfuscated].jna.NativeArray.
1> BINDINGSGENERATOR : warning BG8103: Class Com.[obfuscated].Jna.DateArray has invalid base type com.[obfuscated].jna.NativeArray.
1> BINDINGSGENERATOR : warning BG8103: Class Com.[obfuscated].Jna.DurationArray has invalid base type com.[obfuscated].jna.NativeArray.
1> BINDINGSGENERATOR : warning BG8102: Class Com.[obfuscated].Jna.HNCallback has unknown base type com.sun.jna.PointerType.
1> BINDINGSGENERATOR : warning BG8102: Class Com.[obfuscated].Jna.HNString has unknown base type com.sun.jna.PointerType.
1> BINDINGSGENERATOR : warning BG8103: Class Com.[obfuscated].Jna.NByteTypeArray has invalid base type com.[obfuscated].jna.NativeArray.
1> BINDINGSGENERATOR : warning BG8103: Class Com.[obfuscated].Jna.NEnumArray has invalid base type com.[obfuscated].jna.NativeArray.
1> BINDINGSGENERATOR : warning BG8103: Class Com.[obfuscated].Jna.NEnumSetArray has invalid base type com.[obfuscated].jna.NativeArray.
1> BINDINGSGENERATOR : warning BG8102: Class Com.[obfuscated].Jna.NFunctionMapper has unknown base type com.sun.jna.win32.W32APIFunctionMapper.
1> BINDINGSGENERATOR : warning BG8103: Class Com.[obfuscated].Jna.NIntTypeArray has invalid base type com.[obfuscated].jna.NativeArray.
1> BINDINGSGENERATOR : warning BG8C00: For type Com.[obfuscated].Jna.INLibrary, base interface com.sun.jna.Library does not exist.
1> BINDINGSGENERATOR : warning BG8502: Invalidating Com.[obfuscated].Jna.INLibrary and all nested types because some of its interfaces were invalid.
1> BINDINGSGENERATOR : warning BG8103: Class Com.[obfuscated].Jna.NLongTypeArray has invalid base type com.[obfuscated].jna.NativeArray.
1> BINDINGSGENERATOR : warning BG8103: Class Com.[obfuscated].Jna.NObjectArray has invalid base type com.[obfuscated].jna.NObjectArrayBase.
1> BINDINGSGENERATOR : warning BG8103: Class Com.[obfuscated].Jna.NRationalArray has invalid base type com.[obfuscated].jna.NativeArray.
1> BINDINGSGENERATOR : warning BG8103: Class Com.[obfuscated].Jna.NShortTypeArray has invalid base type com.[obfuscated].jna.NativeArray.
1> BINDINGSGENERATOR : warning BG8103: Class Com.[obfuscated].Jna.NStringWrapper has invalid base type com.[obfuscated].jna.NMemory.
1> BINDINGSGENERATOR : warning BG8103: Class Com.[obfuscated].Jna.NStructure has invalid base type com.[obfuscated].jna.NMemory.
1> BINDINGSGENERATOR : warning BG8103: Class Com.[obfuscated].Jna.NStructureArray has invalid base type com.[obfuscated].jna.NativeArray.
1> BINDINGSGENERATOR : warning BG8102: Class Com.[obfuscated].Jna.NativeSize has unknown base type com.sun.jna.IntegerType.
1> BINDINGSGENERATOR : warning BG8103: Class Com.[obfuscated].Jna.NativeSizeArray has invalid base type com.[obfuscated].jna.NativeArray.
1> BINDINGSGENERATOR : warning BG8103: Class Com.[obfuscated].Jna.ObjectArray has invalid base type com.[obfuscated].jna.NObjectArrayBase.
1> BINDINGSGENERATOR : warning BG8103: Class Com.[obfuscated].Jna.PointerArray has invalid base type com.[obfuscated].jna.NativeArray.
1> BINDINGSGENERATOR : warning BG8103: Class Com.[obfuscated].Jna.StringArray has invalid base type com.[obfuscated].jna.NativeArray.
1> BINDINGSGENERATOR : warning BG8102: Class Com.[obfuscated].Jna.Ptr.BooleanByReference has unknown base type com.sun.jna.ptr.ByReference.
1> BINDINGSGENERATOR : warning BG8102: Class Com.[obfuscated].Jna.Ptr.CharByReference has unknown base type com.sun.jna.ptr.ByReference.
1> BINDINGSGENERATOR : warning BG8102: Class Com.[obfuscated].Jna.Ptr.HNCallbackByReference has unknown base type com.sun.jna.ptr.ByReference.
1> BINDINGSGENERATOR : warning BG8102: Class Com.[obfuscated].Jna.Ptr.HNObjectByReference has unknown base type com.sun.jna.ptr.ByReference.
1> BINDINGSGENERATOR : warning BG8102: Class Com.[obfuscated].Jna.Ptr.HNStringByReference has unknown base type com.sun.jna.ptr.ByReference.
1> BINDINGSGENERATOR : warning BG8102: Class Com.[obfuscated].Jna.Ptr.NativeSizeByReference has unknown base type com.sun.jna.ptr.ByReference.

How come these are not bound and added to the binding library ?

Answers

  • LeonLuLeonLu Member, Xamarin Team Xamurai

    Based on your error message, I found your issue is related to the this thread.

    Java allows deriving a public class from non-public class, but this is unsupported in .NET. Since the binding generator does >not generate bindings for non-public classes, derived classes such as these cannot be generated correctly. To fix this, either >remove the metadata entry for those derived classes using the remove-node in Metadata.xml, or fix the metadata that is >making the non-public class public. Although the latter solution will create the binding so that the C# source will build, the >non-public class should not be used.

    You could change the names.

    <attr path="/api/package[@name='com.some.package']/class[@name='SomeClass']" visibility">public</attr>

  • zerokewl88zerokewl88 Member ✭✭
    edited October 8

    Hi @LeonLu , thanks for your reply.

    I have tried doing this for a particular reference like so.

    <attr path="/api/package[@name='com.sun.jna']/class[@name='PointerType']" name="visibility">public</attr>

    But can still see that the namespace is omitted and not available from the generated assembly.

    warning BG8A04: <attr path="/api/package[@name='com.sun.jna']/class[@name='PointerType']"/> matched no nodes.

    Added: Additionally, this particular section describes a issue for private / hidden members, where as the types i'm trying to bind with and are public - I am using the Java Decompiler GUI to look at the classes and references.

    I also just had another look at this class in the com.sun.java.PointerType.class, and i can see some keywords i think that would not be liked in C# that could also be the cause of it not being picked up by the BINDINGGENERATOR.

    This .jar file that I am also trying to add as a EmbeddedReference, is also the main jna type, is this not a common requirement when binding and not something that is needed by most Binding Library projects ? I find it strange that i am having this trouble with this particular JNA 4.5.jar file, and think alot more people would have had this issue - this leads me to think, am i doing something wrong here, and is the actual JNA not even being picked up and Xamarin takes care of this some other way ?

  • zerokewl88zerokewl88 Member ✭✭

    Actually, working and backtracking through the added JNA, and trying to just create a BindingLibrary for that, i found alot of errors i think which result in it not binding properly - this post led me to find the JNA binding issue.

    I think i need to resolve those issues first, and see the resolved types, then work back to referencing that project and can continue binding from there.

    https://stackoverflow.com/questions/44616449/xamarin-android-cannot-embed-jna-4-2-0-jar-into-an-android-binding-project

Sign In or Register to comment.