Java Platform Module System
21 questions in 9 subtopics.
Module-info
Write amodule-info.java for a module com.acme.orders that uses java.sql, exposes its com.acme.orders.api package, keeps com.acme.orders.internal hidden, lets Jackson reflect on com.acme.orders.dto, and uses a PaymentProvider service.What do requires transitive and requires static mean in module-info, and when would you use each?Would you mandate module descriptors for all new internal code in your company? Present the arguments both ways and your decision criteria.Exports, opens and requires
Explain the difference between exports and opens, and between qualified and unqualified forms of each.A modular application starts withjava.lang.IllegalAccessError: class X (in module a) cannot access class Y (in module b) because module b does not export com.b.impl to module a. List the ways to fix it and which you prefer.Classpath vs module path
What is the difference between putting a jar on the class path and on the module path? What happens to split packages in each case?A Spring Boot service runs fine on the class path. A teammate wants to move it to the module path. What practical issues do you expect, and is it worth it?Automatic and unnamed modules
What are automatic modules and the unnamed module? How is an automatic module's name chosen?You maintain internal libraries used by hundreds of services, most on the class path. Should libraries addmodule-info.java, Automatic-Module-Name only, or nothing? Make a recommendation and explain the risks.Jlink and custom runtimes
Show how to build a minimal custom runtime for an application with jdeps and jlink, and what the resulting image contains.Your organisation runs thousands of containers. Evaluate building per-service jlink runtimes versus using one shared JDK base image.Strong encapsulation of JDK internals
What does strong encapsulation of JDK internals mean, and which JDK release removed the ability to relax it globally with --illegal-access?Upgrading 200 services from Java 11 to 21 shows dozens of failures from libraries using deep reflection intojava.base. How do you plan the upgrade?The JDK spent years moving from free access to internals, through warnings, to enforced strong encapsulation and now integrity by default for agents, JNI and Unsafe. How do you explain the trade-off to leadership, and what is your long-term stance for the organisation?Migrating to modules
You are asked to modularise a large monolith's own code, not only libraries. Describe a migration path and when you would stop.The module system took about ten years to deliver and is widely used by the JDK but less by applications. Why did it develop this way, and what does that tell you about introducing structural changes in a large organisation?Jpackage native installers
What does the jpackage tool do? Explain what the output contains, which formats it can produce on each operating system, and why you must run it on the target platform.Your team ships a JavaFX desktop tool to 3,000 employees on Windows and macOS using jpackage. Users report security warnings on install, and every bug fix means a full reinstall. How do you set up the build and distribution properly?Java on the desktop went from applets and Java Web Start to self-contained installers built with jpackage. Your company still has a dozen internal Java desktop tools. How do you decide their future: keep and modernize them with jpackage, rewrite them as web apps, or buy replacements?Module import declarations
Java 25 finalizes module import declarations. What doesimport module java.base; do, does it require your code to be a module, and how does it interact with normal single-type and on-demand imports?A developer adds import module java.base; and import module java.desktop; to a class, and the line List<String> names = new ArrayList<>(); stops compiling with an ambiguity error. Explain why and how to fix it. Would you allow module imports in your production code base?No question matches these choices.