Skip to content

Commit

Permalink
Merge pull request #9 from zakkak/2024-07-18-fix-graal-9038
Browse files Browse the repository at this point in the history
Backport: Correctly handle resource include patterns
  • Loading branch information
zakkak authored Aug 28, 2024
2 parents fe54a9a + 7127f4a commit 47161c4
Showing 1 changed file with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,28 @@ public void registerIncludePattern(String module, String pattern) {
assert MissingRegistrationUtils.throwMissingRegistrationErrors();
synchronized (includePatterns) {
updateTimeStamp();
includePatterns.add(new ModuleResourcePair(module, pattern));
includePatterns.add(new ModuleResourcePair(module, handleEscapedCharacters(pattern)));
}
}

@Platforms(Platform.HOSTED_ONLY.class)//
private static final String BEGIN_ESCAPED_SEQUENCE = "\\Q";

@Platforms(Platform.HOSTED_ONLY.class)//
private static final String END_ESCAPED_SEQUENCE = "\\E";

/*
* This handles generated include patterns which start and end with \Q and \E. The actual
* resource name is located inbetween those tags.
*/
@Platforms(Platform.HOSTED_ONLY.class)
private static String handleEscapedCharacters(String pattern) {
if (pattern.startsWith(BEGIN_ESCAPED_SEQUENCE) && pattern.endsWith(END_ESCAPED_SEQUENCE)) {
return pattern.substring(BEGIN_ESCAPED_SEQUENCE.length(), pattern.length() - END_ESCAPED_SEQUENCE.length());
}
return pattern;
}

/**
* Avoid pulling native file system by using {@link NativeImageResourcePath} implementation to
* convert <code>resourceName</code> to canonical variant.
Expand Down

0 comments on commit 47161c4

Please sign in to comment.