RFR 8220792: JavacFileManager.list() performance

Jonathan Gibbons jonathan.gibbons at oracle.com
Wed Mar 27 17:46:56 UTC 2019


On 3/27/19 9:06 AM, Ron Shapiro wrote:
>
> > It's not clear to me why you maintain the list of PathAndContainer 
> as a sorted list, and hence why you need to use java.util.List instead 
> of javac's List.
> There are some tests that ensure that the classpath that javac sees is 
> equivalent to the classpath the JVM sees vis-a-vis ordering. Without 
> sorting, javac was seeing a different order, and I presume that is 
> because the JRTImageContainer and DirectoryContainers could appear 
> anywhere. Sorting solved that issue.

OK, I think I understand the issue and why sorting fixes it.

While some tests may check that "the classpath that javac sees is 
equivalent to the classpath the JVM sees vis-a-vis ordering", that's not 
the primary issue. The primary issue is that the new cache must preserve 
the order in which containers are searched on the classpath (i.e just 
within javac, separate from any part set by the JVM). While this is not 
so important when looking up classes in "well-behaved" packages, it is 
important when handling split packages and resources, where the contents 
in one container may hide the contents in another container.

I think this is subtle enough that it is worth a comment in the code, 
explaining that it is important to preserve the search order used in the 
uncached Location path.

-- Jon



More information about the compiler-dev mailing list