AndLong, IntModulo, ASHRLong and native methods
This commit is contained in:
parent
8e5b6bb2b8
commit
796e52241d
3 changed files with 336 additions and 7 deletions
|
@ -461,9 +461,22 @@ impl JavaLangThrowable {
|
|||
}
|
||||
}
|
||||
|
||||
struct JavaSecurityAccessController {}
|
||||
|
||||
impl JavaSecurityAccessController {
|
||||
fn get_stack_access_control_context(_jvm: &mut JVM) -> Result<JVMCallbackOperation, Error> {
|
||||
Ok(JVMCallbackOperation::ReturnFrame(FieldValue::Reference(ObjectReference::NULL)))
|
||||
}
|
||||
}
|
||||
|
||||
struct JdkInternalMiscCDS {}
|
||||
|
||||
impl JdkInternalMiscCDS {
|
||||
fn get_random_seed_for_dumping(_jvm: &mut JVM) -> Result<JVMCallbackOperation, Error> {
|
||||
return Ok(JVMCallbackOperation::ReturnFrame(FieldValue::Long(42))); // TODO: Random seed
|
||||
// depending on JVM
|
||||
// version
|
||||
}
|
||||
fn get_cds_config_status(_jvm: &mut JVM) -> Result<JVMCallbackOperation, Error> {
|
||||
return Ok(JVMCallbackOperation::ReturnFrame(FieldValue::Int(0)));
|
||||
}
|
||||
|
@ -708,12 +721,24 @@ impl JdkInternalMiscUnsafe {
|
|||
Ok(JVMCallbackOperation::ReturnFrame(FieldValue::Int(index_scale)))
|
||||
}
|
||||
|
||||
pub fn array_base_offset_0(jvm: &mut JVM) -> Result<JVMCallbackOperation, Error> {
|
||||
pub fn array_base_offset_0(_jvm: &mut JVM) -> Result<JVMCallbackOperation, Error> {
|
||||
// TODO: Check passed class
|
||||
Ok(JVMCallbackOperation::ReturnFrame(FieldValue::Int(0)))
|
||||
}
|
||||
}
|
||||
|
||||
struct JdkInternalReflectReflection {}
|
||||
|
||||
impl JdkInternalReflectReflection {
|
||||
pub fn get_caller_class(jvm: &mut JVM) -> Result<JVMCallbackOperation, Error> {
|
||||
let caller_frame = &jvm.stack_frames[jvm.stack_frames.len() - 2];
|
||||
let caller_class_index = caller_frame.class_index;
|
||||
let caller_class_reference = jvm.class_store.get_class_objectref_from_index(caller_class_index);
|
||||
|
||||
Ok(JVMCallbackOperation::ReturnFrame(FieldValue::Reference(caller_class_reference)))
|
||||
}
|
||||
}
|
||||
|
||||
pub struct JdkInternalUtilSystemPropsRaw {}
|
||||
|
||||
impl JdkInternalUtilSystemPropsRaw {
|
||||
|
@ -3110,7 +3135,7 @@ pub fn function_for(class_name: &str, m: &crate::classfile::MethodInfo) -> Resul
|
|||
]),
|
||||
return_type: AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Long() },
|
||||
},
|
||||
todo_call
|
||||
JdkInternalMiscCDS::get_random_seed_for_dumping
|
||||
),
|
||||
|
||||
(
|
||||
|
@ -3136,6 +3161,280 @@ pub fn function_for(class_name: &str, m: &crate::classfile::MethodInfo) -> Resul
|
|||
},
|
||||
todo_call
|
||||
),
|
||||
|
||||
(
|
||||
"jdk/internal/reflect/Reflection",
|
||||
"getCallerClass",
|
||||
MethodDescriptor {
|
||||
argument_types: Box::new([
|
||||
]),
|
||||
return_type: AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Classname("java/lang/Class".to_string()) },
|
||||
},
|
||||
JdkInternalReflectReflection::get_caller_class
|
||||
),
|
||||
|
||||
(
|
||||
"jdk/internal/reflect/Reflection",
|
||||
"getClassAccessFlags",
|
||||
MethodDescriptor {
|
||||
argument_types: Box::new([
|
||||
AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Classname("java/lang/Class".to_string())},
|
||||
]),
|
||||
return_type: AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Int() },
|
||||
},
|
||||
todo_call
|
||||
),
|
||||
|
||||
(
|
||||
"jdk/internal/reflect/Reflection",
|
||||
"areNestMates",
|
||||
MethodDescriptor {
|
||||
argument_types: Box::new([
|
||||
AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Classname("java/lang/Class".to_string())},
|
||||
AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Classname("java/lang/Class".to_string())},
|
||||
]),
|
||||
return_type: AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Boolean() },
|
||||
},
|
||||
todo_call
|
||||
),
|
||||
|
||||
(
|
||||
"java/security/AccessController",
|
||||
"getProtectionDomain",
|
||||
MethodDescriptor {
|
||||
argument_types: Box::new([
|
||||
AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Classname("java/lang/Class".to_string())},
|
||||
]),
|
||||
return_type: AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Classname("java/security/ProtectionDomain".to_string()) },
|
||||
},
|
||||
todo_call
|
||||
),
|
||||
|
||||
(
|
||||
"java/security/AccessController",
|
||||
"ensureMaterializedForStackWalk",
|
||||
MethodDescriptor {
|
||||
argument_types: Box::new([
|
||||
AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Classname("java/lang/Object".to_string())},
|
||||
]),
|
||||
return_type: AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Void() },
|
||||
},
|
||||
ignore_call
|
||||
),
|
||||
|
||||
(
|
||||
"java/security/AccessController",
|
||||
"getStackAccessControlContext",
|
||||
MethodDescriptor {
|
||||
argument_types: Box::new([
|
||||
]),
|
||||
return_type: AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Classname("java/security/AccessControlContext".to_string()) },
|
||||
},
|
||||
JavaSecurityAccessController::get_stack_access_control_context
|
||||
),
|
||||
|
||||
(
|
||||
"java/security/AccessController",
|
||||
"getInheritedAccessControlContext",
|
||||
MethodDescriptor {
|
||||
argument_types: Box::new([
|
||||
]),
|
||||
return_type: AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Classname("java/security/AccessControlContext".to_string()) },
|
||||
},
|
||||
todo_call
|
||||
),
|
||||
|
||||
(
|
||||
"java/lang/ref/Reference",
|
||||
"getAndClearReferencePendingList",
|
||||
MethodDescriptor {
|
||||
argument_types: Box::new([
|
||||
]),
|
||||
return_type: AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Classname("java/lang/ref/Reference".to_string()) },
|
||||
},
|
||||
todo_call
|
||||
),
|
||||
|
||||
(
|
||||
"java/lang/ref/Reference",
|
||||
"hasReferencePendingList",
|
||||
MethodDescriptor {
|
||||
argument_types: Box::new([
|
||||
]),
|
||||
return_type: AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Boolean() },
|
||||
},
|
||||
todo_call
|
||||
),
|
||||
|
||||
(
|
||||
"java/lang/ref/Reference",
|
||||
"waitForReferencePendingList",
|
||||
MethodDescriptor {
|
||||
argument_types: Box::new([
|
||||
]),
|
||||
return_type: AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Void() },
|
||||
},
|
||||
todo_call
|
||||
),
|
||||
|
||||
(
|
||||
"java/lang/ref/Reference",
|
||||
"refersTo0",
|
||||
MethodDescriptor {
|
||||
argument_types: Box::new([
|
||||
AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Classname("java/lang/Object".to_string())},
|
||||
]),
|
||||
return_type: AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Boolean() },
|
||||
},
|
||||
todo_call
|
||||
),
|
||||
|
||||
(
|
||||
"java/lang/ref/Reference",
|
||||
"clear0",
|
||||
MethodDescriptor {
|
||||
argument_types: Box::new([
|
||||
]),
|
||||
return_type: AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Void() },
|
||||
},
|
||||
todo_call
|
||||
),
|
||||
|
||||
(
|
||||
"java/lang/ClassLoader",
|
||||
"registerNatives",
|
||||
MethodDescriptor {
|
||||
argument_types: Box::new([
|
||||
]),
|
||||
return_type: AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Void() },
|
||||
},
|
||||
ignore_call
|
||||
),
|
||||
|
||||
(
|
||||
"java/lang/ClassLoader",
|
||||
"defineClass0",
|
||||
MethodDescriptor {
|
||||
argument_types: Box::new([
|
||||
AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Classname("java/lang/ClassLoader".to_string())},
|
||||
AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Classname("java/lang/Class".to_string())},
|
||||
AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Classname("java/lang/String".to_string())},
|
||||
AbstractTypeDescription { array_level: 1, kind: AbstractTypeKind::Byte() },
|
||||
AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Int() },
|
||||
AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Int() },
|
||||
AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Classname("java/security/ProtectionDomain".to_string())},
|
||||
AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Boolean() },
|
||||
AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Int() },
|
||||
AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Classname("java/lang/Object".to_string())},
|
||||
]),
|
||||
return_type: AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Classname("java/lang/Class".to_string()) },
|
||||
},
|
||||
todo_call
|
||||
),
|
||||
|
||||
(
|
||||
"java/lang/ClassLoader",
|
||||
"defineClass1",
|
||||
MethodDescriptor {
|
||||
argument_types: Box::new([
|
||||
AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Classname("java/lang/ClassLoader".to_string())},
|
||||
AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Classname("java/lang/String".to_string())},
|
||||
AbstractTypeDescription { array_level: 1, kind: AbstractTypeKind::Byte() },
|
||||
AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Int() },
|
||||
AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Int() },
|
||||
AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Classname("java/security/ProtectionDomain".to_string())},
|
||||
AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Classname("java/lang/String".to_string())},
|
||||
]),
|
||||
return_type: AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Classname("java/lang/Class".to_string()) },
|
||||
},
|
||||
todo_call
|
||||
),
|
||||
|
||||
(
|
||||
"java/lang/ClassLoader",
|
||||
"defineClass2",
|
||||
MethodDescriptor {
|
||||
argument_types: Box::new([
|
||||
AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Classname("java/lang/ClassLoader".to_string())},
|
||||
AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Classname("java/lang/String".to_string())},
|
||||
AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Classname("java/nio/ByteBuffer".to_string())},
|
||||
AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Int() },
|
||||
AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Int() },
|
||||
AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Classname("java/security/ProtectionDomain".to_string())},
|
||||
AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Classname("java/lang/String".to_string())},
|
||||
]),
|
||||
return_type: AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Classname("java/lang/Class".to_string()) },
|
||||
},
|
||||
todo_call
|
||||
),
|
||||
|
||||
(
|
||||
"java/lang/ClassLoader",
|
||||
"findBootstrapClass",
|
||||
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::Classname("java/lang/Class".to_string()) },
|
||||
},
|
||||
todo_call
|
||||
),
|
||||
|
||||
(
|
||||
"java/lang/ClassLoader",
|
||||
"findLoadedClass0",
|
||||
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::Classname("java/lang/Class".to_string()) },
|
||||
},
|
||||
todo_call
|
||||
),
|
||||
|
||||
(
|
||||
"java/lang/ClassLoader",
|
||||
"retrieveDirectives",
|
||||
MethodDescriptor {
|
||||
argument_types: Box::new([
|
||||
]),
|
||||
return_type: AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Classname("java/lang/AssertionStatusDirectives".to_string()) },
|
||||
},
|
||||
todo_call
|
||||
),
|
||||
|
||||
(
|
||||
"java/lang/reflect/Executable",
|
||||
"getParameters0",
|
||||
MethodDescriptor {
|
||||
argument_types: Box::new([
|
||||
]),
|
||||
return_type: AbstractTypeDescription { array_level: 1, kind: AbstractTypeKind::Classname("java/lang/reflect/Parameter".to_string()) },
|
||||
},
|
||||
todo_call
|
||||
),
|
||||
|
||||
(
|
||||
"java/lang/reflect/Executable",
|
||||
"getTypeAnnotationBytes0",
|
||||
MethodDescriptor {
|
||||
argument_types: Box::new([
|
||||
]),
|
||||
return_type: AbstractTypeDescription { array_level: 1, kind: AbstractTypeKind::Byte() },
|
||||
},
|
||||
todo_call
|
||||
),
|
||||
|
||||
(
|
||||
"java/lang/reflect/Field",
|
||||
"getTypeAnnotationBytes0",
|
||||
MethodDescriptor {
|
||||
argument_types: Box::new([
|
||||
]),
|
||||
return_type: AbstractTypeDescription { array_level: 1, kind: AbstractTypeKind::Byte() },
|
||||
},
|
||||
todo_call
|
||||
),
|
||||
];
|
||||
|
||||
for (classname, methodname, methoddescriptor, binding) in native_mappings {
|
||||
|
@ -3143,7 +3442,7 @@ pub fn function_for(class_name: &str, m: &crate::classfile::MethodInfo) -> Resul
|
|||
continue;
|
||||
}
|
||||
if methoddescriptor != m.descriptor {
|
||||
return Err(Error::RunTimeError(format!("Descriptor mismatch in native method resolution: internal is {} but classfile wants {}", methoddescriptor.source_string(), m.descriptor.source_string())));
|
||||
return Err(Error::RunTimeError(format!("Descriptor mismatch in native method resolution for {class_name}.{method_name}: internal is {} but classfile wants {}", methoddescriptor.source_string(), m.descriptor.source_string())));
|
||||
}
|
||||
|
||||
return Ok(binding);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue