JDK-8021946 : Disabling sun.reflect.Reflection.getCallerCaller(int) by default breaks several frameworks and libraries
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 7u40
  • Priority: P1
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2013-07-31
  • Updated: 2013-10-01
  • Resolved: 2013-08-01
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
7u40 b37Fixed
See JDK-8014925 (and CCR http://oracleplan.oracle.com/gotoEntity?entityType=FEATURE&entityId=1080598) for background.

In 7u40 we have disabled the JDK private method sun.reflect.Reflection.getCallerCaller(int). It turns out that there are several frameworks and libraries that have ignored the warning not to use JDK private methods and now broken by the change in 7u40. This includes Groovy, Log4J and others. The solution in 7u40 includes a system property to re-enable this method but it turns out that this is too awkward to use (the Groovy folks are saying that they cannot ask their users to set this property).

This bug is submitted to re-examine this issue for 7u40 only. Separate enhancement issues have been submitted for 8 to explore API solutions to cover some of the use-cases where the caller class is required.  For 7u40 then we need to explore whether it would make sense to re-enable it to allow existing code to continue to work even through they are making use of a JDK private method.
Verified by provided regression tests on 7u40 b37.

in today's 7u40 Triage meeting - we all agreed that this is a must fix and everyone agreed to mark this as critical approved. - DONE I have also sent the CCR out - since the work was added via CCR and will now need to be backed out and therefore the CCR will need to be rejected. 16956642 ccr: disable sun.reflect.reflection.getcallerclass() by default

The method can remained deprecated in the 7 update train though. That would preserve binary compatibility while providing a warning for source-level usage.

I think it's pretty clear what we need to do here: Remove the system property controlling the behavior of this method and re-enable the method to work correctly by default. If we ship 7u40 without this change then we run a high risk of serious adoption problems.