When I call a Java applet function by reference from JavaScript code, it doesn't work correctly. Is it possible to call Java functions by reference from JavaScript? My guess: I think because Java takes memory on JVM, it is not possible.
-
// Java Code: public class A extends Applet{ public void foo(int[] a) { a[0]=3; } } //Javascript Code: var arg = new Array(1); arg[0]=2; Applet.foo(arg); But `arg[0]` remains `2`
-
Answer:
You are right, JavaScript arrays are copied and converted before they are passed to Java Code. From the https://jdk6.java.net/plugin2/liveconnect/#ARRAY_ACCESS specification: "If a Java method takes an array type as argument, JavaScript may pass a JavaScript array object or literal for that argument. The Java Plug-In will allocate a new Java array and convert each element of the JavaScript array to the appropriate Java type using the conversion rules [...]" If, on the other hand, you allocate the array in Java, you should be able to use it by reference (I didn't try this myself, but the specification above says it).
David Tanzer at Quora Visit the source
Related Q & A:
- How come CD doesn't work in my shell script?Best solution by Super User
- How to create a java applet?Best solution by Stack Overflow
- Why don't I get the little envelope in my taskbar in Outlook Express when I get a message?Best solution by Yahoo! Answers
- Youtube doesn't work on iphone?Best solution by answers.yahoo.com
- My video call on msn doesn't work.Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.