diff --git a/src/native_methods.rs b/src/native_methods.rs index efd1faf..8255dda 100644 --- a/src/native_methods.rs +++ b/src/native_methods.rs @@ -41,6 +41,19 @@ impl EntryPoint { } } +struct JavaIOFileDescriptor {} + +impl JavaIOFileDescriptor { + + fn get_handle(_jvm: &mut JVM) -> Result { + Ok(JVMCallbackOperation::ReturnFrame(FieldValue::Long(0))) + } + + fn get_append(_jvm: &mut JVM) -> Result { + Ok(JVMCallbackOperation::ReturnFrame(FieldValue::Boolean(false))) // TODO: Get append + } +} + struct JavaLangClass {} impl JavaLangClass { @@ -895,6 +908,12 @@ impl JdkInternalUtilSystemPropsRaw { ("user.name", "java"), // TODO ("sun.nio.MaxDirectMemorySize", "9223372036854775807"), ("sun.nio.PageAlignDirectMemory", "false"), + ("native.encoding", "UTF-8"), + ("file.encoding", "UTF-8"), + ("sun.jnu.encoding", "UTF-8"), + ("os.name", "Unknown"), + ("os.version", "Unknown"), + ("os.arch", "Unknown"), ]; // TODO: Cross-Platform tmpdir // TODO: locale detection @@ -3597,6 +3616,156 @@ pub fn function_for(class_name: &str, m: &crate::classfile::MethodInfo) -> Resul }, todo_call ), + + ( + "java/io/FileInputStream", + "open0", + MethodDescriptor { + argument_types: Box::new([ + AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Classname("java/lang/String".to_string())}, + ]), + return_type: AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Void() }, + }, + todo_call + ), + + ( + "java/io/FileInputStream", + "read0", + MethodDescriptor { + argument_types: Box::new([ + ]), + return_type: AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Int() }, + }, + todo_call + ), + + ( + "java/io/FileInputStream", + "readBytes", + MethodDescriptor { + argument_types: Box::new([ + AbstractTypeDescription { array_level: 1, kind: AbstractTypeKind::Byte() }, + AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Int() }, + AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Int() }, + ]), + return_type: AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Int() }, + }, + todo_call + ), + + ( + "java/io/FileInputStream", + "length0", + MethodDescriptor { + argument_types: Box::new([ + ]), + return_type: AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Long() }, + }, + todo_call + ), + + ( + "java/io/FileInputStream", + "position0", + MethodDescriptor { + argument_types: Box::new([ + ]), + return_type: AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Long() }, + }, + todo_call + ), + + ( + "java/io/FileInputStream", + "skip0", + MethodDescriptor { + argument_types: Box::new([ + AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Long() }, + ]), + return_type: AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Long() }, + }, + todo_call + ), + + ( + "java/io/FileInputStream", + "available0", + MethodDescriptor { + argument_types: Box::new([ + ]), + return_type: AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Int() }, + }, + todo_call + ), + + ( + "java/io/FileInputStream", + "initIDs", + MethodDescriptor { + argument_types: Box::new([ + ]), + return_type: AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Void() }, + }, + ignore_call + ), + + ( + "java/io/FileDescriptor", + "sync0", + MethodDescriptor { + argument_types: Box::new([ + ]), + return_type: AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Void() }, + }, + todo_call + ), + + ( + "java/io/FileDescriptor", + "initIDs", + MethodDescriptor { + argument_types: Box::new([ + ]), + return_type: AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Void() }, + }, + ignore_call + ), + + ( + "java/io/FileDescriptor", + "getHandle", + MethodDescriptor { + argument_types: Box::new([ + AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Int() }, + ]), + return_type: AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Long() }, + }, + JavaIOFileDescriptor::get_handle + ), + + ( + "java/io/FileDescriptor", + "getAppend", + MethodDescriptor { + argument_types: Box::new([ + AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Int() }, + ]), + return_type: AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Boolean() }, + }, + JavaIOFileDescriptor::get_append + ), + + ( + "java/io/FileDescriptor", + "close0", + MethodDescriptor { + argument_types: Box::new([ + ]), + return_type: AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Void() }, + }, + todo_call + ), ]; for (classname, methodname, methoddescriptor, binding) in native_mappings {