File tree Expand file tree Collapse file tree 1 file changed +13
-6
lines changed
utbot-framework-api/src/main/kotlin/org/utbot/framework/plugin/api Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -642,14 +642,21 @@ open class ClassId(
642
642
open val simpleName: String get() = jClass.simpleName
643
643
644
644
/* *
645
- * For regular classes this is just a simple name
646
- * For anonymous classes this includes the containing class and numeric indices of the anonymous class
645
+ * For regular classes this is just a simple name.
646
+ * For anonymous classes this includes the containing class and numeric indices of the anonymous class.
647
+ *
648
+ * Note: according to [java.lang.Class.getCanonicalName] documentation, local and anonymous classes
649
+ * do not have canonical names, as well as arrays whose elements don't have canonical classes themselves.
650
+ * In these cases prettified names are constructed using [ClassId.name] instead of [ClassId.canonicalName].
647
651
*/
648
652
val prettifiedName: String
649
- get() = canonicalName
650
- .substringAfterLast(" ." )
651
- .replace(Regex (" [^a-zA-Z0-9]" ), " " )
652
- .let { if (this .isArray) it + " Array" else it }
653
+ get() {
654
+ val className = jClass.canonicalName ? : name // Explicit jClass reference to get null instead of exception
655
+ return className
656
+ .substringAfterLast(" ." )
657
+ .replace(Regex (" [^a-zA-Z0-9]" ), " " )
658
+ .let { if (this .isArray) it + " Array" else it }
659
+ }
653
660
654
661
open val packageName: String get() = jClass.`package`?.name ? : " " // empty package for primitives
655
662
You can’t perform that action at this time.
0 commit comments