@Test public void checkRefCountIncremented() { NetworkKey key = new NetworkKey(1,2,3,4,5,6,7,8); Network n = new Network(0, key, null); ArrayList<NetworkHandle> handles = new ArrayList<NetworkHandle>(); for (int i = 0 ; i < 10 ; i++) { NetworkHandle h = new NetworkHandle(n); handles.add(h); } AtomicInteger count = (AtomicInteger) new Mirror().on(n).get().field("refCount"); assertEquals(10, count.get()); for (NetworkHandle h : handles) { h.free(); } assertEquals(0, count.get()); }
@Override public synchronized void free() { checkState(); super.free(); freed = true; }
NetworkHandle extends Network { @Override public synchronized void free() { checkState(); super.free(); freed = true; } }
NetworkHandle extends Network { @Override public synchronized void free() { checkState(); super.free(); freed = true; } protected  NetworkHandle(Network network); }
NetworkHandle extends Network { @Override public synchronized void free() { checkState(); super.free(); freed = true; } protected  NetworkHandle(Network network); @Override synchronized void free(); @Override synchronized int getNumber(); @Override synchronized NetworkKey getNetworkKey(); }
NetworkHandle extends Network { @Override public synchronized void free() { checkState(); super.free(); freed = true; } protected  NetworkHandle(Network network); @Override synchronized void free(); @Override synchronized int getNumber(); @Override synchronized NetworkKey getNetworkKey();  }