Which JDK is that? I checked both OpenJDK [1] and Oracle [2], neither is showing such a problem. In theory String could have been optimized away, but then the only invariant that needs to be met is that the size is correctly reported. Which should always be the case with Instrumentation.getObjectSize.

If however you do want to treat objects differently you should put that behavior in an extension of LibraObjectVisitor and use an instance of that one as the visitor. e.g. create a new method in the same style as Libra.getDeepObjectSize.

1:
java version "1.7.0_13"
OpenJDK Runtime Environment (IcedTea7 2.3.6) (7u13-2.3.6-0ubuntu0.12.10.1)
OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)

2:
java version "1.7.0_11"
Java(TM) SE Runtime Environment (build 1.7.0_11-b21)
Java HotSpot(TM) 64-Bit Server VM (build 23.6-b04, mixed mode)