Make IBpfMap extends AutoCloseable and BpfMap implements IBpfMap

IBpfMap defines all required functions of BpfMap interface.
Ex: close() from AutoCloseable

After:
AutoCloseable ---> IBpfMap ---> BpfMap

Before:
AutoCloseable -+
               |
               +---> BpfMap
	       |
IBpfMap -------+

Test: BpfMapTest
Change-Id: I5266d9bfdfcb68f632c13d214705309893dded95
This commit is contained in:
Hungming Chen
2022-05-05 23:35:33 +08:00
parent b4b0e32954
commit aadb17ed59
2 changed files with 2 additions and 3 deletions

View File

@@ -39,7 +39,7 @@ import java.util.Objects;
* @param <K> the key of the map.
* @param <V> the value of the map.
*/
public class BpfMap<K extends Struct, V extends Struct> implements IBpfMap<K, V>, AutoCloseable {
public class BpfMap<K extends Struct, V extends Struct> implements IBpfMap<K, V> {
static {
System.loadLibrary(JniUtil.getJniLibraryName(BpfMap.class.getPackage()));
}

View File

@@ -20,7 +20,6 @@ import android.system.ErrnoException;
import androidx.annotation.NonNull;
import java.util.NoSuchElementException;
import java.util.function.BiConsumer;
/**
* The interface of BpfMap. This could be used to inject for testing.
@@ -29,7 +28,7 @@ import java.util.function.BiConsumer;
* @param <K> the key of the map.
* @param <V> the value of the map.
*/
public interface IBpfMap<K extends Struct, V extends Struct> {
public interface IBpfMap<K extends Struct, V extends Struct> extends AutoCloseable {
/** Update an existing or create a new key -> value entry in an eBbpf map. */
void updateEntry(K key, V value) throws ErrnoException;