JaroslavTulach commented on a change in pull request #3165:
URL: https://github.com/apache/netbeans/pull/3165#discussion_r707026231



##########
File path: groovy/libs.groovy/nbproject/project.xml
##########
@@ -53,6 +53,7 @@
                 <package>org.codehaus.groovy.ant</package>
                 <package>org.codehaus.groovy.antlr.parser</package>
                 <package>org.codehaus.groovy.ast</package>
+                <package>org.codehaus.groovy.ast.decompiled</package>

Review comment:
       You should increase the specification version of this module and make 
sure whoever is using the new packages requests that version.

##########
File path: 
groovy/groovy.editor/src/org/netbeans/modules/groovy/editor/compiler/ClassNodeCache.java
##########
@@ -361,36 +405,156 @@ public Class loadClass(
                 Class c = super.loadClass(name, lookupScriptFiles, 
preferClassOverScript, resolve);
                 ok = true;
                 return c;
+            } catch (ClassNotFoundException ex) {
+                // NETBEANS-5982: Groovy tries to load some types (i.e. 
annotations) into JVM. We serve .class resources
+                // from .sig files produced by Java indexer, then Groovy 
"needs" to load them for further inspection,
+                // but the ClassLoaderSupport refuses to do so. Until 
NETBEANS-5982 is fixed, attempt to load .sig file into
+                // JVM.
+                // This ClassLoader is a throwaway one, so if the source 
changes, the classes can be loaded again in a different
+                // ParsingCL instance next parsing round.
+                String cr = name.replace(".", "/") + ".class"; // NOI18N
+                URL u = getResource(cr);
+                if (u != null) {
+                    try {
+                        URLConnection con = u.openConnection(); 
+                        byte[] contents = new byte[con.getContentLength()];
+                        try (InputStream cs = u.openStream()) {
+                            cs.read(contents);
+                        }
+                        Class c = defineClass(name, contents);
+                        ok = true;
+                        return c;
+                    } catch (IOException ex2) {
+                        throw ex;
+                    }
+                } else {
+                    throw ex;
+                }
             } finally {
                 if (!ok && rn != null) {
                     cache.addNonExistentResource(rn);
                 }
             }
         }
+        
+        /**
+         * Will load folder from {@link #path} and return its contents. The 
1st pair element
+         * is the filename, the second is a Map of folder's contents.
+         * @param resourceName full resource name to search for
+         * @return filename and folder contents.
+         */
+        private Pair<String, Map<String, URL>> loadFolder(String resourceName) 
{
+            int lastSlash = resourceName.lastIndexOf('/');
+            String folderName = lastSlash == -1 ? "" : 
resourceName.substring(0, lastSlash);
+            Map<String, URL> contents = folderContents.get(folderName);
+            String rest = resourceName.substring(lastSlash + 1);
+            if (cache.isNonExistentResource(folderName)) {
+                return Pair.of(rest, Collections.emptyMap());
+            }
+            if (contents != null) {
+                return Pair.of(rest, contents);
+            }
+            Map<String, URL> lhm = new LinkedHashMap<>();
+            boolean empty = true;
+            for (FileObject parent: path.findAllResources(folderName)) {
+                for (FileObject f : parent.getChildren()) {
+                    if (lhm.putIfAbsent(f.getNameExt(), PLACEHOLDER) != null) {
+                        lhm.put(f.getNameExt(), MULTIPLE);
+                    }
+                    empty = false;
+                }
+            }
+            folderContents.put(folderName, lhm);
+            if (empty) {
+                cache.addNonExistentResource(folderName);
+            }
+            return Pair.of(rest, lhm);
+        }
 
+        // allow to conditionally disable this optimization, for debugging.
+        private static final boolean RESOURCES_FROM_FILESYSTEMS = 
Boolean.valueOf(System.getProperty(GroovyParser.class.getName() + 
".useFilesystems", "true"));

Review comment:
       Document the `systemproperty` in arch.xml, please.




-- 
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