You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2021/07/21 10:02:38 UTC

[GitHub] [netbeans] JaroslavTulach commented on a change in pull request #3068: Force bytecode parsing. Cache resource misses.

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



##########
File path: groovy/groovy.editor/src/org/netbeans/modules/groovy/editor/compiler/CompilationUnit.java
##########
@@ -75,6 +79,13 @@ public CompilationUnit(GroovyParser parser, CompilerConfiguration configuration,
                 },
                 security, this.configuration, cpInfo, classNodeCache);
     }
+    
+    private static class DebugResolver extends ClassNodeResolver {

Review comment:
       Looks like an unused class.

##########
File path: groovy/groovy.editor/src/org/netbeans/modules/groovy/editor/compiler/ClassNodeCache.java
##########
@@ -315,21 +330,73 @@ public ParsingClassLoader(
             this.path = path;
             this.cache = cache;
         }
-        
+
         @Override
         public Class loadClass(
                 final String name,
                 final boolean lookupScriptFiles,
                 final boolean preferClassOverScript,
                 final boolean resolve) throws ClassNotFoundException, CompilationFailedException {
+            LOG.log(Level.FINE, "Parser {4} asking for {0}, scripts {1}, classOverScript {2}, resolve {3}", 
+                    new Object[] { name, lookupScriptFiles, preferClassOverScript, resolve, 
+                        System.identityHashCode(this)
+                    });
+            String rn = null;
             if (preferClassOverScript && !lookupScriptFiles) {
+                rn = name.replace(".", "/") + ".class";
+                if (cache.isNonExistentResource(rn)) {
+                    LOG.log(Level.FINE, " -> cached NONE");
+                    throw CNF;
+                }
+                
                 //Ideally throw CNF but we need to workaround fix of issue #206811
                 //which hurts performance.
                 if (cache.isNonExistent(name)) {
+                    LOG.log(Level.FINE, " -> cached NONE");
                     throw CNF;
                 }
             }
-            return super.loadClass(name, lookupScriptFiles, preferClassOverScript, resolve);
+            boolean ok = false;
+            try {
+                Class c = super.loadClass(name, lookupScriptFiles, preferClassOverScript, resolve);
+                ok = true;
+                return c;
+            } finally {
+                if (!ok && rn != null) {
+                    cache.addNonExistentResource(rn);
+                }
+            }
+        }
+
+        @Override
+        public Enumeration<URL> getResources(String name) throws IOException {
+            if (cache.isNonExistentResource(name)) {
+                return Enumerations.empty();
+            }
+            return super.getResources(name); 

Review comment:
       ```java
   var en = super.getResources(name);
   if (!en.hasMoreElements()) {
     cache.addNonExistentResource(name);
   }
   return en;
   ```




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