Questions tagged [module-info]

Used for module-info.class related queries used for module declaration in Java since its Java 9 release. This would mostly be coupled with java-9 or above tag.

The State of the Module System defines module declarations as:

A module’s self-description is expressed in its module declaration, a new construct of the Java programming language.

The simplest possible module declaration merely specifies the name of its module:

module com.foo.bar { }

The source code for a module declaration is, by convention, placed in a file named module-info.java at the root of the module’s source-file hierarchy. The source files for the com.foo.bar module, e.g., might include:

module-info.java
com/foo/bar/alpha/AlphaFactory.java
com/foo/bar/alpha/Alpha.java
...

A module’s declaration does not include a version string, nor constraints upon the version strings of the modules upon which it depends. This is intentional: It is not a goal of the module system to solve the version-selection problem, which is best left to build tools and container applications.

Module declarations are part of the Java programming language, rather than a language or notation of their own, for several reasons

157 questions
178
votes
11 answers

Unable to compile simple Java 10 / Java 11 project with Maven

I have a trivial Maven project: src └── main └── java └──…
ZhekaKozlov
  • 36,558
  • 20
  • 126
  • 155
107
votes
7 answers

What's the difference between requires and requires transitive statements in Java 9?

What's the difference between requires and requires transitive module statements in module declaration? For example: module foo { requires java.base; requires transitive java.compiler; }
Michał Szewczyk
  • 7,540
  • 8
  • 35
  • 47
40
votes
3 answers

What is an open module in Java 9 and how do I use it?

What is the difference between a module with the open keyword before it and without it? For instance: open module foo { } module foo { }
user8693774
  • 403
  • 1
  • 4
  • 5
27
votes
1 answer

Using jlink with automatic modules

I have an explicit modular project which is dependent on an automatic module; e.g. on java.activation. Is it still possible to use jlink? See this module-info.java: module hello { requires java.activation; } Then jlink can't add the module: $…
Jonku
  • 383
  • 3
  • 7
27
votes
1 answer

Error scanning entry "module-info.class" when starting Jetty server

I'm seeing this recently when I start my java server. Has anyone else seen this? If so whats the fix? I can confirm the jar's and the module-info.class are present in the relevant paths. MultiException[java.lang.RuntimeException: Error scanning…
Puliyur ranganath
  • 395
  • 1
  • 4
  • 8
26
votes
2 answers

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

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; }
Michał Szewczyk
  • 7,540
  • 8
  • 35
  • 47
25
votes
2 answers

Unable to derive module descriptor for auto generated module names in Java 9?

My project depends on Netty Epoll transport. Here is dependency: io.netty netty-transport-native-epoll ${netty.version}
24
votes
3 answers

How to inject module declaration into JAR?

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…
ZhekaKozlov
  • 36,558
  • 20
  • 126
  • 155
21
votes
1 answer

Why is exporting the entire module not allowed?

In Java 9's module declaration there are 2 constructs: exports com.foo; And opens com.foo; Where exports grants compile-time access, while opens allows runtime access, as reflection and resources. opens has one leniency over exports that you can…
Mordechai
  • 15,437
  • 2
  • 41
  • 82
20
votes
3 answers

What's the purpose of 'uses' directive in Java 9?

Java's ServiceLoader class is now officially baked into the Java language. Instead of looking for providers in META-INF/services you can now use the provides with What I fail to understand is, the use of uses in the…
Mordechai
  • 15,437
  • 2
  • 41
  • 82
20
votes
2 answers

Will Cyclic Module Dependencies be Possible in Java 9?

In Java 9, will cyclic modules be allowed? If no, what are the reasons? module com.foo.bar { requires com.foo.baz; exports com.foo.bar.fizz; } module com.foo.baz { requires com.foo.bar; exports com.foo.baz.buzz; }
flakes
  • 21,558
  • 8
  • 41
  • 88
19
votes
2 answers

Unable to export a package from java.base module

Using IDEA-EAP for JDK9 development experiments. I am getting the following error - Error:(3, 20) java: package jdk.internal.misc is not visible (package jdk.internal.misc is declared in module java.base, which does not export it to module…
Naman
  • 27,789
  • 26
  • 218
  • 353
17
votes
1 answer

What's the difference between Synthetic and Mandated Modifier in Java9

The Modifier for Exports in the java doc states that MANDATED The export was implicitly declared in the source of the module declaration. SYNTHETIC The export was not explicitly or implicitly declared in the source of the module…
Naman
  • 27,789
  • 26
  • 218
  • 353
14
votes
2 answers

Can a module-info.java 'opens' statement include a package and all sub-packages?

I have a module-info.java file that looks like - module foo.microservice { requires spring.core; requires spring.beans; requires spring.context; requires java.sql; // required for Spring Annotation based configuration :( opens…
TK.
  • 46,577
  • 46
  • 119
  • 147
12
votes
2 answers

How to get Eclipse to stop asking to create a module-info java file on new Java project creation?

Everytime I try to create a new java project Eclipse keeps asking if I want to add a module-info java file to the source folder. It's getting pretty annoying as there's no immediately obvious option to opt out of this check. IDE for Java Developers,…
AUzun
  • 151
  • 1
  • 2
  • 9
1
2 3
10 11