-
Notifications
You must be signed in to change notification settings - Fork 853
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The ClassLoader used to load annotation processors does not return directories from getResource/getResources methods, while normal ClassLoaders do - fixing. #6466
Conversation
…rectories from getResource/getResources methods, while normal ClassLoaders do - fixing.
return new URI ("jar:"+zipURI.toString()+"!/"+resourceName); //NOI18N | ||
} catch (URISyntaxException e) { | ||
//Need to encode the resName part (slower) | ||
final StringBuilder sb = new StringBuilder (); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about?
final StringBuilder sb = new StringBuilder (100).append("jar:").append(zipURI).append("!/");
and then just
return new URI(sb.toString);
} | ||
} | ||
return new URI("jar:"+zipURI.toString()+"!/"+sb.toString()); //NOI18N | ||
} catch (final UnsupportedEncodingException e2) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about ?
} catch (final UnsupportedEncodingException | URISyntaxException e2) {
final StringBuilder sb = new StringBuilder (); | ||
final String[] elements = resourceName.split("/"); //NOI18N | ||
try { | ||
for (int i = 0; i< elements.length; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about for-each loop?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
for (int i = 0; i< elements.length; i++) { | ||
String element = elements[i]; | ||
element = URLEncoder.encode(element, "UTF-8"); //NOI18N | ||
element = element.replace("+", "%20"); //NOI18N |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replacing "+" with URL-encoded space
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
URLEncoder.encode
apparently replaces spaces with +
. So this merely undoes that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because URLEncoder
is not designed for encoding URLs. Are you sure that's the only possible problematic character? There are libraries in NetBeans already that could properly encode the path if not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems space is the only character:
https://github.com/openjdk/jdk/blob/670b4567cf8229c9fd40c639a04dd1f1b7cfd551/src/java.base/share/classes/java/net/URLEncoder.java#L233
Please note this code is merely moved from one place to another, verbatim. I am not really confident to change that code, unless there's a bug in it that needs fixing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, makes sense. I think other than space, it might just be escaping more than it needs to in this context.
Thank you for doing this , approved |
Fixes the problem noted in the subject.
^Add meaningful description above
By opening a pull request you confirm that, unless explicitly stated otherwise, the changes -
Please make sure (eg.
git log
) that all commits have a valid name and email address for you in the Author field.If you're a first time contributor, see the Contributing guidelines for more information.
If you're a committer, please label the PR before pressing "Create pull request" so that the right test jobs can run.