Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

include_package not working as expected with jruby-9.0.0.0.rc1 #3036

Closed
monkstone opened this issue Jun 11, 2015 · 4 comments
Closed

include_package not working as expected with jruby-9.0.0.0.rc1 #3036

monkstone opened this issue Jun 11, 2015 · 4 comments

Comments

@monkstone
Copy link
Contributor

In ruby-processing/JRubyArt previously I have been able to

include_package 'processing.core' # imports the processing.core package.

And that has been sufficient for me to run processing sketches (in ruby-processing/JRubyArt) now I've been getting this error

processing/core/PApplet.java:1952:in `makeGraphics': java.lang.RuntimeException: You need to use "Import Library" to add processing.core.PGraphicsJava2D to your sketch.
    from processing/core/PApplet.java:981:in `init'
    from processing/core/PApplet.java:10840:in `runSketch'
    from java/lang/reflect/Method.java:497:in `invoke'
    from /home/tux/.gem/ruby/2.2.0/gems/jruby_art-0.2.6.pre/lib/jruby_art/app.rb:56:in `run_sketch'
    from /home/tux/.gem/ruby/2.2.0/gems/jruby_art-0.2.6.pre/lib/jruby_art/app.rb:150:in `initialize'
    from fred.rb:18:in `<top>'
    from java/lang/invoke/MethodHandle.java:625:in `invokeWithArguments'

This can be "fixed" by modifying JRubyArt app.rb to include
idea for fix didn't work anyway

import 'processing.core.PGraphicsJava2D'

But surely that should not be necessary in addition to the include_package that has previously just worked?

@kares
Copy link
Member

kares commented Jun 11, 2015

@monkstone would be najs to get a clean reproducable piece of .rb instead of mentioning some app.rb somewhere ... if possible of course :) thanks!

@monkstone
Copy link
Contributor Author

Here is a minimal test that requires processing core.jar to make sense. Which I have provided here, previous optimism about a fix with import 'processing.core.PGraphicsJava2D' was misplaced due to me testing with an earlier version jruby:-

https://github.com/monkstone/animationloop

jruby -J-Djruby.backtrace.style=raw test.rb

Output

processing/core/PApplet.java:1952:in `makeGraphics': java.lang.RuntimeException: You need to use "Import Library" to add processing.core.PGraphicsJava2D to your sketch.
    from processing/core/PApplet.java:981:in `init'
    from processing/core/PApplet.java:10840:in `runSketch'
    from sun/reflect/NativeMethodAccessorImpl.java:-2:in `invoke0'
    from sun/reflect/NativeMethodAccessorImpl.java:62:in `invoke'
    from sun/reflect/DelegatingMethodAccessorImpl.java:43:in `invoke'
    from java/lang/reflect/Method.java:483:in `invoke'
    from org/jruby/javasupport/JavaMethod.java:427:in `invokeDirectWithExceptionHandling'
    from org/jruby/javasupport/JavaMethod.java:359:in `invokeStaticDirect'
    from org/jruby/java/invokers/StaticMethodInvoker.java:31:in `call'
    from org/jruby/java/invokers/StaticMethodInvoker.java:94:in `call'
    from org/jruby/internal/runtime/methods/AliasMethod.java:101:in `call'
    from org/jruby/runtime/callsite/CachingCallSite.java:273:in `cacheAndCall'
    from org/jruby/runtime/callsite/CachingCallSite.java:79:in `callBlock'
    from org/jruby/runtime/callsite/CachingCallSite.java:83:in `call'
    from org/jruby/ir/instructions/CallBase.java:419:in `interpret'
    from org/jruby/ir/interpreter/InterpreterEngine.java:324:in `processCall'
    from org/jruby/ir/interpreter/StartupInterpreterEngine.java:78:in `interpret'
    from org/jruby/ir/interpreter/InterpreterEngine.java:78:in `interpret'
    from org/jruby/internal/runtime/methods/MixedModeIRMethod.java:164:in `INTERPRET_METHOD'
    from org/jruby/internal/runtime/methods/MixedModeIRMethod.java:150:in `call'
    from org/jruby/internal/runtime/methods/DynamicMethod.java:197:in `call'
    from org/jruby/runtime/callsite/CachingCallSite.java:293:in `cacheAndCall'
    from org/jruby/runtime/callsite/CachingCallSite.java:131:in `call'
    from org/jruby/ir/interpreter/InterpreterEngine.java:308:in `processCall'
    from org/jruby/ir/interpreter/StartupInterpreterEngine.java:78:in `interpret'
    from org/jruby/ir/interpreter/InterpreterEngine.java:84:in `interpret'
    from org/jruby/internal/runtime/methods/MixedModeIRMethod.java:199:in `INTERPRET_METHOD'
    from org/jruby/internal/runtime/methods/MixedModeIRMethod.java:185:in `call'
    from org/jruby/runtime/callsite/CachingCallSite.java:323:in `cacheAndCall'
    from org/jruby/runtime/callsite/CachingCallSite.java:173:in `callBlock'
    from org/jruby/runtime/callsite/CachingCallSite.java:177:in `call'
    from org/jruby/RubyClass.java:860:in `newInstance'
    from org/jruby/internal/runtime/methods/JavaMethod.java:312:in `call'
    from org/jruby/java/proxies/ConcreteJavaProxy.java:155:in `call'
    from org/jruby/runtime/callsite/CachingCallSite.java:313:in `cacheAndCall'
    from org/jruby/runtime/callsite/CachingCallSite.java:163:in `call'
    from test.rb:14:in `<top>'
    from java/lang/invoke/MethodHandle.java:636:in `invokeWithArguments'
    from org/jruby/ir/Compiler.java:111:in `load'
    from org/jruby/Ruby.java:835:in `runScript'
    from org/jruby/Ruby.java:824:in `runScript'
    from org/jruby/Ruby.java:754:in `runNormally'
    from org/jruby/Ruby.java:575:in `runFromMain'
    from org/jruby/Main.java:401:in `doRunFromMain'
    from org/jruby/Main.java:296:in `internalRun'
    from org/jruby/Main.java:225:in `run'
    from org/jruby/Main.java:197:in `main'

@kares
Copy link
Member

kares commented Jun 11, 2015

@monkstone thanks ... in that case it's not at all related to Java Integration but class-loading being changed on master - the thread context class loader is no longer set to the JRuby class-loader (for consistency between jruby command line use and elsewhere). for now you can work-around by doing :

java.lang.Thread.currentThread.setContextClassLoader JRuby.runtime.jruby_class_loader

(early on e.g. before GreyCircles.new ...) to get the same behaviour as with JRuby 1.7.x

also it's very hard to tell which version of the processing .jar you're using (for linking to source on GH), but the thrown exception should hide a ClassNotFoundException : https://github.com/processing/processing/blob/processing-0227-2.2.1/core/src/processing/core/PApplet.java#L1914-L1954

@kares kares closed this as completed Jun 11, 2015
@kares kares added this to the Invalid or Duplicate milestone Jun 11, 2015
monkstone referenced this issue in jashkenas/ruby-processing Jun 11, 2015
@monkstone
Copy link
Contributor Author

@kares just a footnote here but significant for Windows users CLASSPATH separator is different on Windows ; not : like unix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants