Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8158926

Char value is set as integer, not as character

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 8, 9
    • Fix Version/s: 9
    • Component/s: javafx
    • Labels:
    • Subcomponent:
      web
    • Resolved In Build:
      master
    • CPU:
      generic
    • OS:
      generic

      Backports

        Description

        Reproducible: always
        Platform-specific: no
        Steps to reproduce: same as in parent bug.
        Steps to reproduce:
        1. Set javascript char variable from java.
        2. Try to read the same variable from java code.
        Expected: java.lang.String with single character OR java.lang.Character with original value.
        Actual: Numeric value of original character returned.
        Sample code:

        import javafx.application.Application;
        import javafx.scene.Scene;
        import javafx.scene.layout.StackPane;
        import javafx.scene.web.WebEngine;
        import javafx.scene.web.WebView;
        import javafx.stage.Stage;
        import netscape.javascript.JSObject;

        public class CharBindingFailure extends Application {
            @Override
            public void start(Stage stage) throws Exception {
                WebView view = new WebView();
                WebEngine engine = view.getEngine();
                stage.setScene(new Scene(new StackPane(view), 320, 240));
                stage.setOnShown((e) -> {
                    char value = 'a';
                    JSObject window = (JSObject) engine.executeScript("window;");
                    window.setMember("testObject", value);
                    Object result = engine.executeScript("testObject;");
                    System.out.println(result.getClass());
                });
                stage.show();
            }
            public static void main(String[] args) {
                launch(args);
            }
        }

        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/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:<110>

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  arajkumar Arunprasad Rajkumar
                  Reporter:
                  arusakov Andrey Rusakov (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  7 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: