jigsaw

Why is Sun inventing another module system when everyone has standardised on OSGi?

一笑奈何 提交于 2019-12-03 14:48:43
问题 Sun is putting a lot of effort behind modularising the JDK in the form of Jigsaw, and insinuating that it should be the module format of choice for other Java developers as well. The only notable player who is using this is NetBeans (and derivative applications). On the other hand, the industry has standardised around OSGi, with all of the major application vendors basing their runtimes on the module platform, even Sun's own Glassfish. There's even a port of NetBeans to use OSGi as the module

Why Java 9 does not simply turn all JARs on the class path into automatic modules?

痴心易碎 提交于 2019-12-03 08:29:41
In order to understand the categories we have: platform explicit modules application explicit modules open modules automatic modules unnamed module All classes and jars within the classpath will be part of the unnamed module. But why is that what we need? Where is the advantage over automatic modules? I could "require" those damn legacy jars to make them to an automatic module. Do I not have included everything with it? There are at least two reasons: Just as regular modules, automatic ones are suspect to certain examinations by the module system, e.g. not splitting packages . Since JARs on

cannot compile Java 9 module with --patch-module in IntelliJ IDEA 2017.2.1

拥有回忆 提交于 2019-12-03 04:41:40
I am trying to acquaint myself with Java 9 modules and how to define them in IntelliJ. Among other things, I want to solve a split package problem using the --patch-module compiler/JVM flag and I don't know how to make it work in IntelliJ. I am using IntelliJ IDEA 2017.2.1 Build #IC 172.3544.35 with Java HotSpot(TM) 64-Bit Server VM (build 9+180, mixed mode). This is my source file MyImmutableList.java : package com.google.common.collect; public class MyImmutableList extends RegularImmutableList { public MyImmutableList(Object[] array) { super(array); } } It belongs to my module com.effjava

New Keywords in Java 9

情到浓时终转凉″ 提交于 2019-12-03 04:08:32
问题 One of Java 9's largest features will be a module system defined by Project Jigsaw. When reading slides from the Project Jigsaw: Under the Hood at JavaOne 2015, I noticed the following source code: // src/java.sql/module-info.java module java.sql { exports java.sql; exports javax.sql; exports javax.transaction.xa; } What is interesting here to me is that the file ends in .java and seems to use two new keywords: module , and exports . What other keywords will be introduced in Java 9? How will

Why did Java 9 introduce the JMOD file format?

馋奶兔 提交于 2019-12-02 16:37:28
Java 9 has three ways to package compiled code in files: JAR JMOD JIMAGE JIMAGE is optimized for speed and space and used by the JVM at runtime so it makes sense why JIMAGE was introduced. JIMAGE files are not supposed to be published to maven repos or used at compile or link time. The docs claim that JMOD can store native code and other things that can't be stored by JAR files and that developers can make and distribute their own JMOD files. The JDK ships with jmods/ directory containing all the modules of the JDK for users to depend on. Questions: Why did Java 9 introduce the JMOD file

How can I test a service provider implementation module with Junit 5?

谁说我不能喝 提交于 2019-12-02 08:35:18
问题 This is my base module which needs implementations of interfaces defined in myspi package. Various providers can offer MyProvider implementations. Base module uses them via myspi.MyProvider interface implementation. module base { exports myspi; uses myspi.MyProvider; } This is my sample implementation module which provides the MyProvider implementation with MyProviderImpl module myspi.provider { provides myspi.MyProvider with myspi.provider.MyProviderImpl; } All these work fine when I load

How can I test a service provider implementation module with Junit 5?

谁都会走 提交于 2019-12-02 03:56:21
This is my base module which needs implementations of interfaces defined in myspi package. Various providers can offer MyProvider implementations. Base module uses them via myspi.MyProvider interface implementation. module base { exports myspi; uses myspi.MyProvider; } This is my sample implementation module which provides the MyProvider implementation with MyProviderImpl module myspi.provider { provides myspi.MyProvider with myspi.provider.MyProviderImpl; } All these work fine when I load the implementations in base module, with public static List<MyProvider> getMyProviders() { var

idea: too many module declarations found

纵饮孤独 提交于 2019-12-01 17:42:07
I want to create hello world java 9 application and start it in intellij idea. Now I have following structure: content of inner module-info.java: module my.module.Second { requires my.module.First; } content of outer module-info.java: module my.module.First { exports my.pack; } But idea complains about my project: Error:(1, 1) java: too many module declarations found I don't understand why it happens and what really wrong. So Question: My question is how to force idea to accept my hello world. P.S. From the first glance error looks obvious but I have project which I downloaded from github with

How do I open packages and require dependencies on test scope modules only for JUnit testing

安稳与你 提交于 2019-12-01 16:56:48
I'm migrating a jar project from java 10 using classpath to java 11 using the java 9 jigsaw modules. There are JUnit5 tests for the project. The test dependencies are provided at test scope by maven. How to make all packages open for testing but not open when the module is used by another project? The jar project is just providing a few classes (like a utility project) for other projects (so no main class needed). The project got 5 packages at /src/main/java/a/b/c/ . 2 of them should be accessible for projects using this jar. The other 3 are for internal use only (used by the accessible ones).

How do I open packages and require dependencies on test scope modules only for JUnit testing

与世无争的帅哥 提交于 2019-12-01 15:56:11
问题 I'm migrating a jar project from java 10 using classpath to java 11 using the java 9 jigsaw modules. There are JUnit5 tests for the project. The test dependencies are provided at test scope by maven. How to make all packages open for testing but not open when the module is used by another project? The jar project is just providing a few classes (like a utility project) for other projects (so no main class needed). The project got 5 packages at /src/main/java/a/b/c/ . 2 of them should be