Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 271144bd9371
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 08e9e305bc5e
Choose a head ref
  • 8 commits
  • 6 files changed
  • 1 contributor

Commits on Feb 2, 2016

  1. Copy the full SHA
    35b8447 View commit details
  2. Copy the full SHA
    eead420 View commit details
  3. Copy the full SHA
    1a1d3ad View commit details
  4. Copy the full SHA
    255f87e View commit details
  5. Copy the full SHA
    80a5d2b View commit details
  6. Copy the full SHA
    546c848 View commit details
  7. Copy the full SHA
    2eb7387 View commit details
  8. Copy the full SHA
    08e9e30 View commit details
22 changes: 20 additions & 2 deletions core/src/main/java/org/jruby/RubyModule.java
Original file line number Diff line number Diff line change
@@ -2568,6 +2568,7 @@ private void setVisibility(ThreadContext context, IRubyObject[] args, Visibility
*/
@JRubyMethod(name = "public", rest = true, visibility = PRIVATE, writes = VISIBILITY)
public RubyModule rbPublic(ThreadContext context, IRubyObject[] args) {
checkFrozen();
setVisibility(context, args, PUBLIC);
return this;
}
@@ -2577,6 +2578,7 @@ public RubyModule rbPublic(ThreadContext context, IRubyObject[] args) {
*/
@JRubyMethod(name = "protected", rest = true, visibility = PRIVATE, writes = VISIBILITY)
public RubyModule rbProtected(ThreadContext context, IRubyObject[] args) {
checkFrozen();
setVisibility(context, args, PROTECTED);
return this;
}
@@ -2586,6 +2588,7 @@ public RubyModule rbProtected(ThreadContext context, IRubyObject[] args) {
*/
@JRubyMethod(name = "private", rest = true, visibility = PRIVATE, writes = VISIBILITY)
public RubyModule rbPrivate(ThreadContext context, IRubyObject[] args) {
checkFrozen();
setVisibility(context, args, PRIVATE);
return this;
}
@@ -2655,12 +2658,14 @@ public IRubyObject private_method_defined(ThreadContext context, IRubyObject sym

@JRubyMethod(name = "public_class_method", rest = true)
public RubyModule public_class_method(IRubyObject[] args) {
checkFrozen();
getSingletonClass().setMethodVisibility(args, PUBLIC);
return this;
}

@JRubyMethod(name = "private_class_method", rest = true)
public RubyModule private_class_method(IRubyObject[] args) {
checkFrozen();
getSingletonClass().setMethodVisibility(args, PRIVATE);
return this;
}
@@ -3282,6 +3287,8 @@ public void deprecateConstant(Ruby runtime, String name) {

@JRubyMethod
public IRubyObject deprecate_constant(ThreadContext context, IRubyObject rname) {
checkFrozen();

deprecateConstant(context.runtime, validateConstant(rname));
return this;
}
@@ -3296,6 +3303,8 @@ public IRubyObject deprecate_constant(ThreadContext context, IRubyObject[] names

@JRubyMethod
public IRubyObject private_constant(ThreadContext context, IRubyObject rubyName) {
checkFrozen();

String name = validateConstant(rubyName);

setConstantVisibility(context, name, true);
@@ -3314,6 +3323,8 @@ public IRubyObject private_constant(ThreadContext context, IRubyObject[] rubyNam

@JRubyMethod
public IRubyObject public_constant(ThreadContext context, IRubyObject rubyName) {
checkFrozen();

String name = validateConstant(rubyName);

setConstantVisibility(context, name, false);
@@ -3348,7 +3359,7 @@ public IRubyObject prepend(ThreadContext context, IRubyObject[] modules) {

@JRubyMethod(name = "prepended", required = 1, visibility = PRIVATE)
public IRubyObject prepended(ThreadContext context, IRubyObject other) {
return context.runtime.getNil();
return context.nil;
}

private void setConstantVisibility(ThreadContext context, String name, boolean hidden) {
@@ -4133,7 +4144,7 @@ protected final String validateConstant(String name, IRubyObject errorName) {

// MRI does strlen to check for \0 vs Ruby string length.
if ((nameString.getEncoding() != resultEncoding && !nameString.isAsciiOnly()) ||
nameString.toString().contains("\0")) {
nameString.toString().indexOf('\0') > -1 ) {
nameString = (RubyString) nameString.inspect();
}

@@ -4158,6 +4169,13 @@ private void checkAndRaiseIfFrozen() throws RaiseException {
}
}

@Override
public final void checkFrozen() {
if ( isFrozen() ) {
throw getRuntime().newFrozenError(isClass() ? "class" : "module");
}
}

protected boolean constantTableContains(String name) {
return getConstantMap().containsKey(name);
}
Original file line number Diff line number Diff line change
@@ -99,7 +99,7 @@ public synchronized IRubyObject unshift(IRubyObject item) {
@Override
public synchronized IRubyObject unshift(IRubyObject[] items) {
IRubyObject result = super.unshift(items);
putAll(toJavaArray());
putAll(toJavaArrayUnsafe());
return result;
}

@@ -360,5 +360,5 @@ private void putAll(IRubyObject[] items) {
set.add(string);
}
}

}
12 changes: 5 additions & 7 deletions lib/ruby/stdlib/jruby/compiler/java_class.rb
Original file line number Diff line number Diff line change
@@ -12,18 +12,16 @@ def generate_java(node, script_name = nil)

def generate_javac(files, options)
files_string = files.join(' ')
jruby_jar, = ['jruby.jar', 'jruby-complete.jar'].select do |jar|
File.exist? "#{ENV_JAVA['jruby.home']}/lib/#{jar}"
end
jruby_home = ENV_JAVA['jruby.home']
jruby_jar = ['jruby.jar', 'jruby-complete.jar'].select do |jar|
File.exist? "#{jruby_home}/lib/#{jar}"
end.first
separator = File::PATH_SEPARATOR
classpath_string = options[:classpath].size > 0 ? options[:classpath].join(separator) : "."
javac_opts = options[:javac_options].join(' ')
target = options[:target]
java_home = ENV_JAVA['jruby.home']

compile_string = "javac #{javac_opts} -d #{target} -cp #{java_home}/lib/#{jruby_jar}#{separator}#{classpath_string} #{files_string}"

compile_string
"javac #{javac_opts} -d #{target} -cp #{jruby_home}/lib/#{jruby_jar}#{separator}#{classpath_string} #{files_string}"
end
end

2 changes: 1 addition & 1 deletion test/jruby/test_higher_javasupport.rb
Original file line number Diff line number Diff line change
@@ -800,7 +800,7 @@ def test_java_class_callable_methods
java_class.declared_method 'indexOf'
fail('not failed')
rescue NameError => e
assert e.message.index "undefined method 'indexOf'"
assert e.message.index "undefined method `indexOf'"
end
end

9 changes: 3 additions & 6 deletions test/jruby/test_kernel.rb
Original file line number Diff line number Diff line change
@@ -107,8 +107,7 @@ def test_catch_throw
catch :fred do throw :fred; fail("shouldn't get here") end
assert(!been_where_it_shouldnt)

ex = ArgumentError
assert_raises (ex) do
assert_raises(UncaughtThrowError) do
catch :fred do throw :wilma end
end
end
@@ -133,8 +132,7 @@ def test_throw_should_bubble_up_to_the_right_catch
def test_invalid_throw_after_inner_catch_should_unwind_the_stack_all_the_way_to_the_top
been_at_fred1 = false
been_at_fred2 = false
ex = ArgumentError
assert_raises(ex) do
assert_raises(UncaughtThrowError, "uncaught throw :wilma") do
catch :fred1 do
catch :fred2 do
catch :fred3 do
@@ -157,8 +155,7 @@ def throw_outside_of_any_block_shoudl_raise_an_error
end

def test_catch_stack_should_be_cleaned_up
ex = ArgumentError
assert_raises(ex) do
assert_raises(UncaughtThrowError) do
catch :fred1 do
catch :fred2 do
catch :fred3 do
31 changes: 19 additions & 12 deletions test/jruby/test_load_compiled_ruby_class_from_classpath.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
require "test/unit"
require "fileutils"
require 'test/jruby/test_helper'
require 'rbconfig'

# Necessary because of http://jira.codehaus.org/browse/JRUBY-1579
require "jruby"

require 'jruby/compiler'

class TestLoadCompiledRubyClassFromClasspath < Test::Unit::TestCase
include TestHelper
@@ -20,9 +13,18 @@ class TestLoadCompiledRubyClassFromClasspath < Test::Unit::TestCase
StarterClass = "#{StarterName}.class"
Manifest = "manifest.txt"

def self.startup
require 'rbconfig'
require 'fileutils'
# Necessary because of http://jira.codehaus.org/browse/JRUBY-1579
require 'jruby'
require 'jruby/compiler'
end

if java.lang.System.getProperty("basedir") # FIXME: disabling this test under maven
def test_truth; end
else

def setup
remove_test_artifacts
@original_classpath = ENV["CLASSPATH"]
@@ -72,15 +74,19 @@ def test_loading_compiled_ruby_class_from_jar
end

javac = ENV['JAVA_HOME'] ? "#{ENV['JAVA_HOME']}/bin/javac" : "javac"

`#{javac} -cp #{jruby_jar} #{StarterSource}`
javac_cmd = "#{javac} -cp #{jruby_jar} #{StarterSource}"
puts javac_cmd if $VERBOSE; `#{javac_cmd}`
assert_equal 0, $?.exitstatus, "javac failed to compile #{StarterSource}"
`jar cvfm #{JarFile} #{Manifest} #{StarterClass} #{RubyClass}`

jar = ENV['JAVA_HOME'] ? "#{ENV['JAVA_HOME']}/bin/jar" : "jar"
`#{jar} cvfm #{JarFile} #{Manifest} #{StarterClass} #{RubyClass}`
assert_equal 0, $?.exitstatus, "jar failed to build #{JarFile} from #{RubyClass}"

remove_ruby_source_files

result = `java -jar -Djruby.aot.loadClasses=true #{JarFile}`
java = ENV['JAVA_HOME'] ? "#{ENV['JAVA_HOME']}/bin/java" : "java"
java_cmd = "#{java} -jar -Djruby.aot.loadClasses=true #{JarFile}"
puts java_cmd if $VERBOSE; result = `#{java_cmd}`
assert_equal 0, $?.exitstatus, "did not get 0 for exit status from running java against the jar"
assert_equal "hello from runner", result, "wrong text from runner"
end
@@ -99,7 +105,7 @@ def create_compiled_class
File.open(RubySource, "w") { |f| f << "print 'hello from runner'" }
JRuby::Compiler::compile_argv([RubySource])
rescue Exception => e
raise "jrubyc failed to compile #{RubySource} into #{RubyClass}:\n#{e.message}\n#{e.backtrace}"
raise "jrubyc failed to compile #{RubySource} into #{RubyClass}:\n #{e.inspect}\n #{e.backtrace.join("\n ")}"
ensure
# just in case, remove the rb file
FileUtils.rm_rf RubySource
@@ -113,5 +119,6 @@ def append_to_classpath(*paths)
current_classpath = ENV["CLASSPATH"].nil? ? "" : ENV["CLASSPATH"]
ENV["CLASSPATH"] = "#{current_classpath}#{File::PATH_SEPARATOR}#{paths.join(File::PATH_SEPARATOR)}"
end

end # end FIXME
end