Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8055922

Work around sjavac limitation with public api tracking cross modules

XMLWordPrintable

    • b29

        Since the source layout restructuring into modules, sjavac has stopped working correctly. An example illustrates this best:

        1. Do a full build
        2. Add a public field to java/lang/Object.java
        3. Do an incremental rebuild

        What happens is that only java.base gets rebuilt. What should happen is that every module should get completely rebuilt. This is because sjavac only tracks pubapi changes inside the sources being considered for compilation and not for classes found on the classpath.

        A real fix for this problem in sjavac has been suggested in JDK-8054717 but is subject to debate. In the meantime I suggest the following workaround in the makefiles:

        1. To force recompilation on external dependency changes and not just local source changes, detect external dependency chnages in the makefile and remove all class files if found.

        2. After calling sjavac, filter out the pubapi part of the javac_state file into a separate "pubapi" file and only let this file get updated if it has changed. Now the other module compilations may depend on the pubapi file instead of the sjavac file.

        This is not a complete fix but should cover a large part of the usecases, and most importantly, makes you able to trust the build when using sjavac. When making changes to source code without affecting public apis, only files in the changed package should get recompiled.

              erikj Erik Joelsson
              erikj Erik Joelsson
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: