Commit Graph

467 Commits

Author SHA1 Message Date
beard%netscape.com
26cffce30e Fixed typo in package target. 2000-10-23 15:44:05 +00:00
nboyd%atg.com
ca002f3c20 Fix 56883. 2000-10-23 14:31:05 +00:00
nboyd%atg.com
ec341691ee Patch from beard@netscape.com to fix 56879. 2000-10-23 14:30:40 +00:00
nboyd%atg.com
024a61b8eb Fix bug 56185. 2000-10-12 16:10:55 +00:00
nboyd%atg.com
dbbc5437de Fix bug 56158 2000-10-12 14:59:19 +00:00
beard%netscape.com
4966a3bd51 Outer class loader support, using ClassManager. 2000-10-12 06:30:29 +00:00
beard%netscape.com
db34dd11a5 Map all exceptions to just return null. 2000-10-10 18:14:20 +00:00
nboyd%atg.com
4a13805f10 More javadoc. 2000-10-10 14:58:47 +00:00
beard%netscape.com
0adc2a998b Added ClassManager.java. 2000-10-09 18:16:06 +00:00
beard%netscape.com
c45770cc40 Manages interactions with outer class loaders. 2000-10-09 17:43:51 +00:00
nboyd%atg.com
890b3a1a48 Add support for new Ant-based buildfile. 2000-10-06 16:26:17 +00:00
nboyd%atg.com
d8cbaa15f2 Remove reference that javadoc couldn't find 2000-10-06 16:25:36 +00:00
nboyd%atg.com
f8476f784b Reformat code. 2000-10-06 16:25:14 +00:00
nboyd%atg.com
ac09dd90be Allow superclass to appear anywhere in the list of classes in the JavaAdapter argument list. 2000-10-03 18:34:02 +00:00
beard%netscape.com
f6acc78141 avoid an infinite loop on EOF. 2000-10-03 06:23:11 +00:00
nboyd%atg.com
f294ddcb34 Avoid creating multiple wrappers. 2000-10-02 20:46:08 +00:00
nboyd%atg.com
7a015db6df Do cheap test first. 2000-10-02 17:10:00 +00:00
nboyd%atg.com
d52574f9e0 Allow null returns from SecuritySupport methods if someone only
wants to implement LiveConnect filtering
2000-09-29 13:49:47 +00:00
nboyd%atg.com
f9df3eebdf Miscellaneous formatting changes. 2000-09-25 14:07:45 +00:00
nboyd%atg.com
cca63b74af Drop unneeded references. 2000-09-25 14:06:47 +00:00
nboyd%atg.com
7c22356d9a Fix enum.js regression. 2000-09-25 14:04:20 +00:00
nboyd%atg.com
26a444c83d Expand javadoc. 2000-09-18 18:38:02 +00:00
nboyd%atg.com
358852ab05 Remove old-style debug codegen. 2000-09-18 17:57:02 +00:00
nboyd%atg.com
7f1be5b439 Better error message for common error. 2000-09-18 17:28:59 +00:00
nboyd%atg.com
5e562540ba Fix infinite loop in new code. 2000-09-12 17:06:15 +00:00
nboyd%atg.com
f61a4fa629 Fix bug 49350 2000-09-11 15:12:04 +00:00
nboyd%atg.com
20778e1dde version with debugger directories 2000-09-11 14:10:23 +00:00
nboyd%atg.com
95389f0d7e Better javadoc 2000-08-30 13:41:15 +00:00
nboyd%atg.com
c03250308b Fix bug 48930: work around a MS JIT bug. 2000-08-22 17:04:21 +00:00
nboyd%atg.com
561cf27d98 Fix bug 49325. 2000-08-21 15:56:15 +00:00
nboyd%atg.com
06f16c883f Fix class path 2000-08-21 15:51:57 +00:00
beard%netscape.com
e4a813ca47 added debugger classes. 2000-08-19 02:42:05 +00:00
nboyd%atg.com
aad3b49e2b Fix for bug 49302 2000-08-17 12:37:32 +00:00
nboyd%atg.com
40ff06028a Fix 49301. 2000-08-17 12:28:46 +00:00
nboyd%atg.com
9a21820390 Merge changes from EXP_DEBUGGER branch into tip.
Implements simple command-line debugger for scripts.
2000-08-15 15:54:46 +00:00
nboyd%atg.com
faa5b161dc fix 47859 2000-08-09 20:23:50 +00:00
nboyd%atg.com
c65fc2d8fd Fix 47859 2000-08-09 20:22:37 +00:00
nboyd%atg.com
0667cc6b4b Fix javadoc. 2000-07-31 21:19:05 +00:00
nboyd%atg.com
091e5f848f Experimental changes for debugger. 2000-07-27 14:54:13 +00:00
rogerl%netscape.com
54e6f7c03f Patch from Norris :
A Rhino user has complained about concurrency problems in the interpreter,
and I think the attached diff fixes some problems that could be caused if
the same interpreted function or script was called simultaneously from
two different threads.
2000-07-26 23:04:14 +00:00
nboyd%atg.com
a0e64bea0b Fix 45928 NativeDate uses getDeclaredConstructor instead of getConstructor 2000-07-21 17:13:09 +00:00
beard%netscape.com
7a1c2d350a Added ClassOutput.java, WrapHandler.java. 2000-07-18 01:29:34 +00:00
nboyd%atg.com
22adf6c37b Fix javadoc error. 2000-07-17 14:08:28 +00:00
nboyd%atg.com
0a9b985a17 Deprecate FlattenedObject. 2000-07-07 14:41:35 +00:00
nboyd%atg.com
a1f493ab08 Remove obsolete references to NodeFactory. 2000-07-05 17:08:26 +00:00
nboyd%atg.com
fdeea4b93b Subject:
Re: Rhino1.5.R1: problems with multithreaded embedded application.
        Date:
             Mon, 03 Jul 2000 14:38:56 -0400
       From:
             Norris Boyd <nboyd@atg.com>
 Organization:
             Art Technology Group
         To:
             Fergus Gallagher <Fergus.Gallagher@orbisuk.com>
 Newsgroups:
             netscape.public.mozilla.jseng
  References:
             1




You found a bug in Rhino; I wonder if others have been running into the same thing.

The problem is with a class called LazilyLoadedCtor. I wrote this class to reduce the
time
required by initStandardObjects by only creating standard objects when the associated
constructors are first accessed. The problem is that this class was not threadsafe.
I've
made changes to that class, and to ScriptableObject as well. The design of dynamic
properties calling getters and setters (which LazilyLoadedCtor uses) didn't really
allow
any way for the getter/setter to replace itself without a thread hazard. I've now
extended
setters so that they can return a value which replaces the getter/setter to avoid this
problem.

Thanks for finding this problem. There have been a couple of other reports of problems
in
this area, so I hope this will fix them.

The patch follows.

--N

Index: LazilyLoadedCtor.java
===================================================================
RCS file: /cvsroot/mozilla/js/rhino/org/mozilla/javascript/LazilyLoadedCtor.java,v
retrieving revision 1.1
diff -u -r1.1 LazilyLoadedCtor.java
--- LazilyLoadedCtor.java 2000/02/29 21:34:37 1.1
+++ LazilyLoadedCtor.java 2000/07/03 18:31:03
@@ -58,9 +58,12 @@
     }

     public Object getProperty(ScriptableObject obj) {
-        obj.delete(ctorName);
         try {
-            ScriptableObject.defineClass(obj, Class.forName(className));
+            synchronized (obj) {
+                if (!isReplaced)
+                    ScriptableObject.defineClass(obj, Class.forName(className));
+                isReplaced = true;
+            }
         }
         catch (ClassNotFoundException e) {
             throw WrappedException.wrapException(e);
@@ -83,11 +86,14 @@
         return obj.get(ctorName, obj);
     }

-    public void setProperty(ScriptableObject obj, Object val) {
-        obj.delete(ctorName);
-        obj.put(ctorName, obj, val);
+    public Object setProperty(ScriptableObject obj, Object val) {
+        synchronized (obj) {
+            isReplaced = true;
+            return val;
+        }
     }

     private String ctorName;
     private String className;
+    private boolean isReplaced;
 }
Index: ScriptableObject.java
===================================================================
RCS file: /cvsroot/mozilla/js/rhino/org/mozilla/javascript/ScriptableObject.java,v
retrieving revision 1.17
diff -u -r1.17 ScriptableObject.java
--- ScriptableObject.java 2000/03/13 17:12:36 1.17
+++ ScriptableObject.java 2000/07/03 18:31:04
@@ -246,11 +246,21 @@
                             break;
                         }
                     }
-                    getterSlot.setter.invoke(start, arg);
+                    Object v = getterSlot.setter.invoke(start, arg);
+                    if (getterSlot.setterReturnsValue) {
+                        slots[slotIndex].value = v;
+                        if (!(v instanceof Method))
+                            slots[slotIndex].flags = 0;
+                    }
                     return;
                 }
                 Object[] args = { this, actualArg };
-                getterSlot.setter.invoke(getterSlot.delegateTo, args);
+                Object v = getterSlot.setter.invoke(getterSlot.delegateTo, args);
+                if (getterSlot.setterReturnsValue) {
+                    slots[slotIndex].value = v;
+                    if (!(v instanceof Method))
+                        slots[slotIndex].flags = 0;
+                }
                 return;
             }
             catch (InvocationTargetException e) {
@@ -1183,6 +1193,7 @@
         slot.delegateTo = delegateTo;
         slot.getter = getter;
         slot.setter = setter;
+        slot.setterReturnsValue = setter != null && setter.getReturnType() !=
Void.TYPE;
         slot.value = null;
         slot.attributes = (short) attributes;
         slot.flags = flags;
@@ -1551,6 +1562,7 @@
     Object delegateTo;  // OPT: merge with "value"
     Method getter;
     Method setter;
+    boolean setterReturnsValue;
 }




Fergus Gallagher wrote:

> I am having problems getting my head around contexts and scopes and my
> multi-threaded application fall over.
>
> If I set "global=false" the following code used a per-thread
> initStandardObject() and this seems to work.  But when I set
> "global=true", the global "parentScope" is used and I get some wierd
> errors.
>
> If I change "__CODE__.slice(0,5)" to
> 1. "__CODE__" - works
> 2. "__CODE__.substring(0,5)" - fails
> 3. "__CODE__.toString()" - works
>
> Any help appreciated.
>
> Fergus
>
> ===== Test.java =========================================
> import java.io.*;
> import org.mozilla.javascript.*;
>
> public class Test implements Runnable {
>         private Script script;
>         private Scriptable parentScope;
>         private String __CODE__="ABCDEFGHIJK";
>         private boolean global = true;
>         private static Context globalContext = null;
>         public Test() throws Exception {
>                 String js= "java.lang.System.out.println(__CODE__.slice(0,5));";
>                 globalContext.setCompileFunctionsWithDynamicScope(false);
>                 parentScope = globalContext.initStandardObjects(null);
>                 StringReader sr = new StringReader(js);
>                 script = globalContext.compileReader(parentScope, sr, "(compiled)",
> 1,null);
>         }
>
>         public void run() {
>                 try {
>                         Context context = Context.enter();
>                         Scriptable threadScope;
>                         if (global) {
>                                 threadScope = context.newObject(parentScope);
>                                 threadScope.setPrototype(parentScope);
>                                 threadScope.setParentScope(null);
>                         } else {
>                                 threadScope = context.initStandardObjects(null);
>                         }
>                         threadScope.put("__CODE__",threadScope,__CODE__);
>                         script.exec(context,threadScope);
>                 }
>                 catch (Exception e) {
>                         System.err.println(e.getClass().getName()+":
"+e.getMessage());
>                 }
>                 finally {
>                         Context.exit();
>                 }
>         }
>
>         public static void main(String args[]) throws Exception {
>         globalContext = Context.enter();
>                 Test me = new Test();
>                 int count=10;
>                 Thread[] threads = new Thread[count];
>                 for (int i=0; i<count; i++) {
>                         Thread t = new Thread(me);
>                         threads[i] = t;
>                         t.start();
>                 }
>                 for (int i=0; i<count; i++) {
>                         threads[i].join();
>                 }
>                 Context.exit();
>         }
> }
>
> ==== OUTPUT ===============================================
> ABCDE
> ABCDE
> org.mozilla.javascript.EcmaError: undefined is not a function.
> org.mozilla.javascript.EvaluatorException: Constructor for "String" not
> found.
> org.mozilla.javascript.EvaluatorException: Constructor for "String" not
> found.
> org.mozilla.javascript.EvaluatorException: Constructor for "String" not
> found.
> org.mozilla.javascript.EvaluatorException: Constructor for "String" not
> found.
> org.mozilla.javascript.EvaluatorException: Constructor for "String" not
> found.
> org.mozilla.javascript.EvaluatorException: Constructor for "String" not
> found.
> org.mozilla.javascript.EvaluatorException: Constructor for "String" not
> found.
> ===========================================================
>
> The number and type of exceptions is highly variable from run to run -
> anywhere from 1-9 out of 10.
> The EcmaError in particular only happens occasionally.
>
> --
> Fergus Gallagher          Tel: +44 (20) 8 987 0717
> Orbis                     Fax: +44 (20) 8 742 2649
> The Swan Centre           email: Fergus.Gallagher@orbisuk.com
> Fishers Lane              Web: http://www.orbisuk.com
> London W4 1RX / UK
2000-07-03 18:40:35 +00:00
nboyd%atg.com
e7359ce462 Fix javadoc warning 2000-06-21 15:49:14 +00:00
nboyd%atg.com
4242e00f01 Wrapping a class produces a NativeJavaClass. 2000-06-15 14:00:31 +00:00
nboyd%atg.com
999f43aaec Fix bug 42097 2000-06-14 13:39:44 +00:00
nboyd%atg.com
341e3b8ddf Begin 1.5R2 effort.
Commit the following contributions:
* Andi Vajda's changes to allow embedders to capture the generated bytecode (and thus control
generated class names).
* Marshall Cline's changes to allow embedders to override the default Java object wrapping
behavior
* Kurt Westerfeld's change to handle calling static methods better
2000-06-13 14:33:54 +00:00
rogerl%netscape.com
0b4dc2b357 Added check for FORMAT characters in new unicode cr/lf handling code. 2000-06-12 17:56:05 +00:00
nboyd%atg.com
bd67f54d28 Fix formatting. 2000-06-07 14:51:08 +00:00
nboyd%atg.com
fc46786bff Fix the following problem:
Subject:
        Odd behaviour on placement of .jar files?!
   Date:
        Mon, 05 Jun 2000 10:46:08 -0700
   From:
        John Raykowski <xski@xski.org>
     To:
        nboyd@atg.com




Hello,

I didn't want to post this directly as a rhino bug 'coz I think it may
be more of a JDK thing, but I thought I'd toss it to you as well.

The goal is to create a JavaScript object that implements a Java
interface. Straightforward enough and the example on the page using
ActionListener works without a hitch.  However, when I try to do the
same with my own interface, I get an error message: error instantiating
({0}): class {1} is interface or abstract (coming from
NativeJavaClass.construct).

Here's where it gets a bit strange.  Normally, I run with the jar files
in jre/lib/ext.  When I remove the rhino files from jre/lib/ext and
reference them explicitly on the commandline with the -cp option, it
works as expected and my script can implement the interface just fine.
Go figure.

Anyhoo, there ya go.  Like I said, I think its a JDK issue, but I
thought you'd be interested.  The attached zipfile contains a set of
sample code to demonstrate this problem.

Thanks heaps,

-jmr
2000-06-07 14:50:47 +00:00
nboyd%atg.com
faea4ed119 Fix "in" operator for compiled mode. 2000-06-01 23:40:29 +00:00
nboyd%atg.com
4d4458bd63 Add column number and line source information to the EcmaError object. 2000-06-01 17:30:28 +00:00
nboyd%atg.com
4a72992ae8 check for null scope 2000-05-30 21:50:44 +00:00
nboyd%atg.com
9cc29b7e22 Fix bug 40844 2000-05-29 16:57:13 +00:00
nboyd%atg.com
a50280a77b Fix bug 39906 2000-05-28 19:01:24 +00:00
nboyd%atg.com
d092952991 for Java methods, print the signatures of the overloaded methods in a comment when
the JavaScript function wrapper's toString method is called
2000-05-28 04:25:07 +00:00
nboyd%atg.com
0074ca5edf Remove unused constructor. 2000-05-23 21:03:50 +00:00
nboyd%atg.com
108f81d6ac Fix up bug where direct calls were getting the parent scope when they shouldn't have,
resulting in a NullPointerException on the following code when run on the MS VM with -opt 9:

var testcases = getTestCases();

function getTestCases() {
    return new Boolean(new MyObject(true));
}

function MyObject( value ) {
    this.value = value;
    this.valueOf = new Function( "return this.value" );
    return this;
}
2000-05-23 20:59:13 +00:00
rogerl%netscape.com
e562e8eb21 Fix bug #39309 - parameters must be AnyType, also vars used before def. 2000-05-23 00:06:24 +00:00
nboyd%atg.com
b76123f465 Fix formatting. 2000-05-22 03:03:37 +00:00
nboyd%atg.com
85a7b4aa6c Fix 38590. 2000-05-22 00:10:10 +00:00
beard%netscape.com
f82644b580 added on run handler 2000-05-17 20:02:17 +00:00
beard%netscape.com
ebd9cea0c3 Removing obsolete project file. This is supplanted by js.mcp.xml. 2000-05-17 20:01:08 +00:00
rogerl%netscape.com
02d34752cd Bug #39034. Fixed stupid logic that broke \n, sorry. 2000-05-15 21:48:00 +00:00
beard%netscape.com
95c604b7cc added jsc/Main.java. 2000-05-12 06:23:43 +00:00
rogerl%netscape.com
1f1c369c98 Bug #38384, fix from norris (which I tweaked a little) to handle a bug in
recursive reseting of the thisObj in InterpreterData.
2000-05-10 22:03:15 +00:00
rogerl%netscape.com
178e8e9fc7 Bug #31316, didn't reset paren state after failed alt. 2000-05-09 23:47:18 +00:00
rogerl%netscape.com
732442c367 Bug #32937, toLocaleString added to Number class. 2000-05-09 23:46:13 +00:00
rogerl%netscape.com
a912f99c10 Bug #22866, support \u2028 \u2029 line terminators 2000-05-09 23:44:49 +00:00
norris%netscape.com
3300d508c9 Fix bug of IndexOutOfRangeException for
function query(query, text) {}
2000-05-05 16:38:16 +00:00
norris%netscape.com
26d7203e07 Make NativeJavaPackage.class optional. 2000-05-05 16:37:40 +00:00
norris%netscape.com
afafee3288 Add missing files. 2000-05-03 22:00:22 +00:00
norris%netscape.com
6e0e18c45e Clean up; remove need for synchronize 2000-05-03 21:55:09 +00:00
norris%netscape.com
9bf723214b Fix bug: All the standard object constructors were showing up as enumerable properties of the global object. 2000-05-02 17:36:47 +00:00
norris%netscape.com
ff5f45db12 Propagate changes from 1.21.2.3 into tip. 2000-04-27 18:39:10 +00:00
norris%netscape.com
a0d8c78c2d Allow multiple uses of importClass on the same class. 2000-04-26 23:47:15 +00:00
norris%netscape.com
a5493a0353 Fix bug 37317. 2000-04-26 23:33:25 +00:00
norris%netscape.com
70aa69f0a0 Fix NullPointerException caused by clearing cache 2000-04-26 22:48:48 +00:00
norris%netscape.com
600d365e30 Patch from Matthias Radestock <rade@logee.com>:
Subject:
             JavaAdapter return type conversion
        Date:
             Wed, 19 Apr 2000 12:12:47 +0100
       From:
             Matthias Radestock <rade@logee.com>
 Organization:
             Logee
         To:
             norris@netscape.com
         CC:
             mccabe@netscape.com, beard@netscape.com, rogerl@netscape.com




Dear Rhino team,

When returning an array from a scripted Java object (i.e. a JS object
that implements a Java interface), no type conversion is performed, ie.
a NativeArray is returned instead of a Java array. Example:

Java:
interface Foo {
        public String[] boo();
        }

JS:
FooI = {
        boo: function() { return ["Boo"];}
        }
myFoo = new Packages.Foo(FooI);
myFoo.boo(); //==> breaks with a ClassCastException


Looking at the JavaAdapter code, there is no code for array conversion.
This is particularly bad because precisely such a conversion *does*
happen when calling a Java method from JS. So we end up with a
discrepancy.

See attachment for a patch to fix this and little test program. The
patch works by calling the coerceType function on NativeJavaObject,
which is the function responsible for doing the conversion when calling
from JS to Java. I've simplified the code so that this function gets
called for all non-primitive return type, not just arrays. There are
probably more efficient solutions but I'm not a Java bytecode hacker.


Matthias
PS: I didn't open a bug for this because I wasn't sure whether you guys
would agree that this is indeed a problem ;)





public interface JSReturnTest {

  public boolean returnBoolean();
  public char returnChar();
  public int returnInt();
  public String returnString();
  public org.mozilla.javascript.Scriptable returnScriptable();
  public Object returnObject();
  public boolean[] returnBooleanA();
  public char[] returnCharA();
  public int[] returnIntA();
  public String[] returnStringA();
  public org.mozilla.javascript.Scriptable[] returnScriptableA();
  public Object[] returnObjectA();
  public Object[][] returnObjectAA();
}




Index: JavaAdapter.java
===================================================================
RCS file: /cvsroot/mozilla/js/rhino/org/mozilla/javascript/JavaAdapter.java,v
retrieving revision 1.21
diff -r1.21 JavaAdapter.java
54c54,59
<
---
>
>     public static Object convertResult(Object result, String classname)
>     throws ClassNotFoundException {
>         return NativeJavaObject.coerceType(Class.forName(classname),
>                                            result);
>     }
467,474c472,474
<         } else  if (retType.equals(String.class)) {
<             cfw.add(ByteCode.INVOKESTATIC,
<                     "org/mozilla/javascript/Context",
<                     "toString", "(Ljava/lang/Object;)",
<                     "Ljava/lang/String;");
<             cfw.add(ByteCode.ARETURN);
<         } else if (retType.equals(Scriptable.class)) {
<             cfw.add(ByteCode.ALOAD_0);  // load 'this' to find scope from
---
>         } else {
>             String retTypeStr = retType.getName();
>             cfw.addLoadConstant(retTypeStr);
476,477c476,477
<                     "org/mozilla/javascript/Context",
<                     "toObject",
---
>                     "org/mozilla/javascript/JavaAdapter",
>                     "convertResult",
479,500c479,480
<                      "Lorg/mozilla/javascript/Scriptable;)",
<                     "Lorg/mozilla/javascript/Scriptable;");
<             cfw.add(ByteCode.ARETURN);
<         } else {
<             // If it is a wrapped type, cast to Wrapper and call unwrap()
<             cfw.add(ByteCode.DUP);
<             cfw.add(ByteCode.INSTANCEOF, "org/mozilla/javascript/Wrapper");
<             // skip 3 for IFEQ, 3 for CHECKCAST, and 5 for INVOKEINTERFACE
<             cfw.add(ByteCode.IFEQ, 11);
<             cfw.add(ByteCode.CHECKCAST, "org/mozilla/javascript/Wrapper");
<             cfw.add(ByteCode.INVOKEINTERFACE,
<                     "org/mozilla/javascript/Wrapper",
<                     "unwrap", "()", "Ljava/lang/Object;");
<
<             // If Undefined, return null
<             cfw.add(ByteCode.DUP);
<             cfw.add(ByteCode.INSTANCEOF, "org/mozilla/javascript/Undefined");
<             // skip 3 for IFEQ, 1 for ACONST_NULL, 1 for ARETURN
<             cfw.add(ByteCode.IFEQ, 5);
<             cfw.add(ByteCode.ACONST_NULL);
<             cfw.add(ByteCode.ARETURN);
<
---
>                     "Ljava/lang/String;)",
>                     "Ljava/lang/Object;");
502,503c482
<             String retTypeStr = retType.getName().replace('.', '/');
<             cfw.add(ByteCode.CHECKCAST, retTypeStr);
---
>             cfw.add(ByteCode.CHECKCAST, retTypeStr.replace('.', '/'));



   testpatch.js

               Name:
                     testpatch.js
                Type:
                     JavaScript Program (application/x-javascript)
             Encoding:
                     7bit
2000-04-24 19:36:51 +00:00
norris%netscape.com
2c9997aaf4 Clean up new methods. 2000-04-20 23:08:07 +00:00
rogerl%netscape.com
d2674e90be Added ASSERT cases to FixNext child handling. 2000-04-20 23:00:37 +00:00
norris%netscape.com
07735d8e89 Fix build error. 2000-04-20 22:36:46 +00:00
norris%netscape.com
721391dfa7 Subject:
contextClassloader problem in ScriptRuntime.java
   Date:
        Tue, 11 Apr 2000 09:45:36 -0400
   From:
        "Howard Lin" <howard@softcom.com>
     To:
        "Norris Boyd" <norris@netscape.com>
    CC:
        "Andrew Wason" <aw@softcom.com>




Hi, Norris, we are trying to create a Java class in JavaScript. When security manager is on, everything works fine. But when security
manager is off, we got an error saying the "... is not defined". The problem is that in ScriptRuntime.java, when security is on,
getContextClassLoader is null due to SecurityException and Class.forName is used to find the class, which works fine. When security
is off, ContextClassLoaderMethod is invoked to find the class. Since we use a separate thread to load third party jar files,
ContextClassLoaderMethod will throw a ClassNotFound exception.

To illustrate this problem, I wrote a simple applet, evaluating a simple js file in its paint method, which is running on a separate thread.
When security is off, I got the following:

ReferenceError: "Global" is not defined.
        at org.mozilla.javascript.NativeGlobal.constructError(NativeGlobal.java:
494)
        at org.mozilla.javascript.ScriptRuntime.name(ScriptRuntime.java, Compile
d Code)
        at org.mozilla.javascript.Interpreter.interpret(Interpreter.java, Compil
ed Code)
        at org.mozilla.javascript.InterpretedScript.call(InterpretedScript.java:
67)
        at org.mozilla.javascript.InterpretedScript.exec(InterpretedScript.java:
54)
        at org.mozilla.javascript.Context.evaluateReader(Context.java:739)
        at test.evaluate(test.java:26)
        at test.paint(test.java:16)
        at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:117)
        at java.awt.Component.dispatchEventImpl(Component.java:2447)
        at java.awt.Container.dispatchEventImpl(Container.java:1035)
        at java.awt.Component.dispatchEvent(Component.java:2307)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:287)
        at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java:10
1)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:92)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:83)

When security is on, it runs fine. Or if the code moved to init method, it works fine regardless of security. We are using JDK 1.2.2.

Howard
2000-04-20 19:53:16 +00:00
norris%netscape.com
b27bb891d9 Add line number information. 2000-04-19 23:24:04 +00:00
rogerl%netscape.com
f07ec29168 Added hasOwnProperty, propertyIsEnumerable, isPrototypeOf to Object. 2000-04-19 22:32:50 +00:00
norris%netscape.com
d23d359cba Add missing method for 1.4R3 compatibility. 2000-04-18 16:53:28 +00:00
norris%netscape.com
564f1dca5b Fix bug where a bean property can conflict with a method name. 2000-04-18 16:52:00 +00:00
norris%netscape.com
3ef540f70d Fix bug:
var a = Math.abs;
  a(-245);

  gets the following error :

  org.mozilla.javascript.EvaluatorException: Method "abs" called on
  incompatible object.
2000-04-18 16:34:36 +00:00
rogerl%netscape.com
d8559be163 Fxied oboscure bug when user defines function Object(), the next new Object
gets a stack crash looking for the prototype. (bug #32174)
2000-04-13 17:58:18 +00:00
norris%netscape.com
144d256be4 Fix bug 33841. 2000-04-12 17:30:32 +00:00
norris%netscape.com
1a915ed08b Remove obsolete statement from javadoc. 2000-04-11 18:24:08 +00:00
norris%netscape.com
171751afcb Update javadoc 2000-04-11 18:22:36 +00:00
norris%netscape.com
ea63971f10 Fix bug 33239. 2000-03-24 23:06:02 +00:00
norris%netscape.com
4b10c5a00b fix NullPointerException 2000-03-16 22:43:03 +00:00
norris%netscape.com
6513a8feb0 clean up regressions in test suite from last fix 2000-03-15 19:40:53 +00:00
norris%netscape.com
884167f722 Fix regressions caused by support for function expression statements. 2000-03-15 17:18:12 +00:00
norris%netscape.com
9cca0a1352 31251 NervousText.js applet doesn't work 2000-03-14 01:20:45 +00:00