J.VIII · Java 25 practice question

What happens if a `requires` directive is placed inside the module declaration of `java.base`?

Choose one answer
Check answer and explanation

Correct answer: A compile-time error occurs because java.base is the primordial module and has no dependences

Explanation

Because java.base is the primordial module with no dependences, placing any requires directive in its module declaration results in a compile-time error.

Common trap

Even without a cycle, java.base is prohibited from declaring any dependences at all. This is a hard compile-time error in the specification, not a warning that the compiler ignores.

Source: JLS SE 25 §7.7.1. Dependences
Checked against the cited text on 2026-11-25.

Report an error in this question