On Tue, 2 Jun 2026 07:54:57 GMT, Alan Bateman <[email protected]> wrote:

>> src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageResourcesTree.java 
>> line 252:
>> 
>>> 250:                         parentNode = 
>>> getDirectoryNode(resPath.substring(i + 1, j), parentNode);
>>> 251:                     }
>>> 252:                     new ResourceNode(resPath.substring(pathEnd + 1), 
>>> parentNode);
>> 
>> @AlanBateman  It appears we might still need the logic we have at 
>> line#285-293? 
>> 
>>                     String resourceName = resPath.substring(pathEnd + 1);
>>                     Node resourceNode = parentNode.getChildren(resourceName);
>>                     if (resourceNode == null) {
>>                         new ResourceNode(resourceName, parentNode);
>>                     } else if (!(resourceNode instanceof ResourceNode)) {
>>                         throw new InvalidTreeException(resourceNode);
>>                     }
>> 
>> otherwise we might mishandle the bad input like
>> 
>> /modfoo/META-INF/foo/bar.properties
>> /modfoo/META-INF/foo
>
> Can you construct a test to demonstrate what you mean? For 
> `/modfoo/META-INF/foo/bar.properties` it should construct a resource node for 
> "bar.properties" with "foo" as the parent and just. But maybe you mean 
> resources in META-INF/preview ?

I meant if we have a resource named "foo" as showed in the test case showed 
below. It can overwrites the previous parent "foo" of the foo.bar.properties. 
The logic at line#285-293 throws an ITE exception, instead of silently 
overwriting.
https://cr.openjdk.org/~sherman/8385355-2/test/jdk/jdk/internal/jimage/ImageReaderTest.java.sdiff.html

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/31318#discussion_r3339711122

Reply via email to