Copilot commented on code in PR #54:
URL: https://github.com/apache/netbeans-jackpot30/pull/54#discussion_r4336960846


##########
cmdline/tool/src/org/netbeans/modules/jackpot30/cmdline/Main.java:
##########
@@ -582,9 +584,13 @@ private static GroupResult handleGroup(RootConfiguration 
rootConfiguration, Prog
                 occurrences = filterBatchResult(occurrences, patch);
 
                 if (globalConfig.apply) {
-                    apply(nestedProgress, occurrences, globalConfig.out);
+                    List<MessageImpl> problems = apply(nestedProgress, 
occurrences, globalConfig.out);
 
-                    return GroupResult.SUCCESS; //TODO: WarningsAndErrors?
+                    for (MessageImpl problem : problems) {
+                        System.err.println(problem.kind.name().toLowerCase() + 
": " + problem.text);
+                    }

Review Comment:
   `String#toLowerCase()` is locale-sensitive; on some locales (e.g. Turkish) 
this can produce unexpected output (and break log parsing/tests). Use 
`toLowerCase(Locale.ROOT)` (or avoid case conversion entirely) when formatting 
`problem.kind`.



##########
cmdline/lib/test/unit/src/org/netbeans/modules/jackpot30/cmdline/lib/CreateStandaloneJar.java:
##########
@@ -307,6 +311,33 @@ public InputSource resolveEntity(String publicId, String 
systemId) throws SAXExc
             addMETA_INFRegistration(out, info, e.getValue());
         }
 
+        //named services (@ServiceProvider(path=...)), not discoverable from 
the class closure:
+        Set<String> namedServices = new HashSet<String>();
+        
namedServices.add("Editors/Documents/org.netbeans.editor.BaseDocument/org.netbeans.modules.editor.document.implspi.DocumentServiceFactory");
+        
namedServices.add("Editors/Documents/javax.swing.text.Document/org.netbeans.modules.editor.document.implspi.DocumentServiceFactory");
+
+        for (String namedService : namedServices) {
+            String resourceName = "META-INF/namedservices/" + namedService;
+            Enumeration<URL> resources = 
this.getClass().getClassLoader().getResources(resourceName);
+
+            StringBuilder content = new StringBuilder();
+
+            while (resources.hasMoreElements()) {
+                //keep only implementations that are part of the standalone 
jar;
+                //MetaInfServicesLookup rejects the whole file if one class is 
missing:
+                for (String line : new 
String(readFile(resources.nextElement()), "UTF-8").split("\n")) {
+                    String impl = line.trim();

Review Comment:
   Prefer `StandardCharsets.UTF_8` over string charset names. It avoids 
checked-charset-name handling, is clearer/safer, and is consistent with modern 
Java practices.



##########
cmdline/lib/test/unit/src/org/netbeans/modules/jackpot30/cmdline/lib/CreateStandaloneJar.java:
##########
@@ -307,6 +311,33 @@ public InputSource resolveEntity(String publicId, String 
systemId) throws SAXExc
             addMETA_INFRegistration(out, info, e.getValue());
         }
 
+        //named services (@ServiceProvider(path=...)), not discoverable from 
the class closure:
+        Set<String> namedServices = new HashSet<String>();
+        
namedServices.add("Editors/Documents/org.netbeans.editor.BaseDocument/org.netbeans.modules.editor.document.implspi.DocumentServiceFactory");
+        
namedServices.add("Editors/Documents/javax.swing.text.Document/org.netbeans.modules.editor.document.implspi.DocumentServiceFactory");
+
+        for (String namedService : namedServices) {
+            String resourceName = "META-INF/namedservices/" + namedService;
+            Enumeration<URL> resources = 
this.getClass().getClassLoader().getResources(resourceName);
+
+            StringBuilder content = new StringBuilder();
+
+            while (resources.hasMoreElements()) {
+                //keep only implementations that are part of the standalone 
jar;
+                //MetaInfServicesLookup rejects the whole file if one class is 
missing:
+                for (String line : new 
String(readFile(resources.nextElement()), "UTF-8").split("\n")) {
+                    String impl = line.trim();
+                    if (impl.isEmpty() || impl.startsWith("#") || 
out.containsKey(escapeJavaxLang(info, impl.replace('.', '/') + ".class"))) {
+                        content.append(line).append("\n");
+                    }
+                }
+            }
+
+            if (content.length() > 0) {
+                out.put(resourceName, content.toString().getBytes("UTF-8"));

Review Comment:
   Prefer `StandardCharsets.UTF_8` over string charset names. It avoids 
checked-charset-name handling, is clearer/safer, and is consistent with modern 
Java practices.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

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

Reply via email to