Trim down AdvertizedRoute size 19/94319/1
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 30 Dec 2020 23:41:15 +0000 (00:41 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Thu, 31 Dec 2020 00:19:03 +0000 (01:19 +0100)
Use alignment shadow to store the additional boolean, as it Java <15
will not do that for us.

Change-Id: Ib2c9ec74614cca8d6edaf4d9ffae78b6698f6fff
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
bgp/rib-spi/src/main/java/org/opendaylight/protocol/bgp/rib/spi/entry/AbstractAdvertizedRoute.java
bgp/rib-spi/src/main/java/org/opendaylight/protocol/bgp/rib/spi/entry/AdvertizedRoute.java

index f3af326055477511e798ea3c89ba513a363acea8..12cd5de23a36e14eae0266cba9155fed46e48a2a 100644 (file)
@@ -39,12 +39,22 @@ public abstract class AbstractAdvertizedRoute<C extends Routes & DataObject & Ch
     private final I addPathRouteKeyIdentifier;
     private final boolean depreferenced;
 
+    // Note: this field hides in the alignment shadow of 'depreferenced', but is used only in AdvertizedRoute.
+    // TODO: move this field back when we require JDK15+ (see https://bugs.openjdk.java.net/browse/JDK-8237767)
+    final boolean isFirstBestPath;
+
     AbstractAdvertizedRoute(final RIBSupport<C, S, R, I> ribSupport, final R route, final PeerId fromPeerId,
             final Attributes attributes, final boolean depreferenced) {
+        this(ribSupport, route, fromPeerId, attributes, depreferenced, false);
+    }
+
+    AbstractAdvertizedRoute(final RIBSupport<C, S, R, I> ribSupport, final R route, final PeerId fromPeerId,
+            final Attributes attributes, final boolean depreferenced, final boolean isFirstBestPath) {
         this.fromPeerId = fromPeerId;
         this.route = route;
         this.attributes = attributes;
         this.depreferenced = depreferenced;
+        this.isFirstBestPath = isFirstBestPath;
 
         final @NonNull String routeKey = verifyNotNull(route.getRouteKey());
         this.nonAddPathRouteKeyIdentifier = ribSupport.createRouteListKey(routeKey);
index 2fc8b0763655f403d253f4bc6064bfeca31e9200..2fdbe64af177622764433df627d331461333b41c 100644 (file)
@@ -27,7 +27,6 @@ import org.opendaylight.yangtools.yang.binding.Identifier;
 public final class AdvertizedRoute<C extends Routes & DataObject & ChoiceIn<Tables>,
         S extends ChildOf<? super C>, R extends Route & ChildOf<? super S> & Identifiable<I>,
         I extends Identifier<R>> extends AbstractAdvertizedRoute<C, S, R, I> {
-    private final boolean isFirstBestPath;
 
     public AdvertizedRoute(final RIBSupport<C, S, R, I> ribSupport, final R route, final Attributes attributes,
             final PeerId fromPeerId, final boolean depreferenced) {
@@ -36,11 +35,10 @@ public final class AdvertizedRoute<C extends Routes & DataObject & ChoiceIn<Tabl
 
     public AdvertizedRoute(final RIBSupport<C, S, R, I> ribSupport, final boolean isFirstBestPath,
             final R route, final Attributes attributes, final PeerId fromPeerId, final boolean depreferenced) {
-        super(ribSupport, route, fromPeerId, attributes, depreferenced);
-        this.isFirstBestPath = isFirstBestPath;
+        super(ribSupport, route, fromPeerId, attributes, depreferenced, isFirstBestPath);
     }
 
     public boolean isFirstBestPath() {
-        return this.isFirstBestPath;
+        return isFirstBestPath;
     }
 }