Is there a `balanced BST` structure that also keeps track of subtree size in each node?

In `Java`, `TreeMap` is a red-black tree, but doesn't provide subtree size in each node.

Previously, I did write some BST that could keep track subtree size of each node, but it's not balanced.

**The questions are:** 

* Is it possible to implement such a tree, while keeping efficiency of *(`O(lg(n))` for basic operations)*?
* If yes, then is there any 3rd-party libraries provide such an impl?  

A `Java` impl is great, but other languages *(e.g `c`, `go`)* would also be helpful.

**BTW:** 

* The subtree size should be kept track in each node.  

So that could get the size without traversing the subtree.

**Possible appliation:**

* Keep track of rank of items, whose value *(that the rank depends on)* might change on fly.