diff options
author | 2024-10-16 09:09:23 +0000 | |
---|---|---|
committer | 2024-10-16 20:06:43 +0000 | |
commit | 3e5cfa5a7557395123f4f4648a761d88eda358b7 (patch) | |
tree | 90ad45111cab61092f8433b8d6092211d066eb70 | |
parent | 54c1c76edb6e8cb92788559f9d10a8241e643a15 (diff) |
Provide faulty implementation of System.nanoTime in UnstartedRuntime.
Bug: 297147201
Test: ./art/test/testrunner/testrunner.py --host --64 -b
Change-Id: I3aef44212a26205ad6f1b57389c655800d4ae760
-rw-r--r-- | runtime/interpreter/unstarted_runtime.cc | 8 | ||||
-rw-r--r-- | runtime/interpreter/unstarted_runtime_list.h | 1 |
2 files changed, 9 insertions, 0 deletions
diff --git a/runtime/interpreter/unstarted_runtime.cc b/runtime/interpreter/unstarted_runtime.cc index 0dde04145a..06aeff8394 100644 --- a/runtime/interpreter/unstarted_runtime.cc +++ b/runtime/interpreter/unstarted_runtime.cc @@ -1046,6 +1046,14 @@ void UnstartedRuntime::UnstartedSystemGetPropertyWithDefault( GetSystemProperty(self, shadow_frame, result, arg_offset, true); } +void UnstartedRuntime::UnstartedSystemNanoTime(Thread* self, ShadowFrame*, JValue*, size_t) { + // We don't want `System.nanoTime` to be called at compile time because `java.util.Random`'s + // default constructor uses `nanoTime` to initialize seed and having it set during compile time + // makes that `java.util.Random` instance deterministic for given system image. + self->ThrowNewException("Ljava/lang/IllegalStateException;", + "Should not be called by UnstartedRuntime"); +} + static std::string GetImmediateCaller(ShadowFrame* shadow_frame) REQUIRES_SHARED(Locks::mutator_lock_) { if (shadow_frame->GetLink() == nullptr) { diff --git a/runtime/interpreter/unstarted_runtime_list.h b/runtime/interpreter/unstarted_runtime_list.h index 71e3ae71ae..429fa93485 100644 --- a/runtime/interpreter/unstarted_runtime_list.h +++ b/runtime/interpreter/unstarted_runtime_list.h @@ -46,6 +46,7 @@ V(SystemGetSecurityManager, "Ljava/lang/System;", "getSecurityManager", "()Ljava/lang/SecurityManager;") \ V(SystemGetProperty, "Ljava/lang/System;", "getProperty", "(Ljava/lang/String;)Ljava/lang/String;") \ V(SystemGetPropertyWithDefault, "Ljava/lang/System;", "getProperty", "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;") \ + V(SystemNanoTime, "Ljava/lang/System;", "nanoTime", "()J") \ V(ThreadLocalGet, "Ljava/lang/ThreadLocal;", "get", "()Ljava/lang/Object;") \ V(MathCeil, "Ljava/lang/Math;", "ceil", "(D)D") \ V(MathFloor, "Ljava/lang/Math;", "floor", "(D)D") \ |