java - 当没有中间变量时,在 Eclipse 调试器中操作返回值

标签 java eclipse debugging return-value

如果方法之前尚未分配给中间变量,是否可以使用 Eclipse 调试器更改/定义方法返回的值?

例如我有一些调用的第三方封闭源代码 java.lang.Class.classForName,看起来像这样

  public static Class<?> forName(String className)
              throws ClassNotFoundException {
      return forName0(className, true, ClassLoader.getCallerClassLoader());
  }

通过ClassLoader.getCallerClassLoader()获取的类加载器无法加载类,所以我想尝试是否Thread.currentThread().contextClassLoader更幸运。 所以实际上,我想要这样的东西:

   public static Class<?> forName(String className)
               throws ClassNotFoundException {
       return forName0(className, true, Thread.currentThread().contextClassLoader);
   }

这有可能吗?请注意,forName0 是 native 方法。

最佳答案

您可以使用AspectJ的运行时编织,以围绕 ClassLoader.getCallerClassLoader() 应用您自己的自定义方面来替换返回值。

您也可以尝试Bugdel .

关于java - 当没有中间变量时,在 Eclipse 调试器中操作返回值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12843093/

相关文章:

java - 使用 Gradle 将前端构建的分发文件夹包含在 JAR 中

java - 强制停止 Android 应用程序

Android 模拟器的音频停止工作

c++ - "The breakpoint will not currently be hit. No symbols have been loaded for this document." Visual Studio 2005

ios - 应用程序崩溃 : Index out of bound at random places

java - 为每个对象实例分配唯一编号

java - 为大数据生成最佳 UUID

java - Eclipse Java EE IDE 不支持 javax.servlet 包

java - 不同包中源文件的 Android ClassNotFoundException

debugging - 如何调试 htaccess 重写脚本