Skip to content

Commit 8a4e1a8

Browse files
committed
runtime/native: move remaining java.lang.System methods to JNI
1 parent 6e6fff5 commit 8a4e1a8

File tree

13 files changed

+259
-279
lines changed

13 files changed

+259
-279
lines changed

jni/src/env/array.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ impl super::JniEnv {
141141
&self,
142142
array: JByteArray,
143143
start: jsize,
144-
buf: &[jbyte],
144+
buf: &mut [jbyte],
145145
) -> Result<()> {
146146
unsafe {
147147
let invoke_interface = self.as_native_interface();
@@ -150,7 +150,7 @@ impl super::JniEnv {
150150
array.raw(),
151151
start,
152152
buf.len() as jsize,
153-
buf.as_ptr(),
153+
buf.as_mut_ptr(),
154154
);
155155
}
156156

jni/sys/src/lib.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2002,63 +2002,63 @@ pub struct JNINativeInterface_ {
20022002
array: jbooleanArray,
20032003
start: jsize,
20042004
l: jsize,
2005-
buf: *const jboolean,
2005+
buf: *mut jboolean,
20062006
)),
20072007

20082008
pub SetByteArrayRegion: jni_system_fn!((
20092009
env: *mut JNIEnv,
20102010
array: jbyteArray,
20112011
start: jsize,
20122012
len: jsize,
2013-
buf: *const jbyte,
2013+
buf: *mut jbyte,
20142014
)),
20152015

20162016
pub SetCharArrayRegion: jni_system_fn!((
20172017
env: *mut JNIEnv,
20182018
array: jcharArray,
20192019
start: jsize,
20202020
len: jsize,
2021-
buf: *const jchar,
2021+
buf: *mut jchar,
20222022
)),
20232023

20242024
pub SetShortArrayRegion: jni_system_fn!((
20252025
env: *mut JNIEnv,
20262026
array: jshortArray,
20272027
start: jsize,
20282028
len: jsize,
2029-
buf: *const jshort,
2029+
buf: *mut jshort,
20302030
)),
20312031

20322032
pub SetIntArrayRegion: jni_system_fn!((
20332033
env: *mut JNIEnv,
20342034
array: jintArray,
20352035
start: jsize,
20362036
len: jsize,
2037-
buf: *const jint,
2037+
buf: *mut jint,
20382038
)),
20392039

20402040
pub SetLongArrayRegion: jni_system_fn!((
20412041
env: *mut JNIEnv,
20422042
array: jlongArray,
20432043
start: jsize,
20442044
len: jsize,
2045-
buf: *const jlong,
2045+
buf: *mut jlong,
20462046
)),
20472047

20482048
pub SetFloatArrayRegion: jni_system_fn!((
20492049
env: *mut JNIEnv,
20502050
array: jfloatArray,
20512051
start: jsize,
20522052
len: jsize,
2053-
buf: *const jfloat,
2053+
buf: *mut jfloat,
20542054
)),
20552055

20562056
pub SetDoubleArrayRegion: jni_system_fn!((
20572057
env: *mut JNIEnv,
20582058
array: jdoubleArray,
20592059
start: jsize,
20602060
len: jsize,
2061-
buf: *const jdouble,
2061+
buf: *mut jdouble,
20622062
)),
20632063

20642064
/// Registers native methods with the class specified by the `clazz` argument.

native/nio/src/fs/unix/UnixNativeDispatcher.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,15 @@ pub extern "system" fn Java_sun_nio_fs_UnixNativeDispatcher_getcwd(
128128
todo!("Throw sun/util/UnixException")
129129
}
130130

131+
let cwd_len;
131132
unsafe {
132-
let cwd_len = libc::strlen(cwd) + 1;
133+
cwd_len = libc::strlen(cwd) + 1;
133134
buf.set_len(cwd_len);
134135
}
135136

136-
let buf_without_terminator = &buf[..buf.len() - 1];
137+
let buf_without_terminator = &mut buf[..cwd_len - 1];
137138

138-
let Ok(byte_array) = env.new_byte_array(buf_without_terminator.len() as jsize) else {
139+
let Ok(byte_array) = env.new_byte_array((cwd_len - 1) as jsize) else {
139140
return None;
140141
};
141142

runtime/src/native/java/lang/System.rs

Lines changed: 0 additions & 193 deletions
This file was deleted.

runtime/src/native/java/lang/def/System.def

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)