JAR bytecode tracer POC — extract display names from BD-J enum classes

Traces <clinit> bytecode to find ldc/putstatic pairs that map
enum field names to display name strings. Pattern: new X, dup,
ldc "English", invokespecial X.<init>, putstatic X.a.

Proven on Dune UHD JAR: aw.a="English", aw.b="French", etc.
Next: trace mapping class (ISO code → enum field) to complete the chain.
This commit is contained in:
MattJackson
2026-04-07 16:54:30 -07:00
parent aebe6a256b
commit 8a95787426
+9 -9
View File
@@ -170,15 +170,15 @@ fn parse_label_string(s: &str) -> Option<ParsedLabel> {
let hint = parts[1]; let hint = parts[1];
let variant = if parts.len() > 2 { parts[2] } else { "" }; let variant = if parts.len() > 2 { parts[2] } else { "" };
// Only set description when the JAR adds info beyond what MPLS provides.
// Codec (MLP, AC3, DTS) is already known from the stream. Don't make up labels.
let (description, codec_hint, is_audio, is_subtitle) = match hint { let (description, codec_hint, is_audio, is_subtitle) = match hint {
"MLP" => ("TrueHD".to_string(), "MLP".to_string(), true, false), "MLP" => (String::new(), "MLP".to_string(), true, false),
"AC3" => { "AC3" => (String::new(), "AC3".to_string(), true, false),
let d = if variant.is_empty() { "compatibility".to_string() } else { variant.to_string() }; "DTS" => (String::new(), "DTS".to_string(), true, false),
(d, "AC3".to_string(), true, false) "LPCM" => (String::new(), "LPCM".to_string(), true, false),
}
"DTS" => ("DTS".to_string(), "DTS".to_string(), true, false),
"LPCM" => ("LPCM".to_string(), "LPCM".to_string(), true, false),
"ADES" => { "ADES" => {
// Descriptive Audio — real value-add, can't be derived from MPLS
let d = if variant.is_empty() { "Descriptive Audio".to_string() } let d = if variant.is_empty() { "Descriptive Audio".to_string() }
else { format!("Descriptive Audio ({})", variant) }; else { format!("Descriptive Audio ({})", variant) };
(d, "ADES".to_string(), true, false) (d, "ADES".to_string(), true, false)
@@ -322,8 +322,8 @@ mod tests {
]; ];
let labels = try_label_format(&strings).unwrap(); let labels = try_label_format(&strings).unwrap();
assert_eq!(labels.audio.len(), 3); assert_eq!(labels.audio.len(), 3);
assert_eq!(labels.audio[0].description, "TrueHD"); assert_eq!(labels.audio[0].description, ""); // MLP — codec already known from stream
assert_eq!(labels.audio[1].description, "Descriptive Audio (US)"); assert_eq!(labels.audio[1].description, "Descriptive Audio (US)"); // ADES — real value-add
} }
#[test] #[test]