Preferring class files to source files in

Jeremy Manson jeremymanson at
Wed Nov 13 14:38:09 PST 2013

Hi folks,

A bit of background:

- We use a content-addressable storage around here, so to minimize the
diffs between two JAR files (and get more hits in our content-addressable
storage), we reset all timestamps in JAR files to the same values.
- Some of our users include both source and class files in their JAR files.
- When those users want to put those JAR files on the classpath for javac,
and use them to compile other files, they may not have included enough on
the classpath to compile the source files.
- We've worked around this by favoring classfiles when the two files are of
the same age.  This has the added benefit of not having to recompile the
source files when they are found.
- What do you think?  Too esoteric?  Wait for JDK9?


diff --git a/src/share/classes/com/sun/tools/javac/jvm/
--- a/src/share/classes/com/sun/tools/javac/jvm/
+++ b/src/share/classes/com/sun/tools/javac/jvm/
@@ -2690,7 +2690,11 @@
             long bdate = b.getLastModified();
             // 6449326: policy for bad lastModifiedTime in ClassReader
             //assert adate >= 0 && bdate >= 0;
-            return (adate > bdate) ? a : b;
+            return (adate > bdate) ? a :
+                (bdate > adate) ? b :
+                // These dates can be equal if the files' timestamps were
+                // In this case, prefer the .class file.
+                (a.getKind() == JavaFileObject.Kind.CLASS) ? a : b;
-------------- next part --------------
An HTML attachment was scrubbed...

More information about the compiler-dev mailing list