Michał Szewczyk Michał Szewczyk - 1 year ago 139
Java Question

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;
}

Answer Source

The primary difference between the two is that in case of

requires static foo.module;

The dependence is mandatory in the static phase, during compilation, but is optional in the dynamic phase, during execution while on the other hand

requires bar.module;

Is added to declare that the module depends, by name, upon some other modules, at both compile time and run time.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download