From 67aaaecf1da104b6ad6c95729aae02341683a3e3 Mon Sep 17 00:00:00 2001 From: Jan Ouwens Date: Sat, 23 Nov 2024 10:08:27 +0100 Subject: [PATCH] Fixes bugs that popped up after removing realizeCacheFor --- .../vintage/prefabvalues/factories/FallbackFactory.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/equalsverifier-core/src/main/java/nl/jqno/equalsverifier/internal/reflection/vintage/prefabvalues/factories/FallbackFactory.java b/equalsverifier-core/src/main/java/nl/jqno/equalsverifier/internal/reflection/vintage/prefabvalues/factories/FallbackFactory.java index 605d2dbe5..a206d1ae2 100644 --- a/equalsverifier-core/src/main/java/nl/jqno/equalsverifier/internal/reflection/vintage/prefabvalues/factories/FallbackFactory.java +++ b/equalsverifier-core/src/main/java/nl/jqno/equalsverifier/internal/reflection/vintage/prefabvalues/factories/FallbackFactory.java @@ -1,8 +1,10 @@ package nl.jqno.equalsverifier.internal.reflection.vintage.prefabvalues.factories; import java.lang.reflect.Array; +import nl.jqno.equalsverifier.internal.reflection.ClassProbe; import nl.jqno.equalsverifier.internal.reflection.Tuple; import nl.jqno.equalsverifier.internal.reflection.TypeTag; +import nl.jqno.equalsverifier.internal.reflection.instantiation.InstanceCreator; import nl.jqno.equalsverifier.internal.reflection.instantiation.ValueProvider.Attributes; import nl.jqno.equalsverifier.internal.reflection.instantiation.VintageValueProvider; import nl.jqno.equalsverifier.internal.reflection.vintage.ClassAccessor; @@ -83,7 +85,11 @@ private Tuple giveInstances( ClassAccessor accessor = ClassAccessor.of(tag.getType(), valueProvider, objenesis); T red = accessor.getRedObject(tag, attributes); T blue = accessor.getBlueObject(tag, attributes); - T redCopy = accessor.getRedObject(tag, attributes); + + @SuppressWarnings("unchecked") + Class actualType = (Class) red.getClass(); + T redCopy = new InstanceCreator<>(new ClassProbe(actualType), objenesis).copy(red); + return new Tuple<>(red, blue, redCopy); } }