ikvmnet / ikvm

A Java Virtual Machine and Bytecode-to-IL Converter for .NET
Other
1.15k stars 109 forks source link

IkvmReference jar(s) to dll not working #519

Open ThatCanadianGuy opened 2 months ago

ThatCanadianGuy commented 2 months ago

I am trying to use IKVM in combination with a W3C library called "epubCheck" (the release found here: https://github.com/w3c/epubcheck/releases/tag/v5.1.0). It unzips into basically a jar file and a lib folder of many jar file dependencies. It can be used against an ePub file to get syntax issues etc.

In the sample project linked below, the following command works fine: java -jar .\IKVMTest\epub\epubcheck.jar 'IKVMTest\Book of Cheese.epub'

I've been using a <TargetFramework>net8.0</TargetFramework> project to attempt to use this library within .NET. Unfortunately, when I attempt to run the project (Program.cs) which is meant to load the included Epub file and validate it, the program throws the following: image

My IkvmReference inclusion for the csproj is as follows:

    <ItemGroup>
        <IkvmReference Include="epub\epubcheck.jar">
            <AssemblyName>EpubCheckInternal</AssemblyName>
            <AssemblyVersion>5.1.0</AssemblyVersion>
            <AssemblyFileVersion>5.1.0</AssemblyFileVersion>
            <Compile>epub\lib\accessors-smart-2.4.9.jar;epub\lib\asm-9.3.jar;epub\lib\checker-qual-3.12.0.jar;epub\lib\common-image-3.9.4.jar;epub\lib\common-io-3.9.4.jar;epub\lib\common-lang-3.9.4.jar;epub\lib\commons-codec-1.15.jar;epub\lib\commons-compress-1.21.jar;epub\lib\error_prone_annotations-2.11.0.jar;epub\lib\failureaccess-1.0.1.jar;epub\lib\galimatias-0.1.3.jar;epub\lib\guava-31.1-jre.jar;epub\lib\httpclient5-5.1.3.jar;epub\lib\httpcore5-5.1.3.jar;epub\lib\httpcore5-h2-5.1.3.jar;epub\lib\icu4j-72.1.jar;epub\lib\imageio-core-3.9.4.jar;epub\lib\imageio-jpeg-3.9.4.jar;epub\lib\imageio-metadata-3.9.4.jar;epub\lib\isorelax-20030108.jar;epub\lib\j2objc-annotations-1.3.jar;epub\lib\jackson-core-asl-1.9.12.jar;epub\lib\jackson-mapper-asl-1.9.12.jar;epub\lib\jing-20181222.jar;epub\lib\json-path-2.8.0.jar;epub\lib\json-path-assert-2.8.0.jar;epub\lib\json-smart-2.4.10.jar;epub\lib\jsr305-3.0.2.jar;epub\lib\listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar;epub\lib\sac-1.3.jar;epub\lib\Saxon-HE-11.4.jar;epub\lib\slf4j-api-1.7.36.jar;epub\lib\slf4j-nop-1.7.36.jar;epub\lib\xercesImpl-2.9.1.jar;epub\lib\xml-apis-1.4.01.jar;epub\lib\xmlresolver-4.4.3-data.jar;epub\lib\xmlresolver-4.4.3.jar</Compile>
        </IkvmReference>
    </ItemGroup>

I put all the lib files into compile hoping that keeping them in the single DLL would sort out what seems to be a reference problem, but no dice. Not having them there also fails right away unsurprisingly.

I also tried importing separate IkvmReference entries for each of the lib folder jars and set all of them as <References> to the main jar file, but my error changes to this: image

I've attached the alternate IkvmReferences for the above. AlternativeIkvmReference.txt

I'm not quite sure at this point what I could be doing incorrectly. The instructions in the README seem pretty straightforward but it's certainly blocking.

The minimal test project can be found here (OneDrive as the project is 30MB which is > the 25MB limit for github) : https://1drv.ms/u/c/1db177f83744cbe2/EcfVt1Vfi_xPs_6ESJLVprEBlAOVk9UF6H4bda-3SqhDLg?e=oZfN4J

Any support would be greatly appreciated!

wasabii commented 2 months ago

Check the build output. Might need to look in the cache directory in $temp/ikvm

ThatCanadianGuy commented 2 months ago

Thanks for the response! Looking at that path I'm seeing the following log file in the version with all the compiles from my original issue: EpubCheckInternal.dll.log

I notice there are some class not found items, though the interesting one is this:

ERROR: warning IKVMC0119: Emitted java.lang.VerificationError in "com.google.common.collect.RegularImmutableMap.fromEntryArrayCheckingBucketOverflow(I[Ljava.util.Map$Entry;Z)Lcom.google.common.collect.ImmutableMap;" ERROR: ("Incompatible object argument for function call (class: com.google.common.collect.RegularImmutableMap, method: fromEntryArrayCheckingBucketOverflow, signature: (I[Ljava.util.Map$Entry;Z)Lcom.google.common.collect.ImmutableMap;, offset: 204, instruction: invokevirtual)")

Is this an error you're familiar with? It's the same one I get at execution of the sample project.

wasabii commented 2 months ago

https://github.com/ikvmnet/ikvm/issues/318

Seen it before. Status is the same though, haven't dug into it.

wasabii commented 2 months ago

https://stackoverflow.com/questions/71095560/java-lang-nosuchmethoderror-com-google-common-collect-immutablemap-error-when

wasabii commented 2 months ago

https://forum.image.sc/t/upgrading-to-bioformats-6-13-causes-error-with-ikvm/80696