JRuby

the integratated joda time version should be in a distinct package hierarchy

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: JRuby 1.1.5, JRuby 1.2
  • Fix Version/s: JRuby 1.4
  • Component/s: Java Integration
  • Labels:
    None
  • Environment:
    when using a different version of jodatime with buildr
  • Testcase included:
    yes
  • Number of attachments :
    2

Description

jruby.jar contains a version of joda-time. if an application uses a different version of jodatime, jruby loads the version from jruby.jar first.

an example is a project using buildr and jruby which contains a new version such as 1.6 of joda time as a dependency. the project will not compile if it uses methods that are not in the old version such as
org.joda.time.Duration.standardHours(long);
http://joda-time.sourceforge.net/api-release/org/joda/time/Duration.html

an easy fix would be to move the jodatime classes in jruby from org.joda.time to jruby.org.joda.time for example. this can be done in eclipse in seconds. the patch will be somewhat large ofcourse.

output of buildr package:

compiling joda:hello into /home/erlang/joda/hello/target/classes
/home/erlang/joda/hello/src/main/java/Hello.java:4: cannot find symbol
symbol : method standardHours(long)
location: class org.joda.time.Duration
org.joda.time.Duration.standardHours(1l);
^
1 error

the attachment is a buildr project that will not compile.

Activity

Hide
Bill Dortch added a comment -

This should be done by jarjar in build.xml, as it is for the org.objectweb.asm classes:

<rule pattern="org.joda.time.**" result="jruby.joda.time.@1"/>

I've done this when incorporating JRuby in a couple of projects and encountered no problems.

Might also want to consider doing this for other jars folded into JRuby, though I'd test first to make sure nothing breaks. jarjar seems to pick up class names represented in strings, but might miss something screwy like MY_PACKAGE_BASE + ".subpackage".

Show
Bill Dortch added a comment - This should be done by jarjar in build.xml, as it is for the org.objectweb.asm classes:
<rule pattern="org.joda.time.**" result="jruby.joda.time.@1"/>
I've done this when incorporating JRuby in a couple of projects and encountered no problems. Might also want to consider doing this for other jars folded into JRuby, though I'd test first to make sure nothing breaks. jarjar seems to pick up class names represented in strings, but might miss something screwy like MY_PACKAGE_BASE + ".subpackage".
Hide
Bill Dortch added a comment -

something screwy like MY_PACKAGE_BASE + ".subpackage"

Um, something, I should say, not resolved at compile time, like MY_PACKAGE + getMySubPackageName();

Show
Bill Dortch added a comment -
something screwy like MY_PACKAGE_BASE + ".subpackage"
Um, something, I should say, not resolved at compile time, like MY_PACKAGE + getMySubPackageName();
Hide
Lasse Koskela added a comment -

This affects JRuby 1.1.6, too.

Show
Lasse Koskela added a comment - This affects JRuby 1.1.6, too.
Hide
Lasse Koskela added a comment -

And apparently 1.3.1.

Show
Lasse Koskela added a comment - And apparently 1.3.1.
Hide
Nick Sieger added a comment -

Sorry for the delay in getting this simple fix in. Fix is in master as of dec5a6e.

You can apply the patch in that commit to 1.3 as well and rebuild jruby-complete if you need to.

Show
Nick Sieger added a comment - Sorry for the delay in getting this simple fix in. Fix is in master as of dec5a6e. You can apply the patch in that commit to 1.3 as well and rebuild jruby-complete if you need to.
Hide
Lasse Koskela added a comment -

Thanks!

Show
Lasse Koskela added a comment - Thanks!
Hide
kristian meier added a comment -

when I look at the zip and run buildr there it claims the compile taks uses

javac -classpath /home/kristian/.m2/repository/joda-time/joda-time/1.6/joda-time-1.6.jar:/usr/lib/jvm/java-6-openjdk/lib/tools.jar -sourcepath /home/kristian/projects/trash/joda/hello/src/main/java -d /home/kristian/projects/trash/joda/hello/target/classes -verbose -g /home/kristian/projects/trash/joda/hello/src/main/java/Hello.java

that works fine. but running with buildr it fails and here you can see that compile tasks uses also the classpath/classloader in which buildr is running. this is more a bug in the buildr. how can I build code which shall compile against jruby1.4.0RC1 but buildr gets executed with jruby1.3.1. that is not possible right now.

other buildsystems like maven handles the build classpath in an isolated manner and with ordering the jode-time and jruby the right way you can build your demo. have a look at my attached maven example.

Show
kristian meier added a comment - when I look at the zip and run buildr there it claims the compile taks uses javac -classpath /home/kristian/.m2/repository/joda-time/joda-time/1.6/joda-time-1.6.jar:/usr/lib/jvm/java-6-openjdk/lib/tools.jar -sourcepath /home/kristian/projects/trash/joda/hello/src/main/java -d /home/kristian/projects/trash/joda/hello/target/classes -verbose -g /home/kristian/projects/trash/joda/hello/src/main/java/Hello.java that works fine. but running with buildr it fails and here you can see that compile tasks uses also the classpath/classloader in which buildr is running. this is more a bug in the buildr. how can I build code which shall compile against jruby1.4.0RC1 but buildr gets executed with jruby1.3.1. that is not possible right now. other buildsystems like maven handles the build classpath in an isolated manner and with ordering the jode-time and jruby the right way you can build your demo. have a look at my attached maven example.
Hide
kristian meier added a comment -

maven example which can handle jode-time-1.6 along with jruby in the build classpath

Show
kristian meier added a comment - maven example which can handle jode-time-1.6 along with jruby in the build classpath
Hide
Tuomas Karkkainen added a comment -

http://jira.codehaus.org/browse/JRUBY-4089 explains why moving jodatime classes to another package was not a good choice after all, and why upgrading the version of jodatime shipping with jruby to the newest one is a better solution.

Show
Tuomas Karkkainen added a comment - http://jira.codehaus.org/browse/JRUBY-4089 explains why moving jodatime classes to another package was not a good choice after all, and why upgrading the version of jodatime shipping with jruby to the newest one is a better solution.

People

Vote (1)
Watch (3)

Dates

  • Created:
    Updated:
    Resolved: