Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8335641: [lworld] add the MigratedValueClass annotation to some classes missing it, some bug fixes #1155

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/java.base/share/classes/java/time/Duration.java
Original file line number Diff line number Diff line change
@@ -131,6 +131,7 @@
* @since 1.8
*/
@jdk.internal.ValueBased
@jdk.internal.MigratedValueClass
public final class Duration
implements TemporalAmount, Comparable<Duration>, Serializable {

1 change: 1 addition & 0 deletions src/java.base/share/classes/java/time/Instant.java
Original file line number Diff line number Diff line change
@@ -207,6 +207,7 @@
* @since 1.8
*/
@jdk.internal.ValueBased
@jdk.internal.MigratedValueClass
public final class Instant
implements Temporal, TemporalAdjuster, Comparable<Instant>, Serializable {

1 change: 1 addition & 0 deletions src/java.base/share/classes/java/time/LocalDate.java
Original file line number Diff line number Diff line change
@@ -137,6 +137,7 @@
* @since 1.8
*/
@jdk.internal.ValueBased
@jdk.internal.MigratedValueClass
public final class LocalDate
implements Temporal, TemporalAdjuster, ChronoLocalDate, Serializable {

1 change: 1 addition & 0 deletions src/java.base/share/classes/java/time/LocalDateTime.java
Original file line number Diff line number Diff line change
@@ -133,6 +133,7 @@
* @since 1.8
*/
@jdk.internal.ValueBased
@jdk.internal.MigratedValueClass
public final class LocalDateTime
implements Temporal, TemporalAdjuster, ChronoLocalDateTime<LocalDate>, Serializable {

1 change: 1 addition & 0 deletions src/java.base/share/classes/java/time/LocalTime.java
Original file line number Diff line number Diff line change
@@ -123,6 +123,7 @@
* @since 1.8
*/
@jdk.internal.ValueBased
@jdk.internal.MigratedValueClass
public final class LocalTime
implements Temporal, TemporalAdjuster, Comparable<LocalTime>, Serializable {

1 change: 1 addition & 0 deletions src/java.base/share/classes/java/time/MonthDay.java
Original file line number Diff line number Diff line change
@@ -125,6 +125,7 @@
* @since 1.8
*/
@jdk.internal.ValueBased
@jdk.internal.MigratedValueClass
public final class MonthDay
implements TemporalAccessor, TemporalAdjuster, Comparable<MonthDay>, Serializable {

1 change: 1 addition & 0 deletions src/java.base/share/classes/java/time/OffsetDateTime.java
Original file line number Diff line number Diff line change
@@ -126,6 +126,7 @@
* @since 1.8
*/
@jdk.internal.ValueBased
@jdk.internal.MigratedValueClass
public final class OffsetDateTime
implements Temporal, TemporalAdjuster, Comparable<OffsetDateTime>, Serializable {

1 change: 1 addition & 0 deletions src/java.base/share/classes/java/time/OffsetTime.java
Original file line number Diff line number Diff line change
@@ -116,6 +116,7 @@
* @since 1.8
*/
@jdk.internal.ValueBased
@jdk.internal.MigratedValueClass
public final class OffsetTime
implements Temporal, TemporalAdjuster, Comparable<OffsetTime>, Serializable {

1 change: 1 addition & 0 deletions src/java.base/share/classes/java/time/Period.java
Original file line number Diff line number Diff line change
@@ -131,6 +131,7 @@
* @since 1.8
*/
@jdk.internal.ValueBased
@jdk.internal.MigratedValueClass
public final class Period
implements ChronoPeriod, Serializable {

1 change: 1 addition & 0 deletions src/java.base/share/classes/java/time/Year.java
Original file line number Diff line number Diff line change
@@ -133,6 +133,7 @@
* @since 1.8
*/
@jdk.internal.ValueBased
@jdk.internal.MigratedValueClass
public final class Year
implements Temporal, TemporalAdjuster, Comparable<Year>, Serializable {

1 change: 1 addition & 0 deletions src/java.base/share/classes/java/time/YearMonth.java
Original file line number Diff line number Diff line change
@@ -129,6 +129,7 @@
* @since 1.8
*/
@jdk.internal.ValueBased
@jdk.internal.MigratedValueClass
public final class YearMonth
implements Temporal, TemporalAdjuster, Comparable<YearMonth>, Serializable {

1 change: 1 addition & 0 deletions src/java.base/share/classes/java/time/ZonedDateTime.java
Original file line number Diff line number Diff line change
@@ -162,6 +162,7 @@
* @since 1.8
*/
@jdk.internal.ValueBased
@jdk.internal.MigratedValueClass
public final class ZonedDateTime
implements Temporal, ChronoZonedDateTime<LocalDate>, Serializable {

Original file line number Diff line number Diff line change
@@ -140,6 +140,7 @@
* @param <D> the ChronoLocalDate of this date-time
* @since 1.8
*/
@jdk.internal.MigratedValueClass
abstract class ChronoLocalDateImpl<D extends ChronoLocalDate>
implements ChronoLocalDate, Temporal, TemporalAdjuster, Serializable {

Original file line number Diff line number Diff line change
@@ -117,6 +117,7 @@
* @since 1.8
*/
@jdk.internal.ValueBased
@jdk.internal.MigratedValueClass
public final class HijrahDate
extends ChronoLocalDateImpl<HijrahDate>
implements ChronoLocalDate, Serializable {
Original file line number Diff line number Diff line change
@@ -124,6 +124,7 @@
* @since 1.8
*/
@jdk.internal.ValueBased
@jdk.internal.MigratedValueClass
public final class JapaneseDate
extends ChronoLocalDateImpl<JapaneseDate>
implements ChronoLocalDate, Serializable {
Original file line number Diff line number Diff line change
@@ -104,6 +104,7 @@
* @since 1.8
*/
@jdk.internal.ValueBased
@jdk.internal.MigratedValueClass
public final class MinguoDate
extends ChronoLocalDateImpl<MinguoDate>
implements ChronoLocalDate, Serializable {
Original file line number Diff line number Diff line change
@@ -104,6 +104,7 @@
* @since 1.8
*/
@jdk.internal.ValueBased
@jdk.internal.MigratedValueClass
public final class ThaiBuddhistDate
extends ChronoLocalDateImpl<ThaiBuddhistDate>
implements ChronoLocalDate, Serializable {
1 change: 1 addition & 0 deletions src/java.base/share/classes/java/util/OptionalDouble.java
Original file line number Diff line number Diff line change
@@ -56,6 +56,7 @@
* @since 1.8
*/
@jdk.internal.ValueBased
@jdk.internal.MigratedValueClass
public final class OptionalDouble {
/**
* Common instance for {@code empty()}.
1 change: 1 addition & 0 deletions src/java.base/share/classes/java/util/OptionalInt.java
Original file line number Diff line number Diff line change
@@ -56,6 +56,7 @@
* @since 1.8
*/
@jdk.internal.ValueBased
@jdk.internal.MigratedValueClass
public final class OptionalInt {
/**
* Common instance for {@code empty()}.
1 change: 1 addition & 0 deletions src/java.base/share/classes/java/util/OptionalLong.java
Original file line number Diff line number Diff line change
@@ -56,6 +56,7 @@
* @since 1.8
*/
@jdk.internal.ValueBased
@jdk.internal.MigratedValueClass
public final class OptionalLong {
/**
* Common instance for {@code empty()}.
Original file line number Diff line number Diff line change
@@ -3174,7 +3174,7 @@ long adjustClassFlags(ClassSymbol c, long flags) {
flags &= ~ACC_MODULE;
flags |= MODULE;
}
if (((flags & ACC_IDENTITY) != 0 && !isMigratedValueClass(flags)) || (majorVersion < V66.major && (flags & INTERFACE) == 0)) {
if (((flags & ACC_IDENTITY) != 0 && !isMigratedValueClass(flags)) || (majorVersion < V67.major && (flags & INTERFACE) == 0)) {
flags |= IDENTITY_TYPE;
} else if (needsValueFlag(c, flags)) {
flags |= VALUE_CLASS;
@@ -3186,8 +3186,8 @@ long adjustClassFlags(ClassSymbol c, long flags) {
private boolean needsValueFlag(Symbol c, long flags) {
boolean previewClassFile = minorVersion == ClassFile.PREVIEW_MINOR_VERSION;
if (allowValueClasses) {
if (previewClassFile && majorVersion >= V66.major && (flags & INTERFACE) == 0 ||
majorVersion >= V66.major && isMigratedValueClass(flags)) {
if (previewClassFile && majorVersion >= V67.major && (flags & INTERFACE) == 0 ||
majorVersion >= V67.major && isMigratedValueClass(flags)) {
return true;
}
}
Original file line number Diff line number Diff line change
@@ -447,58 +447,65 @@ void test() {
}
}
"""
),
new TestData(
"compiler.err.type.found.req", // --enable-preview -source"
"""
import java.time.*;
class V {
final Duration val = Duration.ZERO;
void test() {
synchronized (val) { // warn
}
}
}
""",
false // cant do local as there is an import statement
),
new TestData(
"compiler.warn.attempt.to.synchronize.on.instance.of.value.based.class", // empty options
"""
class V {
final Integer val = Integer.valueOf(42);
void test() {
synchronized (val) { // warn
}
}
}
""",
new String[] {}
),
new TestData(
"compiler.warn.attempt.to.synchronize.on.instance.of.value.based.class", // --source
"""
class V {
final Integer val = Integer.valueOf(42);
void test() {
synchronized (val) { // warn
}
}
}
""",
new String[] {"--source", Integer.toString(Runtime.version().feature())}
),
new TestData(
"compiler.warn.attempt.to.synchronize.on.instance.of.value.based.class", // --source
"""
class V {
final Integer val = Integer.valueOf(42);
void test() {
synchronized (val) { // warn
}
}
}
""",
new String[] {"--source", Integer.toString(Runtime.version().feature())}
)
);

@Test
void testSemanticsViolations() {
testHelper(semanticsViolations);
testHelper(
List.of(
new TestData(
"compiler.warn.attempt.to.synchronize.on.instance.of.value.based.class", // empty options
"""
class V {
final Integer val = Integer.valueOf(42);
void test() {
synchronized (val) { // warn
}
}
}
""",
new String[] {}
),
new TestData(
"compiler.warn.attempt.to.synchronize.on.instance.of.value.based.class", // --source
"""
class V {
final Integer val = Integer.valueOf(42);
void test() {
synchronized (val) { // warn
}
}
}
""",
new String[] {"--source", Integer.toString(Runtime.version().feature())}
),
new TestData(
"compiler.err.type.found.req", // --enable-preview --source
"""
class V {
final Integer val = Integer.valueOf(42);
void test() {
synchronized (val) { // warn
}
}
}
""",
new String[] {"--enable-preview", "--source", Integer.toString(Runtime.version().feature())}
)
/* we should add tests for --release and --release --enable-preview once the stubs used for the latest
* release have been updated, right now they are the same as those for 22
*/
)
);
}

private static final List<TestData> sealedClassesData = List.of(