java-module

Incompatible types, equality constraints and method not found during Java 9 Migration

拈花ヽ惹草 提交于 2019-11-27 16:03:45
问题 While migrating one of our projects to Java 9(build 9+181) , I am facing a peculiar problem what looks like an incorrect implementation in some library in use related to type inference and java-module. I am using a dropwizard-core(1.1.0) and guice(4.1.0) configurations as follows: public class CustomService extends io.dropwizard.Application<CustomServiceConfig> { public static void main(String[] args) throws Exception { new CustomService().run(args); } // other initializations @Override

The jdk.incubator.httpclient module not found in Java11

对着背影说爱祢 提交于 2019-11-27 14:50:12
Using the early access build for JDK/11 to compile an existing code based on Java-9 which was using a VM argument --add-modules jdk.incubator.httpclient to resolve the HTTP/2 client incubator module now ends up with a compilation error Module not found: jdk.incubator.httpclient Java version details :- java 11-ea 2018-09-25 Java(TM) SE Runtime Environment 18.9 (build 11-ea+11) Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11-ea+11, mixed mode) With the standardization of the HTTP Client API , the incubated APIs are now removed. The module name and the package name of the standard API will be

Where do resource files go in a Gradle project that builds a Java 9 module?

只谈情不闲聊 提交于 2019-11-27 14:23:56
As of IDEA 2018.2.1, the IDE starts error-highlighting packages "not in the module graph" from dependencies that have been modularized. I added a module-info.java file to my project and added the requisite requires statements, but I'm now having trouble accessing resource files in my src/main/resources directory. (For a complete example, see this GitHub project .) When I used ./gradlew run or ./gradlew installDist + the resulting wrapper script, I was able to read resource files, but when I ran my app from the IDE, I wasn't. I filed an issue with JetBrains, and what I learned was that IDEA was

What is the difference between modules and JAR files?

爷,独闯天下 提交于 2019-11-27 13:41:11
问题 I am learning about Java 9 from What's New in Java9 and one of the hot topics in the discussion is The Modular JDK . Are JAR files modules? How is a module different from a JAR file? 回答1: Module : A new language feature introduced in Java 9 (similar to class, interface, package, etc.) that consists of a collection of packages, similar to how a package consists of a collection of types. JAR : An archive file format that bundles code and resources and which can be loaded by the JVM. More

Error occurred during initialization of boot layer FindException: Module not found

怎甘沉沦 提交于 2019-11-27 06:11:52
问题 Executing a simple "Hello World" program using Java 9 results in the following error message: Error occurred during initialization of boot layer java.lang.module.FindException: Module com.pantech.myModule not found The command line that I executed was: java --module-path bin -m com.pantech.myModule/com.pantech.myModule.HelloWorld This command line is executed from the parent directory of my bin directory that contains all of the .class bytecode files. The module-info.class file is located in

Java 9: Module java.xml.bind is not accessible in Eclipse

怎甘沉沦 提交于 2019-11-27 04:50:57
I migrating a maven project in Java 8 to a Java 9 project without any build tool in Eclipse OxyGen 1a . So my module-info.java looks like this: But java.xml.bind is not accessible, although its in my module path: So what is wrong here? When compiling an unnamed module, java.xml.bind is not accessible by default, but in a modular project (as in this question) failing to resolve reference to module java.xml.bind was a bug (see edit below) . To work around this until the bug is fixed, you can explicitly include module java.xml.bind by double click on Is modular (see screenshot in the question),

How to inject module declaration into JAR?

你说的曾经没有我的故事 提交于 2019-11-27 04:39:15
Suppose I have some library lib.jar for which I do not have the source code (or it is written in some non-Java language which is unaware of modules yet). lib.jar does not have module-info.class and I do not want to use it as an automatic module, so I would like to inject module-info.class into it. I first generate module-info.java with the following command: jdeps --generate-module-info . lib.jar Suppose this generated something like that: module lib { exports package1; exports package2; } Then I try to compile it but javac fails because the packages package1 and package2 do not exist: > javac

What is an automatic module?

醉酒当歌 提交于 2019-11-27 04:37:48
Automatic modules are mentioned many times on stackoverflow but I couldn't find a complete, succinct and self-sufficient definition of an automatic module. So, what is an automatic module? Does it export all packages? Does it open all packages? Does it read all other modules? 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 path. For

What's the difference between requires and requires static in module declaration

烂漫一生 提交于 2019-11-27 03:11:26
问题 What's the difference between requires and requires static module statements in module declaration? For example: module bar { requires java.compiler; requires static java.base; } 回答1: A requires clause expresses that the required module is needed at compile and run time. Consequently, when the module system encounters such a clause during module resolution (the phase in which module descriptors are processed and dependencies are resolved) it searches the universe of observable modules (the

Classloaders hierarchy in Java 9

半世苍凉 提交于 2019-11-27 01:03:15
问题 As of Java-8, I know the hierarchy of the classloaders has been as follows:- Bootstrap classloader -> Extension classloader -> Application classloader What is the change in the hierarchy of classloaders in Java 9 and how does it works? 回答1: The ClassLoader as revised in Java-9 states that: The Java run-time has the following built-in class loaders: Bootstrap class loader : The virtual machine's built-in class loader typically represented as null, and does not have a parent. Platform class