Some code from Understanding JVM or insideJVM or by self