首页 \ 问答 \ 在Java中处理运行时异常(Handling Runtime exception in Java)

在Java中处理运行时异常(Handling Runtime exception in Java)

我有以下一段代码

 try{//do something
     }
  catch (Exception e) {
        log.error(e, e);
        if (e instanceof RuntimeException) {
            throw (RuntimeException) e;
        } else {
            throw new RuntimeException(e);
        }
    }

findbugs stataic分析工具会对此引发此警告

对于methodX中的所有非空值,instanceof将始终返回true,因为所有RuntimeException都是RuntimeException的实例

我不明白的是它被捕获的异常,而不是RuntimeException,那么为什么这个警告呢?


I have the following piece of code

 try{//do something
     }
  catch (Exception e) {
        log.error(e, e);
        if (e instanceof RuntimeException) {
            throw (RuntimeException) e;
        } else {
            throw new RuntimeException(e);
        }
    }

the findbugs stataic analysis tool throws this warning on it

instanceof will always return true for all nonnull values in methodX, since all RuntimeException are instances of RuntimeException

what i dont understand is that its Exception which is being caught and not the RuntimeException, so why this warning ?


原文:https://stackoverflow.com/questions/10717585
更新时间:2023-04-13 09:04

最满意答案

至少在使用低于9的IE时,Internet Explorer的Javascript引擎比其他网络浏览器的引擎慢。因此,如果您使用IE 6,7或8,现在您知道原因了。

就像raynjamin说的,尝试使用Sunspider测试IE。

最新的稳定Firefox(3.6)速度很快,但例如Google Chrome甚至更快。 浏览器的Javascript速度取决于其底层实现。

更新 :为了让您了解“快速”IE与其他浏览器的比较,我使用Sunspider 0.9.1在自己的计算机上进行了基准测试。 结果如下:

- Internet Explorer 8: 5039.8ms
- Firefox 3.6:          967.9ms (loaded with extensions)
- Chrome 9:             276.3ms
- Opera 10.6:           293.2ms
- Safari 5:             397.0ms

正如您所看到的,至少在使用Sunspider测试时,IE 8比Firefox 3.6慢5倍,比Chrome 9慢20倍。 这是一个巨大的差异,你可以看到,IE 8并不是那么快。

更新2 :有一种方法可以让IE更快。 存在称为Chrome框架的插件。 使用这个插件将使IE更快,因为它会使用Chrome的引擎。 我没有亲自尝试过,但我听到过很多好消息。


Internet Explorer's Javascript engine is slower than that from other web browsers, at least when using IE with versions lower than 9. So, if you're using IE 6, 7 or 8, now you know why.

Like raynjamin said, try testing IE using Sunspider.

The latest stable Firefox (3.6) is fast, but for example, Google Chrome is even faster. A browser's Javascript speed depends on its underlying implementation.

Update: to give you an idea of how "fast" IE is compared to other browsers, I've done a benchmark on my own computer using Sunspider 0.9.1. Here are the results:

- Internet Explorer 8: 5039.8ms
- Firefox 3.6:          967.9ms (loaded with extensions)
- Chrome 9:             276.3ms
- Opera 10.6:           293.2ms
- Safari 5:             397.0ms

As you can see, IE 8 is about 5 times slower than Firefox 3.6 and almost 20 times slower than Chrome 9, at least when using Sunspider tests. That is a drastic difference and you can see that IE 8 isn't all that fast.

Update 2: There is one way to make IE faster. A plugin called Chrome frame exists. Using this plugin will make IE faster since it will use Chrome's engine. I haven't tried it personally, but I've heard good things about it.

相关问答

更多

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。