自动异常处理 [英] Automated Exception Handling

查看:270
本文介绍了自动异常处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如果有东西存在(在Java世界中),可以使用以下功能拍摄JVM当前状态的快照:

I was wondering if something exists (in Java world) able to take an snapshot of the JVM current state with the following features:


  • 在抛出异常时执行此操作。

  • 捕获局部变量,方法的参数等。

  • 将其放在一个方便的文件中,用于在IDE中提取或复制源代码中的情况。

需要两个第一个功能(第三个功能将会很棒) 。而且它必须适合于生产使用(所以没有办法调试器)。

The two first features are required (third would be awesome). And it must be suitable for production use (so, there is no way about debuggers).

在询问之前,我通过WWW搜索(尽可能长的)我发现了一些指针:

Before asking this I've searched through the WWW (as long as possible) and I found some pointers:


  • Cajoon Interceptor :如 Dzone post 所述,它是被动的JVM代理满足三要求!但是,它有两个缺点:你必须付出代价,而且网站不合适(也许没有机会支付任何费用)。

  • AviCode Intercept Studio :Cajoon的.NET等价物。只需给出一些见解。

  • JavaFrame :好的,这是一个推文,但它指向一个可用的SVN repo,其中包含一个JVM代理的源代码(在MIT许可证下),看起来不错(我将尝试一下)。

  • Cajoon Interceptor: As said in Dzone post, it's a passive JVM agent which fulfill the three requirements! But, it has two downsides: you must pay for it and the site is down (maybe there is no chance to pay anything).
  • AviCode Intercept Studio: Cajoon's .NET equivalent. Just to give some insight about.
  • JavaFrame: Ok, it's a tweet, but it points to a available SVN repo which have the source code (under MIT license) of a JVM agent which looks fine (I'm going to give a try to it).

那么,也许我正在寻找一个不存在的解决方案?这并不紧急,但是我有一个项目的想法,很有可能探索这个未知(?)路径并获得一些真实的东西。

So, maybe I'm looking for a non existent solution? It's not urgent, but I had this idea for a project and it would be great to explore this "unknown" (?) path and get something real.

请清楚,它将是JVM代理(来自JVMTI的异常事件,对于示例)。

It seems to be clear that it would be a JVM agent (exception event from JVMTI, for example).

最后,我将突出显示维基百科的异常处理文章


在运行时引擎环境中,如
Java或.NET ,存在
附加到运行时引擎的工具,并且每个
时间发生利息
的异常,他们记录调试
内存中的
信息
时间抛出异常
(调用堆栈和堆值)。这些
工具称为自动异常
处理或错误拦截工具
并为异常提供根本原因信息

In runtime engine environments such as Java or .NET, there exist tools that attach to the runtime engine and every time that an exception of interest occurs, they record debugging information that existed in memory at the time the exception was thrown (call stack and heap values). These tools are called Automated Exception Handling or Error Interception tools and provide 'root-cause' information for exceptions.

这是想法。我希望有人可以给我一些洞察力,或者也许在未来有人会被这个谦虚的帖子启发:)

That's the idea. I hope somebody can give me some insight or maybe, in the future, somebody get inspired by this humble post :)

谢谢!

推荐答案

我来看看 JavaFrame这似乎是一个很好的起点。只需安装Apache Ant,在javaframe目录中执行 ant ,并启动测试套件(测试目录内):

I give a look to JavaFrame and it seems a good starting point. Just install Apache Ant, do ant in the javaframe directory and launch the test suite (inside test directory) with:

LD_LIBRARY_PATH=../build/native/ java -agentlib:frameintrospect -classpath ../build/classes/:. org.thobe.frame.Test

它没有任何局部变量,但它尝试。所以,正如我所说,这可能是一个起点。我希望能够进一步了解它的用法,但没有时间和文档(有很多名为JavaFrame的项目)是坏的情况。

It does not get any local variable but it tries. So, as I said, it can be an starting point. I hope to get further about its usage, but no time and no documentation (there are lots of projects named JavaFrame) are bad circumstances.

也许有一天可以完成再次。是的,再次。有一个Cajoon,它看起来很有光泽,但它的网站已经关闭,没有任何可下载的jar尝试的痕迹。

Maybe some day it can be done again. Yes, again. There was Cajoon, it looked promising and shiny but its website is down and there is no trace of any downloadable jar to try.

感谢大家!

PD:仅供参考,研究时发现的一些链接:

PD.: Just for reference, some links I found while researching:

  • How VM Agents Work
  • JVM options

这篇关于自动异常处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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