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

116 Коммитов

Автор SHA1 Сообщение Дата
norris%netscape.com d6d196e334 Long not supported here. Fix up comments so that is clear. 1999-09-02 16:48:20 +00:00
rogerl%netscape.com a59e01d63d Fixes for ecma 2 regexp - adding context to init 1999-08-25 01:05:42 +00:00
rogerl%netscape.com 3c54401cd6 Fixes for ecma 2 regexp - adding context to init. 1999-08-25 01:03:06 +00:00
rogerl%netscape.com bb3f4355d0 New errors for ecma 2 regexp. 1999-08-25 01:01:19 +00:00
rogerl%netscape.com 86ebd61886 Fixes for ecma 2 - add context to regexp init. 1999-08-25 01:00:09 +00:00
rogerl%netscape.com a845f3ca48 Fixed \<digits> interpretation for ecma 2 compliance. 1999-08-25 00:59:21 +00:00
norris%netscape.com cea0ae8198 Add a comment. 1999-08-16 18:54:47 +00:00
beard%netscape.com efd6873119 js now propagates ThreadDeath exceptions 1999-08-14 02:32:20 +00:00
beard%netscape.com f8e5d95fcd added mozilla/js/rhino/org/mozilla/javascript/tools/shell/SharedGlobal.java 1999-08-14 02:01:00 +00:00
norris%netscape.com 6b84d958f4 Fix more importerTopLevel problems. 1999-08-13 20:44:46 +00:00
norris%netscape.com 4751b9866b Fix problem:
The fix sort of works. But there are some new problems. I enclosed two JavaScript files, button.js and image.js.

If I load button.js first and then image.js, I got the following:

js> load("button.js");
js> load("image.js");
Ambiguous import: [JavaClass javax.swing.ImageIcon] and [JavaClass javax.swing.ImageIcon]
js> load("image.js");
Ambiguous import: [JavaClass java.net.URL] and [JavaClass java.net.URL]
js> load("image.js");
Ambiguous import: [JavaClass java.lang.System] and [JavaClass java.lang.System]
js> load("image.js");
loadImage for 0
Ambiguous import: [JavaClass java.awt.Toolkit] and [JavaClass java.awt.Toolkit]
js> load("image.js");
loadImage for 0
js>

If I load imag.js first and then button.js, I got the following:

js> load("image.js");
loadImage for 0
js: [JavaPackage java.lang.URL] is not a function.
[JavaPackage java.lang.URL] is not a function.
js> load("image.js");
js: [JavaPackage java.lang.ImageIcon] is not a function.
[JavaPackage java.lang.ImageIcon] is not a function.
js> load("image.js");
js: [JavaPackage java.lang.ImageIcon] is not a function.
[JavaPackage java.lang.ImageIcon] is not a function.
js> load("image.js");
js: [JavaPackage java.lang.ImageIcon] is not a function.
[JavaPackage java.lang.ImageIcon] is not a function.
js> load("button.js");
js: [JavaPackage java.lang.JButton] is not a function.
[JavaPackage java.lang.JButton] is not a function.
js> load("button.js");
js: [JavaPackage java.lang.JButton] is not a function.
[JavaPackage java.lang.JButton] is not a function.
js> load("image.js");
js: [JavaPackage java.lang.ImageIcon] is not a function.
[JavaPackage java.lang.ImageIcon] is not a function.
js>

It looks like something wrong in the image.js file but this should not interfere with button.js. It looks like some arbitary package objects are created, like java.lang.URL. This happened in NativeJavaPackage.get method. If a class of java.lang.URL is not found, a package object is then created. So next time the interpreter encounters URL, it somehow uses the object java.lang.URL instead of the correct class object java.net.URL.. This is one problem. The interference between button.js and jmage.js is another problem.

Howard
  ----- Original Message -----
  From: Norris Boyd
  To: \ Howard\\ Xuhua Lin
  Sent: Thursday, August 12, 1999 12:58 PM
  Subject: Re: ImporterTopLevel problem


  Sorry I've been slow. I finished up the fix this morning and have posted it on the ftp site and checked into cvs.
  Let me know if it works for you.

  --Norris

  \"Howard\" Xuhua Lin wrote:

    Hi, Norris, what's the status of the ImporterTopeLevel problem (i.e if you use importPackage twice, you will get an "Ambiguous import" exception)? Are you still working on it? Howard
1999-08-13 17:25:14 +00:00
norris%netscape.com 1d174dde8d Fix the following problem:
Subject:
        ImporterTopLevel problem
   Date:
        Fri, 6 Aug 1999 15:42:50 -0400
   From:
        "\"Howard\" Xuhua Lin" <howard@softcom.com>
     To:
        "Norris Boyd" <norris@netscape.com>
    CC:
        "Andrew Wason" <aw@softcom.com>




Hi, The following script will cause an EvaluatorException: Ambiguous import: [JavaPackage java.awt.JButton] and [JavaPackage
java.awt.Packages.javax.swing.JButton] in the js shell:

js>importPackage(java.awt);
js>importPackage(Packages.javax.swing);
js>new JButton();.

The current JS shell will not print this exception message, even though the comment says "// Already printed message, so just fall
through". I add System.err.println(ee.getMessage()); for this exception.

The problem is that in NativeJavaPackage.get(String, Scriptable) method, if a ClassNotFoundException is caught, a
NativeJavaPackage object is created and passed back to ImporterTopLevel.get Method. So in ImporterTopLevel.get method, object v
is always not NOT_FOUND and the ambiguous exception will be thrown. Object v is supposed to be a Class object but it actually is
a Package object.

The fix can be either (1) in NativeJavaPackage.get(String, Scriptable) method, if a ClassNotFoundException is caught, return a
NOT_FOUND object (you may still create a Package object) or (2) in ImporterTopLevel.get method, make sure the returned object
from NativeJavaPackage.get method is of NativeJavaClass type.

Howard
1999-08-12 16:59:29 +00:00
rogerl%netscape.com 8135508ba4 Converting value type for setter method to match declared type. 1999-08-11 18:33:48 +00:00
rogerl%netscape.com d9458a9429 Factored out convertArg so that it can be called from ScriptableObject
for setter methods.
1999-08-11 18:31:34 +00:00
rogerl%netscape.com 9d49971dfa Undo captures from failed OPT child 1999-08-11 04:34:52 +00:00
rogerl%netscape.com f5682225f9 Tentative fix for allowing call to 'exec' on RegExp objects. 1999-08-11 04:34:05 +00:00
rogerl%netscape.com 7971c3069a Fix 'zero' & 'one' to use byte instead of Double 1999-08-11 04:33:08 +00:00
rogerl%netscape.com feb87ac66a Fixed limit parameter interpretation to match ecma_2 spec. 1999-08-10 23:36:23 +00:00
norris%netscape.com d055865e6d Fix problem found by Andrew Wason <aw@softcom.com>:
Subject:
        reflection and illegal package access
   Date:
        Wed, 04 Aug 1999 21:56:20 -0400
   From:
        Andrew Wason <aw@softcom.com>
     To:
        norris@netscape.com (Norris Boyd)
    CC:
        Howard Lin <howard@softcom.com>




If you run Rhino under JDK1.2 with a security manager:

java -Djava.security.manager=java.lang.SecurityManager
org.mozilla.javascript.tools.shell.Main

Then reflection fails for objects that are in a restricted access package
(e.g. sun.*).  Rhino is reflecting based on the dynamic type of the object
instead of the declared static return type.

In this example, createImage is declared to return java.awt.Image, but it
returns sun.awt.image.OffScreenImage.  Attempting to reflect this class
results in a java.security.AccessControlException for
java.lang.RuntimePermission accessClassInPackage.sun.awt.image.

Here is the script.  You will need to type it in because you won't be able
to load it from a file due to the security manager.

var f = new java.awt.Frame();
f.setVisible(true);
var i = f.createImage(10,10);
1999-08-05 16:49:20 +00:00
norris%netscape.com 5528ba5cac Fix problem found by Andrew Wason <aw@softcom.com>:
Subject:
        null arguments
   Date:
        Wed, 04 Aug 1999 13:22:35 -0400
   From:
        Andrew Wason <aw@softcom.com>
     To:
        norris@netscape.com
    CC:
        Howard Lin <howard@softcom.com>




When I try to pass a null argument to an interface implemented in JS, I get:

js: Cannot convert null to an object.
js: uncaught JavaScript exception:
org.mozilla.javascript.EvaluatorException: Cannot convert null to an object.


var b = new Packages.javax.swing.border.Border() {
        getBorderInsets : function(c) {
                return new Insets(0,0,0,0);
        }
};
b.getBorderInsets(null);


Here is the stack trace where the exception is happening:

java.lang.reflect.InvocationTargetException:
org.mozilla.javascript.EvaluatorException: Cannot convert null to an object.
         at
org.mozilla.javascript.tools.ToolErrorReporter.runtimeError(ToolErrorReporte
r.java:106)
         at org.mozilla.javascript.Context.reportRuntimeError(Context.java:484)
         at org.mozilla.javascript.Context.reportRuntimeError(Context.java:500)
         at
org.mozilla.javascript.ScriptRuntime.toObject(ScriptRuntime.java:529)
         at org.mozilla.javascript.Context.toObject(Context.java:1107)
         at adapter0.getBorderInsets(<adapter>)
         at java.lang.reflect.Method.invoke(Native Method)
         at
org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java,
Compiled Code)
         at org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1256)
         at org.mozilla.javascript.Interpreter.interpret(Interpreter.java,
Compiled Code)
         at
org.mozilla.javascript.InterpretedScript.call(InterpretedScript.java:49)
         at
org.mozilla.javascript.InterpretedScript.exec(InterpretedScript.java:37)
         at org.mozilla.javascript.Context.evaluateReader(Context.java:691)
         at
org.mozilla.javascript.tools.shell.Main.processSource(Main.java, Compiled Code)
         at org.mozilla.javascript.tools.shell.Main.main(Main.java:146)


Context.toObject does not allow wrapping nulls.
JavaAdapter.generateOverride should generate bytecode to check if an
argument is null and if it is not call Context.toObject.

I'll take a look at fixing this after the other JavaAdapter patches get
checked in so we don't get out of sync.

Andrew
--
Andrew Wason
SoftCom, Inc.
aw@softcom.com
1999-08-04 23:14:57 +00:00
norris%netscape.com 6588bd269b Fix bug 11077 "ScriptableObject.defineFunctionProperties() uses invalid signature check."
The check was actually okay, but the error message didn't state the error correctly.
1999-08-04 19:37:51 +00:00
norris%netscape.com eb9dcf8b50 * Take advantage of the new semantics of Context.enter & exit to save codesize.
* Accept patch from Andrew Wason <aw@softcom.com>:

Subject:
        Re: partial interface problem
   Date:
        Wed, 04 Aug 1999 13:04:37 -0400
   From:
        Andrew Wason <aw@softcom.com>
     To:
        norris@netscape.com
    CC:
        Howard Lin <howard@softcom.com>




>I'm having a problem implementing a Java interface in JS where I don't
>implement all the methods, and one of the methods I don't define returns
>non-void.

I have a patch for this.  I generate bytecode in
JavaAdapter.generateReturnResult to check the return type on the stack from
JavaAdapter.callMethod.  If it is Undefined, return null.

I'm not positive this is the right way to fix this - maybe it should be
fixed closer to the source (e.g. prevent callMethod from returning
Undefined to begin with)

Andrew

--
Andrew Wason
SoftCom, Inc.
aw@softcom.com
1999-08-04 17:43:18 +00:00
norris%netscape.com 3b0d503649 Accept patch (with modifications) from Andrew Wason <aw@softcom.com>:
Subject:
        default JavaAdapter patch
   Date:
        Tue, 20 Jul 1999 15:35:01 -0400
   From:
        Andrew Wason <aw@softcom.com>
     To:
        norris@netscape.com
    CC:
        mccabe@netscape.com, rogerl@netscape.com




Attached is a patch to the patch I sent a while ago for the JavaAdapter stuff.

If a SecurityManager is installed, attempting to access the
"org.mozilla.javascript.JavaAdapter" system property can throw a
SecurityException.  This should not prevent the default JavaAdapter
implementation from being used.

Andrew
--
Andrew Wason
SoftCom, Inc.
aw@softcom.com
1999-08-04 16:56:18 +00:00
mccabe%netscape.com a2cd4da365 Added missing ImporterTopLevel.java and ListenerCollection.java files to the source list.
Thanks to Andrew Wason <aw@softcom.com> for noticing this problem.
1999-08-04 02:50:47 +00:00
rogerl%netscape.com 02985bde28 Updated internal name of exec function to match new naming rules. 1999-08-03 22:41:57 +00:00
mccabe%netscape.com 86880f3be0 - Added OS_TARGET-switched definition of CLASSPATHSEP, to support building under Windows NT with GNU make. Thanks to Andew Wason <aw@softcom.com> for this fix.
- Removed outdated references to JSDEBUG_JAR.
1999-08-03 22:15:02 +00:00
norris%netscape.com 528ca6cbca Adding patch (with slight modifications for javadoc) from Andrew Wason <aw@softcom.com>:
Subject:
        Rhino reflection patch
   Date:
        Wed, 28 Jul 1999 18:14:52 -0400
   From:
        Andrew Wason <aw@softcom.com>
     To:
        norris@netscape.com
    CC:
        mccabe@netscape.com, rogerl@netscape.com, Howard Lin <howard@softcom.com>




When JavaAdapter generates an adapter class, it does not take into account
the types of method parameters when wrapping the generated methods arguments.

This means that if a non-public class implements a public interface the
non-public class type will be wrapped instead of the declared public
interface - and methods cannot be invoked via the wrapper.

I have attached sample code (reflect-demo.zip) which shows this.  The
JavaScript caller.js generates an adapter implementing the CallerInterface
interface.  CallerInterface has a method (doSomething) which takes an
argument of type pkg.Interface.  pkg.Target is a non-public class that
implements pkg.Interface.  If an instance of pkg.Target is passed to the
CallerInterface adapter doSomething method, an Error is thrown because
pkg.Target.doSomething is called (instead of pkg.Interface.doSomething) and
pkg.Target is not public.

I have attached a patch to Context.java, ScriptRuntime.java and
JavaAdapter.java.  I overloaded toObject in Context and ScriptRuntime to
take a 3rd argument which is the declared type of the object being
wrapped.  This is passed to NativeJavaObject.wrap so that it generates the
correct wrapper. I changed JavaAdapter.generateOverride to generate
bytecode calling Context.toObject passing the declared Class type of the
argument.

Context.java also includes my previously submitted patch for dealing with
SecurityExceptions and the JavaAdapter property (because this patch has not
been checked into CVS yet).

Andrew

--
Andrew Wason
SoftCom, Inc.
aw@softcom.com



   reflect-patch.txt

                Name:
                      reflect-patch.txt
                 Type:
                      Plain Text (text/plain)




   reflect-demo.zip

                   Name:
                         reflect-demo.zip
                    Type:
                         Zip Compressed Data (application/x-zip-compressed)
                Encoding:
                         base64
1999-08-03 21:24:39 +00:00
norris%netscape.com 88aa514a1b Remove unused clone() method. 1999-08-03 20:40:25 +00:00
mccabe%netscape.com 786d00b0e0 Further fix to properly include classes from the org.mozilla.classfile package in the generated .jar file.
Thanks to Andrew Wason <aw@softcom.com> for his continued work on the Rhino make system.
1999-08-03 00:25:30 +00:00
mccabe%netscape.com 7967e283d1 Add the classes defined in org/mozilla/classfile to js.jar. 1999-08-02 09:01:19 +00:00
mccabe%netscape.com 1057414fef Fix code to invoke Wrapper interfaces using INVOKEINTERFACE rather than INVOKEVIRTUAL.
Thanks go to Andrew Wason <aw@softcom.com> for finding this problem and providing the patch:



If we implement a Java interface in JavaScript, and a method in that interface returns a Java object, we get a java.lang.IncompatibleClassChangeError: org/mozilla/javascript/Wrapper  exception.

We have attached a sample JavaScript file which duplicates the error.

The problem is JavaAdapter is generating an INVOKEVIRTUAL bytecode to call Wrapper.unwrap, but Wrapper is an interface and so INVOKEINTERFACE should be used instead.  As a result of this change, the IFEQ bytecode generated needs to jump more bytes.  We have attached a patch that fixes the problem.

Andrew
--
Andrew Wason
SoftCom, Inc.
aw@softcom.com
1999-07-26 10:45:38 +00:00
mccabe%netscape.com db16cf6ac4 Added NPL. 1999-07-26 10:41:46 +00:00
mccabe%netscape.com 9306d81fba Comment fixes.
- normalized initial MPL comment to match the format of others in the tree, including an initial -*- Mode line.

- removed RCS $log$, etc. comments.  We use CVS, and they just make spurious changes...
1999-07-26 10:40:53 +00:00
norris%netscape.com 6563fb2291 Add new example. 1999-07-16 03:03:20 +00:00
norris%netscape.com e07db97ba0 Report errors for incorrect usages of varargs forms. 1999-07-08 16:32:51 +00:00
norris%netscape.com 5212cf9694 Fix javadoc bug. 1999-07-08 00:37:12 +00:00
norris%netscape.com 4369cccbf6 Fix bug in ScriptableObject that make classes with jsGet_ but not jsFunction_ work improperly.
Also update Foo example to conform to new defineClass API.
1999-07-06 17:13:33 +00:00
beard%netscape.com 48ce127df1 added ImporterTopLevel.java 1999-06-19 23:38:35 +00:00
norris%netscape.com 716b905e30 Add support for selectively filtering Java classes' visibility to JS 1999-06-18 21:35:35 +00:00
norris%netscape.com 562b4ecb1b Reduce need for a current context. 1999-06-18 21:32:18 +00:00
norris%netscape.com 75d18cd332 A bunch of changes, some experimental.
Support for jsGet_ and jsSet_ prefixes to methods for explicit getter
and setter definition.
Addition of "importClass" and "importPackage" top-level functions.
The beginnings of a history object accessible from the shell.
1999-06-18 17:37:20 +00:00
frankm%eng.sun.com 33b9d6533a Add "fast" make target, to compile only changed files. 1999-06-14 21:51:52 +00:00
frankm%eng.sun.com 7c763a58f9 Revamp NativeJavaObject.coerceType and associated methods to make code
more maintainable, and to pass lc3/JSObject/ToChar-001.js.
1999-06-12 01:41:20 +00:00
frankm%eng.sun.com a66a71b8d7 Fixes for LC3 regression tests, including:
- check static members of instances in JavaMembers.put

- do not unwrap Wrappers before calling NativeJavaMethod.findFunction
     or NativeJavaObject.coerceType; both methods may need extra information
     provided by the wrapper.

- separate Java signatures for resolving overloaded methods and script
     signatures for error messages, so we can distinguish primitive types
     from classes.

- separate Java signatures for resolving overloaded methods and script
     signatures for error messages, so we can distinguish primitive types
     from classes.

- prevent a NativeJavaClass from being treated as a wrapped instance of
     java.lang.Class

- correct bug which preferred the *less* specific of two classes in
     NativeJavaMethod.preferSignature

- add new LC3 conversion rules to  NativeJavaObject.coerceTypes.

- coerce JS numbers to Java numbers or chars only if the JS number is in
     range.
1999-06-11 01:24:40 +00:00
rogerl%netscape.com 4bf675b98a Added base to ScriptRuntime.numberToString, NativeNumber.toString()
Bug #7625
1999-06-10 01:54:28 +00:00
norris%netscape.com c3423e873f Small reduction in code size. 1999-06-08 20:57:19 +00:00
rogerl%netscape.com 4b314af77e Fixed bug #7703, typeof<var> wasn't referencing activation frame vars
correctly.
1999-06-07 22:29:41 +00:00
norris%netscape.com efa5849c1f Clean up formatting. 1999-06-07 18:14:15 +00:00
norris%netscape.com b901db9067 Optimization: avoid allocating a Vector object for every LiveConnect call. 1999-06-07 18:13:15 +00:00
beard%netscape.com 3b5126c019 added NativeJavaConstructor.java 1999-06-05 08:20:54 +00:00