Skip to content

Commit e4e6a0e

Browse files
committed
Enable .class requires and add a test
This enables precompiled .class files to be loaded with require, since that behavior was made optional in JRuby 9.3, and adds a test that confirms it works for a full filename, reported as broken in jruby#8758.
1 parent 8a7e30f commit e4e6a0e

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

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)