ikvmnet / ikvm

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

Reduce redistribution size #495

Closed Fabian-Schmidt closed 3 months ago

Fabian-Schmidt commented 3 months ago

Thanks for the library, I am able to convert Java bytecode to a .NET assembly. The resulting assembly has a reference to IKVM.Java.dll which is 60MB large.

Is it possible to reduce / shrink the package size?

This large package is blocking my usage of this package.

wasabii commented 3 months ago

You might be able to use the latest .Net trimming stuff. If you're careful. But that's about it.

Fabian-Schmidt commented 3 months ago

Good Suggestion.

Unfortunately this is not an option as I must build the library for .NET Full Framework and not Core :-|

wasabii commented 3 months ago

I'd bet theres some third party trimming utiltiy that preceeded Core. Wouldn't surprise me at all.

Otherwise, kind of out of luck I think. IKVM.Java.dll contains the full Java base class library. Which, in Java-land, would have all been distributed as rt.jar anyways.

If we ever make it to JDK9, this will likely get better, as JDK9 reorganized the BCL in a way where we are likely to package it as separate assemblies.

Fabian-Schmidt commented 3 months ago

I found some very very old examples of the IKVM project (Version 8.1.5717.0). In there the OpenJDK is broken up into individual dlls and if I don't use parts I can remove them and therefore decrease the package size to under 10MB while the assembly is still fully functional.

Looks like this approach is no longer feasible?

wasabii commented 3 months ago

Correct. That break up was pretty artificial. It wasn't based on any JVM specification. So, we opted to merge it all together into a single assembly that lives in a single class loader when introducing the .NET Core version. The same way Java VMs distribute a single rt.jar, we distribute a single IKVM.Java.

JDK9, with it's introduction of JPMS, splits up the source and distribution into separate packages, along meaningful boundaries: java.base, java.compiler, java.desktop, etc. When we introduce JDK9 support, sometime, eventually, we'll follow those boundaries as well. But not until then.

Fabian-Schmidt commented 3 months ago

Thanks for the quick and insightful Response.