Java method data conversion (Definition)

Data types are mapped and converted between JavaScript and Java when methods are called.

When Java methods are called from JavaScript in Netscape they are translated via LiveConnect so that the Java objects appear to be as much like JavaScript objects as possible.

When methods are called, often you want to pass some data to the method. JavaScript supports a variety of primitive data types and more complex objects. These need to be mapped usefully to their corresponding Java equivalent values and types. A similar thing happens when the methods return a result value.

There is some hysteresis effect here because there are not always direct equivalents and so it is possible for the data type to mutate across this boundary, even if the method does nothing other than to echo an input value without modifying it.

It simplifies things a great deal to consider the input arguments and returned values as a separate issue although many factors about the data conversion are similar. On the one hand, we are converting JavaScript values to their nearest and most sensible Java equivalents. On the other hand, we are converting Java values to their best possible JavaScript counterparts.

See also:Java to JavaScript values, JavaScript to Java values, LiveConnect