@CallerSensitive in Java SE 7u25

Chris Hegarty chris.hegarty at oracle.com
Tue Jun 25 10:14:21 UTC 2013


Known issue, Mandy has a fix in progress [1].

-Chris.

[1] http://mail.openjdk.java.net/pipermail/jdk7u-dev/2013-June/006791.html

On 06/25/2013 11:06 AM, Peter Levart wrote:
> Hi Mandy,
>
> I noticed the @CallerSensitive annotation and machinery behind it has
> been back-ported to JDK7. That was when one of my apps using
> sun.reflect.Reflection.getCallerClass(int) failed. The native method
> taking "int" was deprecated, but it also changed the behavior. If I run
> the following program:
>
> import sun.reflect.Reflection;
>
> public class GetCallerClassTest {
>
>      static class Tester {
>          static void test(int frames) {
>              System.out.println(frames + ": " +
> Reflection.getCallerClass(frames));
>          }
>      }
>
>      public static void main(String[] args) {
>          Tester.test(0);
>          Tester.test(1);
>          Tester.test(2);
>          Tester.test(3);
>      }
> }
>
>
> with JDK7u21, I get the following output:
>
> 0: class sun.reflect.Reflection
> 1: class GetCallerClassTest$Tester
> 2: class GetCallerClassTest
> 3: null
>
>
> with JDK7u25, I get the following output:
>
> 0: class sun.reflect.Reflection
> 1: class sun.reflect.Reflection
> 2: class GetCallerClassTest$Tester
> 3: class GetCallerClassTest
>
>
> It seems that with 7u25 the result is "shifted"  for one calling frame.
> Is that behavior change intentional to encourage people to "get off that
> wagon"?
>
> Regards, Peter
>



More information about the core-libs-dev mailing list