On Tue, 30 Jun 2026 12:54:56 GMT, Chen Liang <[email protected]> wrote:
>> Jan Lahoda has updated the pull request incrementally with one additional
>> commit since the last revision:
>>
>> Adjusting tests to the recent change.
>
> src/jdk.compiler/share/classes/com/sun/tools/javac/code/Preview.java line 258:
>
>> 256: */
>> 257: public boolean declaredUsingPreviewFeature(Symbol sym) {
>> 258: return sym.isValueClass();
>
> Should this include records too given how its semantics are changed? Maybe in
> another RFE?
I am not completely certain, but I think this should not include records.
My understanding is that for records, only the implementation of the record's
constructor changes, and that this is transparent(?) for the users of the
record. I.e. the change not in the declaration/signatures, but in the
implementation. If a class, e.g. `PM`, uses a preview feature inside an
implementation only (i.e. not in a declaration), we don't taint another class,
e.g. `Use`, that only uses `PM`.
For example:
$ cat PM.java
public class PM {
private boolean test(Object o) {
return o instanceof byte b;
}
}
$ cat Use.java
public class Use {
PM pm;
}
$ javac --enable-preview --source 28 -Xlint:preview PM.java Use.java
PM.java:3: warning: [preview] primitive patterns are a preview feature and may
be removed in a future release.
return o instanceof byte b;
^
1 warning
There's no warning for the use of `PM` in `Use`, and `Use.class` is not marked
a preview classfile.
Even though `PM` uses a preview feature (primitive patterns), it only does so
inside an implementation, and so the use of the preview feature is invisible to
the use site, leading to no warning.
My understanding (possibly wrong) is that the change in record constructors is
similar to the use of pattern matching in the implementation of `PM`.
-------------
PR Review Comment:
https://git.openjdk.org/valhalla/pull/2601#discussion_r3504414750