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

Char value is set as integer, not as character

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 9
    • 8, 9
    • javafx
    • web
    • master
    • generic
    • generic

        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>

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

                Created:
                Updated:
                Resolved: