gpt4 book ai didi

java - SWING 应用程序中抛出 _​​_NSAutoreleaseNoPool

转载 作者:行者123 更新时间:2023-12-01 05:49:53 25 4
gpt4 key购买 nike

我真的很傻眼(或者可能只是“愚蠢”)。我正在相对较新的 Mac 上使用 JRE 系统库(JVM 内容(MacOS X 默认)、Hibernate 3.0 和 Eclipse Helios 中的 MigLayout)构建一个简单的 Java Swing 应用程序。一切进展顺利,直到我开始看到以下错误消息这会阻止 GUI 甚至渲染。

2011-02-12 09:40:27.842 java[809:903] [Java CocoaComponent compatibility mode]: Enabled
2011-02-12 09:40:27.843 java[809:903] [Java CocoaComponent compatibility mode]: Setting timeout for SWT to 0.100000
2011-02-12 09:41:08.355 java[809:903] *** __NSAutoreleaseNoPool(): Object 0x1001575c0 of class NSConcreteMapTableValueEnumerator autoreleased with no pool in place - just leaking

当我使用以下简单代码实例化 JButton 时,会抛出前两行:

 private JButton button = new JButton();

在 Main() 中调用我的 Controller 构造函数结束时抛出最后一行。

public static void main(String[] args) {

// Creates a model of the system logic.
LeapsAndBoundsModel model = new LeapsAndBoundsModel();

// Creaties a view for the system logic.
LeapsAndBoundsView leapsAndBoundsView = new LeapsAndBoundsView();

// Creates a controller that links the two.
LeapsAndBoundsController controller = new LeapsAndBoundsController(model, leapsAndBoundsView);
}

我在 Google 上搜索了这个问题,发现很多人都遇到同样的问题,但几乎所有人都使用 iPhone 应用程序的 CocoaComponent 进行编码。这是一个简单的 GUI,它使用 Hibernate 将信息保存到本地化的 Derby 数据库中。

我已尝试以下两种建议,但均未成功:

//Set the CocoaComponent CompatibilityMode to "False"
System.setProperty( "com.apple.eawt.CocoaComponent.CompatibilityMode", "false" );

// Use the "invokeLater" method within Main() construct
SwingUtilities.invokeLater( new Runnable() {

public void run() {
doIt();
}
});

任何帮助将不胜感激。

最佳答案

我不确定,Eclipse 中是否显示了 Swing?因为这些错误一般都是SWT(Eclipse使用的)中的bug。 cf 错误如: https://bugs.eclipse.org/bugs/show_bug.cgi?id=211361https://bugs.eclipse.org/bugs/show_bug.cgi?id=106619

您可以尝试升级 Eclipse,或者检查启动 Eclipse 时使用的参数。

关于java - SWING 应用程序中抛出 _​​_NSAutoreleaseNoPool,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4978992/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com