2051 Commits

Author SHA1 Message Date
rogerl%netscape.com
e626dba4ad More exception handling handling.
git-svn-id: svn://10.0.0.236/trunk@67356 18797224-902f-48f8-a5cc-f745e15eee43
2000-04-27 01:27:09 +00:00
norris%netscape.com
63dfd1bdb3 Allow multiple uses of importClass on the same class.
git-svn-id: svn://10.0.0.236/trunk@67323 18797224-902f-48f8-a5cc-f745e15eee43
2000-04-26 23:47:15 +00:00
norris%netscape.com
d1cd56f4c1 Fix bug 37317.
git-svn-id: svn://10.0.0.236/trunk@67319 18797224-902f-48f8-a5cc-f745e15eee43
2000-04-26 23:33:25 +00:00
norris%netscape.com
b443eb6d5e Fix NullPointerException caused by clearing cache
git-svn-id: svn://10.0.0.236/trunk@67314 18797224-902f-48f8-a5cc-f745e15eee43
2000-04-26 22:48:48 +00:00
beard%netscape.com
1977ec8556 oops.
git-svn-id: svn://10.0.0.236/trunk@67308 18797224-902f-48f8-a5cc-f745e15eee43
2000-04-26 22:10:20 +00:00
beard%netscape.com
1ff7c57804 removed JSMap::operator[], added set/getPrototype().
git-svn-id: svn://10.0.0.236/trunk@67307 18797224-902f-48f8-a5cc-f745e15eee43
2000-04-26 22:06:17 +00:00
beard%netscape.com
6fd78a8973 oops getProperty() can't be const unless map.find() is used everywhere.
git-svn-id: svn://10.0.0.236/trunk@67297 18797224-902f-48f8-a5cc-f745e15eee43
2000-04-26 21:48:04 +00:00
beard%netscape.com
0b93de01f3 Using getProperty/setProperty rather than JSMap::operator[]. This follows the prototype chain.
git-svn-id: svn://10.0.0.236/trunk@67293 18797224-902f-48f8-a5cc-f745e15eee43
2000-04-26 21:38:14 +00:00
beard%netscape.com
fdf82b170e added JSMap::setProperty()/getProperty(), and a prototype field.
git-svn-id: svn://10.0.0.236/trunk@67284 18797224-902f-48f8-a5cc-f745e15eee43
2000-04-26 21:27:44 +00:00
rginda%netscape.com
7b16e426c0 initial add of debugger vapors
git-svn-id: svn://10.0.0.236/trunk@67206 18797224-902f-48f8-a5cc-f745e15eee43
2000-04-26 06:04:02 +00:00
beard%netscape.com
638f25e058 Fixing windows bustage in Linkage.
git-svn-id: svn://10.0.0.236/trunk@67204 18797224-902f-48f8-a5cc-f745e15eee43
2000-04-26 05:56:20 +00:00
beard%netscape.com
d0406cbff4 fixing bug: js2.cpp:328: Internal compiler error in scope_die_for, at dwarf2out.c:7794 Please submit a full bug report. See <URL:http://www.gnu.org/software/gcc/faq.html#bugreport> for instructions.
git-svn-id: svn://10.0.0.236/trunk@67203 18797224-902f-48f8-a5cc-f745e15eee43
2000-04-26 05:43:24 +00:00
beard%netscape.com
bad269e6ef testFactorial() now installs a Context::Listener to trace execution.
git-svn-id: svn://10.0.0.236/trunk@67202 18797224-902f-48f8-a5cc-f745e15eee43
2000-04-26 05:37:00 +00:00
beard%netscape.com
7e863f9219 JSActivation -> Activation, JSLinkage --> Linkage. Linkage now implements the Context::Frame interface. Implemented simple Context::Listener support.
git-svn-id: svn://10.0.0.236/trunk@67201 18797224-902f-48f8-a5cc-f745e15eee43
2000-04-26 05:35:07 +00:00
beard%netscape.com
b3a4a03169 Added Context::Frame, Context::Listener abstract classes. Initial support for debugger.
git-svn-id: svn://10.0.0.236/trunk@67199 18797224-902f-48f8-a5cc-f745e15eee43
2000-04-26 05:29:35 +00:00
beard%netscape.com
8a6abe2247 JSFrame -> JSLinkage, using explicit linked list rather than a stack.
git-svn-id: svn://10.0.0.236/trunk@67165 18797224-902f-48f8-a5cc-f745e15eee43
2000-04-26 01:42:00 +00:00
beard%netscape.com
87e47c8e04 removed intentionally private JSActivation/JSFrame types. The debugger should be able to ask questions of the interpreter to obtain this information.
git-svn-id: svn://10.0.0.236/trunk@67164 18797224-902f-48f8-a5cc-f745e15eee43
2000-04-26 01:39:56 +00:00
jband%netscape.com
821ccde88b be less aggresive in shutdown cleanup to avoid shutdown crashes. See bug 37058 for an example stack.
git-svn-id: svn://10.0.0.236/trunk@67101 18797224-902f-48f8-a5cc-f745e15eee43
2000-04-25 07:26:02 +00:00
jband%netscape.com
74a771526d release the threadcontextstack to avoid a shutdown leak
git-svn-id: svn://10.0.0.236/trunk@67082 18797224-902f-48f8-a5cc-f745e15eee43
2000-04-25 04:59:21 +00:00
jband%netscape.com
c2ab972684 Cleanup at shutdown the JSContexts that xpconnect manages on a per thread basis. This should fix some shutdown leaks.
git-svn-id: svn://10.0.0.236/trunk@67081 18797224-902f-48f8-a5cc-f745e15eee43
2000-04-25 04:57:32 +00:00
beard%netscape.com
2483f6c208 changed Context constructor to take JSObject* not JSObject&, to be able to control lifetime a little more carefully.
git-svn-id: svn://10.0.0.236/trunk@67068 18797224-902f-48f8-a5cc-f745e15eee43
2000-04-25 03:32:53 +00:00
beard%netscape.com
d94e75b843 warning removal
git-svn-id: svn://10.0.0.236/trunk@67067 18797224-902f-48f8-a5cc-f745e15eee43
2000-04-25 03:28:41 +00:00
beard%netscape.com
253ee4158c fixing mac bustage (we do reference argc/argv, to initialize them to something sensible).
git-svn-id: svn://10.0.0.236/trunk@67058 18797224-902f-48f8-a5cc-f745e15eee43
2000-04-25 02:58:30 +00:00
beard%netscape.com
9bf768a892 renamed not() -> complement() (not is a keyword in C++), implemented complement().
git-svn-id: svn://10.0.0.236/trunk@67055 18797224-902f-48f8-a5cc-f745e15eee43
2000-04-25 02:55:08 +00:00
brendan%mozilla.org
d9b006ed90 Final destroy-context must await racing GCs before freeing atom state (32525, r=jband).
git-svn-id: svn://10.0.0.236/trunk@67009 18797224-902f-48f8-a5cc-f745e15eee43
2000-04-25 01:12:36 +00:00
rogerl%netscape.com
61ae45d738 Fixes for handling missing params.
git-svn-id: svn://10.0.0.236/trunk@67003 18797224-902f-48f8-a5cc-f745e15eee43
2000-04-24 22:40:53 +00:00
rginda%netscape.com
4a6106e9f6 adding comments
git-svn-id: svn://10.0.0.236/trunk@66997 18797224-902f-48f8-a5cc-f745e15eee43
2000-04-24 21:43:49 +00:00
rginda%netscape.com
f16150cd10 NotARegister check in GenericBranch::print()
git-svn-id: svn://10.0.0.236/trunk@66994 18797224-902f-48f8-a5cc-f745e15eee43
2000-04-24 20:08:16 +00:00
norris%netscape.com
0a8316b7cf 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


git-svn-id: svn://10.0.0.236/trunk@66993 18797224-902f-48f8-a5cc-f745e15eee43
2000-04-24 19:36:51 +00:00
rginda%netscape.com
3bc6bc1635 quieting linux warnings
git-svn-id: svn://10.0.0.236/trunk@66986 18797224-902f-48f8-a5cc-f745e15eee43
2000-04-24 18:41:05 +00:00
jband%netscape.com
2e1e95ace7 belt and suspenders check of WITH_SERVICE results
git-svn-id: svn://10.0.0.236/trunk@66940 18797224-902f-48f8-a5cc-f745e15eee43
2000-04-23 23:04:40 +00:00
jband%netscape.com
7511ada4ea fix a dangerous looking (but harmless) warning on Mac opt
git-svn-id: svn://10.0.0.236/trunk@66822 18797224-902f-48f8-a5cc-f745e15eee43
2000-04-22 01:06:42 +00:00
rogerl%netscape.com
c4747ce60e Added a beginning for exception handling.
git-svn-id: svn://10.0.0.236/trunk@66788 18797224-902f-48f8-a5cc-f745e15eee43
2000-04-21 22:52:52 +00:00
mccabe%netscape.com
0318df82ae Fix to 23532. Check validity of JS_ARENA_ALLOCATE call before using it as an argument of memcpy in JS_ArenaGrow.
Thanks to wyeung@real.com for noticing we were being unsafe here and suggesting the fix.


git-svn-id: svn://10.0.0.236/trunk@66692 18797224-902f-48f8-a5cc-f745e15eee43
2000-04-21 09:25:43 +00:00
brendan%mozilla.org
a1e0219a1d Spruce up a couple of comments.
git-svn-id: svn://10.0.0.236/trunk@66642 18797224-902f-48f8-a5cc-f745e15eee43
2000-04-21 01:49:49 +00:00
brendan%mozilla.org
50400ce9b5 Functions that use unqualified __parent__ or __proto__ must be heavyweight (36625, r=shaver).
git-svn-id: svn://10.0.0.236/trunk@66641 18797224-902f-48f8-a5cc-f745e15eee43
2000-04-21 01:47:20 +00:00
rginda%netscape.com
bb75bc1957 Add nsIScriptError.idl. Build it here rather than back in xpfe/components/console.
Checkin by McCabe, on rginda's mac.


git-svn-id: svn://10.0.0.236/trunk@66621 18797224-902f-48f8-a5cc-f745e15eee43
2000-04-21 00:57:27 +00:00
rogerl%netscape.com
55872f1c24 oops
git-svn-id: svn://10.0.0.236/trunk@66618 18797224-902f-48f8-a5cc-f745e15eee43
2000-04-21 00:46:48 +00:00
rogerl%netscape.com
cf972ed7c0 Added labelled statements, fixed some VC++'isms
git-svn-id: svn://10.0.0.236/trunk@66617 18797224-902f-48f8-a5cc-f745e15eee43
2000-04-21 00:37:51 +00:00
rginda%netscape.com
e7290871fc icodegenerator.cpp
add m prefix to base and offset label members

interpreter.cpp,h
dual license
wrap interpret in a Context class
add RETURN_VOID case

js2.cpp
update to use context class
remove #if 0 code that'll probably never be used anyway.

jstypes.h
add defineProperty/function to JSObject

vmtypes.h
regerated opcode classes:
  added RETURN_VOID, removed LOAD/SAVE_VAR
  reverted bacl to the smaller print function (thanks to RETURN_VOID)
  fixed branch printing issue
  inherit print() from super if possible

tools/gencode.pl
generate smaller print functions again
don't generate print function if superclass can take care of it.


git-svn-id: svn://10.0.0.236/trunk@66611 18797224-902f-48f8-a5cc-f745e15eee43
2000-04-21 00:04:14 +00:00
norris%netscape.com
43bc21e458 Clean up new methods.
git-svn-id: svn://10.0.0.236/trunk@66598 18797224-902f-48f8-a5cc-f745e15eee43
2000-04-20 23:08:07 +00:00
beard%netscape.com
c31b6beead Simple dependency tracking with make depend target.
git-svn-id: svn://10.0.0.236/trunk@66594 18797224-902f-48f8-a5cc-f745e15eee43
2000-04-20 23:02:19 +00:00
rogerl%netscape.com
5c3e4646d4 Added ASSERT cases to FixNext child handling.
git-svn-id: svn://10.0.0.236/trunk@66592 18797224-902f-48f8-a5cc-f745e15eee43
2000-04-20 23:00:37 +00:00
beard%netscape.com
caf86b0278 Simple dependencies list. Rebuilt with make depend target.
git-svn-id: svn://10.0.0.236/trunk@66586 18797224-902f-48f8-a5cc-f745e15eee43
2000-04-20 22:58:23 +00:00
norris%netscape.com
9287db173c Fix build error.
git-svn-id: svn://10.0.0.236/trunk@66574 18797224-902f-48f8-a5cc-f745e15eee43
2000-04-20 22:36:46 +00:00
norris%netscape.com
e40c972eba 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


git-svn-id: svn://10.0.0.236/trunk@66567 18797224-902f-48f8-a5cc-f745e15eee43
2000-04-20 19:53:16 +00:00
jband%netscape.com
486fb4f510 Had the wrong clazz for the root! So it was better when the caching was broken. Now it works on MI objects with caching fixed. My bad copy/paste error from long ago.
git-svn-id: svn://10.0.0.236/trunk@66551 18797224-902f-48f8-a5cc-f745e15eee43
2000-04-20 12:16:45 +00:00
jband%netscape.com
fe72a694dd backing out little fix from earlier today because it causes crashes in some MI cases. I'll investigate and do the right fix
git-svn-id: svn://10.0.0.236/trunk@66549 18797224-902f-48f8-a5cc-f745e15eee43
2000-04-20 11:06:48 +00:00
brendan%mozilla.org
953de28629 Check access and redeclaration legality when defining a getter/setter (36117, r=norris)
git-svn-id: svn://10.0.0.236/trunk@66535 18797224-902f-48f8-a5cc-f745e15eee43
2000-04-20 07:10:14 +00:00
beard%netscape.com
051398cca7 removed extraneous semi-colons after namespace declarations.
git-svn-id: svn://10.0.0.236/trunk@66532 18797224-902f-48f8-a5cc-f745e15eee43
2000-04-20 06:20:31 +00:00