2017-09-03 27 views
-1

私はWindowsのみに失敗したJavaFXのテストを持っていますが、OSXでは正常に動作し、LinuxのJavaFXのWindowsで失敗し、OSXで動作テストおよびLinux

は、スタックトレースです:

編集: 1

Running com.myproject.meditor.SLIVCodeAreaTest 
Tests run: 17, Failures: 0, Errors: 17, Skipped: 0, Time elapsed: 6.656 sec <<< FAILURE! - in com.myproject.meditor.SLIVCodeAreaTest 
testRHBlock(com.myproject.meditor.SLIVCodeAreaTest) Time elapsed: 0 sec <<< ERROR! 
java.lang.ExceptionInInitializerError: null 
    at com.sun.glass.ui.Screen.getScreens(Screen.java:70) 
    at com.sun.glass.ui.Screen.getMainScreen(Screen.java:61) 
    at com.sun.javafx.font.PrismFontFactory.getSystemFontSize(PrismFontFactory.java:1911) 
    at com.sun.javafx.font.PrismFontLoader.getSystemFontSize(PrismFontLoader.java:240) 
    at javafx.scene.text.Font.getDefaultSystemFontSize(Font.java:71) 
    at javafx.scene.text.Font.getDefault(Font.java:86) 
    at javafx.scene.text.Text.getFont(Text.java:478) 
    at javafx.scene.text.Text.getFontInternal(Text.java:487) 
    at javafx.scene.text.Text.access$100(Text.java:95) 
    at javafx.scene.text.Text$1.getFont(Text.java:206) 
    at com.sun.javafx.text.GlyphLayout.breakRuns(GlyphLayout.java:174) 
    at com.sun.javafx.text.PrismTextLayout.buildRuns(PrismTextLayout.java:770) 
    at com.sun.javafx.text.PrismTextLayout.layout(PrismTextLayout.java:1021) 
    at com.sun.javafx.text.PrismTextLayout.ensureLayout(PrismTextLayout.java:223) 
    at com.sun.javafx.text.PrismTextLayout.getBounds(PrismTextLayout.java:246) 
    at javafx.scene.text.TextFlow.computePrefWidth(TextFlow.java:203) 
    at javafx.scene.Parent.prefWidth(Parent.java:915) 
    at javafx.scene.layout.Region.prefWidth(Region.java:1419) 
    at org.fxmisc.richtext.ParagraphBox.computePrefWidth(ParagraphBox.java:199) 
    at org.fxmisc.richtext.ParagraphBox.computeMinWidth(ParagraphBox.java:191) 
    at javafx.scene.Parent.minWidth(Parent.java:943) 
    at javafx.scene.layout.Region.minWidth(Region.java:1383) 
    at org.fxmisc.flowless.VerticalHelper.minBreadth(OrientationHelper.java:234) 
    at org.fxmisc.flowless.OrientationHelper.minBreadth(OrientationHelper.java:44) 
    at org.reactfx.collection.MappedList.get(MappedList.java:27) 
    at org.reactfx.collection.MemoizationListImpl.force(MemoizationList.java:121) 
    at org.fxmisc.flowless.SizeTracker.breadthFor(SizeTracker.java:161) 
    at org.fxmisc.flowless.CellPositioner.getSizedCell(CellPositioner.java:130) 
    at org.fxmisc.flowless.CellPositioner.placeStartAt(CellPositioner.java:95) 
    at org.fxmisc.flowless.Navigator.placeStartAtMayCrop(Navigator.java:183) 
    at org.fxmisc.flowless.Navigator.visit(Navigator.java:111) 
    at org.fxmisc.flowless.StartOffStart.accept(TargetPosition.java:49) 
    at org.fxmisc.flowless.Navigator.layoutChildren(Navigator.java:67) 
    at javafx.scene.Parent.layout(Parent.java:1087) 
    at org.fxmisc.flowless.VirtualFlow.layoutChildren(VirtualFlow.java:165) 
    at javafx.scene.Parent.layout(Parent.java:1087) 
    at org.fxmisc.flowless.VirtualFlow.visibleCells(VirtualFlow.java:138) 
    at com.myproject.util.javafx.codearea.SEditor.<init>(SEditor.java:659) 
    at com.myproject.util.javafx.codearea.SEditor.<init>(SEditor.java:607) 
    at com.myproject.util.javafx.codearea.SCodeArea.<init>(SCodeArea.java:122) 
    at com.myproject.meditor.SLICodeArea.<init>(SLICodeArea.java:124) 
    at com.myproject.meditor.SLICodeArea.<init>(SLICodeArea.java:114) 
    at com.myproject.meditor.SLItemCodeArea.<init>(SLICodeArea.java:106) 
    at com.myproject.meditor.SLItemCodeArea.<init>(SLICodeArea.java:103) 
    at com.myproject.meditor.SLIVCodeAreaTest.<clinit>(SLIVCodeAreaTest.java:14) 

EDIT:2

スタックトレースから

は、例外(SLIVCodeAreaTest.java:14)をトリガーしたコードの一部は、コードの一部にprivate static final SLIVCodeAreaの宣言である:

import static org.junit.Assert.assertTrue; 
import org.junit.Test; 

public class SLIVCodeAreaTest {  
    private static final SLIVCodeArea sEditor = new SLIVCodeArea(new SLICodeArea()) { 

     @Override protected void updateVisibleParagraphRange() {} }; 

    private static final VEditorProblemList sProblemList = 
     new VEditorProblemList(sEditor, new SimpleObjectProperty<>(), false); 

    static { sEditor.aggregatedTextChanges().setAggregationEnabled(false); } 

は編集:3

私が削除した場合キーワードスタティック上記の初期化部分から、エラーのスタックトレースは次のようになります。

Running com.myproject.meditor.SLIVCodeAreaTest 
Tests run: 17, Failures: 0, Errors: 17, Skipped: 0, Time elapsed: 1.124 sec <<< FAILURE! - in Running com.myproject.meditor.SLIVCodeAreaTest 
testRHBlock(com.myproject.meditor.SLIVCodeAreaTest) Time elapsed: 0 sec <<< ERROR! 
java.lang.RuntimeException: Internal graphics not initialized yet 
    at com.sun.glass.ui.Screen.getScreens(Screen.java:70) 
    at com.sun.glass.ui.Screen.getMainScreen(Screen.java:61) 
    at com.sun.javafx.font.PrismFontFactory.getSystemFontSize(PrismFontFactory.java:1911) 
    at com.sun.javafx.font.PrismFontLoader.getSystemFontSize(PrismFontLoader.java:240) 
    at javafx.scene.text.Font.getDefaultSystemFontSize(Font.java:71) 
    at javafx.scene.text.Font.getDefault(Font.java:86) 
    at javafx.scene.text.Text.getFont(Text.java:478) 
    at javafx.scene.text.Text.getFontInternal(Text.java:487) 
    at javafx.scene.text.Text.access$100(Text.java:95) 
    at javafx.scene.text.Text$1.getFont(Text.java:206) 
    at com.sun.javafx.text.GlyphLayout.breakRuns(GlyphLayout.java:174) 
    at com.sun.javafx.text.PrismTextLayout.buildRuns(PrismTextLayout.java:770) 
    at com.sun.javafx.text.PrismTextLayout.layout(PrismTextLayout.java:1021) 
    at com.sun.javafx.text.PrismTextLayout.ensureLayout(PrismTextLayout.java:223) 
    at com.sun.javafx.text.PrismTextLayout.getBounds(PrismTextLayout.java:246) 
    at javafx.scene.text.TextFlow.computePrefWidth(TextFlow.java:203) 
    at javafx.scene.Parent.prefWidth(Parent.java:915) 
    at javafx.scene.layout.Region.prefWidth(Region.java:1419) 
    at org.fxmisc.richtext.ParagraphBox.computePrefWidth(ParagraphBox.java:199) 
    at org.fxmisc.richtext.ParagraphBox.computeMinWidth(ParagraphBox.java:191) 
    at javafx.scene.Parent.minWidth(Parent.java:943) 
    at javafx.scene.layout.Region.minWidth(Region.java:1383) 
    at org.fxmisc.flowless.VerticalHelper.minBreadth(OrientationHelper.java:234) 
    at org.fxmisc.flowless.OrientationHelper.minBreadth(OrientationHelper.java:44) 
    at org.reactfx.collection.MappedList.get(MappedList.java:27) 
    at org.reactfx.collection.MemoizationListImpl.force(MemoizationList.java:121) 
    at org.fxmisc.flowless.SizeTracker.breadthFor(SizeTracker.java:161) 
    at org.fxmisc.flowless.CellPositioner.getSizedCell(CellPositioner.java:130) 
    at org.fxmisc.flowless.CellPositioner.placeStartAt(CellPositioner.java:95) 
    at org.fxmisc.flowless.Navigator.placeStartAtMayCrop(Navigator.java:183) 
    at org.fxmisc.flowless.Navigator.visit(Navigator.java:111) 
    at org.fxmisc.flowless.StartOffStart.accept(TargetPosition.java:49) 
    at org.fxmisc.flowless.Navigator.layoutChildren(Navigator.java:67) 
    at javafx.scene.Parent.layout(Parent.java:1087) 
    at org.fxmisc.flowless.VirtualFlow.layoutChildren(VirtualFlow.java:165) 
    at javafx.scene.Parent.layout(Parent.java:1087) 
    at org.fxmisc.flowless.VirtualFlow.visibleCells(VirtualFlow.java:138) 
    at com.myproject.util.javafx.codearea.SEditor.<init>(SEditor.java:659) 
    at com.myproject.util.javafx.codearea.SEditor.<init>(SEditor.java:607) 
    at com.myproject.util.javafx.codearea.SCodeArea.<init>(SCodeArea.java:122) 
    at com.myproject.meditor.SLICodeArea.<init>(SLICodeArea.java:124) 
    at com.myproject.meditor.SLICodeArea.<init>(SLICodeArea.java:114) 
    at com.myproject.meditor.SLICodeArea.<init>(SLICodeArea.java:106) 
    at com.myproject.meditor.SLICodeArea.<init>(SLICodeArea.java:103) 
    at com.myproject.meditor.SLIVCodeAreaTest.<init>(SLIVCodeAreaTest.java:14) 

PS:テストはしてと静的キーワードなしOSXで働いていました。

LinuxとMacOSでは同じコードが正常に動作しますが、ウィンドウは失敗します。 誰もがなぜアイデアを持っていますか?

+1

[MCVE]を作成して投稿します。 –

+0

あなたの質問に*全体の*スタックトレースを含めてください。例外をトリガしたコードの行はどの行ですか? – VGR

+0

はグローバル変数かローカル変数ですか?あなたのメソッド_staticScreaan_getScreens_はnullを返すので、テーブルにnull要素があると思います。 –

答えて

0

JavaFX,JUnitおよび任意のjava.lang.ExceptionInInitializerErrorの組み合わせは、例外Toolkit not initializedの発生を抑制する指標となります。

JavaFXを初期化するには、ユニットテストを実行する前にnew JFXPanel()が終了するのを待つことがあります。

参照:

+0

_Toolkit初期化されていない_例外が発生した場合、MacOSまたはLinuxではそれがなぜ発生しないのですか? – josephino

+0

MacOS、Linux、またはWindowsで使用されるJRE-Versionに依存することがあります。 –

+0

例外の「抑制された発生」とは何ですか?これが初期化されていないJavaFXアプリケーションの症状であると思われる原因は何ですか?リンクされたSOの質問には何も表示されません。この質問には、質問のスタックトレースのいずれかのクラスが含まれています。 – VGR

0

Class ExceptionInInitializerError

パブリッククラスExceptionInInitializerErrorによると、予期しない例外が静的初期化子内で発生したのLinkageErrorのシグナル を拡張します。 静的イニシャライザの評価中に例外 が発生したこと、または静的変数が初期値 であることを示すために、ExceptionInInitializerErrorがスローされます。

あなたが Minimal, Complete, and Verifiable example. を投稿していなかったのでnewscreens静的ではありませんかヌルによって初期化されているので、私が思うに、あなたは配列にnull変数を転送しようとしました。

+0

多くの依存関係があるため、最小限の完全な例を生成できませんでした。静的な初期化子の評価中に例外が発生したという事実については、上記の私の編集を参照してください – josephino

関連する問題