JDK-8064811 : Use THREAD instead of CHECK_NULL in return statements
  • Type: Bug
  • Component: hotspot
  • Sub-Component: gc
  • Affected Version: 9
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2014-11-13
  • Updated: 2021-03-26
  • Resolved: 2014-11-14
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 JDK 9
8u202Fixed 9 b42Fixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
Take the following method as an example:
 Klass* ConstantPool::klass_ref_at(int which, TRAPS) {
  return klass_at(klass_ref_index_at(which), CHECK_NULL);
 }

This will expand into:
 Klass* ConstantPool::klass_ref_at(int which, TRAPS) {
  return klass_at(klass_ref_index_at(which), THREAD);
  if (HAS_PENDING_EXCEPTIONS) {
    return NULL;
  }
  (void)(0);
 }

The if-statement will never be reached.

We have seen cases where the compiler warns about this, and the recent change to enable -Wreturn-type will make this more likely to happen.

The suggested solution is to change the example above into:
 Klass* ConstantPool::klass_ref_at(int which, TRAPS) {
  return klass_at(klass_ref_index_at(which), THREAD);
 }
Comments
If you're trying to get approval for jdk8u, please follow the jdk8u approval process: http://openjdk.java.net/projects/jdk8u/approval-template.html If you also want approval for JDK11 then please add the jdk11u-fix-request label.
15-10-2018