Skip to content
Merged
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
1 change: 1 addition & 0 deletions processor/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<testRelease>${minimum.java.version}</testRelease>
<annotationProcessorPaths>
<path>
<groupId>org.mapstruct.tools.gem</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,10 @@ public Map<String, PresenceCheckAccessor> getPropertyPresenceCheckers() {
* @return an unmodifiable map of all write accessors indexed by property name
*/
public Map<String, Accessor> getPropertyWriteAccessors( CollectionMappingStrategyGem cmStrategy ) {
if ( isRecord() ) {
// Records do not have setters, so we return an empty map
return Collections.emptyMap();
}
// collect all candidate target accessors
List<Accessor> candidates = new ArrayList<>( getSetters() );
candidates.addAll( getAlternativeTargetAccessors() );
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct.ap.test.bugs._3886.jdk21;

import java.time.LocalDate;

import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;

/**
* @author Filip Hrisafov
*/
@Mapper(unmappedTargetPolicy = ReportingPolicy.ERROR)
public interface Issue3886Mapper {

RangeRecord map(LocalDate validFrom);

record RangeRecord(LocalDate validFrom) {

public RangeRecord restrictTo(RangeRecord other) {
return null;
}

public void setName(String name) {
// This method is here to ensure that MapStruct won't treat it as a setter
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct.ap.test.bugs._3886.jdk21;

import org.mapstruct.ap.testutil.IssueKey;
import org.mapstruct.ap.testutil.ProcessorTest;
import org.mapstruct.ap.testutil.WithClasses;
import org.mapstruct.ap.testutil.runner.Compiler;

/**
* @author Filip Hrisafov
*/
@WithClasses(Issue3886Mapper.class)
@IssueKey("3886")
class Issue3886Test {

// The current version of the Eclipse compiler we use does not support records
@ProcessorTest(Compiler.JDK)
void shouldCompile() {

}
}