Re: Ongoing bsh interface problem
Martin Schwamberger <[email protected]>
| Newsgroups | gmane.emacs.jdee |
|---|---|
| Message-ID | <[email protected]> |
Glenn Murray wrote:
>
>
> On Mon, 13 Mar 2006, Martin Schwamberger wrote:
>> ...
>> But anyway, I think there is an easier solution:
>> JDEE initializes the class list lazily. This means the search takes
>> place when the user requests the class list the first time.
>> Unfortunately, the list update method does not leverage this feature.
>> This could easily be fixed.
>> Together with the classpath check, the deferred update would at least
>> mitigate the problem.
>> Your home directory would only be scanned if it appeared in the
>> classpath *and* you called a function that relies on the class list
>> (e.g. jde-import-*).
>> What do you think?
>
> Well, you're the expert and I'm just a user here, so my understanding of
> JDEE's inner workings is pretty vague. But I would guess that "compile"
> is a function that relies on the class list, and for this discussion we
> can count on it being called, so the lazy loading would seem at best to
> defer the problem.
>
> There are a lot of classpaths involved in JDEE, I am presuming by
> "classpath" you mean a user-specified project class path, and by
> "classpath check" you mean your previous suggestion:
>
> If the directory of the class being compiled does not appear in
> the classpath, there should be no need for updating the class
> list. The JDEE java method ProjectClasses.reloadClasses(String
> classPathEntry) could just ignore the reload request if
> classPathEntry cannot be found in this.classPath.
>
> (where "directory" means "destination directory"). My concern is when
> I'm compiling Test.java in my home directory without specifying any
> classpath or destination directory. Currently this seems to be
> impossible. If your suggestion would make that possible, then I'm a
> happier camper. I am not happy with any scenario in which JDEE locks
> up Emacs while doing a system-wide search I have not explicitly asked
> it to do.
>
> Cheers,
> Glenn
>
>
I'm not member of the JDEE developer team.
I'm just contributing patches from time to time.
The two patches below implement the lazy class list update
and the classpath check.
If someone of the developers is willing to apply these patches,
please don't forget to update the doc-string of
jde-compile-finish-update-class-info.
It might also be a good idea to change the message printed by
jde-compile-update-class-list.
Cheers, Martin
--------------------------------------------------------------------
diff -u ClassPathEntry.java.old ClassPathEntry.java
--- ClassPathEntry.java.old 2004-12-17 05:54:00.000000000 +0100
+++ ClassPathEntry.java 2006-03-13 17:49:55.230520600 +0100
@@ -57,18 +57,17 @@
* based on the extension of the file or on it being a directory.
*
* @param resource a <code>File</code> value
+ * @param create if true, create new ClassPathEntry if none exists
for resource.
* @return a <code>ClassPathEntry</code> value
* @exception IOException if an error occurs
- * @exception IllegalArgumentException if resource is not a
- * zip/jar or a directory.
*/
- static ClassPathEntry instanceForEntry(File resource)
+ static ClassPathEntry instanceForEntry(File resource, boolean create)
throws IOException {
ClassPathEntry entry = null;
if (entryMap.containsKey(resource)) {
entry = (ClassPathEntry)entryMap.get(resource);
- } else {
+ } else if (create) {
if (resource.getName().toLowerCase().endsWith(".jar")) {
entry = new ClassPathZip(resource);
} else if
(resource.getName().toLowerCase().endsWith(".zip")) {
@@ -147,7 +146,6 @@
return nameToClassMap.getAsList(unqualifiedName);
}
-
/**
* Get the value of loaded.
* @return value of loaded.
--------------------------------------------------------------------
diff -u ProjectClasses.java.old ProjectClasses.java
--- ProjectClasses.java.old 2004-12-17 05:54:00.000000000 +0100
+++ ProjectClasses.java 2006-03-14 09:39:27.767315000 +0100
@@ -74,7 +74,7 @@
classPathEntry = st.nextToken();
classPathFile = new File(classPathEntry);
if (classPathFile.exists()) {
- ClassPathEntry cpe = ClassPathEntry.instanceForEntry(classPathFile);
+ ClassPathEntry cpe = ClassPathEntry.instanceForEntry(classPathFile, true);
if (cpe != null) {
classPathEntries.add(cpe);
} // end of if (cpe != null)
@@ -83,7 +83,6 @@
}
-
/**
* Reload classes in a single classpath entry, which may be a class,
* jar, or zip file.
@@ -93,11 +92,9 @@
*/
void reloadClasses(String classPathEntry) throws IOException {
File classPathFile = new File(classPathEntry);
- if (classPathFile.exists()) {
- ClassPathEntry cpe = ClassPathEntry.instanceForEntry(classPathFile);
- if (cpe != null) {
- cpe.reload();
- }
+ ClassPathEntry cpe = ClassPathEntry.instanceForEntry(classPathFile,
false);
+ if (cpe != null) {
+ cpe.clear();
}
}
@@ -112,7 +109,7 @@
for (Iterator i = classPathEntries.iterator(); i.hasNext();) {
cpe = (ClassPathEntry)i.next();
- cpe.reload();
+ cpe.clear();
}
}
@@ -197,7 +194,7 @@
static void addToBootClassPath(File file) throws IOException {
if (file.exists()) {
- ClassPathEntry entry = ClassPathEntry.instanceForEntry(file);
+ ClassPathEntry entry = ClassPathEntry.instanceForEntry(file, true);
if (null != entry) {
bootClassPathEntries.add(new ImmutableClassPathEntry(entry));
}