1

VTK ツールキットをインストールし、Eclipse で VTK 用の Java ラッパーを使用しています。vtk.jar を Java プロジェクトに追加し、環境変数を VTK インストールを指すように設定しました。基本的に、それは働いています。vtk クラスなどが見つかり、プログラムが開始されます。少なくともウィンドウを表示するところまでは。

たとえば、次のサンプル プログラム: http://www.vtk.org/Wiki/VTK/Examples/Java/Imaging/ImageTest

これを実行すると、OS-X (または Cocoa) によって次の例外がスローされ、UndoManager に問題があることが示されます。

私が間違っていること、またはこの問題の原因がわかりません。誰かアイデアはありますか?

2012-05-22 22:48:09.093 java[925:1a03] *** Assertion failure in +[NSUndoManager _endTopLevelGroupings], /SourceCache/Foundation/Foundation-833.25/Misc.subproj/NSUndoManager.m:324
2012-05-22 22:48:09.093 java[925:1a03] +[NSUndoManager(NSInternal) _endTopLevelGroupings] is only safe to invoke on the main thread.
2012-05-22 22:48:09.096 java[925:1a03] (
    0   CoreFoundation                      0x00007fff9363cf56 __exceptionPreprocess + 198
    1   libobjc.A.dylib                     0x00007fff8aa9fd5e objc_exception_throw + 43
    2   CoreFoundation                      0x00007fff9363cd8a +[NSException raise:format:arguments:] + 106
    3   Foundation                          0x00007fff910a371f -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 169
    4   Foundation                          0x00007fff9101295f +[NSUndoManager(NSPrivate) _endTopLevelGroupings] + 144
    5   AppKit                              0x00000001025680ef -[NSApplication run] + 596
    6   libvtkRendering.5.10.dylib          0x000000010ff8c2df -[vtkCocoaServer start] + 335
    7   libvtkRendering.5.10.dylib          0x000000010ff8cf87 _ZN30vtkCocoaRenderWindowInteractor5StartEv + 293
    8   libvtkRenderingJava.5.10.0.dylib    0x000000010f94f29e Java_vtk_vtkRenderWindowInteractor_Start_15 + 62
    9   ???                                 0x0000000103b70d6e 0x0 + 4357295470
    10  ???                                 0x0000000103b6585a 0x0 + 4357249114
)
2012-05-22 22:48:09.096 java[925:1a03] *** Assertion failure in +[NSUndoManager _endTopLevelGroupings], /SourceCache/Foundation/Foundation-833.25/Misc.subproj/NSUndoManager.m:324
2012-05-22 22:48:09.096 java[925:1a03] An uncaught exception was raised
2012-05-22 22:48:09.097 java[925:1a03] +[NSUndoManager(NSInternal) _endTopLevelGroupings] is only safe to invoke on the main thread.
2012-05-22 22:48:09.098 java[925:1a03] (
    0   CoreFoundation                      0x00007fff9363cf56 __exceptionPreprocess + 198
    1   libobjc.A.dylib                     0x00007fff8aa9fd5e objc_exception_throw + 43
    2   CoreFoundation                      0x00007fff9363cd8a +[NSException raise:format:arguments:] + 106
    3   Foundation                          0x00007fff910a371f -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 169
    4   Foundation                          0x00007fff9101295f +[NSUndoManager(NSPrivate) _endTopLevelGroupings] + 144
    5   AppKit                              0x000000010256819c -[NSApplication run] + 769
    6   libvtkRendering.5.10.dylib          0x000000010ff8c2df -[vtkCocoaServer start] + 335
    7   libvtkRendering.5.10.dylib          0x000000010ff8cf87 _ZN30vtkCocoaRenderWindowInteractor5StartEv + 293
    8   libvtkRenderingJava.5.10.0.dylib    0x000000010f94f29e Java_vtk_vtkRenderWindowInteractor_Start_15 + 62
    9   ???                                 0x0000000103b70d6e 0x0 + 4357295470
    10  ???                                 0x0000000103b6585a 0x0 + 4357249114
)
2012-05-22 22:48:09.098 java[925:1a03] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '+[NSUndoManager(NSInternal) _endTopLevelGroupings] is only safe to invoke on the main thread.'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff9363cf56 __exceptionPreprocess + 198
    1   libobjc.A.dylib                     0x00007fff8aa9fd5e objc_exception_throw + 43
    2   CoreFoundation                      0x00007fff9363cd8a +[NSException raise:format:arguments:] + 106
    3   Foundation                          0x00007fff910a371f -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 169
    4   Foundation                          0x00007fff9101295f +[NSUndoManager(NSPrivate) _endTopLevelGroupings] + 144
    5   AppKit                              0x000000010256819c -[NSApplication run] + 769
    6   libvtkRendering.5.10.dylib          0x000000010ff8c2df -[vtkCocoaServer start] + 335
    7   libvtkRendering.5.10.dylib          0x000000010ff8cf87 _ZN30vtkCocoaRenderWindowInteractor5StartEv + 293
    8   libvtkRenderingJava.5.10.0.dylib    0x000000010f94f29e Java_vtk_vtkRenderWindowInteractor_Start_15 + 62
    9   ???                                 0x0000000103b70d6e 0x0 + 4357295470
    10  ???                                 0x0000000103b6585a 0x0 + 4357249114
)
terminate called throwing an exception

提案された VM パラメータは、このエラーにつながります:

2012-05-23 09:10:18.635 java[747:307] [Java CocoaComponent compatibility mode]: Enabled
2012-05-23 09:10:18.635 java[747:307] [Java CocoaComponent compatibility mode]: Setting timeout for SWT to 0.100000
2012-05-23 09:10:18.985 java[747:d303] *** -[NSConditionLock unlock]: lock (<NSConditionLock: 0x7fa108c64600> '(null)') unlocked when not locked
2012-05-23 09:10:18.985 java[747:d303] *** Break on _NSLockError() to debug.
4

1 に答える 1

0

これは、プロセスが実行される最初のスレッドでしか実行できないものがあるという Cocoa の制限に関連する問題である可能性があります。たとえば、SWT イベント ループでも同じ問題が発生します。問題は、mainメソッドが最初のスレッドで実行されないことです。これは、AWT のイベント ループ用に予約されているためです (同じ理由で)。回避策: JVM スイッチを使用し-XstartOnFirstThreadます。

于 2012-05-22T21:04:10.710 に答える