If a class is found in a classes/directory, then JavaFileObject.inferBinaryName will be provided by RegularFileObject.inferBinaryName. There is no reliable way to determine the binary name, and so the method works imperfectly by looking for the first directory on the path whose path is a prefix of the path for the class in question. An empty path provides a trivial and incorrect match.
The solution is to treat empty path elements, if they occur, as user.dir.
A separate issue to be resolved is whether empty path elements should be allowed at all.