Skip to content

Commit a8318f6

Browse files
authored
Merge pull request jruby#9006 from headius/explicit_class_require
Consider .class a source extension during search
2 parents b024952 + e4e6a0e commit a8318f6

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

core/src/main/java/org/jruby/runtime/load/LibrarySearcher.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,12 @@ public static SuffixType getSuffixTypeForLoad(final String[] fileHolder) {
250250
}
251251

252252
public static boolean isSourceExt(String file) {
253-
return file.endsWith(".rb");
253+
for (Suffix suffix : Suffix.SOURCES) {
254+
if (file.endsWith(suffix.extension)) {
255+
return true;
256+
}
257+
}
258+
return false;
254259
}
255260

256261
public static boolean isLibraryExt(String file) {

rakelib/rspec.rake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,6 @@ namespace :spec do
7171

7272
permute_specs "jrubyc", compile_flags do |t|
7373
t.pattern = 'spec/jrubyc/**/*_spec.rb'
74+
t.ruby_opts << "-Xaot.loadClasses"
7475
end
7576
end

spec/jrubyc/java/loading_spec.rb

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require_relative '../spec_helper'
22

3-
describe "JRuby::Compiler.compile_argv" do
3+
describe "Ruby code compiled with JRuby::Compiler.compile_argv" do
44

55
def compile_files(files)
66
JRuby::Compiler.compile_argv(files)
@@ -77,4 +77,21 @@ def compile_files(files)
7777
expect( res ).to eql [ true, { :foo => :bar, :baz => 0 }]
7878
end
7979

80+
describe "can be required" do
81+
before(:each) do
82+
@old_loaded_features = $LOADED_FEATURES.dup
83+
end
84+
85+
after(:each) do
86+
$LOADED_FEATURES.replace(@old_loaded_features)
87+
end
88+
89+
it "using base filename" do
90+
puts File.exist?(File.join(FILES_DIR, 'symbol_proc.class'))
91+
require File.join(FILES_DIR, 'symbol_proc.class')
92+
93+
expect( $symbol_proc_result ).to_not be nil
94+
expect( $symbol_proc_result ).to eql [ 1, 2, 3 ]
95+
end
96+
end
8097
end

0 commit comments

Comments
 (0)