Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8082615 | emb-9 | Per Liden | P4 | Resolved | Fixed | team |
The following pattern is fairly common in the GC code:
ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
Code for a specific collector should use its heap() function to avoid casting and asserting. The example above should be replaced by:
ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
There are also other places where Universe::heap() is used, even when it's clear what we are inside, e.g. ParallelScavenge-related code. We should be using ParallelScavengeHeap::heap() here instead. Universe::heap() should (for clarity) only be used by code that doesn't know/care which collector we are currently using.
ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
Code for a specific collector should use its heap() function to avoid casting and asserting. The example above should be replaced by:
ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
There are also other places where Universe::heap() is used, even when it's clear what we are inside, e.g. ParallelScavenge-related code. We should be using ParallelScavengeHeap::heap() here instead. Universe::heap() should (for clarity) only be used by code that doesn't know/care which collector we are currently using.
- backported by
-
JDK-8082615 Avoid use of Universe::heap() inside collectors
-
- Resolved
-