JDK-8054182 : 15.12.2.6: Clarify the return type of 'getClass'
  • Type: Bug
  • Component: specification
  • Sub-Component: language
  • Affected Version: 8
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2014-08-01
  • Updated: 2017-02-17
  • Resolved: 2015-02-16
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.
JDK 8
8u40Fixed
Related Reports
Relates :  
Description
The longstanding special-case rule for invocations of 'getClass' has been that the return type is 'Class<? extends |T|>'.  See 4.3.2.

15.12.2.6 was modified in JLS 8 to mention this explicitly, but accidentally left off the erasure: 'Class<? extends T>'.  There is some interest in making this language change (see JDK-6184881; compare JDK-5004321), but that was not the intent in JLS 8.  It's simply a typo, and inconsistent with 4.3.2.
Comments
Updated text for 15.12.2.6: "Otherwise, if the chosen method is the getClass method of the class Object (��4.3.2), the invocation type is the same as the method's type, except that the return type is Class<? extends ***|T|***>, where T is the type that was searched, as determined by ��15.12.1." (Might also be useful, here and in 4.3.2, to explain/cross-reference what the "|T|" notation means.)
01-08-2014