它是如何可能的例外是空catch块里面? [英] How is it possible that the Exception is null inside of a catch block?

查看:129
本文介绍了它是如何可能的例外是空catch块里面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很好奇,下面是如何可能的。

 赶上(例外五){
    e.printStackTrace();
}

在调试我的code,他一跃而起抓博客 - 到目前为止好 - 但比我检查是什么样的异常,它是E =空

?!

这怎么可能呢?我有一个例外,但例外的是空?

问候,


解决方案

也许这是与调试器或虚拟机的一个问题 - 例外的是延迟加载,即,未加载异常,直到需要。只要没有从异常方法被调用时,它的数据不被装载。当第一方法被调用时,该虚拟机的填充的异常字段。

您应在执行后的的printStackTrace 或使用调试器来从异常(在Eclipse如前pression视图)执行的一种方法。

I'm curious how the following is possible.

catch (Exception e) {
    e.printStackTrace();
}

When I debug my code he jumps into the catch blog - so far so good - but than i check what kind of exception it is, and it is e = null?!

How is that even possible? I have an exception but the exception is null?

Greetings,

解决方案

Probably it is a problem with the debugger or the virtual machine - the exception is lazy loaded, that is, the exception is not loaded until needed. As long as no method from the exception is called, its data is not loaded. When the first method is called, the virtual machine fills the exception fields.

You should see the exception after executing the printStackTrace or using the debugger to execute one method from that exception (e.g. Expression View in Eclipse).

这篇关于它是如何可能的例外是空catch块里面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆