Skip to content

change dir does not propagate to java runtime #971

@mkristian

Description

@mkristian

jruby -e 'Dir.chdir("..");p File.expand_path(".");p java.io.File.new("").absolute_path;p java.lang.System.get_property("user.dir")'

produces
"/home/christian/projects/active/maven/tesla-polyglot/tesla-polyglot-gems"
"/home/christian/projects/active/maven/tesla-polyglot/tesla-polyglot-gems/ruby-maven"
"/home/christian/projects/active/maven/tesla-polyglot/tesla-polyglot-gems/ruby-maven"

not sure how the java runtime 'knows' the pwd. one way is to set the user.dir system property:
``jruby -e 'Dir.chdir("..");java.lang.System.set_property("user.dir", File.expand_path("."));p java.io.File.new("").absolute_path;p java.lang.System.get_property("user.dir")'`

which does the trick at least for java.io.File

usually I am using jruby and ruby almost exchangable, i.e. ruby calls java and java calls ruby . . .

when looking at the jruby sources I am not sure whether the place to 'add' the system property fix is RubyDir.java or Ruby.java

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions