Skip to content
This repository was archived by the owner on Feb 29, 2024. It is now read-only.

Commit 5baa7be

Browse files
emrekultursayMatt Wachowski
authored andcommitted
Support parsing of class signatures for inner classes inside Scala singleton objects.
Example: Let "MyClass" be a Scala singleton Object, and "Inner" be an inner class inside MyClass. Signature: Lcom/prod/MyClass$$Inner" Type Name: com.prod.MyClass$.Inner (after this CL) com.prod.MyClass..Inner (before this CL) ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=159759658
1 parent f235454 commit 5baa7be

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/agent/type_util.cc

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,8 +437,16 @@ string TypeNameFromJObjectSignature(string object_signature) {
437437
} else if (ch == '$') {
438438
if (source + 1 == object_signature.end()) {
439439
ch = '.';
440-
} else if (!isdigit(*(source + 1)) && *(source + 1) != ';') {
441-
// Neither an anonymous class, nor a Scala singleton.
440+
} else if (*(source + 1) == '$') {
441+
// Inner class inside Scala singleton. Pass the $ character as is.
442+
// E.g., "Lcom/prod/MyClassObject$$anonfun$1"
443+
} else if (isdigit(*(source + 1))) {
444+
// Anonymous class. Pass the $ character as is.
445+
// E.g., "Lcom/prod/MyClass$1;"
446+
} else if (*(source + 1) == ';') {
447+
// Scala singleton object. Pass the $ character as is.
448+
// E.g., "Lcom/prod/MyClassObject$;"
449+
} else {
442450
ch = '.';
443451
}
444452
}

0 commit comments

Comments
 (0)