Crates.io | classreader |
lib.rs | classreader |
version | 0.2.1 |
source | src |
created_at | 2015-07-24 22:10:59.190973 |
updated_at | 2018-06-17 14:24:44.337016 |
description | A Rust library that reads, writes, and parses Java Virtula Machine class files. |
homepage | |
repository | https://github.com/Wright-Language-Developers/classreader-rs |
max_upload_size | |
id | 2671 |
size | 92,340 |
Parses the class file format that is used by the Java Virtual Machine version 8.
extern crate classreader;
use classreader::ClassReader;
use std::fs::File;
pub fn main() {
let mut file = File::open("pkg/Test.class").unwrap();
let class = ClassReader::new_from_reader(file).unwrap();
assert_eq!(0xCAFEBABE, class.magic);
}
classreader uses the log crate to emit some log messages. They are mainly useful for low level debugging.
Parses the whole rt.jar of OpenJDK 8 without issue. Code is not yet decoded. Apart from that, everything is parsed into suitable data structures.
Strings from a class file's constant pool are currently parsed into a Rust String
. It seems that class files may contain code points for surrogate pairs. These are invalid for UTF-8 encoded strings which is what Rust uses. So whenever such a code point is decoded, it is replaced by the Unicode Replacement Character U+FFFD. This happens rarely but it does happen. A log message with info level is emitted.
Apache License Version 2. See LICENSE for the text.