JDK-8014925 : Disable sun.reflect.Reflection.getCallerClass(int) with a temporary switch to re-enable it
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang:reflect
  • Affected Version: 7u40
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2013-05-20
  • Updated: 2017-05-17
  • Resolved: 2013-07-02
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 b33Fixed
Related Reports
Relates :  
Relates :  
Relates :  
JEP-176 proposes to remove sun.reflect.Reflection.getCallerClass(int) that has incompatibility concern since there are existing applications depending on this private API such as Oracle Diagnostic Logging and jidesoft library that breaks Oracle Primavera.

The jdk part of JEP-176 has been backported to 7u25 but keep sun.reflect.Reflection.getCallerClass(int) as the mitigration plan (JDK-8014745) in 7u25.

The following describes the transition plan to allow customers to migrate their applications away from this private API:
1. Disable sun.reflect.Reflection.getCallerClass(int) in 7u40 and provide a flag to re-enable it
2. Determine how this private API is being used and the use cases
3. Remove this private API if there is no valid use case or there is a proper replacement for it. Allow at least 2 CPU releases to allow customers to make appropriate change.  So the earliest for the removal is 7u55.  If there are valid use cases but no proper replacement, we may keep this private API in jdk7u for longer.

Verified with 7u40/b32 by provided test.

SQE is OK with this fix

I know this is work for an approved CCR - but please get SQE-OK and then I will approve this request. I want to make sure SQE is aware of this fix.

Ingrid, Marvin, We can inform CAPS members, licensees, internal and external customers about this change and gather the information how they are using this private API. The above suggested release note can be used for your communication. The JDK team would also like to know how the sun.reflect.Reflection.getCallerClass(int depth) method is being used in their applications and whether they can update their code properly without the dependency of sun.* API. Thanks

Suggested release note: In 7u40, sun.reflect.Reflection.getCallerClass(int depth) is disabled by default and throw an UnsupportedOperationException. This method is in the sun.* namespace. Such methods are not a supported, public interface [1]. This method has been removed in JDK8 to implement JEP 176 [2] [3] and will be removed in a future 7 update release. There is no replacement. Existing code depending on this private API will need to updated properly to work on future 7 update releases. As a temporary measure to allow applications migrate away from it, you can re-enable the previous behavior by adding the following in the command line: -Djdk.reflect.allowGetCallerClass or -Djdk.reflect.allowGetCallerClass=true [1] http://www.oracle.com/technetwork/java/faq-sun-packages-142232.html [2] http://openjdk.java.net/jeps/176 [3] http://hg.openjdk.java.net/jdk8/jdk8/jdk/rev/da6addef956e