From 88e59231da50b9623d775765fbdff31fa32d83e5 Mon Sep 17 00:00:00 2001 From: MiaoWoo Date: Tue, 22 Jun 2021 15:51:28 +0800 Subject: [PATCH] feat: add openjdk nashorn shim Signed-off-by: MiaoWoo --- packages/polyfill/src/index.ts | 1 + packages/polyfill/src/openjdk-nashorn-shim.ts | 7 +++++++ 2 files changed, 8 insertions(+) create mode 100644 packages/polyfill/src/openjdk-nashorn-shim.ts diff --git a/packages/polyfill/src/index.ts b/packages/polyfill/src/index.ts index b1504c32..df76957c 100644 --- a/packages/polyfill/src/index.ts +++ b/packages/polyfill/src/index.ts @@ -4,6 +4,7 @@ import i18n from '@ccms/i18n' let polyfillStartTime = new Date().getTime() i18n.initialize() console.i18n("ms.polyfill.initialize") +import './openjdk-nashorn-shim' import './es5-ext' import './node-shim' import 'core-js' diff --git a/packages/polyfill/src/openjdk-nashorn-shim.ts b/packages/polyfill/src/openjdk-nashorn-shim.ts new file mode 100644 index 00000000..26391204 --- /dev/null +++ b/packages/polyfill/src/openjdk-nashorn-shim.ts @@ -0,0 +1,7 @@ +// fix OpenJDK Nahsorn setPrototypeOf Bug +try { + Java.type('org.openjdk.nashorn.api.scripting.NashornScriptEngine') + Object.setPrototypeOf = ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b }) +} catch (error) { +} +export { }