diff --git a/annotation-processor/pom.xml b/annotation-processor/pom.xml
index 3caf851fb7..7a6db7c910 100644
--- a/annotation-processor/pom.xml
+++ b/annotation-processor/pom.xml
@@ -155,5 +155,36 @@
+
+ testWithJdk17
+
+
+ java-version.test.release
+ 17
+
+
+
+
+
+ org.codehaus.mojo
+ build-helper-maven-plugin
+
+
+ add-test-source
+ generate-test-sources
+
+ add-test-source
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/annotation-processor/src/test/java/org/hibernate/validator/ap/testutil/CompilerTestHelper.java b/annotation-processor/src/test/java/org/hibernate/validator/ap/testutil/CompilerTestHelper.java
index 36e785deb8..c7d98b93aa 100644
--- a/annotation-processor/src/test/java/org/hibernate/validator/ap/testutil/CompilerTestHelper.java
+++ b/annotation-processor/src/test/java/org/hibernate/validator/ap/testutil/CompilerTestHelper.java
@@ -106,6 +106,25 @@ public File getSourceFile(Class> clazz) {
return new File( sourceBaseDir + sourceFileName );
}
+ /**
+ * Retrieves a file object containing the source of the given class.
+ *
+ * @param clazz The class of interest.
+ * @param testSourceBase The test source base in which to look for the class of interest
+ *
+ * @return A file with the source of the given class.
+ */
+ public File getSourceFile(Class> clazz, String testSourceBase) {
+ if ( testSourceBase == null || testSourceBase.trim().isEmpty() ) {
+ return getSourceFile( clazz );
+ }
+
+ String sourceFileName = File.separator + clazz.getName().replace( ".", File.separator ) + ".java";
+ String sourceBaseDir = BASE_DIR.getAbsolutePath() + testSourceBase;
+
+ return new File( sourceBaseDir + sourceFileName );
+ }
+
/**
* @see CompilerTestHelper#compile(Processor, DiagnosticCollector, Kind, Boolean, Boolean, EnumSet, File...)
*/
diff --git a/annotation-processor/src/test/java17/org/hibernate/validator/ap/record/RecordConstraintValidationProcessorTest.java b/annotation-processor/src/test/java17/org/hibernate/validator/ap/record/RecordConstraintValidationProcessorTest.java
new file mode 100644
index 0000000000..a5ba33e9bd
--- /dev/null
+++ b/annotation-processor/src/test/java17/org/hibernate/validator/ap/record/RecordConstraintValidationProcessorTest.java
@@ -0,0 +1,91 @@
+/*
+ * Hibernate Validator, declare and validate application constraints
+ *
+ * License: Apache License, Version 2.0
+ * See the license.txt file in the root directory or .
+ */
+package org.hibernate.validator.ap.record;
+
+import java.io.File;
+import java.util.EnumSet;
+
+import javax.tools.Diagnostic;
+
+import org.hibernate.validator.ap.ConstraintValidationProcessor;
+import org.hibernate.validator.ap.ConstraintValidationProcessorTestBase;
+import org.hibernate.validator.ap.testutil.CompilerTestHelper;
+import org.hibernate.validator.ap.util.DiagnosticExpectation;
+
+import org.testng.annotations.Test;
+
+import static org.hibernate.validator.ap.testutil.CompilerTestHelper.assertThatDiagnosticsMatch;
+import static org.testng.Assert.assertFalse;
+
+/**
+ * @author Jan Schatteman
+ */
+public class RecordConstraintValidationProcessorTest extends ConstraintValidationProcessorTestBase {
+
+ @Test
+ public void testRecordWithInvalidConstraints() {
+
+ File sourceFile = compilerHelper.getSourceFile( RecordWithInvalidConstraints.class, "/src/test/java17" );
+
+ boolean compilationResult =
+ compilerHelper.compile(
+ new ConstraintValidationProcessor(),
+ diagnostics,
+ EnumSet.of( CompilerTestHelper.Library.VALIDATION_API ),
+ sourceFile
+ );
+
+ assertFalse( compilationResult );
+
+ assertThatDiagnosticsMatch(
+ diagnostics,
+ new DiagnosticExpectation( Diagnostic.Kind.ERROR, 15 )
+ );
+ }
+
+ @Test
+ public void testRecordWithInvalidConstructorConstraints() {
+
+ File sourceFile = compilerHelper.getSourceFile( RecordWithInvalidConstructorConstraints.class, "/src/test/java17" );
+
+ boolean compilationResult =
+ compilerHelper.compile(
+ new ConstraintValidationProcessor(),
+ diagnostics,
+ EnumSet.of( CompilerTestHelper.Library.VALIDATION_API ),
+ sourceFile
+ );
+
+ assertFalse( compilationResult );
+
+ assertThatDiagnosticsMatch(
+ diagnostics,
+ new DiagnosticExpectation( Diagnostic.Kind.ERROR, 16 )
+ );
+ }
+
+ @Test
+ public void testRecordWithInvalidMethodConstraints() {
+
+ File sourceFile = compilerHelper.getSourceFile( RecordWithInvalidMethodConstraints.class, "/src/test/java17" );
+
+ boolean compilationResult =
+ compilerHelper.compile(
+ new ConstraintValidationProcessor(),
+ diagnostics,
+ EnumSet.of( CompilerTestHelper.Library.VALIDATION_API ),
+ sourceFile
+ );
+
+ assertFalse( compilationResult );
+
+ assertThatDiagnosticsMatch(
+ diagnostics,
+ new DiagnosticExpectation( Diagnostic.Kind.ERROR, 19 )
+ );
+ }
+}
diff --git a/annotation-processor/src/test/java17/org/hibernate/validator/ap/record/RecordWithInvalidConstraints.java b/annotation-processor/src/test/java17/org/hibernate/validator/ap/record/RecordWithInvalidConstraints.java
new file mode 100644
index 0000000000..ff32f39e0b
--- /dev/null
+++ b/annotation-processor/src/test/java17/org/hibernate/validator/ap/record/RecordWithInvalidConstraints.java
@@ -0,0 +1,16 @@
+/*
+ * Hibernate Validator, declare and validate application constraints
+ *
+ * License: Apache License, Version 2.0
+ * See the license.txt file in the root directory or .
+ */
+package org.hibernate.validator.ap.record;
+
+import java.util.Date;
+import javax.validation.constraints.FutureOrPresent;
+
+/**
+ * @author Jan Schatteman
+ */
+public record RecordWithInvalidConstraints(/* Not allowed */ @FutureOrPresent String string, @FutureOrPresent Date date) {
+}
diff --git a/annotation-processor/src/test/java17/org/hibernate/validator/ap/record/RecordWithInvalidConstructorConstraints.java b/annotation-processor/src/test/java17/org/hibernate/validator/ap/record/RecordWithInvalidConstructorConstraints.java
new file mode 100644
index 0000000000..e85fcd0a40
--- /dev/null
+++ b/annotation-processor/src/test/java17/org/hibernate/validator/ap/record/RecordWithInvalidConstructorConstraints.java
@@ -0,0 +1,20 @@
+/*
+ * Hibernate Validator, declare and validate application constraints
+ *
+ * License: Apache License, Version 2.0
+ * See the license.txt file in the root directory or .
+ */
+package org.hibernate.validator.ap.record;
+
+import java.util.Date;
+import javax.validation.constraints.FutureOrPresent;
+
+/**
+ * @author Jan Schatteman
+ */
+public record RecordWithInvalidConstructorConstraints(String string, Date date) {
+ public RecordWithInvalidConstructorConstraints(@FutureOrPresent String string, @FutureOrPresent Date date) {
+ this.string = string;
+ this.date = date;
+ }
+}
diff --git a/annotation-processor/src/test/java17/org/hibernate/validator/ap/record/RecordWithInvalidMethodConstraints.java b/annotation-processor/src/test/java17/org/hibernate/validator/ap/record/RecordWithInvalidMethodConstraints.java
new file mode 100644
index 0000000000..14c8380c66
--- /dev/null
+++ b/annotation-processor/src/test/java17/org/hibernate/validator/ap/record/RecordWithInvalidMethodConstraints.java
@@ -0,0 +1,22 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * License: GNU Lesser General Public License (LGPL), version 2.1 or later
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
+ */
+package org.hibernate.validator.ap.record;
+
+import java.util.Date;
+import javax.validation.constraints.FutureOrPresent;
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.Positive;
+
+/**
+ * @author Jan Schatteman
+ */
+public record RecordWithInvalidMethodConstraints(@NotBlank String string, @FutureOrPresent Date date) {
+
+ public void doNothing(@Positive String s) {
+ //
+ }
+}