JDK-8331964 : [lworld] C2: Support abstract value class fields
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: repo-valhalla
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2024-05-08
  • Updated: 2025-05-21
  • Resolved: 2024-09-12
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
repo-valhallaFixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Description
Field inheritance for value classes is causing several issues to C2.
For instance:

public class AbstractCircularity {
    static abstract value class AbstractBadField {
	     ConcreteBadField f = new ConcreteBadField();
    }

    static value class ConcreteBadField extends AbstractBadField {
	     int i  = 0;
    }

    public static void main(String[] args) {
	     var c = new ConcreteBadField();
    }
}

Run with -Xcomp  -XX:-TieredCompilation, this program causes an assertion failure in CI:

#  Internal Error (valhalla/open/src/hotspot/share/ci/ciInlineKlass.cpp:33), pid=648122, tid=648136
#  assert(super() == nullptr || !super()->has_nonstatic_fields()) failed: an inline type must not inherit fields from its superclass
#
# JRE version: Java(TM) SE Runtime Environment (23.0) (fastdebug build 23-lworld5ea-2024-05-08-1319037.fred...)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 23-lworld5ea-2024-05-08-1319037.fred..., compiled mode, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# V  [libjvm.so+0x90a087]  ciInlineKlass::compute_nonstatic_fields()+0x207

This issue might be common to C1 and C2 as they share the CI implementation.

Trying to remove this assert causes C2 to crash on the following assert:

#  Internal Error (valhalla/open/src/hotspot/share/opto/parse3.cpp:238), pid=703047, tid=703061
#  assert(obj->as_InlineType()->is_larval()) failed: must be larval
#
# JRE version: Java(TM) SE Runtime Environment (23.0) (fastdebug build 23-lworld5ea-2024-05-08-1319037.fred...)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 23-lworld5ea-2024-05-08-1319037.fred..., compiled mode, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# V  [libjvm.so+0x15d00d2]  Parse::do_put_xxx(Node*, ciField*, bool)+0xb12

Note that this particular test program is triggering an infinite recursion between the constructors of the two value classes, leading to a SOE, but the VM should not crash.


Comments
A pull request was submitted for review. Branch: lworld URL: https://git.openjdk.org/valhalla/pull/1236 Date: 2024-09-04 10:32:49 +0000
04-09-2024

test/hotspot/jtreg/runtime/valhalla/inlinetypes/field_layout/ValueFieldInheritanceTest.java is currently disabled due to JDK-8338261.
13-08-2024

[~vromero] I think you closed the wrong bug. This is still an issue and being worked on. Re-opening.
04-07-2024

already fixed
03-07-2024