0

Here is an example directory structure, created for patching classes in java.base, java.logging:

src
  +- java.base
     + module-info.java
     +- java
        +- lang
            +- Object.java

  +- java.logging
     + module-info.java
     +- java
        +- util
            +- logging
                +- FileHandler.java

Assume that both Object.java and FileHandler.java are modified. For example when compiling FileHandler.java it should only use the locally modified Object.java for the compilation.

Currently I created module descriptors in both 'java.base', and 'java.logging' directories (with empty bodies) though I'm not sure if this is the right way to proceed.

java.base/module-info.java

module java.base {
}

java.logging/module-info.java

module java.logging {
}

If I do:

javac --patch-module java.base=src/java.logging -module-source-path src
-d build
  • Will it use the modified Object.java for patching the classes in java.logging module directory?
  • It also seems to me that declaring module descriptors like this overrides the whole module and not just the classes, so how can I preserve the classes in the original module?

It would be great if I could patch several classes which belongs to different modules at once.

Gayan Weerakutti
  • 11,904
  • 2
  • 71
  • 68
  • 1
    Once you the empty module-info.java files then I would expect this should work: `javac --module-source-path=src --patch-module java.base=src/java.base --patch-module java.logging=src/java.logging -d build $(find src -name "*.java")` – Alan Bateman Mar 11 '18 at 07:40
  • Ty. Can this be used when there are non-module classes in the src tree? For example I get `error: not in a module on the module source path` if I tried something like: `javac --module-source-path=src/modules src/NonModuleClass.java` – Gayan Weerakutti Mar 18 '18 at 10:16

0 Answers0