Skip to content

Commit

Permalink
Showing 271 changed files with 3,636 additions and 1,933 deletions.
11 changes: 1 addition & 10 deletions bin/jruby.bash
Original file line number Diff line number Diff line change
@@ -234,16 +234,7 @@ do
-*)
opt="${opt:1}=false" ;;
esac
java_args=("${java_args[@]}" "-Djvmci.option.$opt")
elif [ "${val:0:15}" = "-Djvmci.option." ]; then # Graal options
opt=${val:15}
java_args=("${java_args[@]}" "-Djvmci.option.$opt")
elif [ "${val:0:15}" = "-Dgraal.option." ]; then # Graal options
opt=${val:15}
java_args=("${java_args[@]}" "-Djvmci.option.$opt")
elif [ "${val:0:8}" = "-Dgraal." ]; then # Graal options
opt=${val:8}
java_args=("${java_args[@]}" "-Djvmci.option.$opt")
java_args=("${java_args[@]}" "-Dgraal.$opt")
else
if [ "${val:0:3}" = "-ea" ]; then
VERIFY_JRUBY="yes"
24 changes: 6 additions & 18 deletions core/src/main/java/org/jruby/RubyIO.java
Original file line number Diff line number Diff line change
@@ -3736,13 +3736,13 @@ private void setupPopen(ModeFlags modes, POpenProcess process) throws RaiseExcep
}

private static class Ruby19POpen {
public final RubyString cmd;
public final IRubyObject[] cmdPlusArgs;
public final RubyHash env;
final RubyString cmd;
final IRubyObject[] cmdPlusArgs;
final RubyHash env;

public Ruby19POpen(Ruby runtime, IRubyObject[] args) {
IRubyObject[] _cmdPlusArgs = null;
IRubyObject _env = null;
Ruby19POpen(Ruby runtime, IRubyObject[] args) {
IRubyObject[] _cmdPlusArgs;
IRubyObject _env;
IRubyObject _cmd;

int firstArg = 0;
@@ -3858,18 +3858,6 @@ public static IRubyObject popen(ThreadContext context, IRubyObject recv, IRubyOb
process = ShellLauncher.popen(runtime, r19Popen.cmdPlusArgs, r19Popen.env, modes);
}

// Yes, this is gross. java.lang.Process does not appear to be guaranteed
// "ready" when we get it back from Runtime#exec, so we try to give it a
// chance by waiting for 10ms before we proceed. Only doing this on 1.5
// since Hotspot 1.6+ does not seem to exhibit the problem.
if (System.getProperty("java.specification.version", "").equals("1.5")) {
synchronized (process) {
try {
process.wait(100);
} catch (InterruptedException ie) {}
}
}

checkPopenOptions(options);

io.setupPopen(modes, process);
25 changes: 16 additions & 9 deletions core/src/main/java/org/jruby/RubyKernel.java
Original file line number Diff line number Diff line change
@@ -1512,7 +1512,7 @@ public static IRubyObject system(ThreadContext context, IRubyObject recv, IRubyO

@JRubyMethod(name = "system", required = 1, rest = true, module = true, visibility = PRIVATE)
public static IRubyObject system19(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
Ruby runtime = context.runtime;
final Ruby runtime = context.runtime;
boolean needChdir = !runtime.getCurrentDirectory().equals(runtime.getPosix().getcwd());

if (!needChdir && runtime.getPosix().isNative() && !Platform.IS_WINDOWS) {
@@ -1546,14 +1546,14 @@ public static IRubyObject system19(ThreadContext context, IRubyObject recv, IRub
if (pid < 0) {
return runtime.getNil();
}
status[0] = (int)((RubyProcess.RubyStatus)context.getLastExitStatus()).getStatus();
status[0] = (int)((RubyProcess.RubyStatus) context.getLastExitStatus()).getStatus();
if (status[0] == 0) return runtime.getTrue();
return runtime.getFalse();
}

// else old JDK logic
if (args[0] instanceof RubyHash) {
RubyHash env = (RubyHash) args[0].convertToHash();
RubyHash env = args[0].convertToHash();
if (env != null) {
runtime.getENV().merge_bang(context, env, Block.NULL_BLOCK);
}
@@ -1575,11 +1575,7 @@ private static int systemCommon(ThreadContext context, IRubyObject recv, IRubyOb
long[] tuple;

try {
IRubyObject lastArg = args[args.length - 1];
if (lastArg instanceof RubyHash) {
runtime.getWarnings().warn(ID.UNSUPPORTED_SUBPROCESS_OPTION, "system does not support options in JRuby yet: " + lastArg.inspect());
args = Arrays.copyOf(args, args.length - 1);
}
args = dropLastArgIfOptions(runtime, args);
if (! Platform.IS_WINDOWS && args[args.length -1].asJavaString().matches(".*[^&]&\\s*")) {
// looks like we need to send process to the background
ShellLauncher.runWithoutWait(runtime, args);
@@ -1592,7 +1588,18 @@ private static int systemCommon(ThreadContext context, IRubyObject recv, IRubyOb

// RubyStatus uses real native status now, so we unshift Java's shifted exit status
context.setLastExitStatus(RubyProcess.RubyStatus.newProcessStatus(runtime, tuple[0] << 8, tuple[1]));
return (int)tuple[0];
return (int) tuple[0];
}

private static IRubyObject[] dropLastArgIfOptions(final Ruby runtime, final IRubyObject[] args) {
IRubyObject lastArg = args[args.length - 1];
if (lastArg instanceof RubyHash) {
if (!((RubyHash) lastArg).isEmpty()) {
runtime.getWarnings().warn(ID.UNSUPPORTED_SUBPROCESS_OPTION, "system does not support options in JRuby yet: " + lastArg);
}
return Arrays.copyOf(args, args.length - 1);
}
return args;
}

public static IRubyObject exec(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
26 changes: 12 additions & 14 deletions core/src/main/java/org/jruby/RubyModule.java
Original file line number Diff line number Diff line change
@@ -3713,21 +3713,21 @@ public IRubyObject setConstant(String name, IRubyObject value, boolean hidden) {
*/
private IRubyObject setConstantCommon(String name, IRubyObject value, boolean hidden, boolean warn) {
IRubyObject oldValue = fetchConstant(name);

setParentForModule(name, value);

if (oldValue != null) {
if (oldValue == UNDEF) {
setAutoloadConstant(name, value);
} else {
if (warn) {
boolean notAutoload = oldValue != UNDEF;
if (notAutoload || !setAutoloadConstant(name, value)) {
if (warn && notAutoload) {
getRuntime().getWarnings().warn(ID.CONSTANT_ALREADY_INITIALIZED, "already initialized constant " + name);
}
setParentForModule(name, value);
// might just call storeConstant(name, value, hidden) but to maintain
// backwards compatibility with calling #storeConstant overrides
if (hidden) storeConstant(name, value, true);
else storeConstant(name, value);
}
} else {
setParentForModule(name, value);
if (hidden) storeConstant(name, value, true);
else storeConstant(name, value);
}
@@ -4248,6 +4248,7 @@ protected final IRubyObject finishAutoload(String name) {
storeConstant(name, value);
}
removeAutoload(name);
invalidateConstantCache(name);
return value;
}

@@ -4270,17 +4271,14 @@ protected IRubyObject getAutoloadConstant(String name, boolean loadConstant) {
/**
* Set an Object as a defined constant in autoloading.
*/
private void setAutoloadConstant(String name, IRubyObject value) {
private boolean setAutoloadConstant(String name, IRubyObject value) {
final Autoload autoload = getAutoloadMap().get(name);
if ( autoload != null ) {
if ( ! autoload.setConstant(getRuntime().getCurrentContext(), value) ) {
storeConstant(name, value);
removeAutoload(name);
}
}
else {
storeConstant(name, value);
boolean set = autoload.setConstant(getRuntime().getCurrentContext(), value);
if ( ! set ) removeAutoload(name);
return set;
}
return false;
}

/**
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/java/proxies/JavaProxy.java
Original file line number Diff line number Diff line change
@@ -501,7 +501,7 @@ private void confirmCachedProxy(String message) {
public static class ClassMethods {

// handling non-public inner classes retrieval ... like private constants
@JRubyMethod(name = "const_missing", required = 1, meta = true, visibility = Visibility.PRIVATE)
@JRubyMethod(name = "const_missing", required = 1, meta = true, visibility = Visibility.PRIVATE, frame = true)
public static IRubyObject const_missing(ThreadContext context, IRubyObject self, IRubyObject name) {
return Java.get_inner_class(context, (RubyModule) self, name);
}
5 changes: 2 additions & 3 deletions core/src/main/java/org/jruby/javasupport/Java.java
Original file line number Diff line number Diff line change
@@ -1074,9 +1074,8 @@ public static IRubyObject get_inner_class(final ThreadContext context,
final String constName = name.asJavaString();

final RubyModule innerClass = getProxyUnderClass(context, self, constName);
if ( innerClass == null ) { // NOTE: probably better to just call super
final String fullName = self.getName() + "::" + constName;
throw context.runtime.newNameError("uninitialized constant " + fullName, fullName);
if ( innerClass == null ) {
return Helpers.invokeSuper(context, self, name, Block.NULL_BLOCK);
}
return cacheConstant(self, constName, innerClass, true); // hidden == true (private_constant)
}
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/util/cli/Options.java
Original file line number Diff line number Diff line change
@@ -225,7 +225,7 @@ public class Options {
public static final Option<Boolean> TRUFFLE_COVERAGE_GLOBAL = bool(TRUFFLE, "truffle.coverage.global", false, "Run coverage for all code and print results on exit.");

public static final Option<String> TRUFFLE_CORE_LOAD_PATH = string(TRUFFLE, "truffle.core.load_path", "truffle:/jruby-truffle", "Location to load the Truffle core library from.");
public static final Option<Boolean> TRUFFLE_POSIX_USE_JAVA = bool(TRUFFLE, "truffle.posix.use_java", false, "Use a Java emulation of POSIX.");
public static final Option<Boolean> TRUFFLE_PLATFORM_USE_JAVA = bool(TRUFFLE, "truffle.platform.use_java", false, "Use a pure-Java platform, so no native POSIX.");

public static final Option<Integer> TRUFFLE_ARRAY_UNINITIALIZED_SIZE = integer(TRUFFLE, "truffle.array.uninitialized_size", 32, "How large an Array to allocate when we have no other information to go on.");
public static final Option<Integer> TRUFFLE_ARRAY_SMALL = integer(TRUFFLE, "truffle.array.small", 3, "Maximum size of an Array to consider small for optimisations.");
24 changes: 19 additions & 5 deletions core/src/main/java/org/jruby/util/io/PopenExecutor.java
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@
import org.jruby.RubyProcess;
import org.jruby.RubyString;
import org.jruby.RubySymbol;
import org.jruby.common.IRubyWarnings;
import org.jruby.platform.Platform;
import org.jruby.runtime.Arity;
import org.jruby.runtime.Block;
@@ -364,9 +365,23 @@ static IRubyObject handleOptionsCommon(ThreadContext context, Ruby runtime, Exec

if (execargAddopt(context, runtime, eargp, key, val) != ST_CONTINUE) {
if (raise) {
if (key instanceof RubySymbol)
throw runtime.newArgumentError("wrong exec option symbol: " + key);
throw runtime.newArgumentError("wrong exec option");
if (key instanceof RubySymbol) {
switch (key.toString()) {
case "gid" :
//runtime.getWarnings().warn(IRubyWarnings.ID.UNSUPPORTED_SUBPROCESS_OPTION, "popen does not support :gid option in JRuby");
//break;
throw runtime.newNotImplementedError("popen does not support :gid option in JRuby");
case "uid" :
//runtime.getWarnings().warn(IRubyWarnings.ID.UNSUPPORTED_SUBPROCESS_OPTION, "popen does not support :uid option in JRuby");
//break;
throw runtime.newNotImplementedError("popen does not support :uid option in JRuby");
default :
throw runtime.newArgumentError("wrong exec option symbol: " + key);
}
}
else {
throw runtime.newArgumentError("wrong exec option");
}
}

if (nonopts == null) nonopts = RubyHash.newHash(runtime);
@@ -1880,8 +1895,7 @@ else if (progByteList.get(p) == '/'){

if (!eargp.use_shell && eargp.argv_buf == null) {
int i;
List<byte[]> argv_buf;
argv_buf = new ArrayList();
ArrayList<byte[]> argv_buf = new ArrayList<>(argc);
for (i = 0; i < argc; i++) {
IRubyObject arg = argv[i];
RubyString argStr = StringSupport.checkEmbeddedNulls(runtime, arg);
6 changes: 2 additions & 4 deletions pom.rb
Original file line number Diff line number Diff line change
@@ -118,9 +118,7 @@
plugin :clean, '2.5'
plugin :dependency, '2.8'
plugin :release, '2.4.1'
plugin :jar, '2.4' do
jar 'org.codehaus.plexus:plexus-io:2.0.5'
end
plugin :jar, '2.6'

rules = { :requireMavenVersion => { :version => '[3.3.0,)' } }
unless model.version =~ /-SNAPSHOT/
@@ -130,7 +128,7 @@
execute_goal :enforce, :rules => rules
end

plugin :compiler, '3.1'
plugin :compiler, '3.3'
plugin :shade, '2.4.3'
plugin :surefire, '2.15'
plugin :plugin, '3.2'
11 changes: 2 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -258,14 +258,7 @@ DO NOT MODIFIY - GENERATED CODE
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-io</artifactId>
<version>2.0.5</version>
</dependency>
</dependencies>
<version>2.6</version>
</plugin>
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
@@ -287,7 +280,7 @@ DO NOT MODIFIY - GENERATED CODE
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<version>3.3</version>
</plugin>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
25 changes: 25 additions & 0 deletions spec/java_integration/types/retrieval_spec.rb
Original file line number Diff line number Diff line change
@@ -153,6 +153,31 @@ class InnerClasses
end
end

it "delegates const_missing" do # crucial for ActiveSupport::Dependencies
const_missing = Module.instance_method(:const_missing)
begin
Module.module_eval do
remove_method(:const_missing)
def const_missing(name)
@_const_missing_names ||= []
@_const_missing_names << name
end
end

InnerClasses::MissingInner
InnerClasses::AnotherMissingInner
InnerClasses::MissingInner

missing_names = InnerClasses.instance_variable_get(:@_const_missing_names)
expect( missing_names ).to eql [ :MissingInner, :AnotherMissingInner, :MissingInner ]

ensure
Module.module_eval do
define_method :const_missing, const_missing
end
end
end

it "raises error importing lower-case names" do
expect do
java_import InnerClasses::lowerInnerClass
6 changes: 6 additions & 0 deletions spec/regression/GH-3645_autoload.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
GH3645.add_mod(:S3)

module GH3645
module S3
end
end
25 changes: 25 additions & 0 deletions spec/regression/GH-3645_set_non_anonymous_constant.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module GH3645
class << self

def add_mod(name) # call this from autoloaded script
mod = Module.new { extend GH3645 }
const_set(name, mod)
mod
end

end
autoload :S3, File.expand_path('GH-3645_autoload', File.dirname(__FILE__))
end

describe 'GH-3645' do

it 'sets a constant' do
GH3645.add_mod :A_MODULE
expect( GH3645::A_MODULE.name ).to eql 'GH3645::A_MODULE'
end

it 'sets an auto-loaded constant' do
expect( GH3645::S3.name ).to eql 'GH3645::S3'
end

end
11 changes: 11 additions & 0 deletions spec/truffle/specs/truffle/attachments/attach_spec.rb
Original file line number Diff line number Diff line change
@@ -35,6 +35,17 @@ def fixture
fixture.should == 14
scratch[0].should be_true
end

it "only runs the block once each time the line is executed" do
scratch = []

@attachments << Truffle::Attachments.attach(__FILE__, 14) do
scratch << :run
end

fixture.should == 14
scratch.size.should == 1
end

it "allows multiple blocks to be installed on the same line and runs both of them" do
scratch = []
Loading

0 comments on commit 094bbef

Please sign in to comment.