JDK-8089842 : JavaScript2Java Bridge: A char value cannot be set from JavaScript
  • Type: Bug
  • Component: javafx
  • Sub-Component: web
  • Affected Version: 7u6,8u40,9
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2012-01-25
  • Updated: 2016-06-07
  • Resolved: 2016-04-21
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 JDK 9
8u102Fixed 9Fixed
Related Reports
Relates :  
Description
Currently, a char value cannot be set to a char field of a bound object from JavaScript. As I suspect, the reason here is that JS has no idea of a character, and operates even the single characters as strings.
This leads to some level of confusion - when a single-character string is assigned to a character field of an object is JavaScript, a zero (0) is placed in that field.
Comments
Changeset: 66eee7a12e81 Author: arajkumar Date: 2016-04-19 15:54 +0530 URL: http://hg.openjdk.java.net/openjfx/9-dev/rt/rev/66eee7a12e81
21-04-2016

Looks fine
21-04-2016

+1
20-04-2016

looks fine.. +1
20-04-2016

http://cr.openjdk.java.net/~arajkumar/8089842/webrev.00/ Please take a look.
19-04-2016

Removing duplicate "affected version" for the JDK 7 code line.
02-03-2016

That happens to JavaFX 8 WebNode too. RULE "WebNodeAutomated/com/sun/fx/webnode/tests/bridge/javascript2java/AddRemoveCommonTypesTest/testAddRemoveJavaScriptBindingChar" Exception java.lang.AssertionError: expected:<a> but was:<97> RULE "WebNodeAutomated/com/sun/fx/webnode/tests/bridge/javascript2java/AssignTest/testSetCharField" Exception java.lang.AssertionError: expected:<111> but was:<0> RULE "WebNodeAutomated/com/sun/fx/webnode/tests/bridge/javascript2java/MethodCallsTest/testCharMethodCallA" Exception java.lang.AssertionError: expected:<n> but was:<110> RULE "WebNodeAutomated/com/sun/fx/webnode/tests/bridge/javascript2java/MethodCallsTest/testCharMethodCallA2" Exception java.lang.AssertionError: expected:<n> but was:<0>
23-12-2015

Affected tests: WebNodeAutomated/com/sun/fx/webnode/tests/bridge/javascript2java/AssignTest/testSetCharField WebNodeAutomated/com/sun/fx/webnode/tests/bridge/javascript2java/MethodCallsTest/testCharMethodCallA WebNodeAutomated/com/sun/fx/webnode/tests/bridge/javascript2java/MethodCallsTest/testCharMethodCallA2 WebNodeAutomated/com/sun/fx/webnode/tests/bridge/javascript2java/AddRemoveCommonTypesTest/testAddRemoveJavaScriptBindingChar
23-10-2012

It wouldn't be difficult to add a special to convert a 1-length JavaScript string to a Java char, when the context (for example a field type or a method parameter) requires it. Basically just add a special case to the convertValueToJValue function (in JNIUtilityPrivate.cpp). However, this does conflict with the LiveConnect2 "specification", which passes the string to java.lang.Short.decode to get a short, which is cast to a char: http://jdk6.java.net/plugin2/liveconnect/#JS_STRING_VALUES I guess one could convert 1-length strings by extracting the first character, and use Short.decode for other strings. That does seem a bit hacky, though.
04-04-2012

I'm not sure if there should be something special done right now to resolve this problem, so I'm leaving this CR with a low priority.
25-01-2012