Skip to content

Commit

Permalink
Merge branch 'jruby-1_7'
Browse files Browse the repository at this point in the history
Conflicts:
	VERSION
	core/pom.xml
	core/src/main/java/org/jruby/RubyString.java
	core/src/main/java/org/jruby/RubyStruct.java
	core/src/main/java/org/jruby/ext/bigdecimal/RubyBigDecimal.java
	docs/man/pom.xml
	docs/pom.xml
	ext/pom.xml
	ext/readline/pom.xml
	ext/ripper/pom.xml
	lib/pom.rb
	lib/pom.xml
	maven/jruby-complete/pom.xml
	maven/jruby-complete/src/it/integrity/verify.bsh
	maven/jruby-dist/pom.xml
	maven/jruby-dist/src/it/integrity/verify.bsh
	maven/jruby-jars/pom.xml
	maven/jruby-jars/src/it/integrity/verify.bsh
	maven/jruby-noasm/pom.xml
	maven/jruby-noasm/src/it/integrity/verify.bsh
	maven/jruby-rake-plugin/pom.xml
	maven/jruby-stdlib/pom.xml
	maven/jruby/pom.rb
	maven/jruby/pom.xml
	maven/jruby/src/it/integrity/verify.bsh
	maven/jruby/src/it/runnable/pom.xml
	maven/pom.xml
	pom.xml
	rakelib/test.rake
	spec/regression/GH-2524_bigdecimal_loss_of_precision_with_different_excution_order_spec.rb
	test/externals/ruby1.9/excludes/OpenSSL/TestASN1.rb
	test/externals/ruby1.9/excludes/OpenSSL/TestCipher.rb
	test/externals/ruby1.9/excludes/OpenSSL/TestDigest.rb
	test/externals/ruby1.9/excludes/OpenSSL/TestX509Name.rb
	test/externals/ruby1.9/excludes/OpenSSL/TestX509Request.rb
	test/externals/ruby1.9/openssl/test_asn1.rb
	test/pom.xml
	test/test_adding_pem_to_x509store.rb
  • Loading branch information
mkristian committed Feb 9, 2015
2 parents 944a8b7 + b6f907f commit a07774e
Show file tree
Hide file tree
Showing 33 changed files with 1,054 additions and 31 deletions.
12 changes: 6 additions & 6 deletions antlib/extra.xml
Expand Up @@ -25,7 +25,7 @@ build jruby-complete.jar
<env key='GEM_PATH' value='lib/ruby/gems/shared'/>
<arg value='-Djruby.home=uri:classloader://META-INF/jruby.home'/>
<arg value='-cp'/>
<arg value='core/target/test-classes:test/target/test-classes:lib/jruby.jar:maven/jruby-stdlib/target/jruby-stdlib-1.7.19-SNAPSHOT.jar'/>
<arg value='core/target/test-classes:test/target/test-classes:lib/jruby.jar:maven/jruby-stdlib/target/jruby-stdlib-1.7.20-SNAPSHOT.jar'/>
<arg value='org.jruby.Main'/>
<arg value='-I.:test/externals/ruby1.9:test/externals/ruby1.9/ruby'/>
<arg value='-r./test/ruby19_env.rb'/>
Expand Down Expand Up @@ -137,7 +137,7 @@ build jruby-complete.jar
<env key='GEM_PATH' value='lib/ruby/gems/shared'/>
<arg value='-Djruby.home=uri:classloader://META-INF/jruby.home'/>
<arg value='-cp'/>
<arg value='core/target/test-classes:test/target/test-classes:maven/jruby-complete/target/jruby-complete-1.7.19-SNAPSHOT.jar'/>
<arg value='core/target/test-classes:test/target/test-classes:maven/jruby-complete/target/jruby-complete-1.7.20-SNAPSHOT.jar'/>
<arg value='org.jruby.Main'/>
<arg value='-I.:test/externals/ruby1.9:test/externals/ruby1.9/ruby'/>
<arg value='-r./test/ruby19_env.rb'/>
Expand All @@ -153,7 +153,7 @@ build jruby-complete.jar
<env key='GEM_PATH' value='lib/ruby/gems/shared'/>
<arg value='-Djruby.home=uri:classloader://META-INF/jruby.home'/>
<arg value='-cp'/>
<arg value='core/target/test-classes:test/target/test-classes:lib/jruby.jar:maven/jruby-stdlib/target/jruby-stdlib-1.7.19-SNAPSHOT.jar'/>
<arg value='core/target/test-classes:test/target/test-classes:lib/jruby.jar:maven/jruby-stdlib/target/jruby-stdlib-1.7.20-SNAPSHOT.jar'/>
<arg value='org.jruby.Main'/>
<arg value='-I.:test/externals/ruby1.9:test/externals/ruby1.9/ruby'/>
<arg value='-r./test/ruby19_env.rb'/>
Expand All @@ -169,7 +169,7 @@ build jruby-complete.jar
<env key='GEM_PATH' value='lib/ruby/gems/shared'/>
<arg value='-Djruby.home=uri:classloader://META-INF/jruby.home'/>
<arg value='-cp'/>
<arg value='core/target/test-classes:test/target/test-classes:lib/jruby.jar:maven/jruby-stdlib/target/jruby-stdlib-1.7.19-SNAPSHOT.jar'/>
<arg value='core/target/test-classes:test/target/test-classes:lib/jruby.jar:maven/jruby-stdlib/target/jruby-stdlib-1.7.20-SNAPSHOT.jar'/>
<arg value='org.jruby.Main'/>
<arg value='-I.:test/externals/ruby1.9:test/externals/ruby1.9/ruby'/>
<arg value='-r./test/ruby19_env.rb'/>
Expand Down Expand Up @@ -461,7 +461,7 @@ build jruby-complete.jar
<env key='GEM_PATH' value='lib/ruby/gems/shared'/>
<arg value='-Djruby.home=uri:classloader://META-INF/jruby.home'/>
<arg value='-cp'/>
<arg value='core/target/test-classes:test/target/test-classes:maven/jruby-complete/target/jruby-complete-1.7.19-SNAPSHOT.jar'/>
<arg value='core/target/test-classes:test/target/test-classes:maven/jruby-complete/target/jruby-complete-1.7.20-SNAPSHOT.jar'/>
<arg value='org.jruby.Main'/>
<arg value='-I.:test/externals/ruby1.9:test/externals/ruby1.9/ruby'/>
<arg value='-r./test/ruby19_env.rb'/>
Expand Down Expand Up @@ -515,4 +515,4 @@ build jruby-complete.jar
<!--arg value='-v'/-->
</exec>
</target>
<target description='test using jruby-complete or jruby-core/jruby-stdlib jars' name='test-jruby-jars' depends='mvn,test-jruby-jars-jruby.1.9,test-jruby-complete-slow,test-jruby-jars-objectspace,test-jruby-jars-mri.1.9,test-jruby-complete-rubicon.1.9'/></project>
<target description='test using jruby-complete or jruby-core/jruby-stdlib jars' name='test-jruby-jars' depends='mvn,test-jruby-jars-jruby.1.9,test-jruby-complete-slow,test-jruby-jars-objectspace,test-jruby-jars-mri.1.9,test-jruby-complete-rubicon.1.9'/></project>
12 changes: 9 additions & 3 deletions core/src/main/java/org/jruby/RubyString.java
Expand Up @@ -5804,11 +5804,17 @@ public static ByteList encodeBytelist(CharSequence value, Encoding encoding) {
public Object toJava(Class target) {
if (target.isAssignableFrom(String.class)) {
return decodeString();
} else if (target.isAssignableFrom(ByteList.class)) {
}
if (target.isAssignableFrom(ByteList.class)) {
return value;
} else {
return super.toJava(target);
}
if (target == Character.class || target == Character.TYPE) {
if ( strLength() != 1 ) {
throw getRuntime().newArgumentError("could not coerce string of length " + strLength() + " (!= 1) into a char");
}
return decodeString().charAt(0);
}
return super.toJava(target);
}

/**
Expand Down
17 changes: 13 additions & 4 deletions core/src/main/java/org/jruby/ext/bigdecimal/RubyBigDecimal.java
Expand Up @@ -877,7 +877,7 @@ private IRubyObject op_quo19_20(ThreadContext context, IRubyObject other) {
int len = value.precision() + preciseOther.value.precision();
int pow = len / 4;
int precision = (pow + 1) * 4 * 2;

return op_div(context, preciseOther, getRuntime().newFixnum(precision));
}

Expand Down Expand Up @@ -929,9 +929,18 @@ public IRubyObject op_div(ThreadContext context, IRubyObject other, IRubyObject
// MRI behavior: "If digits is 0, the result is the same as the / operator."
if (scale == 0) return op_quo(context, other);

MathContext mathContext = new MathContext(scale, getRoundingMode(context.runtime));
return new RubyBigDecimal(context.runtime,
value.divide(val.value, mathContext)).setResult(scale);
if (isZero()) {
return newZero(getRuntime(), zeroSign * val.value.signum());
}

if (scale == 0) {
// MRI behavior: "If digits is 0, the result is the same as the / operator."
return op_quo(context, other);
} else {
MathContext mathContext = new MathContext(scale, getRoundingMode(context.runtime));
return new RubyBigDecimal(getRuntime(),
value.divide(val.value, mathContext)).setResult(scale);
}
}

@JRubyMethod(name = "div")
Expand Down
@@ -0,0 +1,48 @@
package org.jruby.embed;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;

import java.net.URL;
import java.net.URLClassLoader;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;

public class IsolatedScriptingContainerTest {

static ClassLoader cl;

@BeforeClass
public static void setupClassLoader() {
cl = Thread.currentThread().getContextClassLoader();
// make sure we have classloader which does not find jruby
ClassLoader c = new URLClassLoader( new URL[] {}, null );
try {
c.loadClass( "org.jruby.embed.ScriptingContainer" );
fail( "this classloader shall not find jruby" );
}
catch( ClassNotFoundException expected){}
// set it as context classloader
Thread.currentThread().setContextClassLoader( c );
}

@AfterClass
public static void restClassLoader() {
Thread.currentThread().setContextClassLoader( cl );
}

@Test
public void testIsolatedScriptingContainer() throws Exception {
// we do have an instance of "jruby" loaded via some other classloader
//System.setProperty("jruby.debug.loadService", "true");
ScriptingContainer instance = new IsolatedScriptingContainer();
String result = instance.runScriptlet( "$LOAD_PATH" ).toString();
assertNotNull(result);

assertEquals(instance.runScriptlet("JRuby.runtime.jruby_class_loader.parent" ), cl );
assertEquals(ScriptingContainer.class.getClassLoader(), cl);
}
}
9 changes: 9 additions & 0 deletions core/src/test/resources/rubygems/defaults/jruby.rb
@@ -0,0 +1,9 @@
# dummy to run IsolatedScriptingContainerTest
module Gem
class Specification
def self.reset
end
def self.add_dir *args
end
end
end
2 changes: 1 addition & 1 deletion ext/pom.xml
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.jruby</groupId>
<artifactId>jruby-parent</artifactId>
<version>9.0.0.0.pre1</version>
<version>9.0.0.0-SNAPSHOT</version>
</parent>
<artifactId>jruby-ext</artifactId>
<packaging>pom</packaging>
Expand Down
2 changes: 1 addition & 1 deletion ext/ripper/pom.xml
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.jruby</groupId>
<artifactId>jruby-ext</artifactId>
<version>9.0.0.0.pre1</version>
<version>9.0.0.0-SNAPSHOT</version>
</parent>
<groupId>rubygems</groupId>
<artifactId>jruby-ripper</artifactId>
Expand Down
1 change: 1 addition & 0 deletions maven/jruby/src/it/j2ee_jetty_rack/.gitignore
@@ -0,0 +1 @@
pkg
4 changes: 4 additions & 0 deletions maven/jruby/src/it/j2ee_jetty_rack/.jrubydir
@@ -0,0 +1,4 @@
.
config.ru
gems
specifications
80 changes: 80 additions & 0 deletions maven/jruby/src/it/j2ee_jetty_rack/Mavenfile
@@ -0,0 +1,80 @@
#-*- mode: ruby -*-

# it is war-file
packaging 'war'

# get jruby dependencies
properties( 'jruby.version' => '@project.version@',
'jruby.plugins.version' => '1.0.7',
'project.build.sourceEncoding' => 'utf-8',
'public.dir' => '${basedir}/public' )

pom( 'org.jruby:jruby', '${jruby.version}' )

jar( 'org.jruby.rack:jruby-rack', '1.1.18',
:exclusions => [ 'org.jruby:jruby-complete' ] )


# ruby-maven will dump an equivalent pom.xml
properties[ 'tesla.dump.pom' ] = 'pom.xml'

# a gem to be used
gem 'flickraw', '0.9.7'

repository( :url => 'http://rubygems-proxy.torquebox.org/releases',
:id => 'rubygems-releases' )

jruby_plugin :gem, :includeRubygemsInResources => true, :includeLibDirectoryInResources => true do
execute_goal :initialize
end

# not really needed but for completeness:
# pack the war with that ruby-like directory layout
plugin( :war, '2.2',
:warSourceDirectory => '${public.dir}' )

resource :directory => '${basedir}', :includes => [ 'config.ru', '.jrubydir' ]

# start jetty for the tests
plugin( 'org.eclipse.jetty:jetty-maven-plugin', '9.1.3.v20140225',
:path => '/',
:webAppSourceDirectory => '${public.dir}',
:stopPort => 9999,
:stopKey => 'foo' ) do
execute_goal( 'start', :id => 'start jetty', :phase => 'pre-integration-test', :daemon => true )
execute_goal( 'stop', :id => 'stop jetty', :phase => 'post-integration-test' )
end

# download files during the tests
result = nil
execute 'download', :phase => 'integration-test' do
require 'open-uri'
result = open( 'http://localhost:8080' ).string
puts result
end

# verify the downloads
execute 'check download', :phase => :verify do
expected = 'hello world:'
unless result.match( /^#{expected}/ )
raise "missed expected string in download: #{expected}"
end
expected = 'self: uri:classloader://config.ru'
unless result.match( /#{expected}/ )
raise "missed expected string in download: #{expected}"
end
expected = 'PWD: uri:classloader://'
unless result.match( /#{expected}/ )
raise "missed expected string in download: #{expected}"
end
expected = 'Gem.path: ."uri:classloader://",'
unless result.match( /#{expected}/ )
raise "missed expected string in download: #{expected}"
end
# TODO get rid off this over normalization
expected = 'uri:classloader:/gems/flickraw-0.9.7'
unless result.match( /#{expected}/ )
raise "missed expected string in download: #{expected}"
end
end
# vim: syntax=Ruby
19 changes: 19 additions & 0 deletions maven/jruby/src/it/j2ee_jetty_rack/config.ru
@@ -0,0 +1,19 @@
#-*- mode: ruby -*-

use Rack::ShowExceptions

require 'hello_world'

run lambda { |env|
require 'flickraw'
[
200,
{
'Content-Type' => 'text/html',
'Cache-Control' => 'public, max-age=86400'
},
[ "self: #{__FILE__}\n", "PWD: #{Dir.pwd}\n", "Gem.path: #{Gem.path.inspect}\n", Gem.loaded_specs['flickraw'].gem_dir + "\n", HelloWorld.new + "\n" ]
]
}

# vim: syntax=Ruby
7 changes: 7 additions & 0 deletions maven/jruby/src/it/j2ee_jetty_rack/lib/hello_world.rb
@@ -0,0 +1,7 @@
require 'openssl'

class HelloWorld < String
def initialize
super "hello world: #{OpenSSL::Random.random_bytes( 16 ).inspect}"
end
end

0 comments on commit a07774e

Please sign in to comment.