You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Tim Larson <ti...@keow.org> on 2005/03/22 22:51:52 UTC
Fwd: [Patch] importPackage Ambiguous import error fix
I solved the "Ambiguous import" bug caused by importPackage,
and sent this email to the rhino list for them to check it.
----- Forwarded message from Tim Larson <ti...@keow.org> -----
From: Tim Larson <ti...@keow.org>
To: mozilla-jseng@mozilla.org
Subject: [Patch] importPackage Ambiguous import error fix
X-BeenThere: mozilla-jseng@mozilla.org
Attached is a patch to fix importPackage to not import the
same package more than once. This fixes an error that
shows up if a call to importPackage is encountered twice
before classes from the package actually get referenced.
I encountered this error while working with a flowscript
(Cocoon's name for javascript+continuations) for a set of
Cocoon forms. Quickly starting more than one instance of
a form triggers this bug.
The patch replaces a comparison using '=' between two
NativeJavaPackage's with a comparison using string equality.
This effectively compares the package names instead of
checking for object identity.
The other thing which we might need to check is that the
two NativeJavaPackage's both use the same classloader.
I would appreciate it if somebody more knowledgeable of
Rhino internals could sanity check this patch.
--Tim Larson
--- rhino1_6R1/src/org/mozilla/javascript/ImporterTopLevel.java 2004-11-30 22:11:10.000000000 -0500
+++ rhino1_6R1_modified/src/org/mozilla/javascript/ImporterTopLevel.java 2005-03-22 19:52:43.000000000 -0500
@@ -213,7 +213,7 @@
{
synchronized (importedPackages) {
for (int j = 0; j != importedPackages.size(); j++) {
- if (pkg == importedPackages.get(j)) {
+ if (pkg != null && pkg.toString().equals(importedPackages.get(j).toString())) {
pkg = null;
break;
}
----- End forwarded message -----