Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Package-Private access is not allowed between individual assemblies #491

Open
dibble-james opened this issue Feb 19, 2024 · 3 comments
Open

Comments

@dibble-james
Copy link

dibble-james commented Feb 19, 2024

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.

@GeorgeS2019
Copy link

@dibble-james
#493

@wasabii wasabii changed the title java.lang.IllegalAccessError When referencing FOP via MavenReference Package-Private access is not allowed between individual assemblies Mar 11, 2024
@wasabii
Copy link
Contributor

wasabii commented Mar 11, 2024

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
Copy link
Contributor

wasabii commented Mar 11, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants