Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Won't Fix
-
Affects Version/s: JRuby 1.5
-
Fix Version/s: None
-
Component/s: Java Integration
-
Labels:None
-
Number of attachments :
Description
This doesn't work:
foo.rb
require 'java' java_require 'foo' class Foo; end
The problem here is that on systems that aren't case-sensitive, the Foo class gets generated into Foo.class with a require that looks for "foo". Our normal search order tries to find "foo.class" before "foo.rb", and on a non-case-sensitive filesystem it ends up finding Foo.class. This results in a require error, since you can't require a Java class.
renaming the file solves the problem, or putting the class into a specific package, but we need some way to address this (ranging from a nicer error message to making it work...somehow).
Here's the error that results, FWIW:
~/projects/jruby ➔ jrubyc --java foo.rb Generating Java class Foo to Foo.java javac -d /Users/headius/projects/jruby -cp /Users/headius/projects/jruby/lib/jruby.jar:. Foo.java ~/projects/jruby ➔ java -cp .:lib/jruby.jar Foo Exception in thread "main" java.lang.ExceptionInInitializerError Caused by: org.jruby.exceptions.RaiseException: use `java_import' to load normal Java classes at (unknown).new(:1) at (unknown).(unknown)(:1)
Another workaround: remove the java_require line entirely and allow the script to get embedded in the class file.