-
Notifications
You must be signed in to change notification settings - Fork 40
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
LocalDateTime: Warning: An illegal reflective access operation has occurred #131
Comments
Can you please provide the code snippet for your tests? |
it's a old one, but we are facing the same problem.
|
With the release of the new LTS Java 17, this issue now causes test failure. It seems related to issue #110
Code snippets: import lombok.Data;
import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
import java.util.Optional;
/**
* An employee of the company.
*/
@Data
public class Employee {
private long id;
private final String firstName;
private final String middleName;
private final String lastName;
private LocalDate hireDate;
private boolean active = false;
/**
* Get years this employee has been with the company.
*
* @return number of years this employee has been employed
*/
public int getYearsEmployed() {
return Optional.ofNullable(hireDate)
.map(dt -> Math.toIntExact(ChronoUnit.YEARS.between(dt, LocalDate.now())))
.orElse(0);
}
}
class EmployeeTest {
private Employee employee;
@BeforeEach
void initializeEmployee() {
employee = new Employee("John", "Jacob", "Jingleheimer-Schmidt");
}
@Test
void getYearsEmployed_HiredThreeYearsAgo() {
final LocalDate hireDate = LocalDate.now().minusYears(3L);
employee.setHireDate(hireDate);
int actual = employee.getYearsEmployed();
assertEquals(3, actual);
}
@Test
void getYearsEmployed_HiredToday() {
final LocalDate hireDate = LocalDate.now();
employee.setHireDate(hireDate);
int actual = employee.getYearsEmployed();
assertEquals(0, actual);
}
@Test
void validateGettersAndSetters() {
PojoClass employeePojo = PojoClassFactory.getPojoClass(Employee.class);
Validator validator = ValidatorBuilder.create()
.with(new GetterMustExistRule())
.with(new SetterMustExistRule())
.with(new GetterTester())
.with(new SetterTester())
.with(new SerializableMustHaveSerialVersionUIDRule())
.with(new DefaultValuesNullTester())
.build();
validator.validate(employeePojo);
}
} |
Is there any update on this issue as I see no activity on this project since last year? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When testing the Getter and Setter on a LocalDateTime field, the following warnings occur. How do we handle testing LocalDateTime fields?
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.openpojo.reflection.impl.PojoFieldImpl (file:/C:/Users/treadstone/.m2/repository/com/openpojo/openpojo/0.8.10/openpojo-0.8.10.jar) to field java.time.LocalDateTime.serialVersionUID
WARNING: Please consider reporting this to the maintainers of com.openpojo.reflection.impl.PojoFieldImpl
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
The text was updated successfully, but these errors were encountered: