为什么 Java ME 没有异常处理程序?

发布于 2024-12-09 16:32:40 字数 100 浏览 0 评论 0原文

我正在寻找 Java 平台之间的差异,我注意到 J2ME 没有异常处理程序。

是什么让 try-catch 如此繁重以至于 Sun 没有将它们包含在 Java ME 中?

I was looking for the differences between Java platforms and i noticed that J2ME does not have exception handlers.

What makes try-catch so heavy that Sun did not include them in Java ME?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浮华 2024-12-16 16:32:40

如果您正在谈论异常处理程序,例如由 Thread.setUncaughtExceptionHandler,那么原因很简单:

所有当前的 Java ME 版本都基于相当旧的 Java SE 版本(1.3、我想,但不要引用我的确切版本)。而该 Java SE 版本根本没有该功能,因此在本例中他们没有“删除”Java ME 中的任何内容。

另请注意,通过使用捕获所有异常并根据需要进行处理的 Runnable 启动 Thread 来轻松模拟这些处理程序,因此它们不是不可替代的 API 元素。

If you're talking about exception handlers such as set by Thread.setUncaughtExceptionHandler, then the reason is simple:

All current Java ME versions are based on pretty old Java SE versions (1.3, I think, but don't quote me on that exact version). And that Java SE version simply didn't have that feature, so they didn't "remove" anything in Java ME in this instance.

Note, also, that those handlers are easily emulated by starting your Thread with a Runnable that catches all exceptions and handles them as desired, so they are not an irreplaceable API element.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文