-
Notifications
You must be signed in to change notification settings - Fork 297
Make non-minecraft games support access wideners #1049
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall the idea seems sound to me. I'd change the name of the method though.
It's worth noting that downstream projects will need something like Loom to fully utilize the access changes at compile time.
That said, these changes aren't useless to projects without a loom equivalent. Access wideners can still be useful to expose members using reflection without relying on --add-opens or other workarounds.
| return LoaderUtil.hasAwtSupport(); | ||
| } | ||
|
|
||
| default boolean isAccessWidenable(String className) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd probably rename to something like canWidenAccess
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The implementation also needs to be updated to reflect the method name change.
| } | ||
|
|
||
| @Override | ||
| public boolean isAccessWidenable(String className) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will not compile because canWidenAccess() is not implemented. This method needs to be renamed.
| boolean transformAccess = isMinecraftClass && FabricLauncherBase.getLauncher().getMappingConfiguration().requiresPackageAccessHack(); | ||
| boolean environmentStrip = !isMinecraftClass || isDevelopment; | ||
| boolean applyAccessWidener = isMinecraftClass && FabricLoaderImpl.INSTANCE.getAccessWidener().getTargets().contains(name); | ||
| boolean applyAccessWidener = FabricLoaderImpl.INSTANCE.getGameProvider().isAccessWidenable(name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will not compile because isAccessWidenable() is not a method in GameProvider. You should be calling canWidenAccess().
Renamed the method in GameProvider but forgot to update the default minecraft implementation and usages. This caused build errors, and is now corrected.
|
I adjusted your approach to be more configurable by the game provider at #1056 as those properties really depend on more than whether it's a game class. In Minecraft's example we (currently still) have the "widen all" hack and the way Mojang packages it combined with how loom may present the game in-dev as a combined requires env stripping there. Other games likely don't even need these. |
|
Implemented by #1056 |
Adds support for access wideners to other games by adding a new
isAccessWidenablemethod toGameProviderand using that to determine if access wideners should be applied instead of hardcoding it for minecraft only classes inFabricTransformer.