在stacktrace中从第一行调用方法:“MyClass.java:1” [英] calling method from 1st line in stacktrace: "MyClass.java:1"

查看:100
本文介绍了在stacktrace中从第一行调用方法:“MyClass.java:1”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目中,我使用log4j来记录错误和许多框架:AOP,spring等。

In my project I'm using log4j to log errors and many frameworks: AOP, spring etc.

当我在stacktrace中调用时,这是什么意思在第一行,例如:

What does it mean when I have in my stacktrace that calling was in 1st line, e.g:

com.foo.bar.MyException: Error
    at com.foo.bar.MyClass.handleException(MyClass.java:92)
    at com.foo.bar.MyClass.myMethod(MyClass.java:76)
    at com.foo.bar.MyClass.myMethod(MyClass.java:1) // <- here ???
    ...

在第一行,我的班级是评论,一切都正确编译

In 1st line my Class is comment and everything is compiled correctly

MyClass.java:

/* Copyright 2011 */
package com.foo.bar;

import ...

public class MyClass implements MyInterface {...


推荐答案

我在调试过程中也看到过这种现象 - 步入某个方法有时会先跳到声明类的第一行,然后 / em>实际方法。如果没有能够为您提供参考,我认为它与在某些情况下调度重写方法有关(协变返回类型至少有一个)。在这些情况下,编译器需要插入一个在真实方法之前调用的合成桥接方法,我的猜测是这个方法的有效行号为1.

I've seen this phenomenon during debugging as well - stepping into a method sometimes jumps to the first line of the declared class first, then the actual method. Without being able to give you a reference, I think it's something to do with dispatch of overridden methods in some situations (covariant return types being at least one). In these cases, the compiler needs to insert a synthetic bridge method which gets called before the "real" method, and my guess is that this method gets an effective line number of 1.

无论如何,我认为你不用担心 - 正如你所看到的,你自己的 myMethod 实现会在第76行成功调用。

In any case, I don't think it's something for you to worry about - as you can see, your own myMethod implementation gets called successfully on line 76 immediately afterwards.

这篇关于在stacktrace中从第一行调用方法:“MyClass.java:1”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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