ikvm icon indicating copy to clipboard operation
ikvm copied to clipboard

Package-Private access is not allowed between individual assemblies

Open dibble-james opened this issue 2 years ago • 5 comments

I briefly mentioned this to @wasabii over here and have created a little repro project: IKVM.FOP.zip

My Java and Maven knowledge is next to 0, but from anecdotal reading, the fop-util jar file here is being recreated by IKVM with a different signature, so when fop-core tries to call out to it, it think it's working with a different assembly and throws this exception:

Unhandled exception. java.lang.IllegalAccessError: Try to access field org.apache.fop.util.text.AdvancedMessageFormat.COMMA_SEPARATOR_REGEX from class org.apache.fop.util.text.IfFieldPart

In the attached repro, I've got it working with a very basic fo file, it can generate a pdf from align.xml, but there's something in basicfonts.xml that sends it down a slightly different path that then causes the error. I haven't quite figured out how to reference the jar files using IKVMReference so I can absolve IKVM here and just put it down to MavenReference.

dibble-james avatar Feb 19 '24 09:02 dibble-james

@dibble-james https://github.com/ikvmnet/ikvm/issues/493

GeorgeS2019 avatar Mar 09 '24 09:03 GeorgeS2019

So I am working on a solution to this. The basic issue is that fop is split into three JARs, which access each other's package-private members. This is fine as long as all three are loaded dynamically. However, in general IKVM use, we treat each individual JAR as a separate assembly. But, package-private members get converted to 'internal'. So, .NET cannot access across them.

The solution I'm working on currently is to use the IgnoresAccessChecksToAttribute to insure each generated assembly has access to the internals of their referenced assemblies. This does skip a .NET verification check. But, it would have no impact on a Java compiler examine the assembly exported to a stub JAR. So, access should be prevented at compile time. It's an interesting solution, and we'll see if it works.

wasabii avatar Mar 11 '24 18:03 wasabii

It also appears that this is a problem with fop itself, as they're engaged in a modernization effort for JPMS (JDK9+).

https://issues.apache.org/jira/browse/FOP-3160

wasabii avatar Mar 11 '24 18:03 wasabii

Hi, @wasabii

anything we can do to help on this issue?

I'm trying to use the FOP library in my Dotnet project, but I was able to generate PDFs only from simple XSLT/XML files.

herodrigues avatar Jun 05 '24 19:06 herodrigues

I never came up with a good solution inside IKVM as of yet. It looks like the FOP issue I referenced has since been 'resolved'. Might want to check with that and see if any changes have been made that remove need for IKVM to do anything.

wasabii avatar Jun 05 '24 19:06 wasabii