Java:方法会继承JRE超级类吗,就像类会继承Object一样吗? [英] Java: do methods inherit a JRE super class, like classes inherit Object?

查看:55
本文介绍了Java:方法会继承JRE超级类吗,就像类会继承Object一样吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我所知,一切都是Java中的对象.

As far as I know, everything is an object in Java.

我正在研究Java JDK,并正在尝试创建一个自定义JDK,该自定义JDK允许我执行更多调试操作.例如,我可以通过更改Object.java类来操纵每个对象.

I am looking through the java JDK and am experimenting with creating a custom JDK that allows me to perform more debugging operations. For example, I can manipulate every object by changing the Object.java class.

我的问题是:方法是否也从JRE继承了一个类,以便可以将此父级修改为例如.使方法保存最近传递的参数?

My question is: do methods inherit a class from the JRE as well, so that I can modify this parent to eg. make a method save it's most recently passed arguments?

谢谢.

推荐答案

如果您只想增强调试,则可以先查看 JDI ,基于JVMTI构建的更高级别(因此更易于使用)的API可以满足您的需求.

If you only want to enhance debugging, you can start with looking at what JVMTI has to offer. Even before that, see if JDI, a much higher level (and therefore easier to use) API built on top of JVMTI suits your needs.

尽管您说的话本身并不可行,但

And although what you're saying doesn't sound possible in itself, a similar effect can be achieved by instrumentation, using a byte code manipulating library, like BCEL.

对于您的特定示例,如果您想记录方法调用及其参数,只需使用JDI设置断点,然后查询调用堆栈即可.

As for your specific example, if you want to record method invocations and their parameters, simply setting a breakpoint with JDI and then querying the call stack can do the trick.

这篇关于Java:方法会继承JRE超级类吗,就像类会继承Object一样吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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