Граф коммитов

350 Коммитов

Автор SHA1 Сообщение Дата
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
beard%netscape.com 855f2ed7a8 added mozilla/js/rhino/org/mozilla/javascript/tools/jsc/Main.java 2000-03-14 00:24:23 +00:00
norris%netscape.com 092098261a generalize on number of threads, add synchronization point so test case behaves as advertised 2000-03-13 21:45:02 +00:00
norris%netscape.com 068e84c7d4 Implement distinction between function statements, function expressions, and function expression-statements. 2000-03-13 18:27:42 +00:00
norris%netscape.com a05b7af158 Fix 31639 Oldstyle Java property method names no longer work with defineClass 2000-03-13 17:12:36 +00:00
norris%netscape.com b1bb0c6e43 Make Wrapper an API class. 2000-03-10 20:55:36 +00:00
rginda%netscape.com c66d2fe108 Removing debug output 2000-03-10 19:06:36 +00:00
mccabe%netscape.com 3f8b45f3f4 Replace some ternary expressions
step += (InLeapYear(t) ? 29 : 28);

with the form

    if (InLeapYear(t))
        step += 29;
    else
        step += 28;

to work around an apparent JRE bug in which the code always returns 28.
2000-03-10 02:05:41 +00:00
beard%netscape.com 3d929551f5 now includes all of the optimizer classes 2000-03-10 01:05:28 +00:00
norris%netscape.com c567ae6df2 javadoc comment. 2000-03-10 01:03:59 +00:00
beard%netscape.com 789e50b184 imports js.mcp.xml into js-all.mcp 2000-03-10 01:03:58 +00:00
norris%netscape.com d121bdcda7 Fix command line 2000-03-09 23:33:06 +00:00
norris%netscape.com 6b2aea0f90 Add html page for the NervousText applet. 2000-03-09 23:06:54 +00:00
norris%netscape.com cd8ce490e8 Fixes for NervousText example. 2000-03-09 21:50:14 +00:00
norris%netscape.com ec66213a10 Try to fix Solaris/Linux failures. 2000-03-09 21:46:42 +00:00
rogerl%netscape.com 85f0dbf22b Put NonGreedy back in. 2000-03-09 02:39:58 +00:00
rogerl%netscape.com 1a509a268e Fixed handling of {1,} quantifiers 2000-03-08 01:24:55 +00:00
rogerl%netscape.com 08a7900333 Reduced stack usage for greedy matching. 2000-03-08 01:08:32 +00:00