From 5a0c4183896f42ccfc8010c7a7dc2cceb5956c21 Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Mon, 25 Sep 2023 21:23:46 +0200 Subject: [PATCH] wasm: fix duplicate random function --- .../main/java/org/teavm/classlib/java/lang/TMath.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TMath.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TMath.java index d693bd410..d6b4b764e 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TMath.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TMath.java @@ -164,14 +164,19 @@ public final class TMath extends TObject { @Unmanaged public static double random() { - return PlatformDetector.isC() ? randomC() : randomImpl(); + if (PlatformDetector.isC()) { + return randomC(); + } else if (PlatformDetector.isWebAssembly()) { + return WasmSupport.random(); + } else { + return randomImpl(); + } } @Import(name = "teavm_rand") private static native double randomC(); @GeneratedBy(MathNativeGenerator.class) - @Import(module = "teavmMath", name = "random") private static native double randomImpl(); public static int min(int a, int b) {