JEP 494: Module Import Declarations (Second Preview)
🧠What is JEP 494?
JEP 494 introduces import module
declarations to improve readability and clarity when using services or static methods from other modules, particularly with requires static
in module-info.java
.
✅ Why it's useful?
Makes it obvious where a static method, class, or service comes from.
Improves clarity when reading large modular codebases.
Especially useful for service usage and static factory methods.
RUN:
SimpleModuleImportExample -> Only module import is needed
import module java.base;
public class SimpleModuleImportExample {
public static void main(String[] args) {
var r=List.of(1,2,3);
r.stream().map(BigDecimal::new).map(BigDecimal::negate).forEach(System.out::println);
}
}
PreviousJEP 493: Linking Run-Time Images without JMODsNextJEP 495: Simple Source Files and Instance Main Methods (Fourth Preview)
Last updated