dimanche 14 avril 2019

Java stack frames for methods without explicit invocations (call sites)

I have a question regarding methods that appear on the stack when a Java program executes. I have instrumented the code to log when a method execution starts, and when the method exits (think about AOP before and after). I create a log for each thread. The results are mostly as expected, with some subtle differences.

  1. When a reflective call is encountered, not only java.lang.reflect.Method#invoke is logged, but also additional invocations like sun.reflect.DelegatingMethodAccessorImpl#invoke show up. I assume this is related to the hidden frames discussed in the StackWalker documentation.
  2. There are additional invocations, mainly of java.lang.ClassLoader.loadClass , but also sun.instrument.InstrumentationImpl.transform (remember, I instrument the code!). Those are methods that have stack frames, but there are no call sites in the application classes.

I have two questions:

  1. Is there a list of all methods, or a criterion defining methods for which invocations will be hidden (such as "all methods defined in classes in packages starting with sun.)?
  2. Is there a list of all methods, or a criterion defining methods that are invocated by the JVM without a callsite in user code?

Thanks





Aucun commentaire:

Enregistrer un commentaire