Skip to content

Commit

Permalink
Removing reflection trick to mock static final fields (no longer vali…
Browse files Browse the repository at this point in the history
…d with JDK 12+)
  • Loading branch information
yesamer committed Feb 25, 2024
1 parent b0b8993 commit 81a246c
Showing 1 changed file with 1 addition and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
package org.kie.workbench.common.stunner.client.widgets.presenters.session.impl;

import java.lang.reflect.Field;
import java.lang.reflect.Modifier;

import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Style;
Expand Down Expand Up @@ -187,11 +186,7 @@ private static void setFinal(Object instance,
Field field,
Object newValue) throws Exception {
field.setAccessible(true);
// remove final modifier from field
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
modifiersField.setInt(field,
field.getModifiers() & ~Modifier.FINAL);

field.set(instance,
newValue);
}
Expand Down

0 comments on commit 81a246c

Please sign in to comment.