Module resolution
Mark Reinhold
mr at sun.com
Wed Apr 29 14:57:16 PDT 2009
We now have a nearly-complete module-resolution algorithm [1]. It
handles both local and public dependences; optional dependences and
module aliases (i.e., provides) are not yet implemented but should be
straightforward.
The design turned out to be rather different from what we envisioned in
our initial discussions some months ago. I realized, in particular, that
for our principal uses cases an offline resolution algorithm is perfectly
adequate. This greatly simplifies the module class-loader logic, reduces
the amount of work required at run time, and guarantees deterministic
results.
For more details on the algorithm, please see the code itself [2].
A smaller yet significant change in this push is that of refactoring the
Library class into an abstract base class, for use also by javac after
further modification if necessary, and a concrete SimpleLibrary class for
the initial filesystem-based library implementation.
Oh, and there are lots more unit tests.
- Mark
[1] http://hg.openjdk.java.net/jigsaw/jigsaw/jdk/rev/bf711de365f6
[2] http://hg.openjdk.java.net/jigsaw/jigsaw/jdk/file/tip/src/share/classes/org/openjdk/jigsaw/Resolver.java
% sh hello.sh
Hello, world!
% JIGSAW_TRACE=2 sh hello.sh
| Configuring com.greetings@=0.1 using library z.lib
| resolving ROOT requires com.greetings@=0.1
| - trying com.greetings at 0.1
| -- resolving com.greetings at 0.1 requires org.astro@=1.2
| --- trying org.astro at 1.2
| propagating suppliers (pass 1)
| - adding +org.astro*:org.astro to +com.greetings*
| propagating suppliers (pass 2)
| Configured com.greetings at 0.1
| +com.greetings: define com.greetings at 0.1
| +kernel: load jdk at 7-ea:java.lang.Object
| +com.greetings: define com.greetings at 0.1:com.greetings.Hello
| launch: loader +com.greetings, module com.greetings at 0.1, class com.greetings.Hello
| +kernel: load jdk at 7-ea:java.lang.String
| +kernel: load jdk at 7-ea:java.lang.System
| +kernel: load jdk at 7-ea:java.lang.StringBuilder
| +com.greetings: load +org.astro:org.astro.World
| +org.astro: define org.astro at 1.2
| +kernel: load jdk at 7-ea:java.lang.Object
| +org.astro: define org.astro at 1.2:org.astro.World
| +kernel: load jdk at 7-ea:java.io.PrintStream
Hello, world!
% sh maze.sh
You are in a maze of twisty little passages, all alike.
% JIGSAW_TRACE=2 sh maze.sh
| Configuring you@=1 using library z.lib
| resolving ROOT requires you@=1
| - trying you at 1
| -- resolving you at 1 requires in@=1
| --- trying in at 1
| ---- resolving in at 1 requires public maze@=1
| ----- trying maze at 1
| ------ resolving maze at 1 requires public twisty@=1
| ------- trying twisty at 1
| -------- resolving twisty at 1 requires local passages@=1
| --------- trying passages at 1
| ---------- resolving twisty at 1 requires all@=1
| ----------- trying all at 1
| ------------ resolving all at 1 requires in@=1
| propagating suppliers (pass 1)
| - adding +passages+twisty*:twisty to +maze*
| - adding +passages+twisty*:twisty to +in*
| - adding +maze*:maze to +in*
| - adding +maze*:maze to +all*
| - adding +passages+twisty*:twisty to +all*
| - adding +in*:in to +all*
| - adding +maze*:maze to +you*
| - adding +passages+twisty*:twisty to +you*
| - adding +in*:in to +you*
| - adding +all*:all to +passages+twisty*
| propagating suppliers (pass 2)
| Configured you at 1
| +you: define you at 1
| +kernel: load jdk at 7-ea:java.lang.Object
| +you: define you at 1:you.Are
| launch: loader +you, module you at 1, class you.Are
| +kernel: load jdk at 7-ea:java.lang.String
| +kernel: load jdk at 7-ea:java.lang.StringBuilder
| +you: load +in:in.A
| +in: define in at 1
| +kernel: load jdk at 7-ea:java.lang.Object
| +in: define in at 1:in.A
| +you: load +maze:maze.Of
| +maze: define maze at 1
| +kernel: load jdk at 7-ea:java.lang.Object
| +maze: define maze at 1:maze.Of
| +you: load +passages+twisty:twisty.Little
| +passages+twisty: define twisty at 1
| +kernel: load jdk at 7-ea:java.lang.Object
| +passages+twisty: define twisty at 1:twisty.Little
| +kernel: load jdk at 7-ea:java.lang.StringBuilder
| +passages+twisty: load passages at 1:twisty.Passages
| +passages+twisty: define passages at 1
| +passages+twisty: define passages at 1:twisty.Passages
| +passages+twisty: load +all:all.Alike
| +all: define all at 1
| +kernel: load jdk at 7-ea:java.lang.Object
| +all: define all at 1:all.Alike
| +kernel: load jdk at 7-ea:java.lang.StringBuilder
| +all: load +maze:maze.Alike
| +maze: define maze at 1:maze.Alike
| +kernel: load jdk at 7-ea:java.lang.System
| +kernel: load jdk at 7-ea:java.io.PrintStream
You are in a maze of twisty little passages, all alike.
%
More information about the jigsaw-dev
mailing list