Let's Talk: Java Modules
See original GitHub issueThis issue is intended for discussion related to the Java module system that was implemented in Java 9 as part of project Jigsaw.
If implemented in a way that would allow this functionality in Java 9 or greater while maintaining backwards compatibility with Java 8 should be fairly easy, but it will create issues if a backwards compatibility system of sorts is not put in place. If a developer creates a mod and only tests against Java 8 and does not specify any module metadata for Java 9+ it would have to be put into the “Unamed module”.
For what I would consider a proper “backwards compatibility” needs the following:
- A way to read the module metadata (
module-info.java
) in mods - A basic implementation to prevent package collisions, that violates the module system
- You don’t need to prevent reflective access across “modules”, but would be nice (Modules can allow reflective access with the
opens
keyword) - Limited access across modules might not be possible, would be nice
Then the actual module loader implementation would require the following:
- A way to merge the conflicting Minecraft libraries, primarily the logger and Paule’s Audio
- A module definition for all of the included libraries plus Minecraft itself, my toy implementations based this off of the module name in the library manifest
If this is implemented properly it would allow more flexibility with libraries and prevent reflection hacking
from occurring. This prevents many issues with code accessing things that they should not, and can entirely hide internals of libraries if the need arises. It also makes it so all public fields, methods and types have to be explicitly exported. Makes it a little harder to leak info from implementations.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:7
- Comments:20 (13 by maintainers)
Top GitHub Comments
Are you kinda obsessed with security? Please don’t forget that we are modding a game… where you are talking about “hiding internals” or whatever. Are you sure this is the right direction? Malware often occurs for rehosted mods; and this only causes headache to everyone.
The only reason why would you want to use java module system in a game server is to be able to use jingsaw and minimalize size of jre installed on the host machine.
Minecraft is not some complex system made out of several microservices.
“hidding internals” if you are obessed with this why dont you rather focus on creating such api that will allow to modify X without breaking Z. Same goes for reflection access.
Java modules are a powerful tool, but completly useless for mc environment