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

[linux / macOS] fileChooser can't handle emojis

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      generic

      Backports

        Description

        ADDITIONAL SYSTEM INFORMATION :
        OS X newest release,
        Tested and did not work on Java 1.8_181, 1.8_161 and 1.8_60.

        A DESCRIPTION OF THE PROBLEM :
        JavaFx fileChooser can't open any files that contain emoji in their name or anywhere in the file path leading to the file. Exception reporting "file does not exist" and when showing the reported file path last 3 characters are cut off and emoji icon is displayed incorrectly.

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        1. Create simple file opener using fileChooser.
        2. Try to open file that has emoji icon anywhere in the file path or in it's name.


        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        File opens, file path displayed correctly.
        ACTUAL -
        Exception in thread "JavaFX Application Thread" java.lang.IllegalArgumentException: The file: /Users/user/eclipse-workspace/fxTest/emoji😀/test. doesn't exist.
        at java.awt.Desktop.checkFileValidation(Desktop.java:208)
        at java.awt.Desktop.open(Desktop.java:267)
        at fxTest.JavaFxTest.openFile(JavaFxTest.java:52)
        at fxTest.JavaFxTest.access$0(JavaFxTest.java:50)
        at fxTest.JavaFxTest$1.handle(JavaFxTest.java:34)
        at fxTest.JavaFxTest$1.handle(JavaFxTest.java:1)
        at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
        at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
        at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
        at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
        at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
        at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
        at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
        at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
        at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
        at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
        at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
        at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
        at javafx.event.Event.fireEvent(Event.java:198)
        at javafx.scene.Node.fireEvent(Node.java:8411)
        at javafx.scene.control.Button.fire(Button.java:185)
        at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:182)
        at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:96)
        at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:89)
        at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
        at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
        at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
        at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
        at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
        at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
        at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
        at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
        at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
        at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
        at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
        at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
        at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
        at javafx.event.Event.fireEvent(Event.java:198)
        at javafx.scene.Scene$MouseHandler.process(Scene.java:3757)
        at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485)
        at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762)
        at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2494)
        at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:394)
        at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:295)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$353(GlassViewEventHandler.java:432)
        at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389)
        at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:431)
        at com.sun.glass.ui.View.handleMouseEvent(View.java:555)
        at com.sun.glass.ui.View.notifyMouse(View.java:937)

        ---------- BEGIN SOURCE ----------
        import java.awt.Desktop;
        import java.io.File;
        import java.io.IOException;
        import java.util.logging.Level;
        import java.util.logging.Logger;
        import javafx.application.Application;
        import javafx.event.ActionEvent;
        import javafx.event.EventHandler;
        import javafx.scene.Scene;
        import javafx.scene.control.Button;
        import javafx.scene.layout.VBox;
        import javafx.stage.FileChooser;
        import javafx.stage.Stage;
         
        public final class JavaFxTest extends Application {
         
            private Desktop desktop = Desktop.getDesktop();
         
            @Override
            public void start(final Stage stage) {
         
                final FileChooser fileChooser = new FileChooser();
         
                final Button openButton = new Button("Open file");
         
                openButton.setOnAction(
                    new EventHandler<ActionEvent>() {
                        @Override
                        public void handle(final ActionEvent e) {
                            File file = fileChooser.showOpenDialog(stage);
                            if (file != null) {
                                openFile(file);
                            }
                        }
                    });
         
                VBox vBox = new VBox(openButton);
                Scene scene = new Scene(vBox, 100, 40);
         
                stage.setScene(scene);
                stage.show();
            }
         
            public static void main(String[] args) {
                Application.launch(args);
            }
         
            private void openFile(File file) {
                try {
                    desktop.open(file);
                } catch (IOException ex) {
                    Logger.getLogger(
                        JavaFxTest.class.getName()).log(
                            Level.SEVERE, null, ex
                        );
                }
            }
        }
        ---------- END SOURCE ----------

        FREQUENCY : always


          Attachments

            Issue Links

              Activity

                People

                Assignee:
                jpereda Jose Pereda
                Reporter:
                webbuggrp Webbug Group
                Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: