Skip to content

Commit

Permalink
Merge branch 'jruby-1_7'
Browse files Browse the repository at this point in the history
Conflicts:
	.travis.yml
	VERSION
	core/pom.xml
	core/src/main/java/org/jruby/RubyClass.java
	core/src/main/java/org/jruby/util/TypeConverter.java
	core/src/main/java/org/jruby/util/URLResource.java
	docs/man/pom.xml
	docs/pom.xml
	ext/pom.xml
	ext/readline/pom.xml
	ext/ripper/pom.xml
	lib/pom.xml
	maven/jruby-complete/pom.rb
	maven/jruby-complete/pom.xml
	maven/jruby-core-complete/pom.rb
	maven/jruby-core-complete/pom.xml
	maven/jruby-dist/pom.rb
	maven/jruby-dist/pom.xml
	maven/jruby-dist/src/main/assembly/jruby.xml
	maven/jruby-jars/Mavenfile
	maven/jruby-jars/jruby-jars.gemspec
	maven/jruby-jars/lib/jruby-jars.rb
	maven/jruby-jars/lib/jruby-jars/version.rb
	maven/jruby-jars/pom.xml
	maven/jruby-jars/src/it/helloworld/pom.xml
	maven/jruby-jars/src/it/integrity/pom.xml
	maven/jruby-noasm/pom.rb
	maven/jruby-noasm/pom.xml
	maven/jruby-rake-plugin/pom.rb
	maven/jruby-rake-plugin/pom.xml
	maven/jruby-stdlib-complete/pom.rb
	maven/jruby-stdlib-complete/pom.xml
	maven/jruby-stdlib/pom.rb
	maven/jruby-stdlib/pom.xml
	maven/jruby/pom.rb
	maven/jruby/pom.xml
	maven/pom.rb
	maven/pom.xml
	pom.xml
	spec/regression/GH-1963_Array_product_coercion_spec.rb
	test/pom.xml
	test/test_command_line_switches.rb
  • Loading branch information
mkristian committed Sep 29, 2014
2 parents c7a3739 + 1f13c08 commit 5ee0832
Show file tree
Hide file tree
Showing 90 changed files with 1,651 additions and 1,675 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ os:
- osx

env:
# disable cext
global:
- JAVA_OPTS="-XX:+TieredCompilation -XX:TieredStopAtLevel=1 -Djruby.cext.enabled=false"
matrix:
- TARGET='-Ptest'
- TARGET='-Prake -Dtask=test:rubicon'
Expand Down
2 changes: 1 addition & 1 deletion BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ and those files will be installed in you maven local-repository ready to use wit
mvn -Pjruby-jars
```

the gem will be in ./maven/jruby-jars/target
the gem will be in ./maven/jruby-jars/pkg

<<<<<<< HEAD
### building ALL packages ###
Expand Down
2 changes: 1 addition & 1 deletion bin/jirb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

require "irb"

if __FILE__ == $0
if __FILE__.sub(/file:/, '') == $0.sub(/file:/, '')
IRB.start(__FILE__)
else
# check -e option
Expand Down
2 changes: 1 addition & 1 deletion bin/jirb_swing
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ end
JRuby.objectspace = true # useful for code completion

# From vanilla IRB
if __FILE__ == $0
if __FILE__.sub(/file:/, '') == $0.sub(/file:/, '')
IRB.start(__FILE__)
else
# check -e option
Expand Down
1 change: 1 addition & 0 deletions core/.settings/org.eclipse.core.resources.prefs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ encoding//src/main/java=utf-8
encoding//src/main/resources=utf-8
encoding//src/main/ruby=utf-8
encoding//src/test/java=utf-8
encoding//src/test/resources=utf-8
encoding/<project>=utf-8
2 changes: 1 addition & 1 deletion core/pom.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
jar 'com.github.jnr:jffi:${jffi.version}'
jar 'com.github.jnr:jffi:${jffi.version}:native'

jar 'org.jruby.joni:joni:2.1.2'
jar 'org.jruby.joni:joni:2.1.3'
jar 'org.jruby.extras:bytelist:1.0.12-SNAPSHOT'
jar 'org.jruby.jcodings:jcodings:1.0.12-SNAPSHOT'
jar 'org.jruby:yecht:1.0'
Expand Down
2 changes: 1 addition & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
<dependency>
<groupId>org.jruby.joni</groupId>
<artifactId>joni</artifactId>
<version>2.1.2</version>
<version>2.1.3</version>
</dependency>
<dependency>
<groupId>org.jruby.extras</groupId>
Expand Down
9 changes: 7 additions & 2 deletions core/src/main/java/org/jruby/RubyClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
import org.jruby.anno.JRubyClass;
import org.jruby.anno.JRubyMethod;
import org.jruby.compiler.impl.SkinnyMethodAdapter;
import org.jruby.exceptions.RaiseException;
import org.jruby.internal.runtime.methods.DynamicMethod;
import org.jruby.java.codegen.RealClassGenerator;
import org.jruby.java.codegen.Reified;
Expand Down Expand Up @@ -650,7 +651,9 @@ private static boolean checkFuncallRespondTo(ThreadContext context, RubyClass kl
RubyClass defined_class;
DynamicMethod me = klass.searchMethod("respond_to?");

if (me != null && !me.isUndefined()) {
// NOTE: isBuiltin here would be NOEX_BASIC in MRI, a flag only added to respond_to?, method_missing, and
// respond_to_missing? Same effect, I believe.
if (me != null && !me.isUndefined() && !me.isBuiltin()) {
Arity arity = me.getArity();

if (arity.getValue() > 2)
Expand Down Expand Up @@ -683,7 +686,9 @@ private static IRubyObject checkFuncallMissing(ThreadContext context, RubyClass
else {
try {
return checkFuncallExec(context, self, method, args);
} catch (Exception e) {
} catch (RaiseException e) {
// clear $!
context.setErrorInfo(context.nil);
return checkFuncallFailed(context, self, method, runtime.getNoMethodError(), args);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public FoundLibrary findBySearchState(LoadService.SearchState state) {
FoundLibrary lib = findLibrary(state.searchFile, state.suffixType);
if (lib != null) {
state.library = lib;
state.loadName = lib.getLoadName();
state.setLoadName(lib.getLoadName());
}
return lib;
}
Expand Down
28 changes: 16 additions & 12 deletions core/src/main/java/org/jruby/runtime/load/LoadService.java
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ public void loadFromClassLoader(ClassLoader classLoader, String file, boolean wr
Library library = null;
LoadServiceResource resource = getClassPathResource(classLoader, file);
if (resource != null) {
state.loadName = resolveLoadName(resource, file);
state.setLoadName(resolveLoadName(resource, file));
library = createLibrary(state, resource);
}
if (library == null) {
Expand Down Expand Up @@ -873,6 +873,10 @@ public void prepareLoadSearch(final String file) {
}
}

public void setLoadName(String loadName) {
this.loadName = loadName;
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
Expand Down Expand Up @@ -988,7 +992,7 @@ protected Library findBuiltinLibrary(SearchState state, String baseName, SuffixT
String namePlusSuffix = baseName + suffix;
debugLogTry( "builtinLib", namePlusSuffix );
if (builtinLibraries.containsKey(namePlusSuffix)) {
state.loadName = namePlusSuffix;
state.setLoadName(namePlusSuffix);
Library lib = builtinLibraries.get(namePlusSuffix);
debugLogFound( "builtinLib", namePlusSuffix );
return lib;
Expand Down Expand Up @@ -1033,7 +1037,7 @@ protected Library findLibraryWithClassloaders(SearchState state, String baseName
String file = baseName + suffix;
LoadServiceResource resource = findFileInClasspath(file);
if (resource != null) {
state.loadName = resolveLoadName(resource, file);
state.setLoadName(resolveLoadName(resource, file));
return createLibrary(state, resource);
}
}
Expand Down Expand Up @@ -1077,7 +1081,7 @@ protected LoadServiceResource tryResourceFromCWD(SearchState state, String baseN
boolean absolute = true;
foundResource = new LoadServiceResource(file, getFileName(file, namePlusSuffix), absolute);
debugLogFound(foundResource);
state.loadName = resolveLoadName(foundResource, namePlusSuffix);
state.setLoadName(resolveLoadName(foundResource, namePlusSuffix));
break;
}
} catch (IllegalArgumentException illArgEx) {
Expand Down Expand Up @@ -1128,7 +1132,7 @@ protected LoadServiceResource tryResourceFromHome(SearchState state, String base
if (file.isFile() && file.isAbsolute() && file.canRead()) {
boolean absolute = true;

state.loadName = file.getPath();
state.setLoadName(file.getPath());
foundResource = new LoadServiceResource(file, state.loadName, absolute);
debugLogFound(foundResource);
break;
Expand Down Expand Up @@ -1167,7 +1171,7 @@ protected LoadServiceResource tryResourceFromJarURL(SearchState state, String ba
throw runtime.newIOErrorFromException(e);
}
if (foundResource != null) {
state.loadName = resolveLoadName(foundResource, namePlusSuffix);
state.setLoadName(resolveLoadName(foundResource, namePlusSuffix));
break; // end suffix iteration
}
}
Expand All @@ -1191,7 +1195,7 @@ protected LoadServiceResource tryResourceFromJarURL(SearchState state, String ba
throw runtime.newIOErrorFromException(e);
} catch(Exception e) {}
if (foundResource != null) {
state.loadName = resolveLoadName(foundResource, namePlusSuffix);
state.setLoadName(resolveLoadName(foundResource, namePlusSuffix));
break; // end suffix iteration
}
}
Expand All @@ -1209,7 +1213,7 @@ protected LoadServiceResource tryResourceFromLoadPathOrURL(SearchState state, St
foundResource = tryResourceFromDotSlash(state, baseName, suffixType);

if (foundResource != null) {
state.loadName = resolveLoadName(foundResource, foundResource.getName());
state.setLoadName(resolveLoadName(foundResource, foundResource.getName()));
}

// not found, don't bother with load path
Expand All @@ -1221,7 +1225,7 @@ protected LoadServiceResource tryResourceFromLoadPathOrURL(SearchState state, St
foundResource = tryResourceFromHome(state, baseName, suffixType);

if (foundResource != null) {
state.loadName = resolveLoadName(foundResource, foundResource.getName());
state.setLoadName(resolveLoadName(foundResource, foundResource.getName()));
}

// not found, don't bother with load path
Expand All @@ -1235,7 +1239,7 @@ protected LoadServiceResource tryResourceFromLoadPathOrURL(SearchState state, St
foundResource = tryResourceAsIs(namePlusSuffix);

if (foundResource != null) {
state.loadName = resolveLoadName(foundResource, namePlusSuffix);
state.setLoadName(resolveLoadName(foundResource, namePlusSuffix));
return foundResource;
}
}
Expand All @@ -1256,7 +1260,7 @@ protected LoadServiceResource tryResourceFromLoadPathOrURL(SearchState state, St
if(ss.startsWith("./")) {
ss = ss.substring(2);
}
state.loadName = resolveLoadName(foundResource, ss);
state.setLoadName(resolveLoadName(foundResource, ss));
break Outer;
}
} else {
Expand All @@ -1278,7 +1282,7 @@ protected LoadServiceResource tryResourceFromLoadPathOrURL(SearchState state, St
if(ss.startsWith("./")) {
ss = ss.substring(2);
}
state.loadName = resolveLoadName(foundResource, ss);
state.setLoadName(resolveLoadName(foundResource, ss));
break Outer; // end suffix iteration
}
}
Expand Down
6 changes: 3 additions & 3 deletions core/src/main/java/org/jruby/util/JarFileStat.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public boolean isFifo() {

@Override
public boolean isFile() {
return !resource.isDirectory();
return resource.isFile();
}

@Override
Expand Down Expand Up @@ -122,12 +122,12 @@ public boolean isROwned() {

@Override
public boolean isReadable() {
return true;
return resource.canRead();
}

@Override
public boolean isReadableReal() {
return true;
return resource.canRead();
}

@Override
Expand Down
97 changes: 51 additions & 46 deletions core/src/main/java/org/jruby/util/ShellLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,12 @@
import java.lang.reflect.Field;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
Expand Down Expand Up @@ -1078,31 +1080,24 @@ public boolean shouldRunInProcess() {
// and end of each command word and don't run in process if we find them.
for (int i = 0; i < args.length; i++) {
String c = args[i];
if (c.trim().length() == 0) {
continue;
}
if (c.trim().length() == 0) continue;

char[] firstLast = new char[] {c.charAt(0), c.charAt(c.length()-1)};
for (int j = 0; j < firstLast.length; j++) {
switch (firstLast[j]) {
case '<': case '>': case '|': case ';':
case '*': case '?': case '{': case '}':
case '[': case ']': case '(': case ')':
case '~': case '&': case '$': case '"':
case '`': case '\n': case '\\': case '\'':
case '<': case '>': case '|': case ';': case '(': case ')':
case '~': case '&': case '$': case '"': case '`': case '\n':
case '\\': case '\'':
return false;
case '2':
if(c.length() > 1 && c.charAt(1) == '>') {
return false;
}
if(c.length() > 1 && c.charAt(1) == '>') return false;
}
}
}

String command = args[0];

if (Platform.IS_WINDOWS) {
command = command.toLowerCase();
}
if (Platform.IS_WINDOWS) command = command.toLowerCase();

// handle both slash types, \ and /.
String[] slashDelimitedTokens = command.split("[/\\\\]");
Expand All @@ -1112,25 +1107,20 @@ public boolean shouldRunInProcess() {
|| finalToken.endsWith(".rb")
|| finalToken.endsWith("irb"));

if (!inProc) {
return false;
} else {
if (args.length > 1) {
for (int i = 1; i < args.length; i++) {
checkGlobChar(args[i]);
}
}
// snip off ruby or jruby command from list of arguments
// leave alone if the command is the name of a script
int startIndex = command.endsWith(".rb") ? 0 : 1;
if (command.trim().endsWith("irb")) {
startIndex = 0;
args[0] = runtime.getJRubyHome() + File.separator + "bin" + File.separator + "jirb";
}
execArgs = new String[args.length - startIndex];
System.arraycopy(args, startIndex, execArgs, 0, execArgs.length);
return true;
if (!inProc) return false;

// snip off ruby or jruby command from list of arguments
// leave alone if the command is the name of a script
int startIndex = command.endsWith(".rb") ? 0 : 1;
if (command.trim().endsWith("irb")) {
startIndex = 0;
args[0] = runtime.getJRubyHome() + File.separator + "bin" + File.separator + "jirb";
}

execArgs = new String[args.length - startIndex];
System.arraycopy(args, startIndex, execArgs, 0, execArgs.length);

return true;
}

/**
Expand Down Expand Up @@ -1313,17 +1303,6 @@ private static boolean shouldVerifyPathExecutable(String cmdline) {
}
return verifyPathExecutable;
}

private void checkGlobChar(String word) {
if (Options.LAUNCH_INPROC.load() &&
(word.contains("*")
|| word.contains("?")
|| word.contains("[")
|| word.contains("{"))) {
runtime.getErr().println("Warning: treating '" + word + "' literally."
+ " Consider passing -J-Djruby.launch.inproc=false.");
}
}

private Ruby runtime;
private boolean doExecutableSearch;
Expand All @@ -1341,16 +1320,42 @@ public static Process run(Ruby runtime, IRubyObject[] rawArgs, boolean doExecuta
return run(runtime, rawArgs, doExecutableSearch, false);
}

private static boolean hasGlobCharacter(String word) {
return word.contains("*") || word.contains("?") || word.contains("[") || word.contains("{");
}

private static String[] expandGlobs(Ruby runtime, String[] originalArgs) {
List<String> expandedList = new ArrayList<String>(originalArgs.length);
for (int i = 0; i < originalArgs.length; i++) {
if (hasGlobCharacter(originalArgs[i])) {
// FIXME: Encoding lost here
List<ByteList> globs = Dir.push_glob(runtime.getPosix(), runtime.getCurrentDirectory(),
new ByteList(originalArgs[i].getBytes()), 0);

for (ByteList glob: globs) {
expandedList.add(glob.toString());
}
} else {
expandedList.add(originalArgs[i]);
}
}

String[] args = new String[expandedList.size()];
expandedList.toArray(args);

return args;
}

public static Process run(Ruby runtime, IRubyObject[] rawArgs, boolean doExecutableSearch, boolean forceExternalProcess) throws IOException {
Process aProcess = null;
Process aProcess;
File pwd = new File(runtime.getCurrentDirectory());
LaunchConfig cfg = new LaunchConfig(runtime, rawArgs, doExecutableSearch);

try {
if (!forceExternalProcess && cfg.shouldRunInProcess()) {
log(runtime, "Launching in-process");
ScriptThreadProcess ipScript = new ScriptThreadProcess(
runtime, cfg.getExecArgs(), getCurrentEnv(runtime), pwd);
ScriptThreadProcess ipScript = new ScriptThreadProcess(runtime,
expandGlobs(runtime, cfg.getExecArgs()), getCurrentEnv(runtime), pwd);
ipScript.start();
return ipScript;
} else {
Expand Down
Loading

0 comments on commit 5ee0832

Please sign in to comment.