3 ms·
Modules fix two issues that plagues Java for a long time, classpath resolution and monkey patching using reflection. For the former, the classpath is a colon s
by _old_dude_ 5y ago
Modules fix two issues that plagues Java for a long time, classpath resolution and monkey patching using reflection.
For the former, the classpath is a colon separated list of jars (a zip containing the classes). At runtime the VM tries to find a class by scanning linearly all the jars, when needed or panic with a NoClassDefFoundError.
The modulepath is a colon separated list of directories that contains some jars. At runtime, the VM revolves the dependencies (stored in the module descriptor of each jar) before starting the application.
For the later, when you define a module you have to explicitly export packages and open them to reflection
- pjmlp 5y agoThat later solution won't work after Java 17, which I agree with. Java is not the language for doing monkey patching with internals. https://openjdk.java.net/jeps/403 https://openjdk.java.net/jeps/403 Notice that on Android, this kind of tricks earn you the prize of the system killing the process and be done with it.