How to inject module declaration into JAR?
Yes, this is possible with the –patch-module option. This option is most often used at runtime, but it also works at compile time: javac –patch-module <module name>=<path to jar> module-info.java
Yes, this is possible with the –patch-module option. This option is most often used at runtime, but it also works at compile time: javac –patch-module <module name>=<path to jar> module-info.java
Why is that? Does it mean that we shouldn’t implement observer pattern anymore? Answering the latter part first – YES, it does mean you shouldn’t implement Observer and Obervables anymore. Why were they deprecated – They didn’t provide a rich enough event model for applications. For example, they could support only the notion that something … Read more
You’ve run into the fact that the system class loader is no longer a URLClassLoader. As indicated by ClassLoader::getSystemClassLoader‘s return type, this was an implementation detail, albeit one that a non-negligible amount of code relied upon. Judging by the comments, you are looking for a way to dynamically load classes at run time. As Alan … Read more
You can use your library as an automatic module. An automatic module is a module that doesn’t have a module descriptor (i.e. module-info.class). But what name do you need to specify to refer to an automatic module? The name of the automatic module is derived from the JAR name (unless this JAR contains an Automatic-Module-Name … Read more
You can use class path and module path in parallel, but there are a few details to consider. Dependency Module Path ~> Class Path Explicit modules (JARs with a module descriptor on the module path) can not read the unnamed module (JARs on the class path) – that was done on purpose to prevent modular … Read more
The following code achieves module path scanning in Java 9+ (Jigsaw / JPMS). It finds all classes on the callstack, then for each class reference, calls classRef.getModule().getLayer().getConfiguration().modules(), which returns a a List<ResolvedModule>, rather than just a List<Module>. (ResolvedModule gives you access to the module resources, whereas Module does not.) Given a ResolvedModule reference for each … Read more
I first answer your actual question (“What is an automatic module?”), but I also explain what they are there for. It is hard to understand why automatic modules behave the way they do without that information. What is an automatic module? The module system creates a module from every JAR it finds on the module … Read more
This is part of JDK 9 in the form of or, which takes a Supplier<Optional<T>>. Your example would then be: return serviceA(args) .or(() -> serviceB(args)) .or(() -> serviceC(args)); For details see the Javadoc or this post I wrote.
The Module System speaks of the way the unnamed modules as in your case of loading the application from classpath constructs the module graph. Further, from the documentation itself:- When the compiler compiles code in the unnamed module, or the java launcher is invoked and the main class of the application is loaded from the … Read more
According to http://www.oracle.com/technetwork/java/javase/9-deprecated-features-3745636.html Java Deployment Technologies are deprecated and will be removed in a future release Java Applet and WebStart functionality, including the Applet API, The Java plug-in, the Java Applet Viewer, JNLP and Java Web Start including the javaws tool are all deprecated in JDK 9 and will be removed in a future release. … Read more