开发者

calling method from 1st line in stacktrace: "MyClass.java:1"

开发者 https://www.devze.com 2023-02-15 19:40 出处:网络
In my project I\'m using log4j to log errors and many frameworks: AOP, spring etc. What does it mean when I have in my stacktrace that c开发者_开发知识库alling was in 1st line, e.g:

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

What does it mean when I have in my stacktrace that c开发者_开发知识库alling 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 {...


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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消