Hi, when using the --module option of javac, the Java source files of a module are automatically added to the list of to be compiled files, checking timestamps. This works as expected as long as existing source files are changed and/or new source files are added.
If a Java source file is deleted from a module its associated class files are left in place (within the -d destination directory). This leads to unexpected and wrong results in downstream tool calls - for example, a JAR file with stale/orphaned classes as described by [0]. The straightforward "solution" is to delete the -D directory prior to every call of javac --module ... which leads to a "rebuild" of all modules and effectively by-passes the gains provided by the timestamp check. This "solution" can be fine-tuned in some ways via remembering checksums and other external measures. I wonder whether the logic at [1] is a) the sole place that controls this feature and b) whether it can be enhanced to also prune stale classes from previous javac runs. Cheers, Christian [0] https://github.com/sormuras/bach/issues/158 [1] https://github.com/openjdk/jdk/blob/76baa501faa11c934f7ee8e463e13d098ef90518/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Arguments.java#L426-L435