开发者

Why doesn't Java ME have exception handlers?

开发者 https://www.devze.com 2023-04-12 10:24 出处:网络
I was looking for the differences between Java platforms and i noticed that J2ME does not have exception handlers.

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

Wh开发者_高级运维at makes try-catch so heavy that Sun did not include them in Java ME?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号