<artifactId>library</artifactId>
<version>${project.version}</version>
</dependency>
- <dependency>
- <groupId>org.apache.karaf.shell</groupId>
- <artifactId>org.apache.karaf.shell.console</artifactId>
- <scope>provided</scope>
- </dependency>
+ <dependency>
+ <groupId>org.apache.karaf.shell</groupId>
+ <artifactId>org.apache.karaf.shell.console</artifactId>
+ <scope>provided</scope>
+ </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>schema.hardwarevtep</artifactId>
<configuration>
<forkCount>1</forkCount>
<reuseForks>false</reuseForks>
+
+ <!-- FIXME: remove this once we do not muck with static final fields -->
+ <argLine>
+ @{argLine}
+ --add-opens java.base/java.lang=ALL-UNNAMED
+ --add-opens java.base/java.lang.reflect=ALL-UNNAMED
+ </argLine>
</configuration>
</plugin>
</plugins>
import com.google.common.util.concurrent.ListenableFuture;
import java.io.IOException;
import java.io.InputStream;
+import java.lang.invoke.MethodHandles;
+import java.lang.invoke.VarHandle;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.net.InetAddress;
public class DataChangeListenerTestBase extends AbstractDataBrokerTest {
private static final Logger LOG = LoggerFactory.getLogger(DataChangeListenerTestBase.class);
+ // Hack to hack into Field.class for now
+ private static final VarHandle MODIFIERS;
+
+ static {
+ try {
+ var lookup = MethodHandles.privateLookupIn(Field.class, MethodHandles.lookup());
+ MODIFIERS = lookup.findVarHandle(Field.class, "modifiers", int.class);
+ } catch (IllegalAccessException | NoSuchFieldException e) {
+ throw new ExceptionInInitializerError(e);
+ }
+ }
+
static DataBroker dataBroker;
EntityOwnershipService entityOwnershipService;
for (Field field : fields) {
if (fieldName.equals(field.getName())) {
field.setAccessible(true);
- Field modifiersField = Field.class.getDeclaredField("modifiers");
- modifiersField.setAccessible(true);
- modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
+
+ final int mods = field.getModifiers();
+ if (Modifier.isFinal(mods)) {
+ MODIFIERS.set(field, mods & ~Modifier.FINAL);
+ }
+
field.set(null, newValue);
break;
}
return mergeNode(logicalDatastoreType, nodeIid, nodeBuilder);
}
- void deleteData(final LogicalDatastoreType datastoreType, InstanceIdentifier<?>... iids) {
+ void deleteData(final LogicalDatastoreType datastoreType, final InstanceIdentifier<?>... iids) {
WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
for (InstanceIdentifier<?> id : iids) {
transaction.delete(datastoreType, id);
<value>org.sonar.java.jacoco.JUnitListener</value>
</property>
</properties>
+
+ <!-- FIXME: remove this declaration once powermock is gone -->
+ <argLine>
+ @{argLine}
+ --add-opens java.base/java.lang=ALL-UNNAMED
+ --add-opens java.base/java.lang.reflect=ALL-UNNAMED
+ --add-opens java.base/java.net=ALL-UNNAMED
+ --add-opens java.base/java.util=ALL-UNNAMED
+ --add-opens java.base/java.util.concurrent=ALL-UNNAMED
+ --add-opens java.base/java.util.stream=ALL-UNNAMED
+ </argLine>
</configuration>
</plugin>
<plugin>