ckeditor / ckbuilder

The development repository of CKBuilder, a command line builder for CKEditor 4.
Other
19 stars 11 forks source link

Java exception when running builder/build.sh #34

Open lightreign opened 3 years ago

lightreign commented 3 years ago

Type of report

Bug

Provide detailed reproduction steps (if any)

  1. Run /dev/builder/build.sh
  2. builds some files but then stops with exception thrown

Expected result

Build script executes correctly.

NOTE: If I add --add-exports java.desktop/sun.java2d=ALL-UNNAMED argument to java runtime cmd this error does not occur, fixes it?

Actual result

Java Exception thrown:

Starting CKBuilder...
Cleaning up target folder
Copying files (relax, this may take a while)
    Time taken.....: 31.87seconds
Merging language files
    Time taken.....: 5.082seconds
Generating plugins sprite image
Exception in thread "main" org.mozilla.javascript.WrappedException: Wrapped java.lang.IllegalAccessException: class org.mozilla.javascript.MemberBox cannot access class sun.java2d.SunGraphics2D (in module java.desktop) because module java.desktop does not export sun.java2d to unnamed module @619713e5 (C:\ckbuilder\src/lib/image.js#282)
    at org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Context.java:1754)
    at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:134)
    at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:225)
    at org.mozilla.javascript.optimizer.OptRuntime.callN(OptRuntime.java:52)
    at ckbuilder.lib.image._c_anonymous_7(C:\ckbuilder\src/lib/image.js:282)
    at ckbuilder.lib.image.call(C:\ckbuilder\src/lib/image.js)
    at org.mozilla.javascript.optimizer.OptRuntime.callN(OptRuntime.java:52)
    at ckbuilder.lib.image._c_anonymous_4(C:\ckbuilder\src/lib/image.js:144)
    at ckbuilder.lib.image.call(C:\ckbuilder\src/lib/image.js)
    at org.mozilla.javascript.optimizer.OptRuntime.callN(OptRuntime.java:52)
    at ckbuilder.lib.builder._c_createPluginsSpriteImage_15(C:\ckbuilder\src/lib/builder.js:476)
    at ckbuilder.lib.builder.call(C:\ckbuilder\src/lib/builder.js)
    at org.mozilla.javascript.optimizer.OptRuntime.callName0(OptRuntime.java:74)
    at ckbuilder.lib.builder._c_anonymous_20(C:\ckbuilder\src/lib/builder.js:703)
    at ckbuilder.lib.builder.call(C:\ckbuilder\src/lib/builder.js)
    at org.mozilla.javascript.optimizer.OptRuntime.callProp0(OptRuntime.java:85)
    at ckbuilder.lib.controller._c_anonymous_5(C:\ckbuilder\src/lib/controller.js:78)
    at ckbuilder.lib.controller.call(C:\ckbuilder\src/lib/controller.js)
    at org.mozilla.javascript.ScriptRuntime.applyOrCall(ScriptRuntime.java:2430)
    at org.mozilla.javascript.BaseFunction.execIdCall(BaseFunction.java:269)
    at org.mozilla.javascript.IdFunctionObject.call(IdFunctionObject.java:97)
    at org.mozilla.javascript.optimizer.OptRuntime.callN(OptRuntime.java:52)
    at ckbuilder.lib.controller._c_anonymous_14(C:\ckbuilder\src/lib/controller.js:235)
    at ckbuilder.lib.controller.call(C:\ckbuilder\src/lib/controller.js)
    at org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:32)
    at ckbuilder.ckbuilder._c_script_0(C:\ckbuilder\src/ckbuilder.js:112)
    at ckbuilder.ckbuilder.call(C:\ckbuilder\src/ckbuilder.js)
    at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:394)
    at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3091)
    at ckbuilder.ckbuilder.call(C:\ckbuilder\src/ckbuilder.js)
    at ckbuilder.ckbuilder.exec(C:\ckbuilder\src/ckbuilder.js)
    at org.mozilla.javascript.optimizer.OptRuntime$1.run(OptRuntime.java:218)
    at org.mozilla.javascript.Context.call(Context.java:489)
    at org.mozilla.javascript.ContextFactory.call(ContextFactory.java:504)
    at org.mozilla.javascript.optimizer.OptRuntime.main(OptRuntime.java:206)
    at ckbuilder.ckbuilder.main(C:\ckbuilder\src/ckbuilder.js)
Caused by: java.lang.IllegalAccessException: class org.mozilla.javascript.MemberBox cannot access class sun.java2d.SunGraphics2D (in module java.desktop) because module java.desktop does not export sun.java2d to unnamed module @619713e5
    at java.base/jdk.internal.reflect.Reflection.newIllegalAccessException(Reflection.java:385)
    at java.base/java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:687)
    at java.base/java.lang.reflect.Method.invoke(Method.java:559)
    at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:126)
    ... 34 more

Other details

Comandeer commented 3 years ago

I moved the issue to the repo with the CKEditor 4 builder.

Could you check if the builder works with older version of Java (8 or 11)? Probably it would be the easiest workaround for now.

lightreign commented 3 years ago

Thanks @Comandeer, I ran this in Java 11 OpenJDK and got the following warning:

Generating plugins sprite image
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.mozilla.javascript.MemberBox (file:/opt/....../ckbuilder.jar) to method sun.java2d.SunGraphics2D.drawImage(java.awt.Image,int,int,java.awt.image.ImageObserver)
WARNING: Please consider reporting this to the maintainers of org.mozilla.javascript.MemberBox
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

No stack trace, exit code 0 :)

SuperPat45 commented 3 years ago

Like #27, this error with Java 17 need to be fixed by rihno: https://github.com/mozilla/rhino/issues/462 hopefully in their next version v1.7.14 as adding --add-exports java.desktop/sun.java2d=ALL-UNNAMED to jvm arguments seem not work in java 17 for me.

SuperPat45 commented 2 years ago

I successfully recompiled CKeditor4 with Open JDK 17!

You need to recompile CKBuilder.jar by upgrading mozilla rhino with the latest version v1.7.14 You need to add the JVM argument --add-exports java.desktop/sun.java2d=ALL-UNNAMED to your command line

ghostakshay commented 1 year ago

We came across one issue of Riho which is used in elixir repertoire server. We got below error and laber/reports not getting printed properly. ERROR, JavaScript - JavaScript eval: Error evaluating script: java.lang.IllegalAccessException: class org.mozilla.javascript.MemberBox cannot access class sun.java2d.SunGraphics2D (in module java.desktop) because module java.desktop does not export sun.java2d to unnamed module @483f6d77

We resolved above issue by passing below argument while starting Repetior Server using java 17. java --add-opens java.desktop/sun.java2d=ALL-UNNAMED