JEP 176: Mechanical Checking of Caller-Sensitive Methods

Jeroen Frijters jeroen at
Sat Mar 2 08:46:21 UTC 2013

Hi John,

This is really great. I've been using an annotation for caller sensitive methods for many year in IKVM as a performance enhancement and I can say that my experiences with my simple mechanism are really great.

I've got a class ikvm.internal.CallerID that looks something like this:

public final class CallerID {
  @Internal (IKVM specific annotation meaning that it is only public in the module)
  public native Call getCallerClass();

  public native ClassLoader getClassClassLoader();

  public static native getCallerID();

Any (trusted) method with an ikvm.internal.HasCallerID annotation can call the CallerID.getCallerID() intrinsic and from there on the CallerID object gets explicitly passed around to other methods when necessary. I modified sun.reflect.MethodAccessor.invoke() to have an additional CallerID parameter and MethodHandles.Lookup is also CallerID based.

JNI methods automatically act as if they have a HasCalleriD annotation and store the caller on a stack inside the thread's JNIEnv.

(I'm not suggesting HotSpot uses the same design, that probably doesn't make sense. Just that in the many years I've used this, I've found the explicit caller sensitive annotation and explicitly passing around a cookie that represents the caller to be an efficient and secure way to handle this.)


> -----Original Message-----
> From: core-libs-dev-bounces at [mailto:core-libs-dev-
> bounces at] On Behalf Of mark.reinhold at
> Sent: Friday, March 1, 2013 18:59
> To: john.r.rose at
> Cc: core-libs-dev at
> Subject: JEP 176: Mechanical Checking of Caller-Sensitive Methods
> Posted:
> - Mark

More information about the core-libs-dev mailing list