Skip to Main Content

Java HotSpot Virtual Machine

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

A way to avoid method inlining by JIT?

843811Sep 16 2003 — edited Sep 17 2003
I've got a bit of code that relies on the accuracy of the stacktrace for a given call. When that code gets inlined by the JIT compiler (and thus the stacktrace altered), the behavior is no longer what I want because the class that called the method does not show up in the stack. For example:

class A {
main()
{
fooA();
}
public fooA()
{
fooB();
}
}

class B {
public fooB()
{
fooC();
}
}

class C {
public fooC()
{
getStackTrace();
// need to find out that class B called me
}
}

So in the example above, class A calls class B calls class C, and in the method fooC(), its imperative that the stacktrace show its caller as being class B. When JIT is disabled this is fine.

However, when JIT is enabled and this is seen as a hotspot, the code gets optimized and all of a sudden the stacktrace simply shows class A calling class C since the code in class B was inlined into A. Is there a way to make sure that the code in class B does not get inlined, or am I stuck with disabling JIT (which I don't want to do).

The obvious answer is to not rely on the stacktrace, but at this point in my application, that would require a major overhaul. Any ideas would be appreciated.

Thanks,
Charles.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 15 2003
Added on Sep 16 2003
1 comment
509 views