diff --git a/src/flamegraph/color/palettes.rs b/src/flamegraph/color/palettes.rs index 7a2f5eec..6eb28564 100644 --- a/src/flamegraph/color/palettes.rs +++ b/src/flamegraph/color/palettes.rs @@ -28,20 +28,18 @@ pub(super) mod java { name }; - if java_prefix.starts_with("java/") - || java_prefix.starts_with("javax/") - || java_prefix.starts_with("jdk/") - || java_prefix.starts_with("net/") - || java_prefix.starts_with("org/") - || java_prefix.starts_with("com/") - || java_prefix.starts_with("io/") - || java_prefix.starts_with("sun/") + if name.contains("::") || name.starts_with("-[") || name.starts_with("+[") { + // C++ or Objective C + BasicPalette::Yellow + } else if java_prefix.contains("/") + || (java_prefix.contains(".") && !java_prefix.starts_with("[")) + || match java_prefix.chars().next() { + Some(c) => c.is_ascii_uppercase(), + _ => false, + } { // Java BasicPalette::Green - } else if name.contains("::") { - // C++ - BasicPalette::Yellow } else { // system BasicPalette::Red @@ -269,11 +267,11 @@ mod tests { }, TestData { input: String::from("jdk/::[ki]"), - output: BasicPalette::Green, + output: BasicPalette::Yellow, }, TestData { input: String::from("Ajdk/_[ki]"), - output: BasicPalette::Red, + output: BasicPalette::Green, }, TestData { input: String::from("Ajdk/::[ki]"),