diff --git a/Cargo.toml b/Cargo.toml index 53459dc6..5b8be404 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -53,7 +53,7 @@ java_runtime = { workspace = true } test_utils = { workspace = true } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] -tokio = { workspace = true, features = ["rt-multi-thread"] } +tokio = { workspace = true, features = ["rt-multi-thread", "time"] } [target.'cfg(target_arch = "wasm32")'.dependencies] -tokio = { workspace = true, features = ["rt"] } +tokio = { workspace = true, features = ["rt", "time"] } diff --git a/STATE.md b/STATE.md index c17697c3..b3bcba31 100644 --- a/STATE.md +++ b/STATE.md @@ -6,13 +6,29 @@ ## 완료 - [rustjava-runtime-time-todo-impl] RuntimeImpl 시간 API `todo!()` 3건 제거(now/sleep/yield) + test_utils `r#yield` 구현 + tokio `time` 피처 추가 + 회귀 잠금 픽스처(`test_data/TimeApi`). - 브랜치 `runtime-time-impl`, PR #2 게이트② 대기. + ★게이트③ 진행: PR #2 approve 핀 `3afb6cc` 확인 → main(549b9eb) 충돌 해소(STATE/REPORT + superset, docs-only) 후 스쿼시 머지(2026-07-23). - [rustjava-classfile-parse-error-propagation] 클래스파일 파싱 실패를 패닉 대신 `java.lang.ClassFormatError` 로 전파(절단/매직 불일치/미지원 상수풀 태그 구분). - 브랜치 `classfile-parse-error-propagation`, PR 게이트② 대기. + ★게이트③ 완료: PR #3 스쿼시 머지 → main `549b9eb`(2026-07-23), 브랜치 정리 완료. +- [rustjava-tracing-attributes-pin-removal] `#[tracing::instrument]` 1건을 수동 span 으로 대체, + `tracing-attributes` 상한 핀 제거(tracing 0.1.41→0.1.44 언프리즈), wasm32 clippy CI 커버리지 + 교정. 브랜치 `tracing-attributes-pin-removal`, PR 게이트② 대기. +- [rustjava-unsupported-charset-exception] 미지원 charset `unimplemented!()` 패닉 3지점을 + `java.io.UnsupportedEncodingException`(신설) throw 로 전환, String↔InputStreamReader 지원 + charset 을 공용 `charset::Charset` 으로 일치(ISO-8859-1/US-ASCII 가 Reader 에서도 동작). + 부수: `System.setProperty` 반환 시그니처 JDK 규격화(Object→String, jvm 부트스트랩 포함), + `Throwable.getMessage()` 신설, 픽스처 `test_data/UnsupportedCharset`. 브랜치 + `unsupported-charset-exception`, PR #5 게이트② 대기. ## 다음 -- PR approve 후 머지, 브랜치 정리(`gh pr merge --delete-branch` → `git branch -D` → `git fetch --prune`) -- ★두 PR 모두 STATE.md/REPORT.md 를 추가하므로 나중에 머지되는 쪽에서 add/add 충돌 예상 — - 선행 PR 머지 후 후행 브랜치에 `git merge main` 하고 후행(superset) 내용 채택으로 해소. -- (범위 밖 잔여) `jvm_rust/src/interpreter.rs:629` `todo!()` — 별건 티켓 필요 +- 잔여 PR 게이트② approve 후 머지: tracing-attributes-pin-removal, #5(unsupported-charset). + 브랜치 정리(`gh pr merge --delete-branch` → `git branch -D` → `git fetch --prune`) +- ★잔여 PR 도 STATE.md/REPORT.md add/add·수정 충돌 예상 — 선행 머지 후 후행 브랜치에 + `git merge main` 하고 최신(superset) 내용 채택으로 해소. +- ★PR 발권 시 `--repo Jun025/RustJava` 명시(2026-07-22 upstream 오발행 사고 재발 방지). +- (범위 밖 잔여) `jvm_rust/src/interpreter.rs:629` `todo!()` (invokedynamic) — 별건 티켓 필요 +- (신규 발견) javac 21 산출 익명 내부 클래스(.class)가 "Malformed class file" 로 파싱 실패 — + 원인 미조사(태그 15~18 아님). 별건 티켓 필요. +- (신규 발견) InputStreamReader 가 read 마다 스트림 디코더를 새로 생성 — EUC-KR 등 multibyte + 가 버퍼 경계에 걸리면 부분 시퀀스 유실 가능(기존 문제, 이번 범위 밖). 별건 티켓 권장. diff --git a/src/runtime.rs b/src/runtime.rs index 2c705e1b..a6570e43 100644 --- a/src/runtime.rs +++ b/src/runtime.rs @@ -9,6 +9,7 @@ use std::{ fs, io::{Write, stderr, stdin}, sync::Mutex, + time::{SystemTime, UNIX_EPOCH}, }; use java_runtime::{File, FileDescriptorId, FileStat, FileType, IOError, IOResult, RT_RUSTJAR, Runtime, SpawnCallback, get_runtime_class_proto}; @@ -87,12 +88,12 @@ impl Runtime for RuntimeImpl where T: Sync + Send + Write + 'static, { - async fn sleep(&self, _duration: Duration) { - todo!() + async fn sleep(&self, duration: Duration) { + tokio::time::sleep(duration).await; } async fn r#yield(&self) { - todo!() + tokio::task::yield_now().await; } fn spawn(&self, _jvm: &Jvm, callback: Box) { @@ -107,7 +108,7 @@ where } fn now(&self) -> u64 { - todo!() + SystemTime::now().duration_since(UNIX_EPOCH).unwrap_or(Duration::from_secs(0)).as_millis() as u64 } fn current_task_id(&self) -> u64 { diff --git a/test_data/TimeApi.class b/test_data/TimeApi.class new file mode 100644 index 00000000..5a394ad6 Binary files /dev/null and b/test_data/TimeApi.class differ diff --git a/test_data/TimeApi.txt b/test_data/TimeApi.txt new file mode 100644 index 00000000..b10f2546 --- /dev/null +++ b/test_data/TimeApi.txt @@ -0,0 +1,5 @@ +currentTimeMillis positive +yield returned +monotonic after sleep +sleep elapsed +date positive diff --git a/test_utils/src/lib.rs b/test_utils/src/lib.rs index 7328818d..9bba4dd8 100644 --- a/test_utils/src/lib.rs +++ b/test_utils/src/lib.rs @@ -64,7 +64,7 @@ impl Runtime for TestRuntime { } async fn r#yield(&self) { - todo!() + tokio::task::yield_now().await; } fn spawn(&self, _jvm: &Jvm, callback: Box) {