This is an automated email from the ASF dual-hosted git repository.
apolovtsev pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ignite-3.git
The following commit(s) were added to refs/heads/main by this push:
new b0255aa6e0 IGNITE-21645 Fix tests extending AbstractPlannerTest on
Java 21 (#3330)
b0255aa6e0 is described below
commit b0255aa6e0c6fa39f8c4d5bd5e6b61a83a9cb1f9
Author: Roman Puchkovskiy <[email protected]>
AuthorDate: Fri Mar 1 22:33:11 2024 +0400
IGNITE-21645 Fix tests extending AbstractPlannerTest on Java 21 (#3330)
The tests change a final field value. In such a situation, the
corresponding IgniteTestUtils method changes the corresponding Field's
modifiers to remove the final flag from them. The modifiers are changed through
a MethodHandle, and on highest Java versions, a MethodHandle of a final Field
now throws an UnsupportedOperationException.
It turns out, this modification of the modifiers is actually not needed on
any of the currently LTS Java versions (11, 17, 21), so we just remove this in
this commit.
---
.../ignite/internal/testframework/IgniteTestUtils.java | 17 -----------------
1 file changed, 17 deletions(-)
diff --git
a/modules/core/src/testFixtures/java/org/apache/ignite/internal/testframework/IgniteTestUtils.java
b/modules/core/src/testFixtures/java/org/apache/ignite/internal/testframework/IgniteTestUtils.java
index 6972df502e..e4cd5775c6 100644
---
a/modules/core/src/testFixtures/java/org/apache/ignite/internal/testframework/IgniteTestUtils.java
+++
b/modules/core/src/testFixtures/java/org/apache/ignite/internal/testframework/IgniteTestUtils.java
@@ -29,8 +29,6 @@ import static
org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.fail;
import java.io.IOException;
-import java.lang.invoke.MethodHandles;
-import java.lang.invoke.VarHandle;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
@@ -82,17 +80,6 @@ public final class IgniteTestUtils {
private static final int TIMEOUT_SEC = 30;
- private static final VarHandle MODIFIERS;
-
- static {
- try {
- MethodHandles.Lookup lookup =
MethodHandles.privateLookupIn(Field.class, MethodHandles.lookup());
- MODIFIERS = lookup.findVarHandle(Field.class, "modifiers",
int.class);
- } catch (IllegalAccessException | NoSuchFieldException ex) {
- throw new ExceptionInInitializerError(ex);
- }
- }
-
/**
* Set object field value via reflection.
*
@@ -165,10 +152,6 @@ public final class IgniteTestUtils {
throw new IgniteInternalException("Modification of static
final field through reflection.");
}
- if (isFinal) {
- MODIFIERS.set(field, field.getModifiers() & ~Modifier.FINAL);
- }
-
field.set(obj, val);
} catch (NoSuchFieldException | IllegalAccessException e) {
throw new IgniteInternalException("Failed to set object field
[obj=" + obj + ", field=" + fieldName + ']', e);