The field NUM_ENTITIES is supposed to be kept up to date with the actual number of entries that are put into the map. In JDK 19 currently there are 737 map entries, but NUM_ENTITIES is 696.
(These different values won't change the actual map table length of 1024, which is determined by dividing the expected size by the default load factor 0.75 and rounding up to the nearest power of two. But when and if the number of block names and aliases reaches 768, the table will actually need to get larger.)
The test java/lang/Character/UnicodeBlock/OptimalMapSize.java is supposed to test for this, but it copies in the table size computation. It would eventually fail if the number of entries were to grow to 768, but it doesn't check that NUM_ENTITIES matches the actual map size. It also asserts that num_entities == 696. I believe the test should be rewritten simply to check that the value of NUM_ENTITIES matches the actual map size, instead of asserting an incorrect value for NUM_ENTITIES and then replicating the HashMap size computation. That would also remove the need to update this test with every Unicode update, and it would remove the dependency on the OptimalCapacity test utility.
(These different values won't change the actual map table length of 1024, which is determined by dividing the expected size by the default load factor 0.75 and rounding up to the nearest power of two. But when and if the number of block names and aliases reaches 768, the table will actually need to get larger.)
The test java/lang/Character/UnicodeBlock/OptimalMapSize.java is supposed to test for this, but it copies in the table size computation. It would eventually fail if the number of entries were to grow to 768, but it doesn't check that NUM_ENTITIES matches the actual map size. It also asserts that num_entities == 696. I believe the test should be rewritten simply to check that the value of NUM_ENTITIES matches the actual map size, instead of asserting an incorrect value for NUM_ENTITIES and then replicating the HashMap size computation. That would also remove the need to update this test with every Unicode update, and it would remove the dependency on the OptimalCapacity test utility.
- relates to
-
JDK-8282120 optimal capacity tests and test library need to be cleaned up
-
- Resolved
-