On 02/11/2021 06:38, Jaikiran Pai wrote:
:
Perhaps run 1 writing the hash code of each of the boot modules'
descriptor into a file and then run 2 reading that same file to
compare the hash codes would be one way to do it. But I think that
would just make this test more complex, which I think is avoidable.
I'm not sure that we really need this. There are several jlink tests
that check reproducibility, we think one of them is failing
intermittently with this issue already. So maybe we should leave build
reproducibility to the jlink tests and expand them as needed.
For ModuleDescriptor::hashCode then I was hoping we keep it simple and
just test that the hashCode of the descriptors for modules in the boot
layer matches the hashCode computed from re-parsing the module-info
files, e.g. something simple like this:
for (Module module : ModuleLayer.boot().modules()) {
System.out.println(module);
ModuleDescriptor descriptor1 = module.getDescriptor();
ModuleDescriptor descriptor2;
try (InputStream in =
module.getResourceAsStream("module-info.class")) {
descriptor2 = ModuleDescriptor.read(in);
}
assertEquals(descriptor1, descriptor2);
assertEquals(descriptor1.hashCode(), descriptor2.hashCode());
assertEquals(descriptor1.compareTo(descriptor2), 0);
}
It run can twice, with with the default, the other with -Xshare:off.
One other thought on the change to ModuleDescriptor is that we could
drop the modifiers from the computation of the hashCode of
ModuleDescriptor, Requires, Exports, Opens. Summing the ordinals is okay
but it doesn't give a good spread if you really have modules that have
everything the same except for the modifiers then it doesn't really help.
-Alan