From efa169fb8df46e842a47683e85ad5354098456cb Mon Sep 17 00:00:00 2001 From: Andy Clement Date: Thu, 20 Jun 2013 09:26:47 -0700 Subject: [PATCH] GRAILS-10183 --- .../loaded/ri/ReflectiveInterceptor.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/org.springsource.loaded/src/main/java/org/springsource/loaded/ri/ReflectiveInterceptor.java b/org.springsource.loaded/src/main/java/org/springsource/loaded/ri/ReflectiveInterceptor.java index 000cd1c..9fbd3bf 100644 --- a/org.springsource.loaded/src/main/java/org/springsource/loaded/ri/ReflectiveInterceptor.java +++ b/org.springsource.loaded/src/main/java/org/springsource/loaded/ri/ReflectiveInterceptor.java @@ -32,6 +32,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Properties; import java.util.WeakHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -179,6 +180,7 @@ public class ReflectiveInterceptor { return s.toString(); } + private static int depth = 4; /** * Get the Class that declares the method calling interceptor method that called this method. */ @@ -189,7 +191,17 @@ public class ReflectiveInterceptor { //2 = caller of 'getCallerClass' = asAccesibleMethod //3 = caller of 'asAccesibleMethod' = jlrInvoke //4 = caller we are interested in... - Class caller = sun.reflect.Reflection.getCallerClass(4); + + // In jdk17u25 there is an extra frame inserted: + // "This also fixes a regression introduced in 7u25 in which + // getCallerClass(int) is now a Java method that adds an additional frame + // that wasn't taken into account." in http://permalink.gmane.org/gmane.comp.java.openjdk.jdk7u.devel/6573 + Class caller = sun.reflect.Reflection.getCallerClass(depth); + if (caller==ReflectiveInterceptor.class) { + // If this is true we have that extra frame on the stack + depth=5; + caller = sun.reflect.Reflection.getCallerClass(depth); + } String callerClassName = caller.getName();