Return-Path: Delivered-To: apmail-cocoon-dev-archive@www.apache.org Received: (qmail 92052 invoked from network); 22 Mar 2005 21:51:59 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 22 Mar 2005 21:51:59 -0000 Received: (qmail 83827 invoked by uid 500); 22 Mar 2005 21:51:57 -0000 Delivered-To: apmail-cocoon-dev-archive@cocoon.apache.org Received: (qmail 83764 invoked by uid 500); 22 Mar 2005 21:51:57 -0000 Mailing-List: contact dev-help@cocoon.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@cocoon.apache.org Delivered-To: mailing list dev@cocoon.apache.org Received: (qmail 83748 invoked by uid 99); 22 Mar 2005 21:51:57 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from keow.org (HELO keow.org) (69.41.247.100) by apache.org (qpsmtpd/0.28) with SMTP; Tue, 22 Mar 2005 13:51:54 -0800 Received: (qmail 26892 invoked by uid 1000); 22 Mar 2005 21:51:52 -0000 Date: Tue, 22 Mar 2005 21:51:52 +0000 From: Tim Larson To: dev@cocoon.apache.org Subject: Fwd: [Patch] importPackage Ambiguous import error fix Message-ID: <20050322215152.GJ29031@localhost> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.6+20040907i X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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 ----- From: Tim Larson 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 -----