CARVIEW |
Select Language
HTTP/2 301
server: AkamaiGHost
content-length: 0
location: https://mail.openjdk.org/pipermail/jpms-spec-comments/2015-December/000015.html
date: Thu, 31 Jul 2025 08:05:49 GMT
HTTP/2 200
content-type: text/html
last-modified: Mon, 11 Jul 2016 15:04:33 GMT
etag: "210d-5375d7847a240"
accept-ranges: bytes
x-akamai-transformed: 0 - 0 -
vary: Accept-Encoding
content-encoding: gzip
date: Thu, 31 Jul 2025 08:05:50 GMT
content-length: 3627
set-cookie: _abck=2A09C70AF88DB02E5BAA1A5FD7E96F05~-1~YAAQNAHARXTrMT2YAQAA+xyEXw4ZrY322goVu77gKCPViJpkgRhdSVwib7MvPk7oInevbaouQ/q4e3Hdc5uIVYaiO+9GS4SO6SUHxxc43Mh/y2aiSFKs/HxIGMDAE1+1AAxLuzEpBamm0PUQ5Ssax+CsV6AgIuga8rprE2IAegWcGxeyUHRGsZSJbDwFT2jJi9iUR5YJGNPPp4UvZVuEO6K09w8XFsh2dGY09B285CTfsbjXcVy37DURSJONUHAYFyqkPGv3AQB8wEmDYB1/CQcDtCYmwwi369K4ytqNQfaQ+e2QO/sbcKqMbzM3Q8n5XdzduAmuWYIcsVdHHpQEG9yQOPdsUTDPSrKco/ixL9/eQnVcbeZNG29MgAA+zOEa9+g088oNEKrBqbpkjxngDO8CvQTqzPEByok8dV/UfDTXGRGGE7KrXGq/U3XhacMl6RCwQ0U=~-1~-1~-1; Domain=.openjdk.org; Path=/; Expires=Fri, 31 Jul 2026 08:05:50 GMT; Max-Age=31536000; Secure
set-cookie: bm_sz=A1058C8E3452BAB810A28F1B35F22BA0~YAAQNAHARXXrMT2YAQAA+xyEXxywfn5tLgqUY0KOP2JLKmzeP63CHJmEZa41tC6Y6QoXHD78c3ozSRvUfehSCVZe6DB2+4yrOfirn6aW0TACONUZTB0qrPwNpVcAzc7IxKb5RvRh07WjBB9ND0UL/Bar/7eP4SsPo0rMPheR0Tf10w0JqlVC2pSyfT81bA747y/wQxQZ4gC01B80ZNt2GNn5NyPYOiVffSeezT4S4MjTbBU8y4+AxWM78Ly//xozlyrvZ+HEZi6hF8j/SLlpVbtAaLv71H8Jrk7YFbRtYaCRGABmJZ6rsCSQq8LyKFqf82ttVlorsIryDOXdn6LirPqvVbssoFCLklP1F5fTO6N9afEh/wTA8es=~3356464~3687481; Domain=.openjdk.org; Path=/; Expires=Thu, 31 Jul 2025 12:05:49 GMT; Max-Age=14399
Suggestions for improvements of Java modules
Thu Dec 17 13:51:44 UTC 2015
More information about the jpms-spec-comments mailing list
Suggestions for improvements of Java modules
Stephane Epardaud stef at epardaud.frThu Dec 17 13:51:44 UTC 2015
- Previous message: Fwd: Why can modules not be annotated?
- Next message: Payment for driving on toll road, invoice #0000943507
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi, As part of the integration with Ceylon we observed the following limitations of Java 9 which I'd like to ask you to consider: = Optional module imports. This has been pointed out by various users and it should be simple to implement because they would be required at compile-time and optional at run-time, where the linker would just not link that module if it can't find it in the module path. That's pretty useful in many module systems to describe dependencies that will be used if present, but not in the minimal runtime deployment. Discovery is typically via reflection of a class of the optional module, but could be extended by an API of the module such as `this.getClass().getModule().getLayer().hasModule("com.foo")` (or similar). = Versions for module imports. I know this is meant to be off-topic and left to build tools, and I understand why Java wants to leave that hard problem to others. But in much the same way that Java 9 modules support setting an optional module version in the jar tool, ending up as an optional module descriptor class attribute, it would be really great if the module descriptor class file allowed for optional module import versions. Even if the source `module-info.java` does not require them, even if it does not allow them optionally. If the binary form allows versions to be put in there, which would represent the version used at compile-time (even javac could fill it in), then that information is going to be very useful because it means we can take a compiled Java 9 module and we know what it was compiled against. It means that I can run that module without having to download other descriptors. Of course I would suggest that it be possible to specify them in the source module descriptor and javac be able to check that the modules it has in its module path correspond to what the user wants to depend on, but again, if you don't want that, its optional presence in the binary form would already be much better, so that other languages can store (and use) that info. = Module cycles. This is expressely disallowed at compile-time and allowed at run-time only via reflection. I found that to be very annoying. I understand the arguments against module cycles boil down to suggesting to merge them as a single module. This is in effect what forces `java.base` to include collections, time and lots of other things. I understand that argument, and I agree that importing a module with cycles is equivalent to importing the whole group. But it is very useful in terms of authoring to split up a large module into inter-dependent ones. Each module can have its own maintainer and test suite, and they often do. Not only that, but there's no good reason to not allow cycles. The javac compiler can deal with them trivially as long as it can compile both modules at once. Exactly like it deals with Class cycles. And we already know that the run-time allows it via reflection. Just not the linker, for some reason. Semantically, if we allow inter-dependent classes, and packages, I don't understand why we disallow inter-dependent modules. And last, it would be much better for cases where there's only a run-time cycle. For example I have a module A which defines some interfaces and uses (depends on) a module B which implements a plugin-loading system which uses those interfaces via reflection. Module B does not depend on Module A at compile-time, but at run-time it uses reflection to read Module A annotations and so it will depend on it. At the moment I have to add a silly static block _somewhere_ in Module B (hopefully at the Right Place™) to add the dependency (module read) via the Module reflection API, so that Java reflection does not throw me out. Frankly, I'd much prefer to express this cycle dependency somwhere where it could be added during linking because at least I'd be sure it's added at the right time and I don't risk taking a code-path that bypasses my run-time cycle addition and get to a reflection breakage. In my case it's a purely run-time cycle, so I'd really like to be able to define it as `require runtime module.a`, with a `runtime` modifier that would make the module dependency ignored at compile-time (to make sure I don't add non-reflection calls to it), but respected at link and run-time. = Annotations in module descriptors. I've read the argument that they complexify things, but I'm not sure that's true. In practice as long as they don't influence module resolution at all (and they should not be allowed to), it's no more complex than having them on packages and types. Sure you have to look at imports to resolve them, and these imports may only be satisfied once module dependencies are resolved, but since that's an independent phase we're good. First resolve module dependencies, then process imports and resolve annotations, and only at the end generate the binary module descriptor anyway. I don't know of anything in javac's architecture that would make that hard (which does not mean it does not exist, I'll grant you that). Annotations there will enable lots of cool stuff from frameworks, much in the same way they did for types, then packages and last on type uses. It seems very conservative to forbid them on this new language element when Java has caught up with allowing annotations in practically every other location over the years. Sure they will be able to be retrofitted later via a new class file attribute, but let's be honest: they will have to, that's pretty much been Java's evolutionary path, and if it's not hard to implement right away, why not do it? You know people will beg to have them in Java 10 if you don't, and you'll likely take criticism for not adding them from the start. Now, granted it's always better to add things later than too early, and it's possible that it'd be too big of a task to do it, or small but not important enough to warrant a few weeks of work. But IMO it's important, and I really don't see why it'd be hard to do from the start. Finally, as I've already stated in the -dev list: congrats for all the incredible work so far, it's pretty impressive :) Thanks for any comment. Cheers.
- Previous message: Fwd: Why can modules not be annotated?
- Next message: Payment for driving on toll road, invoice #0000943507
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the jpms-spec-comments mailing list