You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by "lahodaj (via GitHub)" <gi...@apache.org> on 2023/09/18 17:01:56 UTC

[GitHub] [netbeans] lahodaj opened a new pull request, #6466: The ClassLoader used to load annotation processors does not return directories from getResource/getResources methods, while normal ClassLoaders do - fixing.

lahodaj opened a new pull request, #6466:
URL: https://github.com/apache/netbeans/pull/6466

   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 -
   
    - are all your own work, and you have the right to contribute them.
    - are contributed solely under the terms and conditions of the Apache License 2.0 (see section 5 of the license for more information).
   
   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.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] lbownik commented on a diff in pull request #6466: The ClassLoader used to load annotation processors does not return directories from getResource/getResources methods, while normal ClassLoaders do - fixing.

Posted by "lbownik (via GitHub)" <gi...@apache.org>.
lbownik commented on code in PR #6466:
URL: https://github.com/apache/netbeans/pull/6466#discussion_r1329061928


##########
java/java.source.base/src/org/netbeans/modules/java/source/parsing/FileObjects.java:
##########
@@ -949,6 +949,34 @@ static Pair<String,List<URL>> parseModulePatches(@NonNull final Iterator<? exten
         return null;
     }
 
+    public static URI getZipPathURI(URI zipURI, String resourceName) {
+        try {
+            //Optimistic try and see
+            return new URI ("jar:"+zipURI.toString()+"!/"+resourceName); //NOI18N
+        } catch (URISyntaxException e) {
+            //Need to encode the resName part (slower)
+            final StringBuilder sb = new StringBuilder ();
+            final String[] elements = resourceName.split("/");           //NOI18N
+            try {
+                for (int i = 0; i< elements.length; i++) {

Review Comment:
   how about for-each loop?



##########
java/java.source.base/src/org/netbeans/modules/java/source/parsing/FileObjects.java:
##########
@@ -949,6 +949,34 @@ static Pair<String,List<URL>> parseModulePatches(@NonNull final Iterator<? exten
         return null;
     }
 
+    public static URI getZipPathURI(URI zipURI, String resourceName) {
+        try {
+            //Optimistic try and see
+            return new URI ("jar:"+zipURI.toString()+"!/"+resourceName); //NOI18N
+        } catch (URISyntaxException e) {
+            //Need to encode the resName part (slower)
+            final StringBuilder sb = new StringBuilder ();

Review Comment:
   how about?
   
    final StringBuilder sb = new StringBuilder (100).append("jar:").append(zipURI).append("!/");
   
   and then just 
   
   return new URI(sb.toString);



##########
java/java.source.base/src/org/netbeans/modules/java/source/parsing/FileObjects.java:
##########
@@ -949,6 +949,34 @@ static Pair<String,List<URL>> parseModulePatches(@NonNull final Iterator<? exten
         return null;
     }
 
+    public static URI getZipPathURI(URI zipURI, String resourceName) {
+        try {
+            //Optimistic try and see
+            return new URI ("jar:"+zipURI.toString()+"!/"+resourceName); //NOI18N
+        } catch (URISyntaxException e) {
+            //Need to encode the resName part (slower)
+            final StringBuilder sb = new StringBuilder ();
+            final String[] elements = resourceName.split("/");           //NOI18N
+            try {
+                for (int i = 0; i< elements.length; i++) {
+                    String element = elements[i];
+                    element = URLEncoder.encode(element, "UTF-8");       //NOI18N
+                    element = element.replace("+", "%20");               //NOI18N
+                    sb.append(element);
+                    if (i< elements.length - 1) {
+                        sb.append(NBFS_SEPARATOR_CHAR);
+                    }
+                }
+                return new URI("jar:"+zipURI.toString()+"!/"+sb.toString());    //NOI18N
+            } catch (final UnsupportedEncodingException e2) {

Review Comment:
   how about ?
   
   } catch (final UnsupportedEncodingException | URISyntaxException e2) {



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] neilcsmith-net commented on a diff in pull request #6466: The ClassLoader used to load annotation processors does not return directories from getResource/getResources methods, while normal ClassLoaders do - fixing.

Posted by "neilcsmith-net (via GitHub)" <gi...@apache.org>.
neilcsmith-net commented on code in PR #6466:
URL: https://github.com/apache/netbeans/pull/6466#discussion_r1329941470


##########
java/java.source.base/src/org/netbeans/modules/java/source/parsing/FileObjects.java:
##########
@@ -949,6 +949,34 @@ static Pair<String,List<URL>> parseModulePatches(@NonNull final Iterator<? exten
         return null;
     }
 
+    public static URI getZipPathURI(URI zipURI, String resourceName) {
+        try {
+            //Optimistic try and see
+            return new URI ("jar:"+zipURI.toString()+"!/"+resourceName); //NOI18N
+        } catch (URISyntaxException e) {
+            //Need to encode the resName part (slower)
+            final StringBuilder sb = new StringBuilder ();
+            final String[] elements = resourceName.split("/");           //NOI18N
+            try {
+                for (int i = 0; i< elements.length; i++) {
+                    String element = elements[i];
+                    element = URLEncoder.encode(element, "UTF-8");       //NOI18N
+                    element = element.replace("+", "%20");               //NOI18N

Review Comment:
   OK, makes sense.  I think other than space, it might just be escaping more than it needs to in this context.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] arvindaprameya commented on pull request #6466: The ClassLoader used to load annotation processors does not return directories from getResource/getResources methods, while normal ClassLoaders do - fixing.

Posted by "arvindaprameya (via GitHub)" <gi...@apache.org>.
arvindaprameya commented on PR #6466:
URL: https://github.com/apache/netbeans/pull/6466#issuecomment-1727320163

   Thank you for doing this , approved


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] lahodaj commented on a diff in pull request #6466: The ClassLoader used to load annotation processors does not return directories from getResource/getResources methods, while normal ClassLoaders do - fixing.

Posted by "lahodaj (via GitHub)" <gi...@apache.org>.
lahodaj commented on code in PR #6466:
URL: https://github.com/apache/netbeans/pull/6466#discussion_r1329829466


##########
java/java.source.base/src/org/netbeans/modules/java/source/parsing/FileObjects.java:
##########
@@ -949,6 +949,34 @@ static Pair<String,List<URL>> parseModulePatches(@NonNull final Iterator<? exten
         return null;
     }
 
+    public static URI getZipPathURI(URI zipURI, String resourceName) {
+        try {
+            //Optimistic try and see
+            return new URI ("jar:"+zipURI.toString()+"!/"+resourceName); //NOI18N
+        } catch (URISyntaxException e) {
+            //Need to encode the resName part (slower)
+            final StringBuilder sb = new StringBuilder ();
+            final String[] elements = resourceName.split("/");           //NOI18N
+            try {
+                for (int i = 0; i< elements.length; i++) {
+                    String element = elements[i];
+                    element = URLEncoder.encode(element, "UTF-8");       //NOI18N
+                    element = element.replace("+", "%20");               //NOI18N

Review Comment:
   `URLEncoder.encode` apparently replaces spaces with `+`. So this merely undoes that.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] sdedic commented on a diff in pull request #6466: The ClassLoader used to load annotation processors does not return directories from getResource/getResources methods, while normal ClassLoaders do - fixing.

Posted by "sdedic (via GitHub)" <gi...@apache.org>.
sdedic commented on code in PR #6466:
URL: https://github.com/apache/netbeans/pull/6466#discussion_r1329683117


##########
java/java.source.base/src/org/netbeans/modules/java/source/parsing/FileObjects.java:
##########
@@ -949,6 +949,34 @@ static Pair<String,List<URL>> parseModulePatches(@NonNull final Iterator<? exten
         return null;
     }
 
+    public static URI getZipPathURI(URI zipURI, String resourceName) {
+        try {
+            //Optimistic try and see
+            return new URI ("jar:"+zipURI.toString()+"!/"+resourceName); //NOI18N
+        } catch (URISyntaxException e) {
+            //Need to encode the resName part (slower)
+            final StringBuilder sb = new StringBuilder ();
+            final String[] elements = resourceName.split("/");           //NOI18N
+            try {
+                for (int i = 0; i< elements.length; i++) {
+                    String element = elements[i];
+                    element = URLEncoder.encode(element, "UTF-8");       //NOI18N
+                    element = element.replace("+", "%20");               //NOI18N

Review Comment:
   Replacing "+" with URL-encoded `space` ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] lahodaj merged pull request #6466: The ClassLoader used to load annotation processors does not return directories from getResource/getResources methods, while normal ClassLoaders do - fixing.

Posted by "lahodaj (via GitHub)" <gi...@apache.org>.
lahodaj merged PR #6466:
URL: https://github.com/apache/netbeans/pull/6466


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] neilcsmith-net commented on a diff in pull request #6466: The ClassLoader used to load annotation processors does not return directories from getResource/getResources methods, while normal ClassLoaders do - fixing.

Posted by "neilcsmith-net (via GitHub)" <gi...@apache.org>.
neilcsmith-net commented on code in PR #6466:
URL: https://github.com/apache/netbeans/pull/6466#discussion_r1329895785


##########
java/java.source.base/src/org/netbeans/modules/java/source/parsing/FileObjects.java:
##########
@@ -949,6 +949,34 @@ static Pair<String,List<URL>> parseModulePatches(@NonNull final Iterator<? exten
         return null;
     }
 
+    public static URI getZipPathURI(URI zipURI, String resourceName) {
+        try {
+            //Optimistic try and see
+            return new URI ("jar:"+zipURI.toString()+"!/"+resourceName); //NOI18N
+        } catch (URISyntaxException e) {
+            //Need to encode the resName part (slower)
+            final StringBuilder sb = new StringBuilder ();
+            final String[] elements = resourceName.split("/");           //NOI18N
+            try {
+                for (int i = 0; i< elements.length; i++) {
+                    String element = elements[i];
+                    element = URLEncoder.encode(element, "UTF-8");       //NOI18N
+                    element = element.replace("+", "%20");               //NOI18N

Review Comment:
   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.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] lahodaj commented on a diff in pull request #6466: The ClassLoader used to load annotation processors does not return directories from getResource/getResources methods, while normal ClassLoaders do - fixing.

Posted by "lahodaj (via GitHub)" <gi...@apache.org>.
lahodaj commented on code in PR #6466:
URL: https://github.com/apache/netbeans/pull/6466#discussion_r1329917086


##########
java/java.source.base/src/org/netbeans/modules/java/source/parsing/FileObjects.java:
##########
@@ -949,6 +949,34 @@ static Pair<String,List<URL>> parseModulePatches(@NonNull final Iterator<? exten
         return null;
     }
 
+    public static URI getZipPathURI(URI zipURI, String resourceName) {
+        try {
+            //Optimistic try and see
+            return new URI ("jar:"+zipURI.toString()+"!/"+resourceName); //NOI18N
+        } catch (URISyntaxException e) {
+            //Need to encode the resName part (slower)
+            final StringBuilder sb = new StringBuilder ();
+            final String[] elements = resourceName.split("/");           //NOI18N
+            try {
+                for (int i = 0; i< elements.length; i++) {
+                    String element = elements[i];
+                    element = URLEncoder.encode(element, "UTF-8");       //NOI18N
+                    element = element.replace("+", "%20");               //NOI18N

Review Comment:
   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.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists