When I used BlueJ, I found a problem with Chinese display. 
/javafx.graphics/com/sun/javafx/font/CompositeGlyphMapper.java#getGlyphCode may 
return a negative number when no font library is specified in Linux,and this 
could cause java.lang.ArrayIndexOutOfBoundsException error.So 
javafx.graphics/com/sun/prism/impl/GlyphCache.java#getCachedGlyph  shou check 
the glyphCode.
The crash demo like this:
`import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuBar;
import javafx.scene.control.MenuItem;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;

public class MenuExample extends Application {
    public static void main(String[] args) {  
    launch(args);  
        }  
  
    @Override  
    public void start(Stage primaryStage) throws Exception {
        BorderPane root = new BorderPane();
        Scene scene = new Scene(root,200,300);
        MenuBar menubar = new MenuBar();
        Menu FileMenu = new Menu("文本");
        MenuItem filemenu1=new MenuItem("新建");
        MenuItem filemenu2=new MenuItem("Save");  
        MenuItem filemenu3=new MenuItem("Exit");  
        Menu EditMenu=new Menu("Edit");  
        MenuItem EditMenu1=new MenuItem("Cut");  
        MenuItem EditMenu2=new MenuItem("Copy");  
        MenuItem EditMenu3=new MenuItem("Paste");  
        EditMenu.getItems().addAll(EditMenu1,EditMenu2,EditMenu3);  
        root.setTop(menubar);  
        FileMenu.getItems().addAll(filemenu1,filemenu2,filemenu3);  
        menubar.getMenus().addAll(FileMenu,EditMenu);  
        primaryStage.setScene(scene);  
        primaryStage.setTitle("TEST");
        primaryStage.show();  
          
    }     
}  `

the error:
`java.lang.ArrayIndexOutOfBoundsException: Index -25 out of bounds for length 32
        at com.sun.prism.impl.GlyphCache.getCachedGlyph(GlyphCache.java:332)
        at com.sun.prism.impl.GlyphCache.render(GlyphCache.java:148)
        at 
com.sun.prism.impl.ps.BaseShaderGraphics.drawString(BaseShaderGraphics.java:2101)
        at com.sun.javafx.sg.prism.NGText.renderText(NGText.java:312)
        at com.sun.javafx.sg.prism.NGText.renderContent2D(NGText.java:270)
        at com.sun.javafx.sg.prism.NGShape.renderContent(NGShape.java:261)
        at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2072)
        at com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1964)
        at com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:270)
        at com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:578)
        at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2072)
        at com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1964)
        at com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:270)
        at com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:578)
        at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2072)
        at com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1964)
        at com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:270)
        at com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:578)
        at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2072)
        at com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1964)
        at com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:270)
        at com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:578)
        at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2072)
        at com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1964)
        at com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:270)
        at com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:578)
        at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2072)
        at com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1964)
        at com.sun.javafx.tk.quantum.ViewPainter.doPaint(ViewPainter.java:479)
        at com.sun.javafx.tk.quantum.ViewPainter.paintImpl(ViewPainter.java:328)
        at 
com.sun.javafx.tk.quantum.PresentingPainter.run(PresentingPainter.java:91)
`

-------------

Commit messages:
 - Update GlyphCache.java
 - Update GlyphCache.java

Changes: https://git.openjdk.java.net/jfx/pull/795/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jfx&pr=795&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8286867
  Stats: 2 lines in 1 file changed: 2 ins; 0 del; 0 mod
  Patch: https://git.openjdk.java.net/jfx/pull/795.diff
  Fetch: git fetch https://git.openjdk.java.net/jfx pull/795/head:pull/795

PR: https://git.openjdk.java.net/jfx/pull/795

Reply via email to