While debugging our product, I already found a NoClassDefFoundError which is however weird to me- I noticed following output from the class loading log(by turning on -verbose:class):
[Loaded com.xxx.yyy.preferences.PreferencesMgr from file:/C:/Users/xxx/.gradle/caches/zzz.jar
PreferencesMgr is just the class that causes NoClassDefFoundError:
java.lang.NoClassDefFoundError: Could not initialize class com.xxx.yyy.preferences.PreferencesMgr
So it seems that jvm actually has already loaded the class sucessfully. Then why there is a NoClassDefFoundError? What possibilities?
Things are clear now. PreferenceMgr depends on another jar which has bug in certain version. In gradle, we set the bug version of the jar. Thus when loading PreferenceMgr, classloader trigers the bug in MAUtils and results in NoClassDefFoundError.