Re: Scripting engine - Java 6



On Jul 31, 5:06 pm, Roedy Green <see_webs...@xxxxxxxxxxxxxxxxxxxx>
wrote:
On Tue, 31 Jul 2007 11:19:00 -0000, debasish
<ghosh.debas...@xxxxxxxxx> wrote, quoted or indirectly quoted someone
who said :

Does this mean that if I want to stick to Sun's generifying layer,
I will be using classes like sun.org.mozilla.javascript.internal.NativeArray
for data type transformations between Javascript and Java ?
Or is there any other way of achieving the same goal.

Keep in mind, if you do that, you are cheating and defeating the
purpose of what Sun has done, so your code could break at any time.
Basically you get objects, find out their class with getClass, then
write code to cast them to specific objects so you can access the
native methods. You may find the methods you need in Sun's glue
objects are private to foil such attempts.

If I return a Javascript array into Java and do a getClass(), I get sun.org.mozilla.javascript.internal.NativeArray. I understand that this is NOT programming to the interface, I am programming to the internal classes, which Java wraps. In that case what will be the best practice to use Javascript arrays which are returned from the script methods ? Of course one option will be to bypass Sun layer, use Rhino directly, possibly through something like BeanShell. But if I want to stick to Sun api, how do I deal with objects returned from Javascript ?

Cheers.
- Debasish


.



Relevant Pages

  • Re: Turning test for a real language
    ... You need native methods to do that. ... >took to mean it would be possible to write an OS in pure java with no ... Let us say for example that you needed to generate the machine code ... compiling a pure Java program. ...
    (comp.lang.java.advocacy)
  • Re: C compiler, 7-character CRC
    ... Java accesses native methods in a way that a method of package ... >> checksum outside the C compiler? ...
    (comp.os.vms)
  • JNI DLL out of memory?
    ... I have a dll with some native methods that I ... (btw. allocating big arrays in JAVA has worked just fine to a certain ...
    (comp.lang.java.help)
  • Vulnerabilities in Microsofts Java implementation
    ... Multiple security vulnerabilities have been ... found in the Java environment. ... Applets are shown, ... Native methods are pieces of ordinary machine language code contained by ...
    (Bugtraq)
  • [Full-Disclosure] Vulnerabilities in Microsofts Java implementation
    ... Multiple security vulnerabilities have been ... found in the Java environment. ... Applets are shown, ... Native methods are pieces of ordinary machine language code contained by ...
    (Full-Disclosure)