Commits

Jan Lahoda committed 436d871

Category's SourceRoots are used as keys to a map, hold them in the Category. Hold classpath via SoftReference.

Comments (0)

Files changed (2)

remoting/server/web/base.web.api/src/org/netbeans/modules/jackpot30/backend/base/CategoryStorage.java

             Logger.getLogger(CategoryStorage.class.getName()).log(Level.SEVERE, null, ex);
         }
 
-        return result;
+        return sourceRoots = result;
     }
 
     private final Map<String, Reference<FileSystem>> embeddedJar2FileSystem = new HashMap<String, Reference<FileSystem>>();

remoting/server/web/base.web.api/src/org/netbeans/modules/jackpot30/backend/base/SourceRoot.java

 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
+import java.lang.ref.Reference;
+import java.lang.ref.SoftReference;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Properties;
 public class SourceRoot {
     
     private static final Logger LOG = Logger.getLogger(SourceRoot.class.getName());
- private final CategoryStorage category;
+    private final CategoryStorage category;
     private final String relativePath;
     private final String code;
 
         return relativePath;
     }
 
-    private Collection<FileObject> classPath; //XXX: soft reference?
+    private Reference<Collection<FileObject>> classPath;
 
     public synchronized Collection<FileObject> getClassPath() {
-        if (classPath == null) {
-            classPath = computeClassPath();
+        Collection<FileObject> cp = classPath != null ? classPath.get() : null;
+        if (cp == null) {
+            classPath = new SoftReference<Collection<FileObject>>(cp = computeClassPath());
         }
 
-        return classPath;
+        return cp;
     }
 
     public String getCode() {