diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java index 81fd759a6ed..d781995b964 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java @@ -1527,6 +1527,7 @@ else if (proxy.type.tsym.flatName() == syms.profileType.tsym.flatName()) { sym.flags_field |= MIGRATED_VALUE_CLASS; if (needsValueFlag(sym, sym.flags_field)) { sym.flags_field |= VALUE_CLASS; + sym.flags_field &= ~IDENTITY_TYPE; } } else if (proxy.type.tsym.flatName() == syms.restrictedType.tsym.flatName()) { Assert.check(sym.kind == MTH); @@ -1548,6 +1549,7 @@ else if (proxy.type.tsym.flatName() == syms.profileType.tsym.flatName()) { sym.flags_field |= MIGRATED_VALUE_CLASS; if (needsValueFlag(sym, sym.flags_field)) { sym.flags_field |= VALUE_CLASS; + sym.flags_field &= ~IDENTITY_TYPE; } } else if (proxy.type.tsym == syms.restrictedType.tsym) { Assert.check(sym.kind == MTH); @@ -3178,6 +3180,7 @@ long adjustClassFlags(ClassSymbol c, long flags) { flags |= IDENTITY_TYPE; } else if (needsValueFlag(c, flags)) { flags |= VALUE_CLASS; + flags &= ~IDENTITY_TYPE; } flags &= ~ACC_IDENTITY; // ACC_IDENTITY and SYNCHRONIZED bits overloaded return flags; diff --git a/test/langtools/tools/javac/valhalla/value-objects/ValueObjectCompilationTests.java b/test/langtools/tools/javac/valhalla/value-objects/ValueObjectCompilationTests.java index 9a4d4929cdf..9e9879d22d1 100644 --- a/test/langtools/tools/javac/valhalla/value-objects/ValueObjectCompilationTests.java +++ b/test/langtools/tools/javac/valhalla/value-objects/ValueObjectCompilationTests.java @@ -189,6 +189,16 @@ static abstract value class V extends ConcreteSuperType {} // Error: concrete s value record Point(int x, int y) {} """ ), + new TestData( + """ + value class One extends Number { + public int intValue() { return 0; } + public long longValue() { return 0; } + public float floatValue() { return 0; } + public double doubleValue() { return 0; } + } + """ + ), new TestData( """ value class V extends Object {}