JDK-8266383 : Improve CheckCSMs test to check for overriding
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang:reflect
  • Affected Version: 17
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2021-04-30
  • Updated: 2022-03-11
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.
Other
tbdUnresolved
Related Reports
Relates :  
Description
CheckCSMs test intends to allow a white list of virtual methods; all other are expected to be static or final instance method.

JDK-8264774 has a sealed interface which defines caller-sensitive interface method.    The test should be updated to allow CSM in a sealed interface if all implementations (all subclasses) of such CSM are final.  

Currently the test does not fail if both interface and implementation methods are @CS annotated but fails if only interface is annotated.
Comments
CheckCSMs test verifies all methods that call jdk.internal.reflect.Reflection::getCallerClass must be annotated with @CallerSensitive and the method must be static or final (cannot be overridden). It's a runtime check that Reflection::getCallerClass can only be called if the method is annotated with @CallerSensitive; otherwise it will throw an exception. On the other hand, there can be methods that do not call Reflection::getCallerClass but annotated with @CallerSensitive. That would not cause any runtime error while it'd be nice to clean that up. Strictly speaking, the abstract methods need not/should not be @CallerSensitive. The implementation should.
11-03-2022