JDK/JAVA Exception NSWindow drag regions should only be invalidated on the Main Thread

Posted 柳鲲鹏

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了JDK/JAVA Exception NSWindow drag regions should only be invalidated on the Main Thread相关的知识,希望对你有一定的参考价值。

  • 在MAC 11上运行jogmap,报错:
2022-01-24 10:56:37.395 java[94984:1325231] Apple AWT Internal Exception: NSWindow drag regions should only be invalidated on the Main Thread!
2022-01-24 10:56:37.395 java[94984:1325231] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'NSWindow drag regions should only be invalidated on the Main Thread!'
*** First throw call stack:
(
  0   CoreFoundation                      0x00007fff2062a1db __exceptionPreprocess + 242
  1   libobjc.A.dylib                     0x00007fff20363d92 objc_exception_throw + 48
  2   CoreFoundation                      0x00007fff206528e6 -[NSException raise] + 9
  3   AppKit                              0x00007fff22de1eb2 -[NSWindow(NSWindow_Theme) _postWindowNeedsToResetDragMarginsUnlessPostingDisabled] + 321
  4   AppKit                              0x00007fff22dccaa2 -[NSWindow _initContent:styleMask:backing:defer:contentView:] + 1296
  5   AppKit                              0x00007fff22dcc58b -[NSWindow initWithContentRect:styleMask:backing:defer:] + 42
  6   libnativewindow_macosx.jnilib       0x00000001b2269502 Java_jogamp_nativewindow_macosx_OSXUtil_CreateNSWindow0 + 354
  7   ???                                 0x000000011937caa8 0x0 + 4718054056
)
libc++abi: terminating with uncaught exception of type NSException
  • 参考网页

  搜索了一下,说JDK242正常,252出现的问题。

java - Apple AWT Internal Exception: NSWindow drag regions should only be invalidated on the Main Thread - Stack Overflow

  吾试了一下,使用官方发布的JDK202确实是可以的。由错误变成了警告。下载链接:

Java Archive | Oracle

  •  原因分析

  对比老新版本的JDK输出,由Warning变成了Error。说明JDK本身没有变化,变化的是Xcode版本(新版本要求必须在主线程进行某些操作)。而其他软件没有及时跟进,于是出错了。

以上是关于JDK/JAVA Exception NSWindow drag regions should only be invalidated on the Main Thread的主要内容,如果未能解决你的问题,请参考以下文章

Centos安装JDK(java环境)

jdk (Java Development Kit)

Java-basic

Java学习2 - JDK和JRE和JVM的区别_JDK的下载安装_环境变量配置

windows系统下,安装多个版本的jdk,java -version

JAVA JDK安装及path环境变量配置