CompilerToVM::getConstantPool method does not work according to javadoc.
Javadoc says: "If the base object is a MetaspaceWrapperObject then the metaspace pointer is fetched from that object and used as the base. Otherwise the object itself is used as the base."
If we look in the native code of this method (http://hg.openjdk.java.net/graal/graal-jvmci-9/hotspot/file/d511f93727fc/src/share/vm/jvmci/jvmciCompilerToVM.cpp#l301), we see that no other Objects except three (HotSpotResolvedJavaMethodImpl, HotSpotConstantPool, HotSpotResolvedObjectTypeImpl) may be used for input.
So we cannot use a custom implementation of MetaspaceWrapperObject interface.
Javadoc should be corrected.
Javadoc should say that no other object except instances of (HotSpotResolvedJavaMethodImpl, HotSpotConstantPool, HotSpotResolvedObjectTypeImpl) and null can be used as input, or java.lang.IllegalArgumentException will be thrown.