ruby-processing / propane

A simpler ruby-processing for linux/Windows/MacOS?
https://ruby-processing.github.io/propane
GNU General Public License v3.0
27 stars 1 forks source link

java.lang.reflect.InvocationTargetException being thrown when running a sketch on on Mac OSX Sierra (JDK 12) #34

Closed Aerlinger closed 5 years ago

Aerlinger commented 5 years ago

I consistently receive a java.lang.reflect.InvocationTargetException when running any propane sketch that does not have the P3D renderer option. This issue appears to be that propane/processing is trying to define an icon for the applet that does not exist.

For example, from within the propane-examples contrib folder, when I run the following from the command line:

$ jruby animation.rb

I get the following stacktrace:

java.lang.reflect.InvocationTargetException
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:567)
    at processing.awt.PSurfaceAWT.setProcessingIcon(PSurfaceAWT.java:616)
    at processing.awt.PSurfaceAWT.initFrame(PSurfaceAWT.java:456)
    at processing.core.PApplet.initSurface(PApplet.java:10822)
    at processing.core.PApplet.runSketch(PApplet.java:10710)
    at processing.core.PApplet.runSketch(PApplet.java:10883)
    at processing.core.PApplet.runPropane(PApplet.java:10897)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:567)
    at org.jruby.javasupport.JavaMethod.invokeDirectWithExceptionHandling(JavaMethod.java:440)
    at org.jruby.javasupport.JavaMethod.tryProxyInvocation(JavaMethod.java:625)
    at org.jruby.javasupport.JavaMethod.invokeDirect(JavaMethod.java:301)
    at org.jruby.java.invokers.InstanceMethodInvoker.call(InstanceMethodInvoker.java:36)
    at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:325)
    at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:141)
    at org.jruby.ir.interpreter.InterpreterEngine.processCall(InterpreterEngine.java:346)
    at org.jruby.ir.interpreter.StartupInterpreterEngine.interpret(StartupInterpreterEngine.java:72)
    at org.jruby.ir.interpreter.InterpreterEngine.interpret(InterpreterEngine.java:80)
    at org.jruby.internal.runtime.methods.MixedModeIRMethod.INTERPRET_METHOD(MixedModeIRMethod.java:138)
    at org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:125)
    at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:336)
    at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:151)
    at org.jruby.RubyClass.newInstance(RubyClass.java:983)
    at org.jruby.RubyClass$INVOKER$i$newInstance.call(RubyClass$INVOKER$i$newInstance.gen)
    at org.jruby.internal.runtime.methods.JavaMethod$JavaMethodZeroOrNBlock.call(JavaMethod.java:309)
    at org.jruby.java.proxies.ConcreteJavaProxy$NewMethod.call(ConcreteJavaProxy.java:151)
    at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:325)
    at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:141)
    at org.jruby.ir.interpreter.InterpreterEngine.processCall(InterpreterEngine.java:346)
    at org.jruby.ir.interpreter.StartupInterpreterEngine.interpret(StartupInterpreterEngine.java:72)
    at org.jruby.ir.interpreter.Interpreter.INTERPRET_ROOT(Interpreter.java:108)
    at org.jruby.ir.interpreter.Interpreter.execute(Interpreter.java:95)
    at org.jruby.ir.interpreter.Interpreter.execute(Interpreter.java:34)
    at org.jruby.ir.IRTranslator.execute(IRTranslator.java:42)
    at org.jruby.Ruby.runInterpreter(Ruby.java:861)
    at org.jruby.Ruby.loadFile(Ruby.java:2953)
    at org.jruby.runtime.load.LibrarySearcher$ResourceLibrary.load(LibrarySearcher.java:251)
    at org.jruby.runtime.load.LibrarySearcher$FoundLibrary.load(LibrarySearcher.java:34)
    at org.jruby.runtime.load.LoadService.load(LoadService.java:346)
    at org.jruby.RubyKernel.loadCommon(RubyKernel.java:1037)
    at org.jruby.RubyKernel.load(RubyKernel.java:1007)
    at org.jruby.RubyKernel$INVOKER$s$load.call(RubyKernel$INVOKER$s$load.gen)
    at org.jruby.internal.runtime.methods.JavaMethod$JavaMethodOneOrNBlock.call(JavaMethod.java:399)
    at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:346)
    at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:172)
    at DashE.invokeOther3:load(-e:1)
    at DashE.RUBY$script(-e:1)
    at java.base/java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:719)
    at org.jruby.ir.Compiler$1.load(Compiler.java:94)
    at org.jruby.Ruby.runScript(Ruby.java:849)
    at org.jruby.Ruby.runNormally(Ruby.java:772)
    at org.jruby.Ruby.runNormally(Ruby.java:790)
    at org.jruby.Ruby.runFromMain(Ruby.java:602)
    at org.jruby.Main.doRunFromMain(Main.java:415)
    at org.jruby.Main.internalRun(Main.java:307)
    at org.jruby.Main.run(Main.java:234)
    at org.jruby.Main.main(Main.java:206)
Caused by: java.lang.NullPointerException
    at processing.core.DesktopHandler.setIconImage(DesktopHandler.java:68)
    ... 62 more

Apart from this error message showing, the sketch does appear to run without issues within the applet (though no icon loads on the applet). So I believe this is a benign issue apart from this verbose and distracting stacktrace which shows on every run.

Oddly, this does not happen for propane sketches with the P3D option called from the size function on setup.

Environment

Expected Behavior

No error should show.

Actual Behavior

Obscure error shows.

image

Let me know if any further details are needed.

monkstone commented 5 years ago

Thanks for report, by benign messages I expect you mean

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.jruby.util.SecurityHelper to field java.lang.reflect.Field.modifiers
WARNING: Please consider reporting this to the maintainers of org.jruby.util.SecurityHelper
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

Some of which are probably emitted from jruby, this is a feature of all recent jdk and will either go-away or completely screw jruby etc, I expect the former, as jruby and jdk develop. I expect if I pay close attention to what Sam Pottinger has done I may be able to get to bottom of icon issue. It is unfortunate Mac has its own icon convention, and I'm a pure linux man.

monkstone commented 5 years ago

@Aerlinger, please can you test propane-3.3.0-java.gem, you will note I have also bumped samples (3.5) and updated documentation. I have found atom editor to be an excellent development environment and use script plugin to run propane from the editor. I have created a plugin for propane/JRubyArt atom-k9 for code-snippets. There is even a reek linter plugin to prompt better OO programming (I'm a big Sandi Metz fan). Equally vim works pretty well but is a bit spartan.

Aerlinger commented 5 years ago

I'm not currently seeing the "illegal reflective access" warning you mention (though I have seen it in the past in other circumstances both on JRuby and elsewhere) so not sure if it's related to the issue I've posted above.

I mean that the error message appears to be benign in that it doesn't appear to interfere with running propane, but not sure if it's a symptom of a larger issue or if others were encountering it so that's why I posted this issue.

I'll give the propane-3.30-java.gem a shot and circle back.

monkstone commented 5 years ago

@Aerlinger pushed propane-3.3.1 sodding reflection caught me out when refactoring, this should fix it. Previously missing some strategy voodoo. I think there is good case for removing the offending code from propane even if it works, because all it is supposed to do is to provide an icon in the java frame, this is not respected in many linux environments (and kind of pointless) but maybe required macOS for menu icon?

monkstone commented 5 years ago

Presume fixed no comment since May