Skip to content
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -1183,6 +1183,7 @@ else if ((sym.owner.flags_field & INTERFACE) != 0)
if (allowValueClasses && (isInstanceFieldOfValueClass || isRecordField)) {
implicit |= FINAL | STRICT;
mask = ValueFieldFlags;
preview.checkSourceLevel(pos, Feature.VALUE_CLASSES);
} else {
mask = VarFlags;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
* @modules java.base/jdk.internal.value
* java.base/jdk.internal.vm.annotation
* @compile TestFieldNullMarkers.java
* @run driver jdk.test.lib.helpers.StrictProcessor
* @run main/othervm --enable-preview jdk.test.lib.helpers.StrictProcessor
* compiler.valhalla.inlinetypes.TestFieldNullMarkers$StrictFieldHolder
* @run main/timeout=300 compiler.valhalla.inlinetypes.TestFieldNullMarkers
*/
Expand All @@ -54,7 +54,7 @@
* @modules java.base/jdk.internal.value
* java.base/jdk.internal.vm.annotation
* @compile TestFieldNullMarkers.java
* @run driver jdk.test.lib.helpers.StrictProcessor
* @run main/othervm --enable-preview jdk.test.lib.helpers.StrictProcessor
* compiler.valhalla.inlinetypes.TestFieldNullMarkers$StrictFieldHolder
* @run main/othervm/timeout=300 -Xbatch
* -XX:+UnlockDiagnosticVMOptions
Expand All @@ -73,7 +73,7 @@
* @modules java.base/jdk.internal.value
* java.base/jdk.internal.vm.annotation
* @compile TestFieldNullMarkers.java
* @run driver jdk.test.lib.helpers.StrictProcessor
* @run main/othervm --enable-preview jdk.test.lib.helpers.StrictProcessor
* compiler.valhalla.inlinetypes.TestFieldNullMarkers$StrictFieldHolder
* @run main/othervm/timeout=300 -Xbatch
* -XX:+UnlockDiagnosticVMOptions
Expand All @@ -92,7 +92,7 @@
* @modules java.base/jdk.internal.value
* java.base/jdk.internal.vm.annotation
* @compile TestFieldNullMarkers.java
* @run driver jdk.test.lib.helpers.StrictProcessor
* @run main/othervm --enable-preview jdk.test.lib.helpers.StrictProcessor
* compiler.valhalla.inlinetypes.TestFieldNullMarkers$StrictFieldHolder
* @run main/othervm/timeout=300 -Xbatch
* -XX:+UnlockDiagnosticVMOptions
Expand All @@ -111,7 +111,7 @@
* @modules java.base/jdk.internal.value
* java.base/jdk.internal.vm.annotation
* @compile TestFieldNullMarkers.java
* @run driver jdk.test.lib.helpers.StrictProcessor
* @run main/othervm --enable-preview jdk.test.lib.helpers.StrictProcessor
* compiler.valhalla.inlinetypes.TestFieldNullMarkers$StrictFieldHolder
* @run main/othervm/timeout=300 -Xbatch
* -XX:+UnlockDiagnosticVMOptions
Expand All @@ -130,7 +130,7 @@
* @modules java.base/jdk.internal.value
* java.base/jdk.internal.vm.annotation
* @compile TestFieldNullMarkers.java
* @run driver jdk.test.lib.helpers.StrictProcessor
* @run main/othervm --enable-preview jdk.test.lib.helpers.StrictProcessor
* compiler.valhalla.inlinetypes.TestFieldNullMarkers$StrictFieldHolder
* @run main/othervm/timeout=300 -Xbatch
* -XX:+UnlockDiagnosticVMOptions
Expand All @@ -149,7 +149,7 @@
* @modules java.base/jdk.internal.value
* java.base/jdk.internal.vm.annotation
* @compile TestFieldNullMarkers.java
* @run driver jdk.test.lib.helpers.StrictProcessor
* @run main/othervm --enable-preview jdk.test.lib.helpers.StrictProcessor
* compiler.valhalla.inlinetypes.TestFieldNullMarkers$StrictFieldHolder
* @run main/othervm/timeout=300 -Xbatch
* -XX:+UnlockDiagnosticVMOptions
Expand All @@ -168,7 +168,7 @@
* @modules java.base/jdk.internal.value
* java.base/jdk.internal.vm.annotation
* @compile TestFieldNullMarkers.java
* @run driver jdk.test.lib.helpers.StrictProcessor
* @run main/othervm --enable-preview jdk.test.lib.helpers.StrictProcessor
* compiler.valhalla.inlinetypes.TestFieldNullMarkers$StrictFieldHolder
* @run main/othervm/timeout=300 -Xbatch
* -XX:+UnlockDiagnosticVMOptions
Expand All @@ -187,7 +187,7 @@
* @modules java.base/jdk.internal.value
* java.base/jdk.internal.vm.annotation
* @compile TestFieldNullMarkers.java
* @run driver jdk.test.lib.helpers.StrictProcessor
* @run main/othervm --enable-preview jdk.test.lib.helpers.StrictProcessor
* compiler.valhalla.inlinetypes.TestFieldNullMarkers$StrictFieldHolder
* @run main/othervm/timeout=300 -Xbatch
* -XX:+UnlockDiagnosticVMOptions
Expand All @@ -206,7 +206,7 @@
* @modules java.base/jdk.internal.value
* java.base/jdk.internal.vm.annotation
* @compile TestFieldNullMarkers.java
* @run driver jdk.test.lib.helpers.StrictProcessor
* @run main/othervm --enable-preview jdk.test.lib.helpers.StrictProcessor
* compiler.valhalla.inlinetypes.TestFieldNullMarkers$StrictFieldHolder
* @run main/othervm/timeout=300 -Xbatch
* -XX:+UnlockDiagnosticVMOptions
Expand All @@ -226,7 +226,7 @@
* @modules java.base/jdk.internal.value
* java.base/jdk.internal.vm.annotation
* @compile TestFieldNullMarkers.java
* @run driver jdk.test.lib.helpers.StrictProcessor
* @run main/othervm --enable-preview jdk.test.lib.helpers.StrictProcessor
* compiler.valhalla.inlinetypes.TestFieldNullMarkers$StrictFieldHolder
* @run main/othervm/timeout=300 -Xbatch
* -XX:+UnlockDiagnosticVMOptions
Expand All @@ -246,7 +246,7 @@
* @modules java.base/jdk.internal.value
* java.base/jdk.internal.vm.annotation
* @compile TestFieldNullMarkers.java
* @run driver jdk.test.lib.helpers.StrictProcessor
* @run main/othervm --enable-preview jdk.test.lib.helpers.StrictProcessor
* compiler.valhalla.inlinetypes.TestFieldNullMarkers$StrictFieldHolder
* @run main/othervm/timeout=300 -Xbatch
* -XX:+UnlockDiagnosticVMOptions
Expand All @@ -266,7 +266,7 @@
* @modules java.base/jdk.internal.value
* java.base/jdk.internal.vm.annotation
* @compile TestFieldNullMarkers.java
* @run driver jdk.test.lib.helpers.StrictProcessor
* @run main/othervm --enable-preview jdk.test.lib.helpers.StrictProcessor
* compiler.valhalla.inlinetypes.TestFieldNullMarkers$StrictFieldHolder
* @run main/othervm/timeout=300 -Xbatch
* -XX:+UnlockDiagnosticVMOptions
Expand All @@ -286,7 +286,7 @@
* @modules java.base/jdk.internal.value
* java.base/jdk.internal.vm.annotation
* @compile TestFieldNullMarkers.java
* @run driver jdk.test.lib.helpers.StrictProcessor
* @run main/othervm --enable-preview jdk.test.lib.helpers.StrictProcessor
* compiler.valhalla.inlinetypes.TestFieldNullMarkers$StrictFieldHolder
* @run main/othervm/timeout=300 -Xbatch
* -XX:+UnlockDiagnosticVMOptions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* @library /test/lib
* @enablePreview
* @compile TestStrictFieldBarriers.java
* @run driver jdk.test.lib.helpers.StrictProcessor
* @run main/othervm --enable-preview jdk.test.lib.helpers.StrictProcessor
* compiler.valhalla.inlinetypes.TestStrictFieldBarriers$A1
* compiler.valhalla.inlinetypes.TestStrictFieldBarriers$B1
* compiler.valhalla.inlinetypes.TestStrictFieldBarriers$C1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* @enablePreview
* @compile FieldLayoutAnalyzer.java StrictFinalTest.java
* @compile StrictFinalTest.java
* @run driver jdk.test.lib.helpers.StrictProcessor StrictFinalTest
* @run main/othervm --enable-preview jdk.test.lib.helpers.StrictProcessor StrictFinalTest
* StrictFinalTest$Container5 StrictFinalTest$Container6
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UseNullableNonAtomicValueFlattening StrictFinalTest
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* @library /test/lib
* @run main RedefineClassHelper
* @compile StrictFieldsOld.java StrictFieldsNew.java
* @run driver jdk.test.lib.helpers.StrictProcessor
* @run main/othervm --enable-preview jdk.test.lib.helpers.StrictProcessor
* StrictFieldsOld StrictFieldsNew
* @run main/othervm -Xverify:remote -javaagent:redefineagent.jar RedefineStrictFieldsTest
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* EarlyLarvalNotSubset.jcod
* InvalidIndexInEarlyLarval.jcod
* @compile StrictInstanceFieldsTest.java
* @run driver jdk.test.lib.helpers.StrictProcessor
* @run main/othervm --enable-preview jdk.test.lib.helpers.StrictProcessor
* StrictInstanceFieldsTest
* Child ControlFlowChild TryCatchChild AssignedInConditionalChild
* SwitchCaseChild NestedConstructorChild FinalChild
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* Creflbefore_BAD.jasm
* WriteAfterReadRefl.jasm
* @compile StrictStaticFieldsTest.java
* @run driver jdk.test.lib.helpers.StrictProcessor
* @run main/othervm --enable-preview jdk.test.lib.helpers.StrictProcessor
* StrictStaticFieldsTest
* Aregular_OK
* Anulls_OK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ void test(Path baseDir, String className, String warningsGoldenFileName) throws
// compile
javaCompiler.compile(com.sun.tools.javac.util.List.of(javacFileManager.getJavaFileObject(javaFile)));
if (goldenFile != null) {
// lets remove preview related messages from the compilation output
compilationOutput.removeIf(msg -> msg.contains("compiler.note.preview"));
java.util.List<String> goldenFileContent = Files.readAllLines(goldenFile);
if (goldenFileContent.size() != compilationOutput.size()) {
System.err.println("compilation output length mismatch");
Expand Down
2 changes: 2 additions & 0 deletions test/langtools/tools/javac/SuperInit/SuperInitFails.out
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,6 @@ SuperInitFails.java:55:32: compiler.err.call.must.only.appear.in.ctor
SuperInitFails.java:85:18: compiler.err.ctor.calls.not.allowed.here
SuperInitFails.java:91:13: compiler.err.return.before.superclass.initialized
SuperInitFails.java:152:18: compiler.err.call.must.only.appear.in.ctor
- compiler.note.preview.filename: SuperInitFails.java, DEFAULT
- compiler.note.preview.recompile
42 errors
2 changes: 2 additions & 0 deletions test/langtools/tools/javac/patterns/DominationWithPP.out
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ Domination.java:193:18: compiler.err.pattern.dominated
Domination.java:202:18: compiler.err.pattern.dominated
Domination.java:211:18: compiler.err.pattern.dominated
Domination.java:228:18: compiler.err.pattern.dominated
- compiler.note.preview.filename: Domination.java, DEFAULT
- compiler.note.preview.recompile
13 errors
3 changes: 2 additions & 1 deletion test/langtools/tools/javac/preview/PreviewAutoSuppress.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ public class Use {
List.of("- compiler.warn.preview.feature.use.classfile: Record.class, " + FEATURE_VERSION,
"Outer.java:3:5: compiler.warn.preview.feature.use.plural: (compiler.misc.feature.records)",
"Outer.java:3:5: compiler.warn.preview.feature.use.plural: (compiler.misc.feature.records)",
"3 warnings");
"Outer.java:3:18: compiler.warn.preview.feature.use.plural: (compiler.misc.feature.value.classes)",
"4 warnings");
if (!log.equals(expected))
throw new Exception("expected output not found" + log);
checkPreviewClassfile(classes.resolve("test").resolve("Outer.class"), true); //TODO: correct?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1483,4 +1483,37 @@ value class Test {
"aconst_null,putstatic,getstatic,astore_2,aload_0,aload_2,putfield,aload_0,aload_2," +
"putfield,aload_0,invokespecial,return");
}

@Test
void testIdentityRecordUsesPreview() throws Exception {
String source_withComponents =
"""
record IdentityRecord(int i) {}
""";
String source_noComponents =
"""
record IdentityRecord() {}
""";
String[] previousOptions = getCompileOptions();
try {
setCompileOptions("--enable-preview",
"-source", Integer.toString(Runtime.version().feature()),
"-Xlint:preview");
assertOKWithWarning("compiler.warn.preview.feature.use.plural", 1, source_withComponents);

File dir = assertOK(true, source_withComponents);
File classFile = new File(dir, "IdentityRecord.class");
Assert.check(classFile.exists(), "missing class file");
Assert.check(ClassFile.of().parse(classFile.toPath()).minorVersion() == ClassFile.PREVIEW_MINOR_VERSION,
"identity records should produce preview class files when compiled with preview enabled");

dir = assertOK(true, source_noComponents);
classFile = new File(dir, "IdentityRecord.class");
Assert.check(classFile.exists(), "missing class file");
Assert.check(ClassFile.of().parse(classFile.toPath()).minorVersion() == 0,
"identity records with no components should not produce preview class files even with preview enabled");
} finally {
setCompileOptions(previousOptions);
}
}
}
2 changes: 1 addition & 1 deletion test/lib-test/jdk/test/lib/StrictProcessorSuperTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* @enablePreview
* @library /test/lib
* @compile StrictProcessorSuperTest.java
* @run driver jdk.test.lib.helpers.StrictProcessor --deferSuperCall
* @run main/othervm --enable-preview jdk.test.lib.helpers.StrictProcessor --deferSuperCall
* StrictProcessorSuperTest$Rec StrictProcessorSuperTest$Exp
* StrictProcessorSuperTest$Inner
* @run junit StrictProcessorSuperTest
Expand Down
2 changes: 1 addition & 1 deletion test/lib-test/jdk/test/lib/StrictProcessorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* @enablePreview
* @library /test/lib
* @build StrictProcessorTest
* @run driver jdk.test.lib.helpers.StrictProcessor StrictProcessorTest$StrictTarget
* @run main/othervm --enable-preview jdk.test.lib.helpers.StrictProcessor StrictProcessorTest$StrictTarget
* @run junit StrictProcessorTest
*/

Expand Down