Skip to content

Commit

Permalink
Updated TODOs to reflect insights about the Java 18+ problem.
Browse files Browse the repository at this point in the history
  • Loading branch information
jlink committed Nov 11, 2023
1 parent f15d935 commit 8bf52e5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
4 changes: 3 additions & 1 deletion TODO.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# 1.8.2

- Make run with Java 21 (22?).
- Make run with Java 18+.
See https://github.com/jqwik-team/jqwik/issues/528.
This may require a change to how methods are invoked via reflection.
See JqwikReflectionSupport.invokeMethodPotentiallyOuter() will probably need to accept the current property context as parameter.

- Can large array shrinking be improved?
See https://github.com/jqwik-team/jqwik/issues/525
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
import net.jqwik.api.*;
import net.jqwik.api.providers.*;
import net.jqwik.api.support.*;
import net.jqwik.engine.properties.shrinking.*;
import net.jqwik.engine.support.types.*;

import static java.util.stream.Collectors.*;

Expand Down Expand Up @@ -47,7 +45,7 @@ private static Optional<Object> getOuterInstance(Object inner) {
// but has been stable so far in all JDKs

return Arrays
.stream(getDeclaredFields(inner))
.stream(inner.getClass().getDeclaredFields())
.filter(field -> field.getName().startsWith("this$"))
.findFirst()
.map(field -> {
Expand All @@ -62,11 +60,6 @@ private static Optional<Object> getOuterInstance(Object inner) {
});
}

// Public for testing purposes only
public static Field[] getDeclaredFields(Object any) {
return any.getClass().getDeclaredFields();
}

@SuppressWarnings("deprecation") // Deprecated as of Java 9
private static <T extends AccessibleObject> T makeAccessible(T object) {
if (!object.isAccessible()) {
Expand Down Expand Up @@ -169,7 +162,7 @@ public static List<Field> findFieldsPotentiallyOuter(

public static Object readFieldPotentiallyOuter(Field field, Object target) {
makeAccessible(field);
List<Field> declaredFields = Arrays.stream(getDeclaredFields(target)).collect(toList());
List<Field> declaredFields = Arrays.stream(target.getClass().getDeclaredFields()).collect(toList());
if (declaredFields.contains(field)) {
try {
return field.get(target);
Expand All @@ -189,7 +182,7 @@ public static Object readFieldPotentiallyOuter(Field field, Object target) {

public static void setFieldPotentiallyOuter(Field field, Object value, Object target) {
makeAccessible(field);
List<Field> declaredFields = Arrays.stream(getDeclaredFields(target)).collect(toList());
List<Field> declaredFields = Arrays.stream(target.getClass().getDeclaredFields()).collect(toList());
if (declaredFields.contains(field)) {
try {
if (isStatic(field)) {
Expand Down

0 comments on commit 8bf52e5

Please sign in to comment.