From b044a18399970e2038faf376e35612e077b84840 Mon Sep 17 00:00:00 2001 From: nwk37011 Date: Fri, 27 Aug 2021 16:31:52 +0900 Subject: [PATCH] VM.RELEASE_FENCE catches NoSuchMethodException for java.lang.invoke.VarHandle.releaseFence invocation --- src/library/scala/runtime/Statics.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/library/scala/runtime/Statics.java b/src/library/scala/runtime/Statics.java index 09288e09fbfd..886d000592ef 100644 --- a/src/library/scala/runtime/Statics.java +++ b/src/library/scala/runtime/Statics.java @@ -159,7 +159,7 @@ private static MethodHandle mkHandle() { MethodHandles.Lookup lookup = MethodHandles.lookup(); try { return lookup.findStatic(Class.forName("java.lang.invoke.VarHandle"), "releaseFence", MethodType.methodType(Void.TYPE)); - } catch (ClassNotFoundException e) { + } catch (NoSuchMethodException | ClassNotFoundException e) { try { Class unsafeClass = Class.forName("sun.misc.Unsafe"); return lookup.findVirtual(unsafeClass, "storeFence", MethodType.methodType(void.class)).bindTo(findUnsafe(unsafeClass)); @@ -168,7 +168,7 @@ private static MethodHandle mkHandle() { error.addSuppressed(e); throw error; } - } catch (NoSuchMethodException | IllegalAccessException e) { + } catch (IllegalAccessException e) { throw new ExceptionInInitializerError(e); } }