String (final String type1, final String type2) { //PsiManager.getInstance(myProject).findClass(type1.replace('/', '.').replace('$', '.'), myProject.getAllScope()); return ReadAction.compute(() -> { final PsiManager manager = PsiManager.getInstance(myProject); PsiClass c = ClassUtil.findPsiClassByJVMName(manager, type1); if (c == null) { return "java/lang/Object"; } PsiClass d = ClassUtil.findPsiClassByJVMName(manager, type2); if (d == null) { return "java/lang/Object"; } if (c.isInheritor(d, true)) { return ClassUtil.getJVMClassName(d).replace('.', '/'); } if (d.isInheritor(c, true)) { return ClassUtil.getJVMClassName(c).replace('.', '/'); } if (c.isInterface() || d.isInterface()) { return "java/lang/Object"; } do { c = c.getSuperClass(); } while (c != null && !d.isInheritor(c, true)); if (c == null) { return "java/lang/Object"; } return ClassUtil.getJVMClassName(c).replace('.', '/'); }); }