GROOVY-5249 ClassInfo refactoring: extract method isValidWeakMetaClass and use it also in getMetaClassForClass() method