aboutsummaryrefslogtreecommitdiffstats
path: root/vpp-japi
diff options
context:
space:
mode:
authorRobert Varga <nite@hq.sk>2016-01-31 12:25:45 +0100
committerDave Wallace <dwallacelf@gmail.com>2016-02-01 03:00:39 +0000
commit004da76d2b83276a1fccf1876494ba0038816c68 (patch)
tree3d172effcdf0fb1cc9e722a0e8d5049a0460d268 /vpp-japi
parent52a3a4de071cae9fe8cad4227ab44627721ae175 (diff)
Make public fields final where possible
Class fields initialized via the constructor should be final. Also mark leaking byte[] instances with a FIXME. API users consider them immutable, but they are vulnerable to System.arrayCopy(). Also fixes constructor arguments so they do not use underscores, which is prohibited by Java 9. Change-Id: I393d55ed7234149cb3604bc92b2cb1d1207c55dc Signed-off-by: Robert Varga <nite@hq.sk>
Diffstat (limited to 'vpp-japi')
-rw-r--r--vpp-japi/japi/org/openvpp/vppjapi/vppIPv4Address.java12
-rw-r--r--vpp-japi/japi/org/openvpp/vppjapi/vppIPv6Address.java5
-rw-r--r--vpp-japi/japi/org/openvpp/vppjapi/vppInterfaceCounters.java44
-rw-r--r--vpp-japi/japi/org/openvpp/vppjapi/vppInterfaceDetails.java45
-rw-r--r--vpp-japi/japi/org/openvpp/vppjapi/vppL2Fib.java29
-rw-r--r--vpp-japi/japi/org/openvpp/vppjapi/vppVersion.java21
-rw-r--r--vpp-japi/japi/org/openvpp/vppjapi/vppVxlanTunnelDetails.java26
7 files changed, 92 insertions, 90 deletions
diff --git a/vpp-japi/japi/org/openvpp/vppjapi/vppIPv4Address.java b/vpp-japi/japi/org/openvpp/vppjapi/vppIPv4Address.java
index cd60e711be0..046ceab52f0 100644
--- a/vpp-japi/japi/org/openvpp/vppjapi/vppIPv4Address.java
+++ b/vpp-japi/japi/org/openvpp/vppjapi/vppIPv4Address.java
@@ -15,12 +15,12 @@
package org.openvpp.vppjapi;
-public class vppIPv4Address {
- public int ip;
- public byte prefixLength;
+public final class vppIPv4Address {
+ public final int ip;
+ public final byte prefixLength;
- public vppIPv4Address(int _ip, byte _prefixLength) {
- ip = _ip;
- prefixLength = _prefixLength;
+ public vppIPv4Address(int ip, byte prefixLength) {
+ this.ip = ip;
+ this.prefixLength = prefixLength;
}
}
diff --git a/vpp-japi/japi/org/openvpp/vppjapi/vppIPv6Address.java b/vpp-japi/japi/org/openvpp/vppjapi/vppIPv6Address.java
index efaa89c2ad5..7bf10f23402 100644
--- a/vpp-japi/japi/org/openvpp/vppjapi/vppIPv6Address.java
+++ b/vpp-japi/japi/org/openvpp/vppjapi/vppIPv6Address.java
@@ -16,8 +16,9 @@
package org.openvpp.vppjapi;
public class vppIPv6Address {
- public byte[] ip;
- public byte prefixLength;
+ // FIXME: this is dangerous
+ public final byte[] ip;
+ public final byte prefixLength;
public vppIPv6Address(byte[] _ip, byte _prefixLength) {
ip = _ip;
diff --git a/vpp-japi/japi/org/openvpp/vppjapi/vppInterfaceCounters.java b/vpp-japi/japi/org/openvpp/vppjapi/vppInterfaceCounters.java
index 1777d5d5691..8a02ad09633 100644
--- a/vpp-japi/japi/org/openvpp/vppjapi/vppInterfaceCounters.java
+++ b/vpp-japi/japi/org/openvpp/vppjapi/vppInterfaceCounters.java
@@ -17,29 +17,29 @@ package org.openvpp.vppjapi;
public class vppInterfaceCounters {
- public long rxOctets;
- public long rxIp4;
- public long rxIp6;
- public long rxUnicast;
- public long rxMulticast;
- public long rxBroadcast;
- public long rxDiscard;
- public long rxFifoFull;
- public long rxError;
- public long rxUnknownProto;
- public long rxMiss;
+ 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 long txOctets;
- public long txIp4;
- public long txIp6;
- public long txUnicast;
- public long txMulticast;
- public long txBroadcast;
- public long txDiscard;
- public long txFifoFull;
- public long txError;
- public long txUnknownProto;
- public long txMiss;
+ 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,
diff --git a/vpp-japi/japi/org/openvpp/vppjapi/vppInterfaceDetails.java b/vpp-japi/japi/org/openvpp/vppjapi/vppInterfaceDetails.java
index 8bc94d20bbf..b2edae043f7 100644
--- a/vpp-japi/japi/org/openvpp/vppjapi/vppInterfaceDetails.java
+++ b/vpp-japi/japi/org/openvpp/vppjapi/vppInterfaceDetails.java
@@ -15,28 +15,29 @@
package org.openvpp.vppjapi;
-public class vppInterfaceDetails {
- public int ifIndex;
- public String interfaceName;
- public int supIfIndex;
- public byte[] physAddr;
- public byte adminUp;
- public byte linkUp;
- public byte linkDuplex;
- public byte linkSpeed;
- public int subId;
- public byte subDot1ad;
- public byte subNumberOfTags;
- public int subOuterVlanId;
- public int subInnerVlanId;
- public byte subExactMatch;
- public byte subDefault;
- public byte subOuterVlanIdAny;
- public byte subInnerVlanIdAny;
- public int vtrOp;
- public int vtrPushDot1q;
- public int vtrTag1;
- public int vtrTag2;
+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 vppInterfaceDetails(int ifIndex, String interfaceName, int supIfIndex, byte[] physAddr, byte adminUp,
byte linkUp, byte linkDuplex, byte linkSpeed, int subId, byte subDot1ad, byte subNumberOfTags,
diff --git a/vpp-japi/japi/org/openvpp/vppjapi/vppL2Fib.java b/vpp-japi/japi/org/openvpp/vppjapi/vppL2Fib.java
index 9f43449d63a..b38d801e9e0 100644
--- a/vpp-japi/japi/org/openvpp/vppjapi/vppL2Fib.java
+++ b/vpp-japi/japi/org/openvpp/vppjapi/vppL2Fib.java
@@ -15,20 +15,21 @@
package org.openvpp.vppjapi;
-public class vppL2Fib {
- public byte[] physAddress;
- public boolean staticConfig;
- public String outgoingInterface;
- public boolean filter;
- public boolean bridgedVirtualInterface;
+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) {
- physAddress = _physAddress;
- staticConfig = _staticConfig;
- outgoingInterface = _outgoingInterface;
- filter = _filter;
- bridgedVirtualInterface = _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-japi/japi/org/openvpp/vppjapi/vppVersion.java b/vpp-japi/japi/org/openvpp/vppjapi/vppVersion.java
index 557ca7b79ee..6408dee2754 100644
--- a/vpp-japi/japi/org/openvpp/vppjapi/vppVersion.java
+++ b/vpp-japi/japi/org/openvpp/vppjapi/vppVersion.java
@@ -15,18 +15,17 @@
package org.openvpp.vppjapi;
-public class vppVersion {
- public String programName;
- public String buildDirectory;
- public String gitBranch;
- public String buildDate;
+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)
- {
- programName = _progName;
- buildDirectory = _buildDir;
- gitBranch = _gitBranch;
- buildDate = _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-japi/japi/org/openvpp/vppjapi/vppVxlanTunnelDetails.java b/vpp-japi/japi/org/openvpp/vppjapi/vppVxlanTunnelDetails.java
index a90e9336331..dd81e98cf27 100644
--- a/vpp-japi/japi/org/openvpp/vppjapi/vppVxlanTunnelDetails.java
+++ b/vpp-japi/japi/org/openvpp/vppjapi/vppVxlanTunnelDetails.java
@@ -15,19 +15,19 @@
package org.openvpp.vppjapi;
-public class vppVxlanTunnelDetails {
- public int srcAddress;
- public int dstAddress;
- public int encapVrfId;
- public int vni;
- public int decap_next_index;
+public final class vppVxlanTunnelDetails {
+ public final int srcAddress;
+ public final int dstAddress;
+ public final int encapVrfId;
+ public final int vni;
+ public final int decapNextIndex;
- public vppVxlanTunnelDetails(int _srcAddress, int _dstAddress,
- int _encapVrfId, int _vni, int _decap_next_index) {
- srcAddress = _srcAddress;
- dstAddress = _dstAddress;
- encapVrfId = _encapVrfId;
- vni = _vni;
- decap_next_index = _decap_next_index;
+ public vppVxlanTunnelDetails(int srcAddress, int dstAddress,
+ int encapVrfId, int vni, int decapNextIndex) {
+ this.srcAddress = srcAddress;
+ this.dstAddress = dstAddress;
+ this.encapVrfId = encapVrfId;
+ this.vni = vni;
+ this.decapNextIndex = decapNextIndex;
}
}