diff --git a/vpp-api/java/Makefile.am b/vpp-api/java/Makefile.am
index c06caf5..d3f3c4f 100644
--- a/vpp-api/java/Makefile.am
+++ b/vpp-api/java/Makefile.am
@@ -21,80 +21,11 @@
 CLEANFILES = 
 lib_LTLIBRARIES = 
 
-nobase_include_HEADERS =		\
-  japi/org_openvpp_vppjapi_vppApi.h	\
-  japi/org_openvpp_vppjapi_vppConn.h
-
-lib_LTLIBRARIES += libvppjni.la
-
-libvppjni_la_SOURCES = japi/vppjni.c japi/vppapi.c japi/vppjni_env.h japi/vppjni_env.c
-libvppjni_la_LIBADD = -lvlibmemoryclient -lvlibapi -lsvm -lvppinfra \
-	              -lpthread -lm -lrt
-libvppjni_la_LDFLAGS = -module
-libvppjni_la_CPPFLAGS = -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux
-
-jarfile = vppjapi-$(PACKAGE_VERSION).jar
-packagedir = org/openvpp/vppjapi
-JAVAROOT = .
-
-$(jarfile): libvppjni.la
-	cd .libs ; $(JAR) cf $(JARFLAGS) ../$@ libvppjni.so.0.0.0 ../$(packagedir)/*.class ; cd ..
-
-BUILT_SOURCES += japi/org_openvpp_vppjapi_vppConn.h japi/vppapi.c 
-
-japi/org_openvpp_vppjapi_vppConn.h: 					\
-    japi/org/openvpp/vppjapi/vppVersion.java 				\
-    japi/org/openvpp/vppjapi/vppInterfaceDetails.java 			\
-    japi/org/openvpp/vppjapi/vppInterfaceCounters.java 			\
-    japi/org/openvpp/vppjapi/vppBridgeDomainDetails.java 		\
-    japi/org/openvpp/vppjapi/vppBridgeDomainInterfaceDetails.java	\
-    japi/org/openvpp/vppjapi/vppL2Fib.java 				\
-    japi/org/openvpp/vppjapi/vppIPv4Address.java 			\
-    japi/org/openvpp/vppjapi/vppIPv6Address.java 			\
-    japi/org/openvpp/vppjapi/vppVxlanTunnelDetails.java 		\
-    japi/org/openvpp/vppjapi/vppConn.java 				\
-    japi/org/openvpp/vppjapi/vppApiCallbacks.java 			\
-    ../../vpp/vpp-api/vpe.api.h
-	$(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppVersion.java ;				\
-	$(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppVersion ;						\
-	$(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppInterfaceDetails.java ;			\
-	$(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppInterfaceDetails ;					\
-	$(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppInterfaceCounters.java ;		\
-	$(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppInterfaceCounters ;				\
-	$(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppBridgeDomainInterfaceDetails.java ;	\
-	$(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppBridgeDomainInterfaceDetails ;			\
-	$(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppBridgeDomainDetails.java ;		\
-	$(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppBridgeDomainDetails ;				\
-	$(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppL2Fib.java ;				\
-	$(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppL2Fib ;						\
-	$(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppIPv4Address.java ;			\
-	$(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppIPv4Address ;					\
-	$(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppIPv6Address.java ;			\
-	$(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppIPv6Address ;					\
-	$(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppVxlanTunnelDetails.java ;		\
-	$(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppVxlanTunnelDetails ;				\
-	$(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppConn.java ;				\
-	$(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppConn ;
-
-japi/vppapi.c: japi/org_openvpp_vppjapi_vppConn.h
-	pushd .. ; dir=`pwd` ; popd ;								\
-	instdir=`echo $${dir} | sed -e 's:build-root/build:build-root/install:'` ;		\
-	vppapigen --input $${instdir}/../vpp/vpp-api/vpe.api --jni  japi/vppapi.c --app vpe ;	\
-	vppapigen --input $${instdir}/../vpp/vpp-api/vpe.api --java japi/vppApi.java --app vpe ;	\
-	$(JAVAC) -classpath . -d . japi/vppApi.java ;						\
-	$(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppApi ;				\
-	$(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppApiCallbacks.java ;	\
-	$(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppApiCallbacks ;
-
-demo = japi/test/demo.class
-$(demo): $(jarfile)
-	$(JAVAC) -cp $(jarfile) -d $(JAVAROOT) @srcdir@/japi/test/demo.java
-
 #
 # jVpp binding
 #
 
-nobase_include_HEADERS +=		\
+nobase_include_HEADERS =		\
   jvpp/org_openvpp_jvpp_VppJNIConnection.h
 
 lib_LTLIBRARIES += libjvpp.la
@@ -138,4 +69,4 @@
 $(jarfile_jvpp): libjvpp.la
 	cd .libs ; $(JAR) cf $(JARFLAGS) ../$@ libjvpp.so.0.0.0 ../$(packagedir_jvpp)/* ; cd ..;
 
-all-local: $(jarfile) $(jarfile_jvpp) $(demo)
+all-local: $(jarfile_jvpp)
diff --git a/vpp-api/java/configure.ac b/vpp-api/java/configure.ac
index 2b9f258..d2033ee 100644
--- a/vpp-api/java/configure.ac
+++ b/vpp-api/java/configure.ac
@@ -1,4 +1,4 @@
-AC_INIT(vpp-japi, 16.09)
+AC_INIT(jvpp, 16.09)
 LT_INIT
 AC_CONFIG_MACRO_DIR([m4])
 AM_INIT_AUTOMAKE
diff --git a/vpp-api/java/japi/org/openvpp/vppjapi/vppApiCallbacks.java b/vpp-api/java/japi/org/openvpp/vppjapi/vppApiCallbacks.java
deleted file mode 100644
index df5b953..0000000
--- a/vpp-api/java/japi/org/openvpp/vppjapi/vppApiCallbacks.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openvpp.vppjapi;
-
-import java.io.IOException;
-import org.openvpp.vppjapi.vppApi;
-
-public abstract class vppApiCallbacks extends vppApi {
-     public vppApiCallbacks(String clientName) throws IOException {
-         super(clientName);
-     }
-/* Disabled!
- *
- * public abstract void interfaceDetails(
-            int ifIndex, String interfaceName, int supIfIndex, byte[] physAddr,
-            byte adminUp, byte linkUp, byte linkDuplex, byte linkSpeed,
-            int subId, byte subDot1ad, byte subNumberOfTags, int subOuterVlanId, int subInnerVlanId,
-            byte subExactMatch, byte subDefault, byte subOuterVlanIdAny, byte subInnerVlanIdAny,
-            int vtrOp, int vtrPushDot1q, int vtrTag1, int vtrTag2);
- */
-
-}
diff --git a/vpp-api/java/japi/org/openvpp/vppjapi/vppBridgeDomainDetails.java b/vpp-api/java/japi/org/openvpp/vppjapi/vppBridgeDomainDetails.java
deleted file mode 100644
index db859a0..0000000
--- a/vpp-api/java/japi/org/openvpp/vppjapi/vppBridgeDomainDetails.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openvpp.vppjapi;
-
-import org.openvpp.vppjapi.vppBridgeDomainInterfaceDetails;
-
-public final class vppBridgeDomainDetails {
-    public String name;
-    public int bdId;
-    public boolean flood;
-    public boolean uuFlood;
-    public boolean forward;
-    public boolean learn;
-    public boolean arpTerm;
-    public String bviInterfaceName;
-    public vppBridgeDomainInterfaceDetails[] interfaces;
-}
diff --git a/vpp-api/java/japi/org/openvpp/vppjapi/vppBridgeDomainInterfaceDetails.java b/vpp-api/java/japi/org/openvpp/vppjapi/vppBridgeDomainInterfaceDetails.java
deleted file mode 100644
index ab99ee4..0000000
--- a/vpp-api/java/japi/org/openvpp/vppjapi/vppBridgeDomainInterfaceDetails.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openvpp.vppjapi;
-
-public final class vppBridgeDomainInterfaceDetails {
-    public String interfaceName;
-    public byte splitHorizonGroup;
-}
diff --git a/vpp-api/java/japi/org/openvpp/vppjapi/vppConn.java b/vpp-api/java/japi/org/openvpp/vppjapi/vppConn.java
deleted file mode 100644
index 3e8c12a..0000000
--- a/vpp-api/java/japi/org/openvpp/vppjapi/vppConn.java
+++ /dev/null
@@ -1,237 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openvpp.vppjapi;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.StandardCopyOption;
-import java.nio.file.attribute.PosixFilePermission;
-import java.nio.file.attribute.PosixFilePermissions;
-import java.util.Set;
-
-import org.openvpp.vppjapi.vppVersion;
-import org.openvpp.vppjapi.vppInterfaceDetails;
-import org.openvpp.vppjapi.vppInterfaceCounters;
-import org.openvpp.vppjapi.vppBridgeDomainDetails;
-import org.openvpp.vppjapi.vppIPv4Address;
-import org.openvpp.vppjapi.vppIPv6Address;
-import org.openvpp.vppjapi.vppVxlanTunnelDetails;
-
-public class vppConn implements AutoCloseable {
-    private static final String LIBNAME = "libvppjni.so.0.0.0";
-
-    static {
-        try {
-            loadLibrary();
-        } catch (Exception e) {
-            System.out.printf("Can't find vpp jni library: %s\n", LIBNAME);
-            throw new ExceptionInInitializerError(e);
-        }
-    }
-
-    private static void loadStream(final InputStream is) throws IOException {
-        final Set<PosixFilePermission> perms = PosixFilePermissions.fromString("rwxr-x---");
-        final Path p = Files.createTempFile(LIBNAME, null, PosixFilePermissions.asFileAttribute(perms));
-        try {
-            Files.copy(is, p, StandardCopyOption.REPLACE_EXISTING);
-
-            try {
-                Runtime.getRuntime().load(p.toString());
-            } catch (UnsatisfiedLinkError e) {
-                throw new IOException(String.format("Failed to load library %s", p), e);
-            }
-        } finally {
-            try {
-                Files.deleteIfExists(p);
-            } catch (IOException e) {
-            }
-        }
-    }
-
-    private static void loadLibrary() throws IOException {
-      try (final InputStream is = vppConn.class.getResourceAsStream('/' + LIBNAME)) {
-          if (is == null) {
-              throw new IOException(String.format("Failed to open library resource %s",
-                                                LIBNAME));
-          }
-          loadStream(is);
-        }
-    }
-
-    private static vppConn currentConnection = null;
-    private final String clientName;
-    private volatile boolean disconnected = false;
-
-    // Hidden on purpose to prevent external instantiation
-    vppConn(final String clientName) throws IOException {
-        this.clientName = clientName;
-
-        synchronized (vppConn.class) {
-            if (currentConnection != null) {
-                throw new IOException("Already connected as " + currentConnection.clientName);
-            }
-
-            final int ret = clientConnect(clientName);
-            if (ret != 0) {
-                throw new IOException("Connection returned error " + ret);
-            }
-
-            currentConnection = this;
-        }
-    }
-
-    @Override
-    public synchronized final void close() {
-        if (!disconnected) {
-            disconnected = true;
-
-            synchronized (vppConn.class) {
-                clientDisconnect();
-                currentConnection = null;
-            }
-        }
-    }
-
-    /**
-     * Check if this instance is connected.
-     *
-     * @throws IllegalStateException if this instance was disconnected.
-     */
-    protected final void checkConnected() {
-        if (disconnected) {
-            throw new IllegalStateException("Disconnected client " + clientName);
-        }
-    }
-
-    public final int getRetval(int context, int release) {
-        checkConnected();
-        return getRetval0(context, release);
-    }
-
-    public final String getInterfaceList (String nameFilter) {
-        checkConnected();
-        return getInterfaceList0(nameFilter);
-    }
-
-    public final int swIfIndexFromName (String interfaceName) {
-        checkConnected();
-        return swIfIndexFromName0(interfaceName);
-    }
-
-    public final String interfaceNameFromSwIfIndex (int swIfIndex) {
-        checkConnected();
-        return interfaceNameFromSwIfIndex0(swIfIndex);
-    }
-
-    public final void clearInterfaceTable () {
-        checkConnected();
-        clearInterfaceTable0();
-    }
-
-    public final vppInterfaceDetails[] swInterfaceDump (byte nameFilterValid, byte [] nameFilter) {
-        checkConnected();
-        return swInterfaceDump0(nameFilterValid, nameFilter);
-    }
-
-    public final int bridgeDomainIdFromName(String bridgeDomain) {
-        checkConnected();
-        return bridgeDomainIdFromName0(bridgeDomain);
-    }
-
-    public final int findOrAddBridgeDomainId(String bridgeDomain) {
-        checkConnected();
-        return findOrAddBridgeDomainId0(bridgeDomain);
-    }
-
-    public final vppVersion getVppVersion() {
-        checkConnected();
-        return getVppVersion0();
-    }
-
-    public final vppInterfaceCounters getInterfaceCounters(int swIfIndex) {
-        checkConnected();
-        return getInterfaceCounters0(swIfIndex);
-    }
-
-    public final int[] bridgeDomainDump(int bdId) {
-        checkConnected();
-        return bridgeDomainDump0(bdId);
-    }
-
-    public final vppBridgeDomainDetails getBridgeDomainDetails(int bdId) {
-        checkConnected();
-        return getBridgeDomainDetails0(bdId);
-    }
-
-    public final vppL2Fib[] l2FibTableDump(int bdId) {
-        checkConnected();
-        return l2FibTableDump0(bdId);
-    }
-
-    public final int bridgeDomainIdFromInterfaceName(String interfaceName) {
-        checkConnected();
-        return bridgeDomainIdFromInterfaceName0(interfaceName);
-    }
-
-    public final vppIPv4Address[] ipv4AddressDump(String interfaceName) {
-        checkConnected();
-        return ipv4AddressDump0(interfaceName);
-    }
-
-    public final vppIPv6Address[] ipv6AddressDump(String interfaceName) {
-        checkConnected();
-        return ipv6AddressDump0(interfaceName);
-    }
-
-    public final vppVxlanTunnelDetails[] vxlanTunnelDump(int swIfIndex) {
-        checkConnected();
-        return vxlanTunnelDump0(swIfIndex);
-    }
-
-    public final int setInterfaceDescription(String ifName, String ifDesc) {
-        checkConnected();
-        return setInterfaceDescription0(ifName, ifDesc);
-    }
-
-    public final String getInterfaceDescription(String ifName) {
-        checkConnected();
-        return getInterfaceDescription0(ifName);
-    }
-
-    private static native int clientConnect(String clientName);
-    private static native void clientDisconnect();
-    private static native int getRetval0(int context, int release);
-    private static native String getInterfaceList0(String nameFilter);
-    private static native int swIfIndexFromName0(String interfaceName);
-    private static native String interfaceNameFromSwIfIndex0(int swIfIndex);
-    private static native void clearInterfaceTable0();
-    private static native vppInterfaceDetails[] swInterfaceDump0(byte nameFilterValid, byte [] nameFilter);
-    private static native int bridgeDomainIdFromName0(String bridgeDomain);
-    private static native int findOrAddBridgeDomainId0(String bridgeDomain);
-    private static native vppVersion getVppVersion0();
-    private static native vppInterfaceCounters getInterfaceCounters0(int swIfIndex);
-    private static native int[] bridgeDomainDump0(int bdId);
-    private static native vppBridgeDomainDetails getBridgeDomainDetails0(int bdId);
-    private static native vppL2Fib[] l2FibTableDump0(int bdId);
-    private static native int bridgeDomainIdFromInterfaceName0(String interfaceName);
-    private static native vppIPv4Address[] ipv4AddressDump0(String interfaceName);
-    private static native vppIPv6Address[] ipv6AddressDump0(String interfaceName);
-    private static native vppVxlanTunnelDetails[] vxlanTunnelDump0(int swIfIndex);
-    private static native int setInterfaceDescription0(String ifName, String ifDesc);
-    private static native String getInterfaceDescription0(String ifName);
-}
diff --git a/vpp-api/java/japi/org/openvpp/vppjapi/vppIPv4Address.java b/vpp-api/java/japi/org/openvpp/vppjapi/vppIPv4Address.java
deleted file mode 100644
index 046ceab..0000000
--- a/vpp-api/java/japi/org/openvpp/vppjapi/vppIPv4Address.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openvpp.vppjapi;
-
-public final class vppIPv4Address {
-    public final int ip;
-    public final byte prefixLength;
-
-    public vppIPv4Address(int ip, byte prefixLength) {
-        this.ip = ip;
-        this.prefixLength = prefixLength;
-    }
-}
diff --git a/vpp-api/java/japi/org/openvpp/vppjapi/vppIPv6Address.java b/vpp-api/java/japi/org/openvpp/vppjapi/vppIPv6Address.java
deleted file mode 100644
index 6690a5d..0000000
--- a/vpp-api/java/japi/org/openvpp/vppjapi/vppIPv6Address.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openvpp.vppjapi;
-
-public class vppIPv6Address {
-    // FIXME: this is dangerous
-    public final byte[] ip;
-    public final byte prefixLength;
-
-    public vppIPv6Address(byte[] ip, byte prefixLength) {
-        this.ip = ip;
-        this.prefixLength = prefixLength;
-    }
-}
diff --git a/vpp-api/java/japi/org/openvpp/vppjapi/vppInterfaceCounters.java b/vpp-api/java/japi/org/openvpp/vppjapi/vppInterfaceCounters.java
deleted file mode 100644
index b2687fb..0000000
--- a/vpp-api/java/japi/org/openvpp/vppjapi/vppInterfaceCounters.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openvpp.vppjapi;
-
-public final class vppInterfaceCounters {
-
-    public final long rxOctets;
-    public final long rxIp4;
-    public final long rxIp6;
-    public final long rxUnicast;
-    public final long rxMulticast;
-    public final long rxBroadcast;
-    public final long rxDiscard;
-    public final long rxFifoFull;
-    public final long rxError;
-    public final long rxUnknownProto;
-    public final long rxMiss;
-
-    public final long txOctets;
-    public final long txIp4;
-    public final long txIp6;
-    public final long txUnicast;
-    public final long txMulticast;
-    public final long txBroadcast;
-    public final long txDiscard;
-    public final long txFifoFull;
-    public final long txError;
-    public final long txUnknownProto;
-    public final long txMiss;
-
-    public vppInterfaceCounters(
-            long rxOctets, long rxIp4, long rxIp6, long rxUni, long rxMulti,
-            long rxBcast, long rxDiscard, long rxFifoFull, long rxError,
-            long rxUnknownProto, long rxMiss,
-            long txOctets, long txIp4, long txIp6, long txUni, long txMulti,
-            long txBcast, long txDiscard, long txFifoFull, long txError,
-            long txUnknownProto, long txMiss)
-    {
-        this.rxOctets = rxOctets;
-        this.rxIp4 = rxIp4;
-        this.rxIp6 = rxIp6;
-        this.rxUnicast = rxUni;
-        this.rxMulticast = rxMulti;
-        this.rxBroadcast = rxBcast;
-        this.rxDiscard = rxDiscard;
-        this.rxFifoFull = rxFifoFull;
-        this.rxError = rxError;
-        this.rxUnknownProto = rxUnknownProto;
-        this.rxMiss = rxMiss;
-
-        this.txOctets = txOctets;
-        this.txIp4 = txIp4;
-        this.txIp6 = txIp6;
-        this.txUnicast = txUni;
-        this.txMulticast = txMulti;
-        this.txBroadcast = txBcast;
-        this.txDiscard = txDiscard;
-        this.txFifoFull = txFifoFull;
-        this.txError = txError;
-        this.txUnknownProto = txUnknownProto;
-        this.txMiss = txMiss;
-    }
-}
-
diff --git a/vpp-api/java/japi/org/openvpp/vppjapi/vppInterfaceDetails.java b/vpp-api/java/japi/org/openvpp/vppjapi/vppInterfaceDetails.java
deleted file mode 100644
index 742dd25..0000000
--- a/vpp-api/java/japi/org/openvpp/vppjapi/vppInterfaceDetails.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openvpp.vppjapi;
-
-public final class vppInterfaceDetails {
-    public final int ifIndex;
-    public final String interfaceName;
-    public final int supIfIndex;
-    // FIXME: this is dangerous
-    public final byte[] physAddr;
-    public final byte adminUp;
-    public final byte linkUp;
-    public final byte linkDuplex;
-    public final byte linkSpeed;
-    public final int subId;
-    public final byte subDot1ad;
-    public final byte subNumberOfTags;
-    public final int subOuterVlanId;
-    public final int subInnerVlanId;
-    public final byte subExactMatch;
-    public final byte subDefault;
-    public final byte subOuterVlanIdAny;
-    public final byte subInnerVlanIdAny;
-    public final int vtrOp;
-    public final int vtrPushDot1q;
-    public final int vtrTag1;
-    public final int vtrTag2;
-    public final int linkMtu;
-
-    public vppInterfaceDetails(int ifIndex, String interfaceName, int supIfIndex, byte[] physAddr, byte adminUp,
-            byte linkUp, byte linkDuplex, byte linkSpeed, int subId, byte subDot1ad, byte subNumberOfTags,
-            int subOuterVlanId, int subInnerVlanId, byte subExactMatch, byte subDefault, byte subOuterVlanIdAny,
-            byte subInnerVlanIdAny, int vtrOp, int vtrPushDot1q, int vtrTag1, int vtrTag2, int linkMtu)
-    {
-        this.ifIndex = ifIndex;
-        this.interfaceName = interfaceName;
-        this.supIfIndex = supIfIndex;
-        this.physAddr = physAddr;
-        this.adminUp = adminUp;
-        this.linkUp = linkUp;
-        this.linkDuplex = linkDuplex;
-        this.linkSpeed = linkSpeed;
-        this.subId = subId;
-        this.subDot1ad = subDot1ad;
-        this.subNumberOfTags = subNumberOfTags;
-        this.subOuterVlanId = subOuterVlanId;
-        this.subInnerVlanId = subInnerVlanId;
-        this.subExactMatch = subExactMatch;
-        this.subDefault = subDefault;
-        this.subOuterVlanIdAny = subOuterVlanIdAny;
-        this.subInnerVlanIdAny = subInnerVlanIdAny;
-        this.vtrOp = vtrOp;
-        this.vtrPushDot1q = vtrPushDot1q;
-        this.vtrTag1 = vtrTag1;
-        this.vtrTag2 = vtrTag2;
-        this.linkMtu = linkMtu;
-    }
-}
diff --git a/vpp-api/java/japi/org/openvpp/vppjapi/vppL2Fib.java b/vpp-api/java/japi/org/openvpp/vppjapi/vppL2Fib.java
deleted file mode 100644
index b38d801..0000000
--- a/vpp-api/java/japi/org/openvpp/vppjapi/vppL2Fib.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openvpp.vppjapi;
-
-public final class vppL2Fib {
-    // FIXME: this is dangerous
-    public final byte[] physAddress;
-    public final boolean staticConfig;
-    public final String outgoingInterface;
-    public final boolean filter;
-    public final boolean bridgedVirtualInterface;
-
-    public vppL2Fib(byte[] physAddress, boolean staticConfig,
-            String outgoingInterface, boolean filter,
-            boolean bridgedVirtualInterface) {
-        this.physAddress = physAddress;
-        this.staticConfig = staticConfig;
-        this.outgoingInterface = outgoingInterface;
-        this.filter = filter;
-        this.bridgedVirtualInterface = bridgedVirtualInterface;
-    }
-}
diff --git a/vpp-api/java/japi/org/openvpp/vppjapi/vppVersion.java b/vpp-api/java/japi/org/openvpp/vppjapi/vppVersion.java
deleted file mode 100644
index 6408dee..0000000
--- a/vpp-api/java/japi/org/openvpp/vppjapi/vppVersion.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openvpp.vppjapi;
-
-public final class vppVersion {
-    public final String programName;
-    public final String buildDirectory;
-    public final String gitBranch;
-    public final String buildDate;
-
-    public vppVersion(String progName, String buildDir, String gitBranch, String buildDate) {
-        this.programName = progName;
-        this.buildDirectory = buildDir;
-        this.gitBranch = gitBranch;
-        this.buildDate = buildDate;
-    }
-}
-
diff --git a/vpp-api/java/japi/org/openvpp/vppjapi/vppVxlanTunnelDetails.java b/vpp-api/java/japi/org/openvpp/vppjapi/vppVxlanTunnelDetails.java
deleted file mode 100644
index fe3d0bc..0000000
--- a/vpp-api/java/japi/org/openvpp/vppjapi/vppVxlanTunnelDetails.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openvpp.vppjapi;
-
-public final class vppVxlanTunnelDetails {
-    public final byte[] srcAddress;
-    public final byte[] dstAddress;
-    public final int encapVrfId;
-    public final int vni;
-    public final int decapNextIndex;
-    public final boolean isIpv6;
-
-    public vppVxlanTunnelDetails(byte[] srcAddress, byte[] dstAddress,
-            int encapVrfId, int vni, int decapNextIndex, boolean isIpv6) {
-        this.srcAddress = srcAddress;
-        this.dstAddress = dstAddress;
-        this.encapVrfId = encapVrfId;
-        this.vni = vni;
-        this.decapNextIndex = decapNextIndex;
-        this.isIpv6 = isIpv6;
-    }
-}
diff --git a/vpp-api/java/japi/test/demo.java b/vpp-api/java/japi/test/demo.java
deleted file mode 100644
index ea1db84..0000000
--- a/vpp-api/java/japi/test/demo.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import org.openvpp.vppjapi.*;
-
-public class demo {
-    public static void main (String[] args) throws Exception {
-        vppApi api = new vppApi ("JavaTest");
-        System.out.printf ("Connected OK...");
-
-        String intlist;
-        int [] contexts;
-        int i, limit;
-        int trips;
-        int rv, errors, saved_error;
-        long before, after;
-
-        if (false)
-        {
-            intlist = api.getInterfaceList ("");
-            System.out.printf ("Unfiltered interface list:\n%s", intlist);
-            
-            trips = 0;
-            
-            contexts = new int[6];
-            
-            for (i = 0; i < 6; i++)
-            {
-                contexts[i] = api.swInterfaceSetFlags 
-                    (5 + i /* sw_if_index */,
-                     (byte)1 /* admin_up */,
-                     (byte)1 /* link_up (ignored) */,
-                     (byte)0 /* deleted */);
-            }
-            
-            /* Thread.sleep (1); */
-            errors = 0;
-            saved_error = 0;
-            
-            for (i = 0; i < 6; i ++)
-            {
-                while (true)
-                {
-                    rv = api.getRetval (contexts[i], 1 /* release */);
-                    if (rv != -77)
-                        break;
-                    Thread.sleep (1);
-                    trips++;
-                }
-                if (rv < 0)
-                {
-                    saved_error = rv;
-                    errors++;
-                }
-            }
-            
-            if (errors == 0)
-                System.out.printf ("intfcs up...\n");
-            else
-                System.out.printf 
-                    ("%d errors, last error %d...\n", errors, saved_error);
-        }
-        
-        limit = 250000;
-        saved_error = 0;
-        errors = 0;
-        contexts = new int [limit];
-        byte [] address = new byte [4];
-        byte [] zeros = new byte [4];
-
-        address[0] = (byte)192;
-        address[1] = (byte)168;
-        address[2] = (byte)2;
-        address[3] = (byte)1;
-
-        for (i = 0; i < 4; i++)
-            zeros[i] = 0;
-
-        System.out.printf ("start %d route ops ...", limit);
-
-        before = System.currentTimeMillis();
-
-        for (i = 0; i < limit; i++) {
-            contexts[i] = api.ipAddDelRoute 
-                (0 /* int nextHopSwIfIndex */, 
-                 0 /* int vrfId */, 
-                 0 /* int lookupInVrf */, 
-                 0 /* int resolveAttempts */, 
-                 0 /* int classifyTableIndex */, 
-                 (byte)0 /* byte createVrfIfNeeded */, 
-                 (byte)0 /* byte resolveIfNeeded */, 
-                 (byte)1 /* byte isAdd */, 
-                 (byte)1 /* byte isDrop */, 
-                 (byte)0 /* byte isIpv6 */, 
-                 (byte)0 /* byte isLocal */, 
-                 (byte)0 /* byte isClassify */, 
-                 (byte)0 /* byte isMultipath */, 
-                 (byte)0 /* byte notLast */, 
-                 (byte)0 /* byte nextHopWeight */, 
-                 (byte)32 /* byte dstAddressLength */, 
-                 address, 
-                 zeros);
-            
-            address[3] += 1;
-            if (address[3] == 0)
-            {
-                address[2] += 1;
-                if (address[2] == 0)
-                {
-                    address[1] += 1;
-                    {
-                        if (address[1] == 0)
-                        {
-                            address[0] += 1;
-                        }
-                    }
-                }
-            }
-        }
-
-        trips = 0;
-                        
-        for (i = 0; i < limit; i++)
-        {
-            while (true)
-            {
-                rv = api.getRetval (contexts[i], 1 /* release */);
-                if (rv != -77)
-                    break;
-                Thread.sleep (1);
-                trips++;
-            }
-            if (rv < 0)
-            {
-                saved_error = rv;
-                errors++;
-            }
-        }
-
-        after = System.currentTimeMillis();
-
-
-        if (errors == 0)
-            System.out.printf ("done %d route ops (all OK)...\n", limit);
-        else
-            System.out.printf 
-                ("%d errors, last error %d...\n", errors, saved_error);
-        
-        System.out.printf ("result in %d trips\n", trips);
-
-        System.out.printf ("%d routes in %d milliseconds, %d routes/msec\n",
-                           limit, after - before, 
-                           limit / (after - before));
-
-        api.close();
-        System.out.printf ("Done...\n");
-    }
-}
diff --git a/vpp-api/java/japi/test/vppApi.java b/vpp-api/java/japi/test/vppApi.java
deleted file mode 100644
index 87af329..0000000
--- a/vpp-api/java/japi/test/vppApi.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import java.net.InetAddress;
-import org.openvpp.vppjapi.*;
-
-public class vppApi {
-
-    native int controlPing();
-    native void test (byte[] array, byte[] array2);
-
-    public static void main (String[] args) throws Exception {
-        vppConn api = new vppConn ();
-        String ipv6 = "db01::feed";
-        String ipv4 = "192.168.1.1";
-        InetAddress addr6 = InetAddress.getByName(ipv6);
-        InetAddress addr4 = InetAddress.getByName(ipv4);
-        byte[] ip4bytes = addr4.getAddress();
-        byte[] ip6bytes = addr6.getAddress();
-        int rv;
-
-        api.test(ip4bytes,ip6bytes);
-
-        rv = api.clientConnect ("JavaTest");
-        if (rv == 0)
-            System.out.printf ("Connected OK...");
-        else
-        {
-            System.out.printf ("clientConnect returned %d\n", rv);
-            System.exit (1);
-        }
-        rv = api.controlPing();
-        System.out.printf ("data plane pid is %d\n", rv);
-
-        Thread.sleep (5000);
-
-        api.clientDisconnect();
-        System.out.printf ("Done...\n");
-    }
-}
diff --git a/vpp-api/java/japi/vppjni.c b/vpp-api/java/japi/vppjni.c
deleted file mode 100644
index 2b58b36..0000000
--- a/vpp-api/java/japi/vppjni.c
+++ /dev/null
@@ -1,1954 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#define _GNU_SOURCE /* for strcasestr(3) */
-#include <vnet/vnet.h>
-
-#define vl_api_version(n,v) static u32 vpe_api_version = (v);
-#include <vpp-api/vpe.api.h>
-#undef vl_api_version
-
-#include <jni.h>
-#include <japi/vppjni.h>
-#include <japi/vppjni_bridge_domain.h>
-#include <japi/vppjni_env.h>
-#include <japi/org_openvpp_vppjapi_vppConn.h>
-#include <japi/org_openvpp_vppjapi_vppApi.h>
-
-#include <vpp-api/vpe_msg_enum.h>
-#define vl_typedefs             /* define message structures */
-#include <vpp-api/vpe_all_api_h.h>
-#undef vl_typedefs
-
-#define vl_endianfun
-#include <vpp-api/vpe_all_api_h.h>
-#undef vl_endianfun
-
-/* instantiate all the print functions we know about */
-#define vl_print(handle, ...)
-#define vl_printfun
-#include <vpp-api/vpe_all_api_h.h>
-#undef vl_printfun
-
-#ifndef VPPJNI_DEBUG
-#define VPPJNI_DEBUG 0
-#endif
-
-#if VPPJNI_DEBUG == 1
-  #define DEBUG_LOG(...) clib_warning(__VA_ARGS__)
-#else
-  #define DEBUG_LOG(...)
-#endif
-
-static int connect_to_vpe(char *name);
-
-/*
- * The Java runtime isn't compile w/ -fstack-protector,
- * so we have to supply missing external references for the
- * regular vpp libraries. Weak reference in case folks get religion
- * at a later date...
- */
-void __stack_chk_guard (void) __attribute__((weak));
-void __stack_chk_guard (void) {  }
-
-BIND_JAPI_CLASS(vppBridgeDomainDetails, "()V");
-BIND_JAPI_BOOL_FIELD(vppBridgeDomainDetails, arpTerm);
-BIND_JAPI_BOOL_FIELD(vppBridgeDomainDetails, flood);
-BIND_JAPI_BOOL_FIELD(vppBridgeDomainDetails, forward);
-BIND_JAPI_BOOL_FIELD(vppBridgeDomainDetails, learn);
-BIND_JAPI_BOOL_FIELD(vppBridgeDomainDetails, uuFlood);
-BIND_JAPI_INT_FIELD(vppBridgeDomainDetails, bdId);
-BIND_JAPI_STRING_FIELD(vppBridgeDomainDetails, name);
-BIND_JAPI_STRING_FIELD(vppBridgeDomainDetails, bviInterfaceName);
-BIND_JAPI_OBJ_FIELD(vppBridgeDomainDetails, interfaces, "[Lorg/openvpp/vppjapi/vppBridgeDomainInterfaceDetails;");
-
-BIND_JAPI_CLASS(vppBridgeDomainInterfaceDetails, "()V");
-BIND_JAPI_BYTE_FIELD(vppBridgeDomainInterfaceDetails, splitHorizonGroup);
-BIND_JAPI_STRING_FIELD(vppBridgeDomainInterfaceDetails, interfaceName);
-
-BIND_JAPI_CLASS(vppInterfaceCounters, "(JJJJJJJJJJJJJJJJJJJJJJ)V");
-BIND_JAPI_CLASS(vppInterfaceDetails, "(ILjava/lang/String;I[BBBBBIBBIIBBBBIIIII)V");
-BIND_JAPI_CLASS(vppIPv4Address, "(IB)V");
-BIND_JAPI_CLASS(vppIPv6Address, "([BB)V");
-BIND_JAPI_CLASS(vppL2Fib, "([BZLjava/lang/String;ZZ)V");
-BIND_JAPI_CLASS(vppVersion, "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
-BIND_JAPI_CLASS(vppVxlanTunnelDetails, "(IIIII)V");
-
-void vl_client_add_api_signatures (vl_api_memclnt_create_t *mp)
-{
-    /*
-     * Send the main API signature in slot 0. This bit of code must
-     * match the checks in ../vpe/api/api.c: vl_msg_api_version_check().
-     */
-    mp->api_versions[0] = clib_host_to_net_u32 (vpe_api_version);
-}
-
-/* Note: non-static, called once to set up the initial intfc table */
-static int sw_interface_dump (vppjni_main_t * jm)
-{
-    vl_api_sw_interface_dump_t *mp;
-    f64 timeout;
-    hash_pair_t * p;
-    name_sort_t * nses = 0, * ns;
-    sw_interface_subif_t * sub = NULL;
-
-    /* Toss the old name table */
-    hash_foreach_pair (p, jm->sw_if_index_by_interface_name,
-    ({
-        vec_add2 (nses, ns, 1);
-        ns->name = (u8 *)(p->key);
-        ns->value = (u32) p->value[0];
-    }));
-
-    hash_free (jm->sw_if_index_by_interface_name);
-
-    vec_foreach (ns, nses)
-        vec_free (ns->name);
-
-    vec_free (nses);
-
-    vec_foreach (sub, jm->sw_if_subif_table) {
-        vec_free (sub->interface_name);
-    }
-    vec_free (jm->sw_if_subif_table);
-
-    /* recreate the interface name hash table */
-    jm->sw_if_index_by_interface_name
-      = hash_create_string (0, sizeof(uword));
-
-    /* Get list of ethernets */
-    M(SW_INTERFACE_DUMP, sw_interface_dump);
-    mp->name_filter_valid = 1;
-    strncpy ((char *) mp->name_filter, "Ether", sizeof(mp->name_filter)-1);
-    S;
-
-    /* and local / loopback interfaces */
-    M(SW_INTERFACE_DUMP, sw_interface_dump);
-    mp->name_filter_valid = 1;
-    strncpy ((char *) mp->name_filter, "lo", sizeof(mp->name_filter)-1);
-    S;
-
-    /* and vxlan tunnel interfaces */
-    M(SW_INTERFACE_DUMP, sw_interface_dump);
-    mp->name_filter_valid = 1;
-    strncpy ((char *) mp->name_filter, "vxlan", sizeof(mp->name_filter)-1);
-    S;
-
-    /* and tap tunnel interfaces */
-    M(SW_INTERFACE_DUMP, sw_interface_dump);
-    mp->name_filter_valid = 1;
-    strncpy ((char *) mp->name_filter, "tap", sizeof(mp->name_filter)-1);
-    S;
-
-    /* and host (af_packet) interfaces */
-    M(SW_INTERFACE_DUMP, sw_interface_dump);
-    mp->name_filter_valid = 1;
-    strncpy ((char *) mp->name_filter, "host", sizeof(mp->name_filter)-1);
-    S;
-
-    /* and l2tpv3 tunnel interfaces */
-    M(SW_INTERFACE_DUMP, sw_interface_dump);
-    mp->name_filter_valid = 1;
-    strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
-             sizeof(mp->name_filter)-1);
-    S;
-
-    /* Use a control ping for synchronization */
-    {
-        vl_api_control_ping_t * mp;
-        M(CONTROL_PING, control_ping);
-        S;
-    }
-    W;
-}
-
-JNIEXPORT jobject JNICALL Java_org_openvpp_vppjapi_vppConn_getVppVersion0
-  (JNIEnv *env, jobject obj)
-{
-    vppjni_main_t * jm = &vppjni_main;
-
-    vppjni_lock (jm, 11);
-    jstring progName = (*env)->NewStringUTF(env, (char *)jm->program_name);
-    jstring buildDir = (*env)->NewStringUTF(env, (char *)jm->build_directory);
-    jstring version = (*env)->NewStringUTF(env, (char *)jm->version);
-    jstring buildDate = (*env)->NewStringUTF(env, (char *)jm->build_date);
-    vppjni_unlock (jm);
-
-    return vppVersionObject(env, progName, buildDir, version, buildDate);
-}
-
-static int jm_show_version (vppjni_main_t *jm)
-{
-    int rv;
-    vl_api_show_version_t *mp;
-    f64 timeout;
-
-    vppjni_lock (jm, 10);
-    M(SHOW_VERSION, show_version);
-
-    S;
-    vppjni_unlock (jm);
-    WNR;
-    return rv;
-}
-
-static int jm_stats_enable_disable (vppjni_main_t *jm, u8 enable)
-{
-    vl_api_want_stats_t * mp;
-    f64 timeout;
-    int rv;
-
-    vppjni_lock (jm, 13);
-
-    M(WANT_STATS, want_stats);
-
-    mp->enable_disable = enable;
-
-    S;
-    vppjni_unlock (jm);
-    WNR;
-
-    // already subscribed / already disabled (it's ok)
-    if (rv == -2 || rv == -3)
-        rv = 0;
-    return rv;
-}
-
-JNIEXPORT jint JNICALL Java_org_openvpp_vppjapi_vppConn_setInterfaceDescription0
-  (JNIEnv *env, jobject obj, jstring ifName, jstring ifDesc)
-{
-    int rv = 0;
-    vppjni_main_t * jm = &vppjni_main;
-    uword * p;
-    u32 sw_if_index = ~0;
-    sw_if_config_t *cfg;
-
-    const char *if_name_str = (*env)->GetStringUTFChars (env, ifName, 0);
-    const char *if_desc_str = (*env)->GetStringUTFChars (env, ifDesc, 0);
-
-    vppjni_lock (jm, 23);
-
-    p = hash_get_mem (jm->sw_if_index_by_interface_name, if_name_str);
-    if (p == 0) {
-        rv = -1;
-        goto out;
-    }
-    sw_if_index = (jint) p[0];
-
-    u8 *if_desc = 0;
-    vec_validate_init_c_string (if_desc, if_desc_str, strlen(if_desc_str));
-    (*env)->ReleaseStringUTFChars (env, ifDesc, if_desc_str);
-
-    p = hash_get (jm->sw_if_config_by_sw_if_index, sw_if_index);
-    if (p != 0) {
-        cfg = (sw_if_config_t *) (p[0]);
-        if (cfg->desc)
-            vec_free(cfg->desc);
-    } else {
-        cfg = (sw_if_config_t *) clib_mem_alloc(sizeof(sw_if_config_t));
-        hash_set (jm->sw_if_config_by_sw_if_index, sw_if_index, cfg);
-    }
-
-    cfg->desc = if_desc;
-
-out:
-    (*env)->ReleaseStringUTFChars (env, ifName, if_name_str);
-    vppjni_unlock (jm);
-    return rv;
-}
-
-JNIEXPORT jstring JNICALL Java_org_openvpp_vppjapi_vppConn_getInterfaceDescription0
-(JNIEnv * env, jobject obj, jstring ifName)
-{
-    vppjni_main_t * jm = &vppjni_main;
-    u32 sw_if_index = ~0;
-    uword * p;
-    jstring ifDesc = NULL;
-    const char *if_name_str = (*env)->GetStringUTFChars (env, ifName, 0);
-    if (!if_name_str)
-        return NULL;
-
-    vppjni_lock (jm, 24);
-    p = hash_get_mem (jm->sw_if_index_by_interface_name, if_name_str);
-    if (p == 0)
-        goto out;
-
-    sw_if_index = (jint) p[0];
-
-    p = hash_get (jm->sw_if_config_by_sw_if_index, sw_if_index);
-    if (p == 0)
-        goto out;
-
-    sw_if_config_t *cfg = (sw_if_config_t *) (p[0]);
-    u8 * s = format (0, "%s%c", cfg->desc, 0);
-    ifDesc = (*env)->NewStringUTF(env, (char *)s);
-
-out:
-    vppjni_unlock (jm);
-
-    return ifDesc;
-}
-
-JNIEXPORT jint JNICALL Java_org_openvpp_vppjapi_vppConn_clientConnect
-  (JNIEnv *env, jobject obj, jstring clientName)
-{
-    int rv;
-    const char *client_name;
-    void vl_msg_reply_handler_hookup(void);
-    vppjni_main_t * jm = &vppjni_main;
-    api_main_t * am = &api_main;
-    u8 * heap;
-    mheap_t * h;
-    f64 timeout;
-
-    /*
-     * Bail out now if we're not running as root
-     */
-    if (geteuid() != 0)
-        return -1;
-
-    if (jm->is_connected)
-        return -2;
-
-    client_name = (*env)->GetStringUTFChars(env, clientName, 0);
-    if (!client_name)
-        return -3;
-
-    if (jm->heap == 0)
-        clib_mem_init (0, 128<<20);
-
-    heap = clib_mem_get_per_cpu_heap();
-    h = mheap_header (heap);
-
-    clib_time_init (&jm->clib_time);
-
-    rv = connect_to_vpe ((char *) client_name);
-
-    if (rv < 0)
-        clib_warning ("connection failed, rv %d", rv);
-
-    (*env)->ReleaseStringUTFChars (env, clientName, client_name);
-
-    if (rv == 0) {
-        vl_msg_reply_handler_hookup ();
-        jm->is_connected = 1;
-        /* make the main heap thread-safe */
-        h->flags |= MHEAP_FLAG_THREAD_SAFE;
-
-        jm->reply_hash = hash_create (0, sizeof (uword));
-        //jm->callback_hash = hash_create (0, sizeof (uword));
-        //jm->ping_hash = hash_create (0, sizeof (uword));
-        jm->api_main = am;
-        vjbd_main_init(&jm->vjbd_main);
-        jm->sw_if_index_by_interface_name =
-            hash_create_string (0, sizeof (uword));
-        jm->sw_if_config_by_sw_if_index =
-            hash_create (0, sizeof (uword));
-
-        {
-            // call control ping first to attach rx thread to java thread
-            vl_api_control_ping_t * mp;
-            M(CONTROL_PING, control_ping);
-            S;
-            WNR;
-
-            if (rv != 0) {
-                clib_warning ("first control ping failed: %d", rv);
-            }
-        }
-        rv = jm_show_version(jm);
-        if (rv != 0)
-            clib_warning ("unable to retrieve vpp version (rv: %d)", rv);
-        rv = sw_interface_dump(jm);
-        if (rv != 0)
-            clib_warning ("unable to retrieve interface list (rv: %d)", rv);
-        rv = jm_stats_enable_disable(jm, 1);
-        if (rv != 0)
-            clib_warning ("unable to subscribe to stats (rv: %d)", rv);
-    }
-    DEBUG_LOG ("clientConnect result: %d", rv);
-
-    return rv;
-}
-
-JNIEXPORT void JNICALL Java_org_openvpp_vppjapi_vppConn_clientDisconnect
-  (JNIEnv *env, jobject obj)
-{
-    u8 *save_heap;
-    vppjni_main_t * jm = &vppjni_main;
-    vl_client_disconnect_from_vlib();
-
-    save_heap = jm->heap;
-    memset (jm, 0, sizeof (*jm));
-    jm->heap = save_heap;
-}
-
-void vl_api_generic_reply_handler (vl_api_generic_reply_t *mp)
-{
-    api_main_t * am = &api_main;
-    u16 msg_id = clib_net_to_host_u16 (mp->_vl_msg_id);
-    trace_cfg_t *cfgp;
-    i32 retval = clib_net_to_host_u32 (mp->retval);
-    int total_bytes = sizeof(mp);
-    vppjni_main_t * jm = &vppjni_main;
-    u8 * saved_reply = 0;
-    u32 context = clib_host_to_net_u32 (mp->context);
-
-    cfgp = am->api_trace_cfg + msg_id;
-
-    if (!cfgp)
-        clib_warning ("msg id %d: no trace configuration\n", msg_id);
-    else
-        total_bytes = cfgp->size;
-
-    jm->context_id_received = context;
-
-    DEBUG_LOG ("Received generic reply for msg id %d", msg_id);
-
-    /* A generic reply, successful, we're done */
-    if (retval >= 0 && total_bytes == sizeof(*mp))
-        return;
-
-    /* Save the reply */
-    vec_validate (saved_reply, total_bytes - 1);
-    clib_memcpy (saved_reply, mp, total_bytes);
-
-    vppjni_lock (jm, 2);
-    hash_set (jm->reply_hash, context, saved_reply);
-    jm->saved_reply_count ++;
-    vppjni_unlock (jm);
-}
-
-JNIEXPORT jint JNICALL Java_org_openvpp_vppjapi_vppConn_getRetval0
-(JNIEnv * env, jobject obj, jint context, jint release)
-{
-    vppjni_main_t * jm = &vppjni_main;
-    vl_api_generic_reply_t * mp;
-    uword * p;
-    int rv = 0;
-
-    /* Dunno yet? */
-    if (context > jm->context_id_received)
-        return (VNET_API_ERROR_RESPONSE_NOT_READY);
-
-    vppjni_lock (jm, 1);
-    p = hash_get (jm->reply_hash, context);
-
-    /*
-     * Two cases: a generic "yes" reply - won't be in the hash table
-     * or "no", or "more data" which will be in the table.
-     */
-    if (p == 0)
-        goto out;
-
-    mp = (vl_api_generic_reply_t *) (p[0]);
-    rv = clib_net_to_host_u32 (mp->retval);
-
-    if (release) {
-        u8 * free_me = (u8 *) mp;
-        vec_free (free_me);
-        hash_unset (jm->reply_hash, context);
-        jm->saved_reply_count --;
-    }
-
-out:
-    vppjni_unlock (jm);
-    return (rv);
-}
-
-static int
-name_sort_cmp (void * a1, void * a2)
-{
-    name_sort_t * n1 = a1;
-    name_sort_t * n2 = a2;
-
-    return strcmp ((char *)n1->name, (char *)n2->name);
-}
-
-JNIEXPORT jstring JNICALL Java_org_openvpp_vppjapi_vppConn_getInterfaceList0
-  (JNIEnv * env, jobject obj, jstring name_filter)
-{
-    vppjni_main_t * jm = &vppjni_main;
-    jstring rv;
-    hash_pair_t * p;
-    name_sort_t * nses = 0, * ns;
-    const char *this_name;
-    u8 * s = 0;
-    const char * nf = (*env)->GetStringUTFChars (env, name_filter, NULL);
-    if (!nf)
-        return NULL;
-
-    vppjni_lock (jm, 4);
-
-    hash_foreach_pair (p, jm->sw_if_index_by_interface_name,
-            ({
-                this_name = (const char *)(p->key);
-                if (strlen (nf) == 0 || strcasestr (this_name, nf)) {
-                    vec_add2 (nses, ns, 1);
-                    ns->name = (u8 *)(p->key);
-                    ns->value = (u32) p->value[0];
-                }
-            }));
-
-    vec_sort_with_function (nses, name_sort_cmp);
-
-    vec_foreach (ns, nses)
-        s = format (s, "%s: %d, ", ns->name, ns->value);
-
-    _vec_len (s) = vec_len (s) - 2;
-    vec_terminate_c_string (s);
-    vppjni_unlock (jm);
-
-    vec_free (nses);
-
-    (*env)->ReleaseStringUTFChars (env, name_filter, nf);
-
-    rv = (*env)->NewStringUTF (env, (char *) s);
-    vec_free (s);
-
-    return rv;
-}
-
-JNIEXPORT jint JNICALL Java_org_openvpp_vppjapi_vppConn_swIfIndexFromName0
-  (JNIEnv * env, jobject obj, jstring interfaceName)
-{
-    vppjni_main_t * jm = &vppjni_main;
-    jint rv = -1;
-    const char * if_name = (*env)->GetStringUTFChars (env, interfaceName, NULL);
-    if (if_name) {
-        uword * p;
-
-        vppjni_lock (jm, 5);
-
-        p = hash_get_mem (jm->sw_if_index_by_interface_name, if_name);
-
-        if (p != 0)
-            rv = (jint) p[0];
-
-        vppjni_unlock (jm);
-
-        (*env)->ReleaseStringUTFChars (env, interfaceName, if_name);
-    }
-
-    return rv;
-}
-
-JNIEXPORT jobject JNICALL Java_org_openvpp_vppjapi_vppConn_getInterfaceCounters0
-(JNIEnv * env, jobject obj, jint swIfIndex)
-{
-    vppjni_main_t * jm = &vppjni_main;
-    sw_interface_stats_t *s;
-    u32 sw_if_index = swIfIndex;
-    jobject result = NULL;
-
-    vppjni_lock (jm, 16);
-
-    if (sw_if_index >= vec_len(jm->sw_if_stats_by_sw_if_index)) {
-        goto out;
-    }
-    s = &jm->sw_if_stats_by_sw_if_index[sw_if_index];
-    if (!s->valid) {
-        goto out;
-    }
-
-    result = vppInterfaceCountersObject(env,
-            s->rx.octets, s->rx.pkts.ip4, s->rx.pkts.ip6, s->rx.pkts.unicast,
-            s->rx.pkts.multicast, s->rx.pkts.broadcast, s->rx.pkts.discard,
-            s->rx.pkts.fifo_full, s->rx.pkts.error, s->rx.pkts.unknown_proto,
-            s->rx.pkts.miss,
-            s->tx.octets, s->tx.pkts.ip4, s->tx.pkts.ip6, s->tx.pkts.unicast,
-            s->tx.pkts.multicast, s->tx.pkts.broadcast, s->tx.pkts.discard,
-            s->tx.pkts.fifo_full, s->tx.pkts.error, s->tx.pkts.unknown_proto,
-            s->tx.pkts.miss);
-
-out:
-    vppjni_unlock (jm);
-    return result;
-}
-
-JNIEXPORT jstring JNICALL Java_org_openvpp_vppjapi_vppConn_interfaceNameFromSwIfIndex0
-(JNIEnv * env, jobject obj, jint swIfIndex)
-{
-    vppjni_main_t * jm = &vppjni_main;
-    sw_interface_details_t *sw_if_details;
-    u32 sw_if_index;
-    jstring ifname = NULL;
-
-    vppjni_lock (jm, 8);
-
-    sw_if_index = swIfIndex;
-
-    if (sw_if_index >= vec_len(jm->sw_if_table)) {
-        goto out;
-    }
-    sw_if_details = &jm->sw_if_table[sw_if_index];
-    if (!sw_if_details->valid) {
-        goto out;
-    }
-
-    u8 * s = format (0, "%s%c", sw_if_details->interface_name, 0);
-    ifname = (*env)->NewStringUTF(env, (char *)s);
-
-out:
-    vppjni_unlock (jm);
-
-    return ifname;
-}
-
-JNIEXPORT void JNICALL Java_org_openvpp_vppjapi_vppConn_clearInterfaceTable0
-(JNIEnv * env, jobject obj)
-{
-    vppjni_main_t * jm = &vppjni_main;
-
-    vppjni_lock (jm, 21);
-
-    vec_reset_length(jm->sw_if_table);
-
-    vppjni_unlock (jm);
-}
-
-static jobjectArray sw_if_dump_get_interfaces ();
-
-JNIEXPORT jobjectArray JNICALL Java_org_openvpp_vppjapi_vppConn_swInterfaceDump0
-(JNIEnv * env, jobject obj, jbyte name_filter_valid, jbyteArray name_filter)
-{
-    vppjni_main_t *jm = &vppjni_main;
-    f64 timeout;
-    vl_api_sw_interface_dump_t * mp;
-    u32 my_context_id;
-    int rv;
-    rv = vppjni_sanity_check (jm);
-    if (rv) {
-        clib_warning("swInterfaceDump sanity_check rv = %d", rv);
-        return NULL;
-    }
-
-    vppjni_lock (jm, 7);
-    my_context_id = vppjni_get_context_id (jm);
-    jsize cnt = (*env)->GetArrayLength (env, name_filter);
-
-    M(SW_INTERFACE_DUMP, sw_interface_dump);
-    mp->context = clib_host_to_net_u32 (my_context_id);
-    mp->name_filter_valid = name_filter_valid;
-
-    if (cnt > sizeof(mp->name_filter))
-        cnt = sizeof(mp->name_filter);
-
-    (*env)->GetByteArrayRegion(env, name_filter, 0, cnt, (jbyte *)mp->name_filter);
-
-    DEBUG_LOG ("interface filter (%d, %s, len: %d)", mp->name_filter_valid, (char *)mp->name_filter, cnt);
-
-    jm->collect_indices = 1;
-
-    S;
-    {
-        // now send control ping so we know when it ends
-        vl_api_control_ping_t * mp;
-        M(CONTROL_PING, control_ping);
-        mp->context = clib_host_to_net_u32 (my_context_id);
-
-        S;
-    }
-    vppjni_unlock (jm);
-    WNR;
-
-    vppjni_lock (jm, 7);
-    jobjectArray result = sw_if_dump_get_interfaces(env);
-    vppjni_unlock (jm);
-    return result;
-}
-
-static jobjectArray sw_if_dump_get_interfaces (JNIEnv * env)
-{
-    vppjni_main_t * jm = &vppjni_main;
-    sw_interface_details_t *sw_if_details;
-    u32 i;
-
-    int len = vec_len(jm->sw_if_dump_if_indices);
-
-    jobjectArray ifArray = vppInterfaceDetailsArray(env, len);
-
-    for (i = 0; i < len; i++) {
-        u32 sw_if_index = jm->sw_if_dump_if_indices[i];
-        ASSERT(sw_if_index < vec_len(jm->sw_if_table));
-        sw_if_details = &jm->sw_if_table[sw_if_index];
-        ASSERT(sw_if_details->valid);
-
-        u8 * s = format (0, "%s%c", sw_if_details->interface_name, 0);
-
-        jstring ifname = (*env)->NewStringUTF(env, (char *)s);
-        jint ifIndex = sw_if_details->sw_if_index;
-        jint supIfIndex = sw_if_details->sup_sw_if_index;
-        jbyteArray physAddr = (*env)->NewByteArray(env,
-                sw_if_details->l2_address_length);
-        (*env)->SetByteArrayRegion(env, physAddr, 0,
-                sw_if_details->l2_address_length,
-                (signed char*)sw_if_details->l2_address);
-        jint subId = sw_if_details->sub_id;
-        jint subOuterVlanId = sw_if_details->sub_outer_vlan_id;
-        jint subInnerVlanId = sw_if_details->sub_inner_vlan_id;
-        jint vtrOp = sw_if_details->vtr_op;
-        jint vtrPushDot1q = sw_if_details->vtr_push_dot1q;
-        jint vtrTag1 = sw_if_details->vtr_tag1;
-        jint vtrTag2 = sw_if_details->vtr_tag2;
-        jint linkMtu = sw_if_details->link_mtu;
-
-        jbyte adminUpDown = sw_if_details->admin_up_down;
-        jbyte linkUpDown = sw_if_details->link_up_down;
-        jbyte linkDuplex = sw_if_details->link_duplex;
-        jbyte linkSpeed = sw_if_details->link_speed;
-        jbyte subDot1ad = sw_if_details->sub_dot1ad;
-        jbyte subNumberOfTags = sw_if_details->sub_number_of_tags;
-        jbyte subExactMatch = sw_if_details->sub_exact_match;
-        jbyte subDefault = sw_if_details->sub_default;
-        jbyte subOuterVlanIdAny = sw_if_details->sub_outer_vlan_id_any;
-        jbyte subInnerVlanIdAny = sw_if_details->sub_inner_vlan_id_any;
-
-        jobject ifObj = vppInterfaceDetailsObject(env,
-                ifIndex, ifname,
-                supIfIndex, physAddr, adminUpDown, linkUpDown,
-                linkDuplex, linkSpeed, subId, subDot1ad,
-                subNumberOfTags, subOuterVlanId, subInnerVlanId,
-                subExactMatch, subDefault, subOuterVlanIdAny,
-                subInnerVlanIdAny, vtrOp, vtrPushDot1q, vtrTag1, vtrTag2, linkMtu);
-        (*env)->SetObjectArrayElement(env, ifArray, i, ifObj);
-    }
-
-    jm->collect_indices = 0;
-    vec_reset_length(jm->sw_if_dump_if_indices);
-    return ifArray;
-}
-
-JNIEXPORT jint JNICALL Java_org_openvpp_vppjapi_vppConn_findOrAddBridgeDomainId0
-  (JNIEnv * env, jobject obj, jstring bridgeDomain)
-{
-    vppjni_main_t * jm = &vppjni_main;
-    jint rv = -1;
-    const char * bdName = (*env)->GetStringUTFChars (env, bridgeDomain, NULL);
-    if (bdName) {
-        static u8 * bd_name = 0;
-
-        vec_validate_init_c_string (bd_name, bdName, strlen(bdName));
-        (*env)->ReleaseStringUTFChars (env, bridgeDomain, bdName);
-
-        vppjni_lock (jm, 6);
-        rv = (jint)vjbd_find_or_add_bd (&jm->vjbd_main, bd_name);
-        vppjni_unlock (jm);
-
-        _vec_len(bd_name) = 0;
-    }
-    return rv;
-}
-
-JNIEXPORT jint JNICALL Java_org_openvpp_vppjapi_vppConn_bridgeDomainIdFromName0
-  (JNIEnv * env, jobject obj, jstring bridgeDomain)
-{
-    vppjni_main_t * jm = &vppjni_main;
-    jint rv = -1;
-    const char * bdName = (*env)->GetStringUTFChars (env, bridgeDomain, NULL);
-    if (bdName) {
-        static u8 * bd_name = 0;
-
-        vec_validate_init_c_string (bd_name, bdName, strlen(bdName));
-        (*env)->ReleaseStringUTFChars (env, bridgeDomain, bdName);
-
-        vppjni_lock (jm, 20);
-        rv = (jint)vjbd_id_from_name(&jm->vjbd_main, (u8 *)bd_name);
-        vppjni_unlock (jm);
-
-        _vec_len(bd_name) = 0;
-    }
-
-    return rv;
-}
-
-JNIEXPORT jint JNICALL Java_org_openvpp_vppjapi_vppConn_bridgeDomainIdFromInterfaceName0
-  (JNIEnv * env, jobject obj, jstring interfaceName)
-{
-    vppjni_main_t * jm = &vppjni_main;
-    vjbd_main_t * bdm = &jm->vjbd_main;
-    u32 sw_if_index;
-    jint rv = -1;
-    const char * if_name;
-    uword * p;
-
-    if_name = (*env)->GetStringUTFChars (env, interfaceName, NULL);
-
-    vppjni_lock (jm, 14);
-
-    p = hash_get_mem (jm->sw_if_index_by_interface_name, if_name);
-
-    if (p != 0) {
-        sw_if_index = (jint) p[0];
-        p = hash_get (bdm->bd_id_by_sw_if_index, sw_if_index);
-        if (p != 0) {
-            rv = (jint) p[0];
-        }
-    }
-
-    vppjni_unlock (jm);
-
-    (*env)->ReleaseStringUTFChars (env, interfaceName, if_name);
-
-    return rv;
-}
-
-/*
- * Special-case: build the interface table, maintain
- * the next loopback sw_if_index vbl.
- */
-static void vl_api_sw_interface_details_t_handler
-(vl_api_sw_interface_details_t * mp)
-{
-    vppjni_main_t * jm = &vppjni_main;
-    static sw_interface_details_t empty_sw_if_details = {0,};
-    sw_interface_details_t *sw_if_details;
-    u32 sw_if_index;
-
-    vppjni_lock (jm, 1);
-
-    sw_if_index = ntohl (mp->sw_if_index);
-
-    u8 * s = format (0, "%s%c", mp->interface_name, 0);
-
-    if (jm->collect_indices) {
-        u32 pos = vec_len(jm->sw_if_dump_if_indices);
-        vec_validate(jm->sw_if_dump_if_indices, pos);
-        jm->sw_if_dump_if_indices[pos] = sw_if_index;
-    }
-
-    vec_validate_init_empty(jm->sw_if_table, sw_if_index, empty_sw_if_details);
-    sw_if_details = &jm->sw_if_table[sw_if_index];
-    sw_if_details->valid = 1;
-
-    snprintf((char *)sw_if_details->interface_name,
-            sizeof(sw_if_details->interface_name), "%s", (char *)s);
-    sw_if_details->sw_if_index = sw_if_index;
-    sw_if_details->sup_sw_if_index = ntohl(mp->sup_sw_if_index);
-    sw_if_details->l2_address_length = ntohl (mp->l2_address_length);
-    ASSERT(sw_if_details->l2_address_length <= sizeof(sw_if_details->l2_address));
-    clib_memcpy(sw_if_details->l2_address, mp->l2_address,
-            sw_if_details->l2_address_length);
-    sw_if_details->sub_id = ntohl (mp->sub_id);
-    sw_if_details->sub_outer_vlan_id = ntohl (mp->sub_outer_vlan_id);
-    sw_if_details->sub_inner_vlan_id = ntohl (mp->sub_inner_vlan_id);
-    sw_if_details->vtr_op = ntohl (mp->vtr_op);
-    sw_if_details->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
-    sw_if_details->vtr_tag1 = ntohl (mp->vtr_tag1);
-    sw_if_details->vtr_tag2 = ntohl (mp->vtr_tag2);
-
-    sw_if_details->admin_up_down = mp->admin_up_down;
-    sw_if_details->link_up_down = mp->link_up_down;
-    sw_if_details->link_duplex = mp->link_duplex;
-    sw_if_details->link_speed = mp->link_speed;
-    sw_if_details->sub_dot1ad = mp->sub_dot1ad;
-    sw_if_details->sub_number_of_tags = mp->sub_number_of_tags;
-    sw_if_details->sub_exact_match = mp->sub_exact_match;
-    sw_if_details->sub_default = mp->sub_default;
-    sw_if_details->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any;
-    sw_if_details->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any;
-
-    hash_set_mem (jm->sw_if_index_by_interface_name, s, sw_if_index);
-    DEBUG_LOG ("Got interface %s", (char *)s);
-
-    /* In sub interface case, fill the sub interface table entry */
-    if (mp->sw_if_index != mp->sup_sw_if_index) {
-        sw_interface_subif_t * sub = NULL;
-
-        vec_add2(jm->sw_if_subif_table, sub, 1);
-
-        vec_validate(sub->interface_name, strlen((char *)s) + 1);
-        strncpy((char *)sub->interface_name, (char *)s,
-                vec_len(sub->interface_name));
-        sub->sw_if_index = ntohl(mp->sw_if_index);
-        sub->sub_id = ntohl(mp->sub_id);
-
-        sub->sub_dot1ad = mp->sub_dot1ad;
-        sub->sub_number_of_tags = mp->sub_number_of_tags;
-        sub->sub_outer_vlan_id = ntohs(mp->sub_outer_vlan_id);
-        sub->sub_inner_vlan_id = ntohs(mp->sub_inner_vlan_id);
-        sub->sub_exact_match = mp->sub_exact_match;
-        sub->sub_default = mp->sub_default;
-        sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any;
-        sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any;
-
-        /* vlan tag rewrite */
-        sub->vtr_op = ntohl(mp->vtr_op);
-        sub->vtr_push_dot1q = ntohl(mp->vtr_push_dot1q);
-        sub->vtr_tag1 = ntohl(mp->vtr_tag1);
-        sub->vtr_tag2 = ntohl(mp->vtr_tag2);
-    }
-    vppjni_unlock (jm);
-}
-
-static void vl_api_sw_interface_set_flags_t_handler
-(vl_api_sw_interface_set_flags_t * mp)
-{
-  /* $$$ nothing for the moment */
-}
-
-static jintArray create_array_of_bd_ids(JNIEnv * env, jint bd_id)
-{
-    vppjni_main_t *jm = &vppjni_main;
-    vjbd_main_t * bdm = &jm->vjbd_main;
-    u32 *buf = NULL;
-    u32 i;
-
-    if (bd_id != ~0) {
-        vec_add1(buf, bd_id);
-    } else {
-        for (i = 0; i < vec_len(bdm->bd_oper); i++) {
-            u32 bd_id = bdm->bd_oper[i].bd_id;
-            vec_add1(buf, bd_id);
-        }
-    }
-
-    jintArray bdidArray = (*env)->NewIntArray(env, vec_len(buf));
-    if (!bdidArray) {
-        goto out;
-    }
-
-    (*env)->SetIntArrayRegion(env, bdidArray, 0, vec_len(buf), (int*)buf);
-
-out:
-    vec_free(buf);
-    return bdidArray;
-}
-
-static void bridge_domain_oper_free(void)
-{
-    vppjni_main_t *jm = &vppjni_main;
-    vjbd_main_t *bdm = &jm->vjbd_main;
-    u32 i;
-
-    for (i = 0; i < vec_len(bdm->bd_oper); i++) {
-        vec_free(bdm->bd_oper->l2fib_oper);
-    }
-    vec_reset_length(bdm->bd_oper);
-    hash_free(bdm->bd_id_by_sw_if_index);
-    hash_free(bdm->oper_bd_index_by_bd_id);
-}
-
-JNIEXPORT jintArray JNICALL Java_org_openvpp_vppjapi_vppConn_bridgeDomainDump0
-(JNIEnv * env, jobject obj, jint bd_id)
-{
-    vppjni_main_t *jm = &vppjni_main;
-    vl_api_bridge_domain_dump_t * mp;
-    u32 my_context_id;
-    f64 timeout;
-    int rv;
-    rv = vppjni_sanity_check (jm);
-    if (rv) return NULL;
-
-    vppjni_lock (jm, 15);
-
-    if (~0 == bd_id) {
-        bridge_domain_oper_free();
-    }
-
-    my_context_id = vppjni_get_context_id (jm);
-    M(BRIDGE_DOMAIN_DUMP, bridge_domain_dump);
-    mp->context = clib_host_to_net_u32 (my_context_id);
-    mp->bd_id = clib_host_to_net_u32(bd_id);
-    S;
-
-    /* Use a control ping for synchronization */
-    {
-        vl_api_control_ping_t * mp;
-        M(CONTROL_PING, control_ping);
-        S;
-    }
-
-    WNR;
-    if (0 != rv) {
-        return NULL;
-    }
-
-    jintArray ret = create_array_of_bd_ids(env, bd_id);
-
-    vppjni_unlock (jm);
-
-    return ret;
-}
-
-static void
-vl_api_bridge_domain_details_t_handler (vl_api_bridge_domain_details_t * mp)
-{
-    vppjni_main_t *jm = &vppjni_main;
-    vjbd_main_t * bdm = &jm->vjbd_main;
-    vjbd_oper_t * bd_oper;
-    u32 bd_id, bd_index;
-
-    bd_id = ntohl (mp->bd_id);
-
-    bd_index = vec_len(bdm->bd_oper);
-    vec_validate (bdm->bd_oper, bd_index);
-    bd_oper = vec_elt_at_index(bdm->bd_oper, bd_index);
-
-    hash_set(bdm->oper_bd_index_by_bd_id, bd_id, bd_index);
-
-    bd_oper->bd_id = bd_id;
-    bd_oper->flood = mp->flood != 0;
-    bd_oper->forward = mp->forward != 0;
-    bd_oper->learn =  mp->learn != 0;
-    bd_oper->uu_flood = mp->uu_flood != 0;
-    bd_oper->arp_term = mp->arp_term != 0;
-    bd_oper->bvi_sw_if_index = ntohl (mp->bvi_sw_if_index);
-    bd_oper->n_sw_ifs = ntohl (mp->n_sw_ifs);
-
-    bd_oper->bd_sw_if_oper = 0;
-}
-
-static void
-vl_api_bridge_domain_sw_if_details_t_handler
-(vl_api_bridge_domain_sw_if_details_t * mp)
-{
-    vppjni_main_t *jm = &vppjni_main;
-    vjbd_main_t * bdm = &jm->vjbd_main;
-    bd_sw_if_oper_t * bd_sw_if_oper;
-    u32 bd_id, sw_if_index;
-
-    bd_id = ntohl (mp->bd_id);
-    sw_if_index = ntohl (mp->sw_if_index);
-
-    uword *p;
-    p = hash_get (bdm->oper_bd_index_by_bd_id, bd_id);
-    if (p == 0) {
-        clib_warning("Invalid bd_id %d in bridge_domain_sw_if_details_t_handler", bd_id);
-        return;
-    }
-    u32 oper_bd_index = (jint) p[0];
-    vjbd_oper_t *bd_oper = vec_elt_at_index(bdm->bd_oper, oper_bd_index);
-
-    u32 len = vec_len(bd_oper->bd_sw_if_oper);
-    vec_validate(bd_oper->bd_sw_if_oper, len);
-    bd_sw_if_oper = &bd_oper->bd_sw_if_oper[len];
-    bd_sw_if_oper->bd_id = bd_id;
-    bd_sw_if_oper->sw_if_index = sw_if_index;
-    bd_sw_if_oper->shg = mp->shg;
-
-    hash_set(bdm->bd_id_by_sw_if_index, sw_if_index, bd_id);
-}
-
-static const char* interface_name_from_sw_if_index(u32 sw_if_index)
-{
-    vppjni_main_t *jm = &vppjni_main;
-
-    if (sw_if_index >= vec_len(jm->sw_if_table)) {
-        return NULL;
-    }
-    if (!jm->sw_if_table[sw_if_index].valid) {
-        return NULL;
-    }
-    return (const char*)jm->sw_if_table[sw_if_index].interface_name;
-}
-
-JNIEXPORT jobject JNICALL Java_org_openvpp_vppjapi_vppConn_getBridgeDomainDetails0
-(JNIEnv * env, jobject obj, jint bdId)
-{
-    vppjni_main_t *jm = &vppjni_main;
-    vjbd_main_t * bdm = &jm->vjbd_main;
-    u32 oper_bd_index;
-    u32 bd_id = bdId;
-    jobject rv = NULL;
-    uword *p;
-
-    vppjni_lock (jm, 16);
-
-    p = hash_get (bdm->oper_bd_index_by_bd_id, bd_id);
-    if (p == 0) {
-        rv = NULL;
-        goto out;
-    }
-    oper_bd_index = (jint) p[0];
-
-    vjbd_oper_t *bd_oper = vec_elt_at_index(bdm->bd_oper, oper_bd_index);
-
-
-    /* setting BridgeDomainDetails */
-
-    jobject bddObj = vppBridgeDomainDetailsObject(env);
-
-    u8 *vec_bd_name = vjbd_oper_name_from_id(bdm, bd_id);
-    if (NULL == vec_bd_name) {
-        rv = NULL;
-        goto out;
-    }
-    char *str_bd_name = (char*)format (0, "%s%c", vec_bd_name, 0);
-    vec_free(vec_bd_name);
-    jstring bdName = (*env)->NewStringUTF(env, str_bd_name);
-    vec_free(str_bd_name);
-    if (NULL == bdName) {
-        rv = NULL;
-        goto out;
-    }
-
-    set_vppBridgeDomainDetails_name(env, bddObj, bdName);
-    set_vppBridgeDomainDetails_bdId(env, bddObj, bdId);
-    set_vppBridgeDomainDetails_flood(env, bddObj, (jboolean)bd_oper->flood);
-    set_vppBridgeDomainDetails_uuFlood(env, bddObj, (jboolean)bd_oper->uu_flood);
-    set_vppBridgeDomainDetails_forward(env, bddObj, (jboolean)bd_oper->forward);
-    set_vppBridgeDomainDetails_learn(env, bddObj, (jboolean)bd_oper->learn);
-    set_vppBridgeDomainDetails_arpTerm(env, bddObj, (jboolean)bd_oper->arp_term);
-
-    jstring bviInterfaceName = NULL;
-    if (~0 != bd_oper->bvi_sw_if_index) {
-        const char *str_if_name = interface_name_from_sw_if_index(bd_oper->bvi_sw_if_index);
-        if (NULL == str_if_name) {
-            clib_warning("Could not get interface name for sw_if_index %d", bd_oper->bvi_sw_if_index);
-            rv = NULL;
-            goto out;
-        }
-        bviInterfaceName = (*env)->NewStringUTF(env, str_if_name);
-        if (NULL == bviInterfaceName) {
-            rv = NULL;
-            goto out;
-        }
-    }
-
-    set_vppBridgeDomainDetails_bviInterfaceName(env, bddObj, bviInterfaceName);
-
-    /* setting BridgeDomainInterfaceDetails */
-
-    u32 len = vec_len(bd_oper->bd_sw_if_oper);
-    ASSERT(len == bd_oper->n_sw_ifs);
-
-    jobjectArray bdidArray = vppBridgeDomainInterfaceDetailsArray(env, len);
-
-    u32 i;
-    for (i = 0; i < len; i++) {
-        bd_sw_if_oper_t *sw_if_oper = &bd_oper->bd_sw_if_oper[i];
-
-        jobject bdidObj = vppBridgeDomainInterfaceDetailsObject(env);
-        (*env)->SetObjectArrayElement(env, bdidArray, i, bdidObj);
-
-        u32 sw_if_index = sw_if_oper->sw_if_index;
-        const char *str_if_name = interface_name_from_sw_if_index(sw_if_index);
-        if (NULL == str_if_name) {
-            rv = NULL;
-            goto out;
-        }
-        jstring interfaceName = (*env)->NewStringUTF(env, str_if_name);
-        if (NULL == interfaceName) {
-            rv = NULL;
-            goto out;
-        }
-
-        set_vppBridgeDomainInterfaceDetails_interfaceName(env, bdidObj, interfaceName);
-        set_vppBridgeDomainInterfaceDetails_splitHorizonGroup(env, bdidObj, (jbyte)sw_if_oper->shg);
-    }
-
-    set_vppBridgeDomainDetails_interfaces(env, bddObj, bdidArray);
-
-    rv = bddObj;
-
-out:
-
-    vppjni_unlock (jm);
-
-    return rv;
-}
-
-static jobject l2_fib_create_object(JNIEnv *env, bd_l2fib_oper_t *l2_fib)
-{
-    u32 sw_if_index = l2_fib->sw_if_index;
-    const char *str_if_name = interface_name_from_sw_if_index(sw_if_index);
-    if (NULL == str_if_name) {
-        return NULL;
-    }
-    jstring interfaceName = (*env)->NewStringUTF(env, str_if_name);
-    if (NULL == interfaceName) {
-        return NULL;
-    }
-
-    jbyteArray physAddr = (*env)->NewByteArray(env, 6);
-    (*env)->SetByteArrayRegion(env, physAddr, 0, 6,
-            (signed char*)l2_fib->mac_addr.fields.mac);
-    jboolean staticConfig = !l2_fib->learned;
-    jstring outgoingInterface = interfaceName;
-    jboolean filter = l2_fib->filter;
-    jboolean bridgedVirtualInterface = l2_fib->bvi;
-
-    return vppL2FibObject(env, physAddr, staticConfig, outgoingInterface, filter, bridgedVirtualInterface);
-}
-
-JNIEXPORT jobjectArray JNICALL Java_org_openvpp_vppjapi_vppConn_l2FibTableDump0
-(JNIEnv * env, jobject obj, jint bd_id)
-{
-    vppjni_main_t *jm = &vppjni_main;
-    vjbd_main_t * bdm = &jm->vjbd_main;
-    vl_api_l2_fib_table_dump_t *mp;
-    jobjectArray l2FibArray = NULL;
-    vjbd_oper_t *bd_oper;
-    u32 oper_bd_index;
-    uword *p;
-    f64 timeout;
-    int rv;
-    u32 i;
-
-    vppjni_lock (jm, 17);
-
-    //vjbd_l2fib_oper_reset (bdm);
-
-    p = hash_get (bdm->oper_bd_index_by_bd_id, bd_id);
-    if (p == 0) {
-        goto done;
-    }
-    oper_bd_index = p[0];
-    bd_oper = vec_elt_at_index(bdm->bd_oper, oper_bd_index);
-    vec_reset_length (bd_oper->l2fib_oper);
-
-    /* Get list of l2 fib table entries */
-    M(L2_FIB_TABLE_DUMP, l2_fib_table_dump);
-    mp->bd_id = ntohl(bd_id);
-    S;
-
-    /* Use a control ping for synchronization */
-    {
-        vl_api_control_ping_t * mp;
-        M(CONTROL_PING, control_ping);
-        S;
-    }
-
-    WNR;
-    if (0 != rv) {
-        goto done;
-    }
-
-    u32 count = vec_len(bd_oper->l2fib_oper);
-    bd_l2fib_oper_t *l2fib_oper = bd_oper->l2fib_oper;
-
-    l2FibArray = vppL2FibArray(env, count);
-    for (i = 0; i < count; i++) {
-        bd_l2fib_oper_t *l2_fib = &l2fib_oper[i];
-        jobject l2FibObj = l2_fib_create_object(env, l2_fib);
-        (*env)->SetObjectArrayElement(env, l2FibArray, i, l2FibObj);
-    }
-
-done:
-    vppjni_unlock (jm);
-
-    return l2FibArray;
-}
-
-static void
-vl_api_l2_fib_table_entry_t_handler (vl_api_l2_fib_table_entry_t * mp)
-{
-    //static u8 * mac_addr;
-    vppjni_main_t *jm = &vppjni_main;
-    vjbd_main_t * bdm = &jm->vjbd_main;
-    vjbd_oper_t * bd_oper;
-    u32 bd_id, oper_bd_index;
-    //uword mhash_val_l2fi;
-    bd_l2fib_oper_t * l2fib_oper;
-    l2fib_u64_mac_t * l2fe_u64_mac = (l2fib_u64_mac_t *)&mp->mac;
-
-    bd_id = ntohl (mp->bd_id);
-
-    uword *p = hash_get (bdm->oper_bd_index_by_bd_id, bd_id);
-    if (p == 0) {
-        return;
-    }
-    oper_bd_index = (jint) p[0];
-    bd_oper = vec_elt_at_index(bdm->bd_oper, oper_bd_index);
-
-#if 0
-    vec_validate (mac_addr, MAC_ADDRESS_SIZE);
-    clib_memcpy (mac_addr, l2fe_u64_mac->fields.mac, MAC_ADDRESS_SIZE);
-    mhash_val_l2fi = vec_len (bd_oper->l2fib_oper);
-    if (mhash_elts (&bd_oper->l2fib_index_by_mac) == 0)
-        mhash_init (&bd_oper->l2fib_index_by_mac, sizeof (u32), MAC_ADDRESS_SIZE);
-    mhash_set_mem (&bd_oper->l2fib_index_by_mac, mac_addr, &mhash_val_l2fi, 0);
-#endif
-
-    vec_add2 (bd_oper->l2fib_oper, l2fib_oper, 1);
-
-    l2fib_oper->bd_id = bd_id;
-    l2fib_oper->mac_addr.raw = l2fib_mac_to_u64 (l2fe_u64_mac->fields.mac);
-    l2fib_oper->sw_if_index = ntohl (mp->sw_if_index);
-    l2fib_oper->learned = !mp->static_mac;
-    l2fib_oper->filter = mp->filter_mac;
-    l2fib_oper->bvi = mp->bvi_mac;
-}
-
-static int ipAddressDump
-(JNIEnv * env, jobject obj, jstring interfaceName, jboolean isIPv6)
-{
-    vppjni_main_t *jm = &vppjni_main;
-    vl_api_ip_address_dump_t * mp;
-    const char *if_name;
-    u32 my_context_id;
-    u32 sw_if_index;
-    f64 timeout;
-    uword *p;
-    int rv = 0;
-
-    if (NULL == interfaceName) {
-        return -1;
-    }
-
-    if_name = (*env)->GetStringUTFChars (env, interfaceName, NULL);
-    if (!if_name) {
-        return -1;
-    }
-
-    p = hash_get_mem (jm->sw_if_index_by_interface_name, if_name);
-    (*env)->ReleaseStringUTFChars (env, interfaceName, if_name);
-    if (p == 0) {
-        return -1;
-    }
-    sw_if_index = (u32) p[0];
-
-    rv = vppjni_sanity_check (jm);
-    if (0 != rv) {
-        return rv;
-    }
-
-    my_context_id = vppjni_get_context_id (jm);
-    M(IP_ADDRESS_DUMP, ip_address_dump);
-    mp->context = clib_host_to_net_u32 (my_context_id);
-    mp->sw_if_index = clib_host_to_net_u32(sw_if_index);
-    mp->is_ipv6 = isIPv6;
-    jm->is_ipv6 = isIPv6;
-    S;
-
-    /* Use a control ping for synchronization */
-    {
-      vl_api_control_ping_t * mp;
-      M(CONTROL_PING, control_ping);
-      S;
-    }
-
-    WNR;
-
-    return rv;
-}
-
-JNIEXPORT jobjectArray JNICALL Java_org_openvpp_vppjapi_vppConn_ipv4AddressDump0
-(JNIEnv * env, jobject obj, jstring interfaceName)
-{
-    vppjni_main_t *jm = &vppjni_main;
-    jobject returnArray = NULL;
-    int i;
-
-    vppjni_lock (jm, 18);
-
-    vec_reset_length(jm->ipv4_addresses);
-
-    if (0 != ipAddressDump(env, obj, interfaceName, 0)) {
-        goto done;
-    }
-
-    u32 count = vec_len(jm->ipv4_addresses);
-    ipv4_address_t *ipv4_address = jm->ipv4_addresses;
-
-    jobjectArray ipv4AddressArray = vppIPv4AddressArray(env, count);
-
-    for (i = 0; i < count; i++) {
-        ipv4_address_t *address = &ipv4_address[i];
-
-        jint ip = address->ip;
-        jbyte prefixLength = address->prefix_length;
-
-        jobject ipv4AddressObj = vppIPv4AddressObject(env, ip, prefixLength);
-
-        (*env)->SetObjectArrayElement(env, ipv4AddressArray, i, ipv4AddressObj);
-    }
-
-    returnArray = ipv4AddressArray;
-
-done:
-    vppjni_unlock (jm);
-    return returnArray;
-}
-
-JNIEXPORT jobjectArray JNICALL Java_org_openvpp_vppjapi_vppConn_ipv6AddressDump0
-(JNIEnv * env, jobject obj, jstring interfaceName)
-{
-    vppjni_main_t *jm = &vppjni_main;
-    jobject returnArray = NULL;
-    int i;
-
-    vppjni_lock (jm, 19);
-
-    vec_reset_length(jm->ipv6_addresses);
-
-    if (0 != ipAddressDump(env, obj, interfaceName, 1)) {
-        goto done;
-    }
-
-    u32 count = vec_len(jm->ipv6_addresses);
-    ipv6_address_t *ipv6_address = jm->ipv6_addresses;
-
-    jobjectArray ipv6AddressArray = vppIPv6AddressArray(env, count);
-
-    for (i = 0; i < count; i++) {
-        ipv6_address_t *address = &ipv6_address[i];
-
-        jbyteArray ip = (*env)->NewByteArray(env, 16);
-        (*env)->SetByteArrayRegion(env, ip, 0, 16,
-                (signed char*)address->ip);
-
-        jbyte prefixLength = address->prefix_length;
-
-        jobject ipv6AddressObj = vppIPv6AddressObject(env, ip, prefixLength);
-
-        (*env)->SetObjectArrayElement(env, ipv6AddressArray, i, ipv6AddressObj);
-    }
-
-    returnArray = ipv6AddressArray;
-
-done:
-    vppjni_unlock (jm);
-    return returnArray;
-}
-
-static void vl_api_ip_address_details_t_handler (vl_api_ip_address_details_t * mp)
-{
-    vppjni_main_t * jm = &vppjni_main;
-
-    if (!jm->is_ipv6) {
-        ipv4_address_t *address = 0;
-        vec_add2(jm->ipv4_addresses, address, 1);
-        clib_memcpy(&address->ip, mp->ip, 4);
-        address->prefix_length = mp->prefix_length;
-    } else {
-        ipv6_address_t *address = 0;
-        vec_add2(jm->ipv6_addresses, address, 1);
-        clib_memcpy(address->ip, mp->ip, 16);
-        address->prefix_length = mp->prefix_length;
-    }
-}
-
-#define VXLAN_TUNNEL_INTERFACE_NAME_PREFIX "vxlan_tunnel"
-
-JNIEXPORT jobjectArray JNICALL Java_org_openvpp_vppjapi_vppConn_vxlanTunnelDump0
-(JNIEnv * env, jobject obj, jint swIfIndex)
-{
-    vppjni_main_t *jm = &vppjni_main;
-    vl_api_vxlan_tunnel_dump_t * mp;
-    jobjectArray returnArray = NULL;
-    u32 my_context_id;
-    f64 timeout;
-    int rv = 0;
-    int i;
-
-    vppjni_lock (jm, 22);
-
-    vec_reset_length(jm->vxlan_tunnel_details);
-
-    my_context_id = vppjni_get_context_id (jm);
-    M(VXLAN_TUNNEL_DUMP, vxlan_tunnel_dump);
-    mp->context = clib_host_to_net_u32 (my_context_id);
-    mp->sw_if_index = clib_host_to_net_u32 (swIfIndex);
-    S;
-
-    /* Use a control ping for synchronization */
-    {
-      vl_api_control_ping_t * mp;
-      M(CONTROL_PING, control_ping);
-      S;
-    }
-
-    WNR;
-    if (0 != rv) {
-        goto done;
-    }
-
-    u32 count = vec_len(jm->vxlan_tunnel_details);
-
-    jobjectArray vxlanTunnelDetailsArray = vppVxlanTunnelDetailsArray(env, count);
-
-    for (i = 0; i < count; i++) {
-        vxlan_tunnel_details_t *details = &jm->vxlan_tunnel_details[i];
-
-
-        /* This interface to support both v4 and v6 addresses is nasty */
-        jbyteArray src_address = (*env)->NewByteArray(env, 16);
-        (*env)->SetByteArrayRegion(env, src_address, 0, 16,
-                (signed char*)details->src_address);
-
-        jbyteArray dst_address = (*env)->NewByteArray(env, 16);
-        (*env)->SetByteArrayRegion(env, dst_address, 0, 16,
-                (signed char*)details->dst_address);
-
-        jint encap_vrf_id = details->encap_vrf_id;
-        jint vni = details->vni;
-        jint decap_next_index = details->decap_next_index;
-        jboolean is_ipv6 = details->is_ipv6 ? 1 : 0;
-
-        jobject vxlanTunnelDetailsObj = vppVxlanTunnelDetailsObject(env,
-                src_address, dst_address, encap_vrf_id, vni,
-                decap_next_index, is_ipv6);
-
-        (*env)->SetObjectArrayElement(env, vxlanTunnelDetailsArray, i,
-                vxlanTunnelDetailsObj);
-    }
-
-    returnArray = vxlanTunnelDetailsArray;
-
-done:
-    vppjni_unlock (jm);
-    return returnArray;
-}
-
-static void vl_api_vxlan_tunnel_details_t_handler
-(vl_api_vxlan_tunnel_details_t * mp)
-{
-    vppjni_main_t * jm = &vppjni_main;
-    vxlan_tunnel_details_t *tunnel_details;
-
-    vec_add2(jm->vxlan_tunnel_details, tunnel_details, 1);
-    if (mp->is_ipv6){
-        u64 *s, *d;
-
-        /* this is ugly - why is this in host order at all? -cluke */
-        /* Per notes from Ole, Maros and Keith, this should all be
-         * superceded with a new api builder soon, so this interface will
-         * be short lived -cluke */
-        s = (void *)mp->src_address;
-        d = (void *)tunnel_details->src_address;
-#if CLIB_ARCH_IS_LITTLE_ENDIAN
-        d[0] = clib_net_to_host_u64(s[1]);
-        d[1] = clib_net_to_host_u64(s[0]);
-#else /* big endian */
-        d[0] = s[0];
-        d[1] = s[1];
-#endif
-
-        s = (void *)mp->dst_address;
-        d = (void *)tunnel_details->dst_address;
-#if CLIB_ARCH_IS_LITTLE_ENDIAN
-        d[0] = clib_net_to_host_u64(s[1]);
-        d[1] = clib_net_to_host_u64(s[0]);
-#else /* big endian */
-        d[0] = s[0];
-        d[1] = s[1];
-#endif
-    } else {
-        u32 *s, *d;
-
-        /* the type changed from a u32 to u8[16] - this does
-         * the same as dst = ntohl(src) with the u32 of a v4
-         * address in the first 32 bits */
-
-        s = (void *)mp->src_address;
-        d = (void *)tunnel_details->src_address;
-        d[0] = ntohl(s[0]);
-
-        s = (void *)mp->dst_address;
-        d = (void *)tunnel_details->dst_address;
-        d[0] = ntohl(s[0]);
-    }
-    tunnel_details->encap_vrf_id = ntohl(mp->encap_vrf_id);
-    tunnel_details->vni = ntohl(mp->vni);
-    tunnel_details->decap_next_index = ntohl(mp->decap_next_index);
-    tunnel_details->is_ipv6 = mp->is_ipv6;
-}
-
-/* cleanup handler for RX thread */
-static void cleanup_rx_thread(void *arg)
-{
-    vppjni_main_t * jm = &vppjni_main;
-
-    vppjni_lock (jm, 99);
-
-    int getEnvStat = (*jm->jvm)->GetEnv(jm->jvm, (void **)&(jm->jenv), JNI_VERSION_1_6);
-    if (getEnvStat == JNI_EVERSION) {
-        clib_warning ("Unsupported JNI version\n");
-        jm->retval = -999;
-        goto out;
-    } else if (getEnvStat != JNI_EDETACHED) {
-        (*jm->jvm)->DetachCurrentThread(jm->jvm);
-    }
-out:
-    vppjni_unlock (jm);
-}
-
-static void
-vl_api_show_version_reply_t_handler (vl_api_show_version_reply_t * mp)
-{
-    vppjni_main_t * jm = &vppjni_main;
-    i32 retval = ntohl(mp->retval);
-
-    if (retval >= 0) {
-        DEBUG_LOG ("show version request succeeded(%d)");
-        strncpy((char*)jm->program_name, (const char*)mp->program,
-                sizeof(jm->program_name)-1);
-        jm->program_name[sizeof(jm->program_name)-1] = 0;
-
-        strncpy((char*)jm->build_directory, (const char*)mp->build_directory,
-                sizeof(jm->build_directory)-1);
-        jm->build_directory[sizeof(jm->build_directory)-1] = 0;
-
-        strncpy((char*)jm->version, (const char*)mp->version,
-                sizeof(jm->version)-1);
-        jm->version[sizeof(jm->version)-1] = 0;
-
-        strncpy((char*)jm->build_date, (const char*)mp->build_date,
-                sizeof(jm->build_date)-1);
-        jm->build_date[sizeof(jm->build_date)-1] = 0;
-    } else {
-        clib_error ("show version request failed(%d)", retval);
-    }
-    jm->retval = retval;
-    jm->result_ready = 1;
-}
-
-static void vl_api_want_stats_reply_t_handler (vl_api_want_stats_reply_t * mp)
-{
-    vppjni_main_t * jm = &vppjni_main;
-    jm->retval = mp->retval; // FIXME: vpp api does not do ntohl on this retval
-    jm->result_ready = 1;
-}
-
-// control ping needs to be very first thing called
-// to attach rx thread to java thread
-static void vl_api_control_ping_reply_t_handler
-(vl_api_control_ping_reply_t * mp)
-{
-    vppjni_main_t * jm = &vppjni_main;
-    i32 retval = ntohl(mp->retval);
-    jm->retval = retval;
-
-    // attach to java thread if not attached
-    int getEnvStat = (*jm->jvm)->GetEnv(jm->jvm, (void **)&(jm->jenv), JNI_VERSION_1_6);
-    if (getEnvStat == JNI_EDETACHED) {
-        if ((*jm->jvm)->AttachCurrentThread(jm->jvm, (void **)&(jm->jenv), NULL) != 0) {
-            clib_warning("Failed to attach thread\n");
-            jm->retval = -999;
-            goto out;
-        }
-
-        // workaround as we can't use pthread_cleanup_push
-        pthread_key_create(&jm->cleanup_rx_thread_key, cleanup_rx_thread);
-        // destructor is only called if the value of key is non null
-        pthread_setspecific(jm->cleanup_rx_thread_key, (void *)1);
-    } else if (getEnvStat == JNI_EVERSION) {
-        clib_warning ("Unsupported JNI version\n");
-        jm->retval = -999;
-        goto out;
-    }
-    // jm->jenv is now stable global reference that can be reused (only within RX thread)
-
-#if 0
-    // ! callback system removed for now
-    //
-    // get issuer msg-id
-    p = hash_get (jm->ping_hash, context);
-    if (p != 0) { // ping marks end of some dump call
-        JNIEnv *env = jm->jenv;
-        u16 msg_id = (u16)p[0];
-
-        // we will no longer need this
-        hash_unset (jm->ping_hash, context);
-
-        // get original caller obj
-        p = hash_get (jm->callback_hash, context);
-
-        if (p == 0) // don't have callback stored
-            goto out;
-
-        jobject obj = (jobject)p[0]; // object that called original call
-
-        switch (msg_id) {
-            case VL_API_SW_INTERFACE_DUMP:
-                if (0 != sw_if_dump_call_all_callbacks(obj)) {
-                    goto out2;
-                }
-                break;
-            default:
-                clib_warning("Unhandled control ping issuer msg-id: %d", msg_id);
-                goto out2;
-                break;
-        }
-out2:
-        // free the saved obj
-        hash_unset (jm->callback_hash, context);
-        // delete global reference
-        (*env)->DeleteGlobalRef(env, obj);
-    }
-#endif
-
-out:
-    jm->result_ready = 1;
-}
-
-#ifndef VPPJNI_DEBUG_COUNTERS
-#define VPPJNI_DEBUG_COUNTERS 0
-#endif
-
-static void vl_api_vnet_interface_counters_t_handler
-(vl_api_vnet_interface_counters_t *mp)
-{
-    vppjni_main_t *jm = &vppjni_main;
-    CLIB_UNUSED(char *counter_name);
-    u32 count, sw_if_index;
-    int i;
-    static sw_interface_stats_t empty_stats = {0, };
-
-    vppjni_lock (jm, 12);
-    count = ntohl (mp->count);
-    sw_if_index = ntohl (mp->first_sw_if_index);
-    if (mp->is_combined == 0) {
-        u64 * vp, v;
-        vp = (u64 *) mp->data;
-
-        for (i = 0; i < count; i++) {
-            sw_interface_details_t *sw_if = NULL;
-
-            v = clib_mem_unaligned (vp, u64);
-            v = clib_net_to_host_u64 (v);
-            vp++;
-
-            if (sw_if_index < vec_len(jm->sw_if_table))
-                sw_if = vec_elt_at_index(jm->sw_if_table, sw_if_index);
-
-            if (sw_if /* && (sw_if->admin_up_down == 1)*/ && sw_if->interface_name[0] != 0) {
-                vec_validate_init_empty(jm->sw_if_stats_by_sw_if_index, sw_if_index, empty_stats);
-                sw_interface_stats_t * s = vec_elt_at_index(jm->sw_if_stats_by_sw_if_index, sw_if_index);
-
-                s->sw_if_index = sw_if_index;
-                s->valid = 1;
-
-                switch (mp->vnet_counter_type) {
-                    case  VNET_INTERFACE_COUNTER_DROP:
-                        counter_name = "drop";
-                        s->rx.pkts.discard = v;
-                        break;
-                    case  VNET_INTERFACE_COUNTER_PUNT:
-                        counter_name = "punt";
-                        s->rx.pkts.unknown_proto = v;
-                        break;
-                    case  VNET_INTERFACE_COUNTER_IP4:
-                        counter_name = "ip4";
-                        s->rx.pkts.ip4 = v;
-                        break;
-                    case  VNET_INTERFACE_COUNTER_IP6:
-                        counter_name = "ip6";
-                        s->rx.pkts.ip6 = v;
-                        break;
-                    case  VNET_INTERFACE_COUNTER_RX_NO_BUF:
-                        counter_name = "rx-no-buf";
-                        s->rx.pkts.fifo_full = v;
-                        break;
-                    case  VNET_INTERFACE_COUNTER_RX_MISS:
-                        counter_name = "rx-miss";
-                        s->rx.pkts.miss = v;
-                        break;
-                    case  VNET_INTERFACE_COUNTER_RX_ERROR:
-                        counter_name = "rx-error";
-                        s->rx.pkts.error = v;
-                        break;
-                    case  VNET_INTERFACE_COUNTER_TX_ERROR:
-                        counter_name = "tx-error (fifo-full)";
-                        s->tx.pkts.fifo_full = v;
-                        break;
-                    default:
-                        counter_name = "bogus";
-                        break;
-                }
-
-#if VPPJNI_DEBUG_COUNTERS == 1
-                clib_warning ("%s (%d): %s (%lld)\n", sw_if->interface_name, s->sw_if_index,
-                        counter_name, v);
-#endif
-            }
-            sw_if_index++;
-        }
-    } else {
-        vlib_counter_t *vp;
-        u64 packets, bytes;
-        vp = (vlib_counter_t *) mp->data;
-
-        for (i = 0; i < count; i++) {
-            sw_interface_details_t *sw_if = NULL;
-
-            packets = clib_mem_unaligned (&vp->packets, u64);
-            packets = clib_net_to_host_u64 (packets);
-            bytes = clib_mem_unaligned (&vp->bytes, u64);
-            bytes = clib_net_to_host_u64 (bytes);
-            vp++;
-
-            if (sw_if_index < vec_len(jm->sw_if_table))
-                sw_if = vec_elt_at_index(jm->sw_if_table, sw_if_index);
-
-            if (sw_if /* && (sw_if->admin_up_down == 1) */ && sw_if->interface_name[0] != 0) {
-                vec_validate_init_empty(jm->sw_if_stats_by_sw_if_index, sw_if_index, empty_stats);
-                sw_interface_stats_t * s = vec_elt_at_index(jm->sw_if_stats_by_sw_if_index, sw_if_index);
-
-                s->valid = 1;
-                s->sw_if_index = sw_if_index;
-
-                switch (mp->vnet_counter_type) {
-                    case  VNET_INTERFACE_COUNTER_RX:
-                        s->rx.pkts.unicast = packets;
-                        s->rx.octets = bytes;
-                        counter_name = "rx";
-                        break;
-
-                    case  VNET_INTERFACE_COUNTER_TX:
-                        s->tx.pkts.unicast = packets;
-                        s->tx.octets = bytes;
-                        counter_name = "tx";
-                        break;
-
-                    default:
-                        counter_name = "bogus";
-                        break;
-                }
-
-#if VPPJNI_DEBUG_COUNTERS == 1
-                clib_warning ("%s (%d): %s.packets %lld\n",
-                        sw_if->interface_name,
-                        sw_if_index, counter_name, packets);
-                clib_warning ("%s (%d): %s.bytes %lld\n",
-                        sw_if->interface_name,
-                        sw_if_index, counter_name, bytes);
-#endif
-            }
-            sw_if_index++;
-        }
-    }
-    vppjni_unlock (jm);
-}
-
-jint JNI_OnLoad(JavaVM *vm, void *reserved) {
-    vppjni_main_t * jm = &vppjni_main;
-    JNIEnv* env;
-    if ((*vm)->GetEnv(vm, (void**) &env, JNI_VERSION_1_6) != JNI_OK) {
-        return JNI_ERR;
-    }
-
-    if (vppjni_init(env) != 0) {
-        return JNI_ERR;
-    }
-
-    jm->jvm = vm;
-    return JNI_VERSION_1_6;
-}
-
-void JNI_OnUnload(JavaVM *vm, void *reserved) {
-    vppjni_main_t * jm = &vppjni_main;
-    JNIEnv* env;
-    if ((*vm)->GetEnv(vm, (void**) &env, JNI_VERSION_1_6) != JNI_OK) {
-        return;
-    }
-
-    vppjni_uninit(env);
-
-    jm->jenv = NULL;
-    jm->jvm = NULL;
-}
-
-#define foreach_vpe_api_msg                             \
-_(CONTROL_PING_REPLY, control_ping_reply)               \
-_(SW_INTERFACE_DETAILS, sw_interface_details)           \
-_(SHOW_VERSION_REPLY, show_version_reply)               \
-_(WANT_STATS_REPLY, want_stats_reply)                   \
-_(VNET_INTERFACE_COUNTERS, vnet_interface_counters)     \
-_(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags)       \
-_(BRIDGE_DOMAIN_DETAILS, bridge_domain_details)         \
-_(BRIDGE_DOMAIN_SW_IF_DETAILS, bridge_domain_sw_if_details) \
-_(L2_FIB_TABLE_ENTRY, l2_fib_table_entry)               \
-_(IP_ADDRESS_DETAILS, ip_address_details)               \
-_(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details)
-
-static int connect_to_vpe(char *name)
-{
-    vppjni_main_t * jm = &vppjni_main;
-    api_main_t * am = &api_main;
-
-    if (vl_client_connect_to_vlib("/vpe-api", name, 32) < 0)
-        return -1;
-
-    jm->my_client_index = am->my_client_index;
-    jm->vl_input_queue = am->shmem_hdr->vl_input_queue;
-
-#define _(N,n)                                  \
-    vl_msg_api_set_handlers(VL_API_##N, #n,     \
-            vl_api_##n##_t_handler,	            \
-            vl_noop_handler,                    \
-            vl_api_##n##_t_endian,              \
-            vl_api_##n##_t_print,               \
-            sizeof(vl_api_##n##_t), 1);
-    foreach_vpe_api_msg;
-#undef _
-
-    return 0;
-}
-
-/* Format an IP6 address. */
-u8 * format_ip6_address (u8 * s, va_list * args)
-{
-    ip6_address_t * a = va_arg (*args, ip6_address_t *);
-    u32 max_zero_run = 0, this_zero_run = 0;
-    int max_zero_run_index = -1, this_zero_run_index=0;
-    int in_zero_run = 0, i;
-    int last_double_colon = 0;
-
-    /* Ugh, this is a pain. Scan forward looking for runs of 0's */
-    for (i = 0; i < ARRAY_LEN (a->as_u16); i++) {
-        if (a->as_u16[i] == 0) {
-            if (in_zero_run) {
-                this_zero_run++;
-            } else {
-                in_zero_run = 1;
-                this_zero_run =1;
-                this_zero_run_index = i;
-            }
-        } else {
-            if (in_zero_run) {
-                /* offer to compress the biggest run of > 1 zero */
-                if (this_zero_run > max_zero_run && this_zero_run > 1) {
-                    max_zero_run_index = this_zero_run_index;
-                    max_zero_run = this_zero_run;
-                }
-            }
-            in_zero_run = 0;
-            this_zero_run = 0;
-        }
-    }
-
-    if (in_zero_run) {
-        if (this_zero_run > max_zero_run && this_zero_run > 1) {
-            max_zero_run_index = this_zero_run_index;
-            max_zero_run = this_zero_run;
-        }
-    }
-
-    for (i = 0; i < ARRAY_LEN (a->as_u16); i++) {
-        if (i == max_zero_run_index) {
-            s = format (s, "::");
-            i += max_zero_run - 1;
-            last_double_colon = 1;
-        } else {
-            s = format (s, "%s%x",
-                    (last_double_colon || i == 0) ? "" : ":",
-                    clib_net_to_host_u16 (a->as_u16[i]));
-            last_double_colon = 0;
-        }
-    }
-
-    return s;
-}
-
-/* Format an IP4 address. */
-u8 * format_ip4_address (u8 * s, va_list * args)
-{
-    u8 * a = va_arg (*args, u8 *);
-    return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
-}
-
-
diff --git a/vpp-api/java/japi/vppjni.h b/vpp-api/java/japi/vppjni.h
deleted file mode 100644
index bc73836..0000000
--- a/vpp-api/java/japi/vppjni.h
+++ /dev/null
@@ -1,309 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef __included_vppjni_h__
-#define __included_vppjni_h__
-
-#include <vnet/vnet.h>
-#include <vnet/ip/ip.h>
-#include <vnet/api_errno.h>
-#include <vlibapi/api.h>
-#include <vlibmemory/api.h>
-#include <jni.h>
-#include <japi/vppjni_bridge_domain.h>
-
-typedef struct {
-    u8 * name;
-    u32 value;
-} name_sort_t;
-
-typedef struct {
-    u8 valid; // used in a vector of sw_interface_details_t
-
-    u8 interface_name[64];
-    u32 sw_if_index;
-    u32 sup_sw_if_index;
-    u32 l2_address_length;
-    u8 l2_address[8];
-    u8 admin_up_down;
-    u8 link_up_down;
-    u8 link_duplex;
-    u8 link_speed;
-    u16 link_mtu;
-    u32 sub_id;
-    u8 sub_dot1ad;
-    u8 sub_number_of_tags;
-    u16 sub_outer_vlan_id;
-    u16 sub_inner_vlan_id;
-    u8 sub_exact_match;
-    u8 sub_default;
-    u8 sub_outer_vlan_id_any;
-    u8 sub_inner_vlan_id_any;
-    u32 vtr_op;
-    u32 vtr_push_dot1q;
-    u32 vtr_tag1;
-    u32 vtr_tag2;
-} sw_interface_details_t;
-
-typedef struct {
-    u8 * interface_name;
-    u32 sw_if_index;
-    /* 
-     * Subinterface ID. A number 0-N to uniquely identify 
-     * this subinterface under the super interface
-     */
-    u32 sub_id;
-
-    /* 0 = dot1q, 1=dot1ad */
-    u8 sub_dot1ad;
-
-    /* Number of tags 0-2 */
-    u8 sub_number_of_tags;
-    u16 sub_outer_vlan_id;
-    u16 sub_inner_vlan_id;
-    u8 sub_exact_match;
-    u8 sub_default;
-    u8 sub_outer_vlan_id_any;
-    u8 sub_inner_vlan_id_any;
-
-    /* vlan tag rewrite */
-    u32 vtr_op;
-    u32 vtr_push_dot1q;
-    u32 vtr_tag1;
-    u32 vtr_tag2;
-} sw_interface_subif_t;
-
-typedef struct {
-    u8 *desc;
-} sw_if_config_t;
-
-typedef struct {
-    u32 ip;
-    u8 prefix_length;
-} ipv4_address_t;
-
-typedef struct {
-    u8 ip[16];
-    u8 prefix_length;
-} ipv6_address_t;
-
-typedef struct {
-  u64 ip4;
-  u64 ip6;
-  u64 unicast;
-  u64 multicast;
-  u64 broadcast;
-  u64 discard;
-  u64 fifo_full;
-  u64 error;
-  u64 unknown_proto;
-  u64 miss;
-} packet_counters_t;
-
-typedef struct {
-  u64 octets;
-  packet_counters_t pkts;
-} if_counters_t;
-
-typedef struct {
-  u8 valid;
-  u32 sw_if_index;
-  if_counters_t rx;
-  if_counters_t tx;
-} sw_interface_stats_t;
-
-typedef struct {
-    u8 src_address[16];
-    u8 dst_address[16];
-    u32 encap_vrf_id;
-    u32 vni;
-    u32 decap_next_index;
-    u8 is_ipv6;
-} vxlan_tunnel_details_t;
-
-
-typedef struct {
-  /* Context IDs */
-  volatile u32 context_id_sent;
-  volatile u32 context_id_received;
-
-  /* Spinlock */
-  volatile u32 lock;
-  u32 tag;
-
-  /* To recycle pseudo-synchronous message code from vpp_api_test... */
-  volatile u32 result_ready;
-  volatile i32 retval;
-  volatile u8 *shmem_result;
-
-  /* thread cleanup */
-  pthread_key_t cleanup_rx_thread_key;
-  /* attachment of rx thread to java thread */
-  JNIEnv *jenv;
-  JavaVM *jvm;
-  uword *callback_hash;     // map context_id => jobject
-  uword *ping_hash;         // map ping context_id => msg type called
-
-  /* Timestamp */
-  clib_time_t clib_time;
-
-  /* connected indication */
-  u8 is_connected;
-
-  /* context -> non-trivial reply hash */
-  uword * reply_hash;
-  u32 saved_reply_count;
-
-  /* interface name map */
-  uword * sw_if_index_by_interface_name;
-
-  /* interface counters */
-  sw_interface_stats_t * sw_if_stats_by_sw_if_index;
-
-  /* interface table */
-  sw_interface_details_t * sw_if_table;
-
-  uword * sw_if_config_by_sw_if_index;
-
-  /* interface indices of responses to one sw_if_dump request */
-  u8 collect_indices;
-  u32 * sw_if_dump_if_indices;
-
-  /* program name, build_dir, version */
-  u8 program_name[32];
-  u8 build_directory[256];
-  u8 version[32];
-  u8 build_date[32];
-
-  /* subinterface table */
-  sw_interface_subif_t * sw_if_subif_table;
-
-  /* used in ip_address_dump request and response handling */
-  ipv4_address_t *ipv4_addresses;
-  ipv6_address_t *ipv6_addresses;
-  u8 is_ipv6;
-
-  /* used in vxlan_tunnel_dump request and response handling */
-  vxlan_tunnel_details_t *vxlan_tunnel_details;
-
-  /* main heap */
-  u8 * heap;
-
-  /* convenience */
-  unix_shared_memory_queue_t * vl_input_queue;
-  api_main_t * api_main;
-  u32 my_client_index;
-
-  vjbd_main_t vjbd_main;
-} vppjni_main_t;
-
-vppjni_main_t vppjni_main __attribute__((aligned (64)));
-
-
-static inline u32 vppjni_get_context_id (vppjni_main_t * jm)
-{
-  u32 my_context_id;
-  my_context_id = __sync_add_and_fetch (&jm->context_id_sent, 1);
-  return my_context_id;
-}
-
-static inline void vppjni_lock (vppjni_main_t * jm, u32 tag)
-{
-  while (__sync_lock_test_and_set (&jm->lock, 1))
-    ;
-  jm->tag = tag;
-}
-
-static inline void vppjni_unlock (vppjni_main_t * jm)
-{
-  jm->tag = 0;
-  CLIB_MEMORY_BARRIER();
-  jm->lock = 0;
-}
-
-static inline f64 vppjni_time_now (vppjni_main_t *jm)
-{
-  return clib_time_now (&jm->clib_time);
-}
-
-static inline int vppjni_sanity_check (vppjni_main_t * jm)
-{
-  if (!jm->is_connected)
-    return VNET_API_ERROR_NOT_CONNECTED;
-  return 0;
-}
-
-#define __PACKED(x) x __attribute__((packed))
-
-typedef __PACKED(struct _vl_api_generic_reply {
-  u16 _vl_msg_id;
-  u32 context;
-  i32 retval;
-  u8 data[0];
-}) vl_api_generic_reply_t;
-
-void vl_api_generic_reply_handler (vl_api_generic_reply_t *mp);
-
-/* M: construct, but don't yet send a message */
-
-#define M(T,t)                                  \
-do {                                            \
-  jm->result_ready = 0;                         \
-  mp = vl_msg_api_alloc(sizeof(*mp));           \
-  memset (mp, 0, sizeof (*mp));                 \
-  mp->_vl_msg_id = ntohs (VL_API_##T);          \
-  mp->client_index = jm->my_client_index;       \
- } while(0);
-
-#define M2(T,t,n)                               \
-do {                                            \
-  jm->result_ready = 0;                         \
-  mp = vl_msg_api_alloc(sizeof(*mp)+(n));       \
-  memset (mp, 0, sizeof (*mp));                 \
-  mp->_vl_msg_id = ntohs (VL_API_##T);          \
-  mp->client_index = jm->my_client_index;       \
- } while(0);
-
-
-/* S: send a message */
-#define S (vl_msg_api_send_shmem (jm->vl_input_queue, (u8 *)&mp))
-
-/* W: wait for results, with timeout */
-#define W                                       \
-  do {                                          \
-    timeout = vppjni_time_now (jm) + 1.0;       \
-                                                \
-    while (vppjni_time_now (jm) < timeout) {    \
-      if (jm->result_ready == 1) {              \
-        return (jm->retval);                    \
-      }                                         \
-    }                                           \
-    return -99;                                 \
-} while(0);
-
-/* WNR: wait for results, with timeout (without returning) */
-#define WNR                                     \
-  do {                                          \
-    timeout = vppjni_time_now (jm) + 1.0;       \
-                                                \
-    rv = -99;                                   \
-    while (vppjni_time_now (jm) < timeout) {    \
-      if (jm->result_ready == 1) {              \
-        rv = (jm->retval);                      \
-        break;                                  \
-      }                                         \
-    }                                           \
-} while(0);
-
-#endif /* __included_vppjni_h__ */
diff --git a/vpp-api/java/japi/vppjni_bridge_domain.h b/vpp-api/java/japi/vppjni_bridge_domain.h
deleted file mode 100644
index b614a5b..0000000
--- a/vpp-api/java/japi/vppjni_bridge_domain.h
+++ /dev/null
@@ -1,510 +0,0 @@
-/*---------------------------------------------------------------------------
- * Copyright (c) 2009-2014 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *---------------------------------------------------------------------------
- */
-
-#ifndef __included_vppjni_bridge_domain_h__
-#define __included_vppjni_bridge_domain_h__
-
-#include <vlib/vlib.h>
-#include <vppinfra/clib.h>
-#include <vppinfra/mhash.h>
-
-/*
- * The L2fib key is the mac address and bridge domain ID
- */
-#define MAC_ADDRESS_SIZE  6
-
-typedef struct {
-  union {
-    struct {
-      u16 unused1;
-      u8  mac[MAC_ADDRESS_SIZE]; 
-    } fields;
-    u64 raw;
-  };
-} l2fib_u64_mac_t;
-
-/* 
- * The l2fib entry results
- */
-typedef struct {
-  u32 bd_id;
-  l2fib_u64_mac_t mac_addr;
-  u32 sw_if_index;
-  u8  learned:1;
-  u8  bvi:1;
-  u8  filter:1;      // drop packets to/from this mac
-  u8  unused1:5;
-} bd_l2fib_oper_t;
-
-typedef struct {
-  u32 bd_id;
-  u8 * bd_name;
-} bd_local_cfg_t;
-
-typedef struct {
-  u32 bd_id;
-  u32 sw_if_index;
-  u32 shg;
-} bd_sw_if_oper_t;
-
-typedef struct {
-  u32 bd_id;
-  u8 flood:1;
-  u8 forward:1;
-  u8 learn:1;
-  u8 uu_flood:1;
-  u8 arp_term:1;
-  u8 unused1:3;
-  u32 bvi_sw_if_index;
-  u32 n_sw_ifs;
-  bd_sw_if_oper_t * bd_sw_if_oper;
-  f64 last_sync_time;
-  mhash_t l2fib_index_by_mac;
-  bd_l2fib_oper_t * l2fib_oper;	// vector indexed by l2fib_index
-} vjbd_oper_t;
-
-#define BD_OPER_REFRESH_INTERVAL  	2.0
-#define BD_OPER_L2FIB_REFRESH_INTERVAL	5.0
-
-typedef struct {
-  u32 next_bd_id;
-  uword * bd_index_bitmap;
-  uword * bd_index_by_id;
-  mhash_t bd_id_by_name;
-  bd_local_cfg_t * local_cfg;		// vector indexed by bd_index
-  vjbd_oper_t * bd_oper;		// vector indexed by oper_bd_index
-  f64 bd_oper_last_sync_all_time;
-  bd_sw_if_oper_t * sw_if_oper;	// vector indexed by sw_if_index
-  f64 l2fib_oper_last_sync_time;
-  uword * bd_id_by_sw_if_index;
-  uword * oper_bd_index_by_bd_id;
-} vjbd_main_t;
-
-extern vjbd_main_t vjbd_main;
-
-always_inline
-u64 l2fib_mac_to_u64 (u8 * mac_address) {
-  u64 temp;
-
-  // The mac address in memory is A:B:C:D:E:F
-  // The bd id in register is H:L
-#if CLIB_ARCH_IS_LITTLE_ENDIAN
-  // Create the in-register key as F:E:D:C:B:A:H:L
-  // In memory the key is L:H:A:B:C:D:E:F
-  temp = *((u64 *)(mac_address - 2));
-  temp = (temp & ~0xffff);
-#else
-  // Create the in-register key as H:L:A:B:C:D:E:F
-  // In memory the key is H:L:A:B:C:D:E:F
-  temp = *((u64 *)(mac_address)) >> 16;
-#endif
-
-  return temp;
-}
-
-static_always_inline void vjbd_main_init (vjbd_main_t *bdm)
-{
-  bdm->bd_index_by_id = hash_create (0, sizeof(uword));
-  mhash_init_vec_string (&bdm->bd_id_by_name, sizeof (u32));
-  bdm->bd_id_by_sw_if_index = hash_create (0, sizeof (u32));
-  bdm->oper_bd_index_by_bd_id = hash_create (0, sizeof (u32));
-}
-
-static_always_inline u32 vjbd_id_is_valid (vjbd_main_t * bdm, u32 bd_id)
-{
-  return ((bd_id != 0) && (bd_id != ~0) && (bd_id <= bdm->next_bd_id));
-}
-
-static_always_inline u32 vjbd_index_is_free (vjbd_main_t * bdm, u16 bd_index)
-{
-  u32 bd_id = vec_elt_at_index(bdm->local_cfg, bd_index)->bd_id;
-
-  return (!clib_bitmap_get (bdm->bd_index_bitmap, (bd_index)) &&
-          (bd_index < vec_len (bdm->local_cfg)) &&
-          ((bd_id == 0) || (bd_id == ~0)));
-}
-
-static_always_inline u32 vjbd_index_is_valid (vjbd_main_t * bdm, u16 bd_index)
-{
-  return (clib_bitmap_get (bdm->bd_index_bitmap, bd_index) &&
-          (bd_index < vec_len (bdm->local_cfg)));
-}
-
-static_always_inline u32 vjbd_id_from_name (vjbd_main_t * bdm,
-                                            const u8 * bd_name)
-{
-  u32 bd_id;
-  uword * p;
-
-  ASSERT (vec_c_string_is_terminated (bd_name));
-
-  if (bdm->next_bd_id == 0)
-    return ~0;
-
-  p = mhash_get (&bdm->bd_id_by_name, (void *)bd_name);
-  if (p)
-    {
-      bd_id = p[0];
-      ASSERT (vjbd_id_is_valid (bdm, bd_id));
-    }
-  else
-    bd_id = ~0;
-
-  return bd_id;
-}
-
-static_always_inline u32 vjbd_index_from_id (vjbd_main_t * bdm, u32 bd_id)
-{
-  uword * p;
-  u16 bd_index;
-
-  ASSERT (vjbd_id_is_valid (bdm, bd_id));
-
-  p = hash_get (bdm->bd_index_by_id, bd_id);
-
-  ASSERT (p); // there is always an index associated with a valid bd_id
-  bd_index = p[0];
-
-  ASSERT (vjbd_index_is_valid (bdm, bd_index));
-
-  return bd_index;
-}
-
-static_always_inline u32 vjbd_id_from_index (vjbd_main_t * bdm, u16 bd_index)
-{
-  u32 bd_id;
-
-  ASSERT (vjbd_index_is_valid (bdm, bd_index));
-
-  bd_id = vec_elt_at_index(bdm->local_cfg, bd_index)->bd_id;
-
-  ASSERT (vjbd_id_is_valid (bdm, bd_id));
-
-  return bd_id;
-}
-
-static_always_inline u8 * vjbd_name_from_id (vjbd_main_t * bdm, u32 bd_id)
-{
-  u16 bd_index = vjbd_index_from_id (bdm, bd_id);
-
-  return vec_elt_at_index(bdm->local_cfg, bd_index)->bd_name;
-}
-
-static_always_inline u8 * vjbd_oper_name_from_id (vjbd_main_t * bdm, u32 bd_id)
-{
-    if (vjbd_id_is_valid (bdm, bd_id)) {
-        return format(0, "%s", vjbd_name_from_id(bdm, bd_id));
-    } else {
-        return format(0, "BridgeDomainOper%d", bd_id);
-    }
-}
-
-static_always_inline vjbd_oper_t * vjbd_oper_from_id (vjbd_main_t * bdm,
-                                                  u32 bd_id)
-{
-  u16 bd_index = vjbd_index_from_id (bdm, bd_id);
-  return vec_elt_at_index (bdm->bd_oper, bd_index);
-}
-
-static_always_inline void vjbd_oper_maybe_sync_from_vpp (vjbd_main_t * bdm, 
-                                                       u32 bd_id)
-{
-#ifdef VPPJNI_OPER
-  vppjni_vpe_api_msg_main_t *ovam = ovam_get_main ();
-
-  if (bd_id == ~0)
-    {
-      if ((ovam_time_now (ovam) - bdm->bd_oper_last_sync_all_time) >
-          BD_OPER_REFRESH_INTERVAL)
-        {
-          ovam_bridge_domain_dump (bd_id);
-          bdm->bd_oper_last_sync_all_time = ovam_time_now (ovam);
-        }
-    }
-    
-  else 
-    {
-      vjbd_oper_t * bd_oper = vjbd_oper_from_id (bdm, bd_id);
-
-      if ((ovam_time_now (ovam) - bd_oper->last_sync_time) >
-          BD_OPER_REFRESH_INTERVAL)
-        {
-          ovam_bridge_domain_dump (bd_id);
-
-          bd_oper->last_sync_time = ovam_time_now (ovam);
-        }
-    }
-#endif
-}
-
-static_always_inline u32 vjbd_id_from_sw_if_index (vjbd_main_t * bdm,
-                                                 u32 sw_if_index)
-{
-  bd_sw_if_oper_t * bd_sw_if_oper;
-  u32 bd_id = ~0;
-
-  vjbd_oper_maybe_sync_from_vpp (bdm, ~0);
-  if (sw_if_index < vec_len (bdm->sw_if_oper))
-    {
-      bd_sw_if_oper = vec_elt_at_index (bdm->sw_if_oper, sw_if_index);
-      bd_id = bd_sw_if_oper->bd_id;
-    }
-
-  return bd_id;
-}
-
-static_always_inline u8 * vjbd_name_from_sw_if_index (vjbd_main_t * bdm,
-                                                    u32 sw_if_index)
-{
-  u32 bd_id, bd_index;
-  u8 * bd_name = 0;
-  
-  /* DAW-FIXME:
-  ASSERT (ovam_sw_if_index_valid (ovam_get_main(), sw_if_index));
-  */
-  vjbd_oper_maybe_sync_from_vpp (bdm, ~0);
-  bd_id = vjbd_id_from_sw_if_index (bdm, sw_if_index);
-  if (vjbd_id_is_valid (bdm, bd_id))
-    {
-      bd_index = vjbd_index_from_id (bdm, bd_id);
-      bd_name = vec_elt_at_index (bdm->local_cfg, bd_index)->bd_name;
-    }
-
-  return bd_name;
-}
-
-static_always_inline u32 
-vjbd_oper_l2fib_index_from_mac (vjbd_oper_t * bd_oper, u8 * mac)
-{
-  u32 l2fib_index;
-  uword * p;
-
-  p = mhash_get (&bd_oper->l2fib_index_by_mac, mac);
-  if (p)
-    {
-      l2fib_index = p[0];
-      ASSERT (l2fib_index < vec_len (bd_oper->l2fib_oper));
-    }
-  else
-    l2fib_index = ~0;
-
-  return l2fib_index;
-}
-
-static_always_inline u32 vjbd_local_cfg_next_id (vjbd_main_t * bdm, 
-                                               u32 bd_id)
-{
-  u32 i, end = vec_len (bdm->local_cfg);
-  u32 next_bd_id = 0;
-
-  if ((bd_id == 0) || vjbd_id_is_valid (bdm, bd_id))
-    for (i = 0; i < end; i++)
-      {
-        u32 curr_bd_id = bdm->local_cfg[i].bd_id;
-        if ((curr_bd_id != ~0) && (curr_bd_id > bd_id) && 
-            ((next_bd_id == 0) || (curr_bd_id < next_bd_id)))
-          next_bd_id = curr_bd_id;
-      }
-
-  return next_bd_id;
-}
-
-static_always_inline u32 vjbd_sw_if_oper_next_index (vjbd_main_t * bdm, 
-                                                   u32 start, u32 bd_id)
-{
-  u32 i, end = vec_len (bdm->sw_if_oper);
-
-  if (vjbd_id_is_valid (bdm, bd_id))
-    for (i = start; i < end; i++)
-      if (bdm->sw_if_oper[i].bd_id == bd_id)
-        return i;
-
-  return ~0;
-}
-
-static_always_inline void 
-vjbd_oper_l2fib_maybe_sync_from_vpp (vjbd_main_t * bdm)
-{
-#ifdef VPPJNI_OPER
-  vppjni_vpe_api_msg_main_t *ovam = ovam_get_main ();
-  if ((ovam_time_now (ovam) - bdm->l2fib_oper_last_sync_time) >
-      BD_OPER_L2FIB_REFRESH_INTERVAL)
-    {
-      ovam_l2fib_table_dump ();
-      bdm->l2fib_oper_last_sync_time = ovam_time_now (ovam);
-    }
-#endif
-}
-
-static_always_inline void vjbd_l2fib_oper_reset (vjbd_main_t * bdm)
-{
-  vjbd_oper_t * bd_oper;
-
-  vec_foreach (bd_oper, bdm->bd_oper)
-    {
-      mhash_init (&bd_oper->l2fib_index_by_mac, sizeof (u32), MAC_ADDRESS_SIZE);
-      vec_reset_length (bd_oper->l2fib_oper);      
-    }
-}
-
-static_always_inline void vjbd_oper_reset (vjbd_main_t * bdm, u32 bd_id)
-{
-  u16 bd_index;
-  u32 si, len;
-  vjbd_oper_t * bd_oper;
-  u32 end;
-
-  if (!bdm->bd_oper)
-    {
-      ASSERT (vec_len (bdm->sw_if_oper) == 0);
-      return;
-    }
-
-  if (bd_id == ~0)
-    {
-      bdm->bd_oper_last_sync_all_time = 0.0;
-      bd_index = 0;
-      end = vec_len (bdm->bd_oper);
-    }
-  else
-    {
-      bd_index = vjbd_index_from_id (bdm, bd_id);
-      end = bd_index + 1;
-    }
-
-  for (; bd_index < end; bd_index++)
-    {
-      bd_oper = vec_elt_at_index (bdm->bd_oper, bd_index);
-      bd_oper->last_sync_time = 0.0;
-
-      len = vec_len (bdm->sw_if_oper);
-      for (si = vjbd_sw_if_oper_next_index (bdm, 0, bd_id);
-           (si != ~0) && (si < len);
-           si = vjbd_sw_if_oper_next_index (bdm, si + 1, bd_id))
-        {
-          bd_sw_if_oper_t * bd_sw_if_oper;
-
-          bd_sw_if_oper = vec_elt_at_index (bdm->sw_if_oper, si);
-          bd_sw_if_oper->bd_id = ~0;
-        }
-    }
-}
-
-static_always_inline void 
-vjbd_sw_if_add_del (u32 sw_if_index ,u32 bd_id, u8 bvi, u8 shg, u8 is_add)
-{
-  vjbd_main_t * bdm = &vjbd_main;
-  u16 bd_index = vjbd_index_from_id (bdm, bd_id);
-  vjbd_oper_t * bd_oper = vec_elt_at_index (bdm->bd_oper, bd_index);
-  bd_sw_if_oper_t * bd_sw_if_oper;
-  
-  ASSERT (vjbd_id_is_valid (bdm, bd_id));
-  /* DAW-FIXME
-  ASSERT (ovam_sw_if_index_valid (ovam_get_main (), sw_if_index));
-  */
-
-  vec_validate (bdm->sw_if_oper, sw_if_index);
-  bd_sw_if_oper = vec_elt_at_index (bdm->sw_if_oper, sw_if_index);
-  if (is_add)
-    {
-      bd_sw_if_oper->bd_id = bd_id;
-      bd_sw_if_oper->shg = shg;
-      bd_oper->bvi_sw_if_index = bvi ? sw_if_index : ~0;
-    }
-  else
-    {
-      bd_sw_if_oper->bd_id = 0;
-      bd_sw_if_oper->shg = 0;
-      if (bd_oper->bvi_sw_if_index == sw_if_index)
-        bd_oper->bvi_sw_if_index = ~0;
-    }
-}
-
-static_always_inline u32 vjbd_id_sw_if_count (vjbd_main_t * bdm, u32 bd_id)
-{
-  u32 count = 0, i, end = vec_len (bdm->sw_if_oper);
-
-  if (vjbd_id_is_valid (bdm, bd_id))
-    for (count = i = 0; i < end; i++)
-      if (bdm->sw_if_oper[i].bd_id == bd_id)
-        count++;
-
-  return count;
-}
-
-static_always_inline u32 vjbd_find_or_add_bd (vjbd_main_t * bdm, u8 * bd_name)
-{
-  u16 bd_index;
-  u32 bd_id;
-  bd_local_cfg_t * bd_local_cfg;
-  uword mhash_val_bd_id;
-
-  bd_id = vjbd_id_from_name (bdm, bd_name);
-  if (bd_id != ~0)
-    return bd_id;
-
-  mhash_val_bd_id = bd_id = ++bdm->next_bd_id;
-  mhash_set_mem (&bdm->bd_id_by_name, (void *)bd_name, &mhash_val_bd_id, 0);
-
-  bd_index = clib_bitmap_first_clear (bdm->bd_index_bitmap);
-  vec_validate (bdm->local_cfg, bd_index);
-  vec_validate (bdm->bd_oper, bd_index);
-
-  ASSERT (vjbd_index_is_free (bdm, bd_index));
-
-  bd_local_cfg = vec_elt_at_index (bdm->local_cfg, bd_index);
-  bd_local_cfg->bd_id = bd_id;
-  vec_validate_init_c_string (bd_local_cfg->bd_name, bd_name,
-                              vec_len (bd_name) - 1);
-  hash_set (bdm->bd_index_by_id, bd_id, bd_index);
-  bdm->bd_index_bitmap = clib_bitmap_set (bdm->bd_index_bitmap,
-                                          bd_index, 1);
-  return bd_id;
-}
-
-static_always_inline void vjbd_delete_bd (vjbd_main_t * bdm, u32 bd_id)
-{
-  u16 bd_index;
-  bd_local_cfg_t * bd_local_cfg;
-
-  ASSERT (vjbd_id_is_valid (bdm, bd_id));
-
-  // bd must not have any members before deleting
-  ASSERT (!vjbd_id_sw_if_count (bdm, bd_id));
-
-  bd_index = vjbd_index_from_id (bdm, bd_id);
-  bd_local_cfg = vec_elt_at_index (bdm->local_cfg, bd_index);
-  vjbd_oper_reset (bdm, bd_id);
-
-  mhash_unset (&bdm->bd_id_by_name, vjbd_name_from_id (bdm, bd_id), 0);
-  bdm->bd_index_bitmap = clib_bitmap_set (bdm->bd_index_bitmap,
-                                          bd_index, 0);
-  hash_unset (bdm->bd_index_by_id, bd_id);
-  bd_local_cfg->bd_id = ~0;
-  vec_validate_init_c_string (bd_local_cfg->bd_name, "", 0);
-
-  if (clib_bitmap_is_zero (bdm->bd_index_bitmap))
-    {
-      vec_reset_length (bdm->local_cfg);
-      vec_reset_length (bdm->bd_oper);
-    }
-
-  /* Force a resync of all bd_oper data. */
-  bdm->bd_oper_last_sync_all_time = 0.0;
-  vjbd_oper_maybe_sync_from_vpp (bdm, ~0);
-}
-
-#endif /* __included_vppjni_vpp_bridge_domain_h__ */
diff --git a/vpp-api/java/japi/vppjni_env.c b/vpp-api/java/japi/vppjni_env.c
deleted file mode 100644
index 1c4ea6e..0000000
--- a/vpp-api/java/japi/vppjni_env.c
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright (c) 2016 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include <jni.h>
-
-#include "vppjni_env.h"
-
-// Head of the class registration list.
-static vppjni_class_t *class_head;
-// Head of the class registration list.
-static vppjni_field_t *field_head;
-
-void vppjni_register_class(vppjni_class_t *ptr)
-{
-    vppjni_class_t **where = &class_head;
-    while (*where != NULL) {
-        where = &((*where)->next);
-    }
-    *where = ptr;
-}
-
-void vppjni_register_field(vppjni_field_t *ptr) {
-    vppjni_field_t **where = &field_head;
-    while (*where != NULL) {
-        where = &((*where)->next);
-    }
-    *where = ptr;
-}
-
-jobject vppjni_new_object(JNIEnv *env, const vppjni_class_t *ptr, va_list ap) {
-    jobject obj = (*env)->NewObjectV(env, ptr->jclass, ptr->jinit, ap);
-    if ((*env)->ExceptionCheck(env)) {
-        (*env)->ExceptionDescribe(env);
-        return NULL;
-    }
-
-    return obj;
-}
-
-int vppjni_init(JNIEnv *env)
-{
-    vppjni_class_t *cwlk;
-    vppjni_field_t *fwlk;
-
-    for (cwlk = class_head; cwlk != NULL; cwlk = cwlk->next) {
-        jclass cls;
-        jmethodID method;
-
-        cls = (*env)->FindClass(env, cwlk->fqcn);
-        if ((*env)->ExceptionCheck(env)) {
-            (*env)->ExceptionDescribe(env);
-            vppjni_uninit(env);
-            return JNI_ERR;
-        }
-
-        method = (*env)->GetMethodID(env, cls, "<init>", cwlk->init_sig);
-        if ((*env)->ExceptionCheck(env)) {
-            (*env)->ExceptionDescribe(env);
-            vppjni_uninit(env);
-            return JNI_ERR;
-        }
-
-        cwlk->jclass = (*env)->NewGlobalRef(env, cls);
-        if (cwlk->jclass == NULL) {
-            vppjni_uninit(env);
-            return JNI_ERR;
-        }
-        cwlk->jinit = method;
-    }
-
-    for (fwlk = field_head; fwlk != NULL; fwlk = fwlk->next) {
-        fwlk->jfield = (*env)->GetFieldID(env, fwlk->clsref->jclass, fwlk->name, fwlk->type);
-        if ((*env)->ExceptionCheck(env)) {
-            (*env)->ExceptionDescribe(env);
-            vppjni_uninit(env);
-            return JNI_ERR;
-        }
-    }
-
-    return 0;
-}
-
-void vppjni_uninit(JNIEnv *env) {
-    vppjni_class_t *cwlk;
-    vppjni_field_t *fwlk;
-
-    for (fwlk = field_head; fwlk != NULL; fwlk = fwlk->next) {
-        fwlk->jfield = NULL;
-    }
-
-    for (cwlk = class_head; cwlk != NULL; cwlk = cwlk->next) {
-        if (cwlk->jclass != NULL ) {
-            (*env)->DeleteGlobalRef(env, cwlk->jclass);
-        }
-
-        cwlk->jclass = NULL;
-        cwlk->jinit = NULL;
-    }
-}
-
diff --git a/vpp-api/java/japi/vppjni_env.h b/vpp-api/java/japi/vppjni_env.h
deleted file mode 100644
index 44029c2..0000000
--- a/vpp-api/java/japi/vppjni_env.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright (c) 2016 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
- * Utilities for accessing Java classes/method/fields in an efficient
- * manner.
- */
-
-/*
- * A potentially-uninitialized reference to a Java class
- */
-typedef struct vppjni_class {
-    // Fully-Qualified Class Name
-    const char          *fqcn;
-    // Constructor signature
-    const char          *init_sig;
-    // Global reference to class handle
-    jclass              jclass;
-    // Constructor method handle
-    jmethodID           jinit;
-    // Next item in linked list
-    struct vppjni_class *next;
-} vppjni_class_t;
-
-typedef struct jenv_field {
-    // Field name
-    const char           *name;
-    // Field type
-    const char           *type;
-    // Defining class reference
-    const vppjni_class_t *clsref;
-    // Field handle
-    jfieldID             jfield;
-    // Next item in linked list
-    struct jenv_field    *next;
-} vppjni_field_t;
-
-#define VPPJNI_CLASS_SYMBOL(name) vppjni_class_##name
-#define VPPJNI_CLASS_INIT(name) vppjni_class_##name##_init
-#define BIND_JAPI_CLASS(name, sig) \
-    static vppjni_class_t VPPJNI_CLASS_SYMBOL(name); \
-    static void VPPJNI_CLASS_INIT(name)(void) __attribute__((__constructor__)); \
-    static void VPPJNI_CLASS_INIT(name)() \
-    { \
-        VPPJNI_CLASS_SYMBOL(name).fqcn = "org/openvpp/vppjapi/" #name; \
-        VPPJNI_CLASS_SYMBOL(name).init_sig = sig; \
-        vppjni_register_class(&VPPJNI_CLASS_SYMBOL(name)); \
-    } \
-    static __attribute__((unused)) jobject name##Array(JNIEnv *env, jsize length) \
-    { \
-        return (*env)->NewObjectArray(env, length, VPPJNI_CLASS_SYMBOL(name).jclass, NULL); \
-    } \
-    static jobject name##Object(JNIEnv *env, ...) \
-    { \
-        va_list ap; \
-        va_start(ap, env); \
-        jobject obj = vppjni_new_object(env, &VPPJNI_CLASS_SYMBOL(name), ap); \
-        va_end(ap); \
-        return obj; \
-    }
-
-#define VPPJNI_FIELD_SYMBOL(cls, name) vppjni_field_##cls##_##name
-#define VPPJNI_FIELD_INIT(cls, name) vppjni_field_##cls##_##name##_init
-#define BIND_JAPI_FIELD(cls, field, sig) \
-    static vppjni_field_t VPPJNI_FIELD_SYMBOL(cls, field); \
-        static void VPPJNI_FIELD_INIT(cls, field)(void) __attribute__((__constructor__)); \
-    static void VPPJNI_FIELD_INIT(cls, field)() \
-    { \
-        VPPJNI_FIELD_SYMBOL(cls, field).name = #field; \
-        VPPJNI_FIELD_SYMBOL(cls, field).type = sig; \
-        VPPJNI_FIELD_SYMBOL(cls, field).clsref = &VPPJNI_CLASS_SYMBOL(cls); \
-        vppjni_register_field(&VPPJNI_FIELD_SYMBOL(cls, field)); \
-    }
-#define BIND_JAPI_BOOL_FIELD(cls, field) \
-    BIND_JAPI_FIELD(cls, field, "Z"); \
-    static void set_##cls##_##field(JNIEnv *env, jobject obj, jboolean value) \
-    { \
-        (*env)->SetBooleanField(env, obj, VPPJNI_FIELD_SYMBOL(cls, field).jfield, value); \
-    }
-#define BIND_JAPI_BYTE_FIELD(cls, field) \
-    BIND_JAPI_FIELD(cls, field, "B"); \
-    static void set_##cls##_##field(JNIEnv *env, jobject obj, jbyte value) \
-    { \
-        (*env)->SetByteField(env, obj, VPPJNI_FIELD_SYMBOL(cls, field).jfield, value); \
-    }
-#define BIND_JAPI_INT_FIELD(cls, field) \
-    BIND_JAPI_FIELD(cls, field, "I"); \
-    static void set_##cls##_##field(JNIEnv *env, jobject obj, jint value) \
-    { \
-        (*env)->SetIntField(env, obj, VPPJNI_FIELD_SYMBOL(cls, field).jfield, value); \
-    }
-#define BIND_JAPI_OBJ_FIELD(cls, field, sig) \
-    BIND_JAPI_FIELD(cls, field, sig); \
-    static void set_##cls##_##field(JNIEnv *env, jobject obj, jobject value) \
-    { \
-        (*env)->SetObjectField(env, obj, VPPJNI_FIELD_SYMBOL(cls, field).jfield, value); \
-    }
-#define BIND_JAPI_STRING_FIELD(cls, field) \
-    BIND_JAPI_OBJ_FIELD(cls, field, "Ljava/lang/String;")
-
-jobject vppjni_new_object(JNIEnv *env, const vppjni_class_t *ptr, va_list ap) __attribute__ ((visibility ("hidden")));
-void vppjni_register_class(vppjni_class_t *ptr) __attribute__ ((visibility ("hidden")));
-void vppjni_register_field(vppjni_field_t *ptr) __attribute__ ((visibility ("hidden")));
-int vppjni_init(JNIEnv *env) __attribute__ ((visibility ("hidden")));
-void vppjni_uninit(JNIEnv *env) __attribute__ ((visibility ("hidden")));
-
