Skip to content

Commit

Permalink
Merge branch 'master' into truffle-pack
Browse files Browse the repository at this point in the history
Conflicts:
	tool/jt.rb
  • Loading branch information
chrisseaton committed Apr 29, 2015
2 parents dccd802 + ad4ba4b commit be3b19c
Show file tree
Hide file tree
Showing 120 changed files with 954 additions and 778 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -41,6 +41,7 @@ env:
- PHASE='-Ptruffle-specs-language'
- PHASE='-Ptruffle-specs-core'
- PHASE='-Ptruffle-specs-library'
- PHASE='-Ptruffle-mri-tests'

matrix:
include:
Expand Down
10 changes: 10 additions & 0 deletions bin/jirb_swing
Expand Up @@ -39,6 +39,16 @@ frame = JFrame.new(FRAME_TITLE).tap do |frame|

tar = org.jruby.demo.readline.TextAreaReadline.new(text, HEADER)
tar.hook_into_runtime_with_streams(JRuby.runtime)

# Ruby does not like redefining constants but we do not want the warnings
# readline reads constants and not the globals so we need to reassign
# the globals.
saved_verbose = $VERBOSE
$VERBOSE = nil
STDIN = $stdin
STDOUT = $stdout
STDERR = $stderr
$VERBOSE = saved_verbose
end
end)

Expand Down
2 changes: 1 addition & 1 deletion core/pom.rb
Expand Up @@ -255,7 +255,7 @@
'mainClass' => 'org.jruby.Main' } ] )
execute_goals( 'shade',
:id => 'shade the asm classes',
:phase => 'verify',
:phase => 'package',
'artifactSet' => {
'includes' => [ 'com.github.jnr:jnr-ffi',
'org.ow2.asm:*' ]
Expand Down
2 changes: 1 addition & 1 deletion core/pom.xml
Expand Up @@ -548,7 +548,7 @@
</execution>
<execution>
<id>shade the asm classes</id>
<phase>verify</phase>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
Expand Down
14 changes: 0 additions & 14 deletions core/src/main/java/org/jruby/Main.java
Expand Up @@ -283,8 +283,6 @@ public void run() {
}

try {
doSetContextClassLoader(runtime);

if (in == null) {
// no script to run, return success
return new Status();
Expand Down Expand Up @@ -454,18 +452,6 @@ private boolean checkStreamSyntax(Ruby runtime, InputStream in, String filename)
}
}

private void doSetContextClassLoader(Ruby runtime) {
// set thread context JRuby classloader here, for the main thread
try {
Thread.currentThread().setContextClassLoader(runtime.getJRubyClassLoader());
} catch (SecurityException se) {
// can't set TC classloader
if (runtime.getInstanceConfig().isVerbose()) {
config.getError().println("WARNING: Security restrictions disallowed setting context classloader for main thread.");
}
}
}

private void doProcessArguments(InputStream in) {
config.processArguments(config.parseShebangOptions(in));
}
Expand Down
9 changes: 7 additions & 2 deletions core/src/main/java/org/jruby/RubyInstanceConfig.java
Expand Up @@ -40,6 +40,8 @@
import org.jruby.util.KCode;
import org.jruby.util.NormalizedFile;
import org.jruby.util.SafePropertyAccessor;
import org.jruby.util.URLResource;
import org.jruby.util.FileResource;
import org.jruby.util.cli.ArgumentProcessor;
import org.jruby.util.cli.Options;
import org.jruby.util.cli.OutputStrings;
Expand Down Expand Up @@ -342,7 +344,7 @@ else if (home.startsWith("cp:")) {
}
if (home.startsWith("jar:") || ( home.startsWith("file:") && home.contains(".jar!/") ) ||
home.startsWith("classpath:") || home.startsWith("uri:")) {
error.println("Warning: JRuby home with uri like pathes may not have full functionality - use at your own risk");
error.println("Warning: JRuby home with uri like paths may not have full functionality - use at your own risk");
}
// do not normalize on plain jar like pathes coming from jruby-rack
else if (!home.contains(".jar!/") && !home.startsWith("uri:")) {
Expand Down Expand Up @@ -391,6 +393,9 @@ public InputStream getScriptSource() {
stream = new URL("jar:" + script).openStream();
} else if (script.startsWith("classpath:")) {
stream = getScriptSourceFromJar(script);
} else if (script.startsWith("uri:classloader:")) {
FileResource urlResource = URLResource.create(loader, script);
stream = urlResource.inputStream();
} else {
File file = JRubyFile.create(getCurrentDirectory(), getScriptFileName());
if (isXFlag()) {
Expand Down Expand Up @@ -1405,7 +1410,7 @@ public String getProfilingService() {
public void setProfilingService( String service ) {
this.profilingService = service;
}

private static ClassLoader setupLoader() {
ClassLoader loader = RubyInstanceConfig.class.getClassLoader();

Expand Down
25 changes: 18 additions & 7 deletions core/src/main/java/org/jruby/RubyModule.java
Expand Up @@ -2985,18 +2985,25 @@ public RubyBoolean const_defined_p19(ThreadContext context, IRubyObject[] args)
String symbol = fullName;
boolean inherit = args.length == 1 || (!args[1].isNil() && args[1].isTrue());

int sep = symbol.indexOf("::");
// symbol form does not allow ::
if (args[0] instanceof RubySymbol && symbol.indexOf("::") != -1) {
if (args[0] instanceof RubySymbol && sep != -1) {
throw runtime.newNameError("wrong constant name", symbol);
}

RubyModule mod = this;

if (symbol.startsWith("::")) mod = runtime.getObject();
if (sep == 0) { // ::Foo::Bar
mod = runtime.getObject();
symbol = symbol.substring(2);
}

// Bare ::
if (symbol.length() == 0) throw context.runtime.newNameError("wrong constant name ::", fullName);

int sep;
while((sep = symbol.indexOf("::")) != -1) {
String segment = symbol.substring(0, sep);
if (segment.length() == 0) throw context.runtime.newNameError("wrong constant name " + fullName, symbol);
symbol = symbol.substring(sep + 2);
IRubyObject obj = mod.getConstantNoConstMissing(validateConstant(segment, args[0]), inherit, inherit);
if(obj instanceof RubyModule) {
Expand Down Expand Up @@ -3040,6 +3047,9 @@ public IRubyObject const_get_2_0(ThreadContext context, IRubyObject[] args) {
symbol = symbol.substring(2);
}

// Bare ::
if (symbol.length() == 0) throw context.runtime.newNameError("wrong constant name ::", fullName);

while ((sep = symbol.indexOf("::")) != -1) {
String segment = symbol.substring(0, sep);
symbol = symbol.substring(sep + 2);
Expand Down Expand Up @@ -3107,15 +3117,16 @@ private boolean hasConstantInHierarchy(final String name) {
@JRubyMethod(name = "const_missing", required = 1)
public IRubyObject const_missing(ThreadContext context, IRubyObject rubyName, Block block) {
Ruby runtime = context.runtime;
String name;
String shortName = rubyName.asJavaString();
String longName;

if (this != runtime.getObject()) {
name = getName() + "::" + rubyName.asJavaString();
longName = getName() + "::" + shortName;
} else {
name = rubyName.asJavaString();
longName = shortName;
}

throw runtime.newNameErrorObject("uninitialized constant " + name, runtime.newSymbol(name));
throw runtime.newNameErrorObject("uninitialized constant " + longName, runtime.newSymbol(shortName));
}

public RubyArray constants(ThreadContext context) {
Expand Down
7 changes: 0 additions & 7 deletions core/src/main/java/org/jruby/util/NullDeviceResource.java
Expand Up @@ -151,13 +151,6 @@ private Channel createChannel(ModeFlags flags) throws ResourceException {
throw new ResourceException.IOError(ioe);
}

try {
if (flags.isTruncate()) fileChannel.truncate(0);
} catch (IOException ioe) {
// ignore; it's a pipe or fifo that can't be truncated (we only care about illegal seek).
if (!ioe.getMessage().equals("Illegal seek")) throw new ResourceException.IOError(ioe);
}

return fileChannel;
}
}
43 changes: 23 additions & 20 deletions core/src/main/java/org/jruby/util/URLResource.java
Expand Up @@ -40,11 +40,11 @@ public class URLResource extends AbstractFileResource {
URLResource(String uri, URL url, String[] files) {
this(uri, url, null, null, files);
}

URLResource(String uri, ClassLoader cl, String pathname, String[] files) {
this(uri, null, cl, pathname, files);
}

private URLResource(String uri, URL url, ClassLoader cl, String pathname, String[] files) {
this.uri = uri;
this.list = files;
Expand All @@ -53,7 +53,7 @@ private URLResource(String uri, URL url, ClassLoader cl, String pathname, String
this.pathname = pathname;
this.fileStat = new JarFileStat(this);
}

@Override
public String absolutePath()
{
Expand Down Expand Up @@ -129,7 +129,7 @@ public FileStat stat() {
public FileStat lstat() {
return stat(); // URLs don't have symbolic links, so lstat == stat
}

@Override
public JRubyFile hackyGetJRubyFile() {
return JRubyNonExistentFile.NOT_EXIST;
Expand All @@ -149,20 +149,23 @@ public Channel openChannel( ModeFlags flags, int perm ) throws ResourceException
return Channels.newChannel(inputStream());
}

public static FileResource create(ClassLoader cl, String pathname) {
try
{
pathname = new URI(pathname.replaceFirst("^/*", "/")).normalize().getPath().replaceAll("^/([.][.]/)*", "");
} catch (URISyntaxException e) {
pathname = pathname.replaceAll("^[.]?/*", "");
}
URL url = cl.getResource(pathname);
String[] files = listClassLoaderFiles(cl, pathname);
return new URLResource(URI_CLASSLOADER + pathname,
cl,
url == null ? null : pathname,
files);
}

public static FileResource createClassloaderURI(Ruby runtime, String pathname) {
ClassLoader cl = runtime.getJRubyClassLoader();
try
{
pathname = new URI(pathname.replaceFirst("^/*", "/")).normalize().getPath().replaceAll("^/([.][.]/)*", "");
} catch (URISyntaxException e) {
pathname = pathname.replaceAll("^[.]?/*", "");
}
URL url = cl.getResource(pathname);
String[] files = listClassLoaderFiles(cl, pathname);
return new URLResource(URI_CLASSLOADER + pathname,
cl,
url == null ? null : pathname,
files);
return create(runtime.getJRubyClassLoader(), pathname);
}

public static FileResource create(Ruby runtime, String pathname)
Expand All @@ -176,7 +179,7 @@ public static FileResource create(Ruby runtime, String pathname)
}
return createRegularURI(pathname);
}

private static FileResource createRegularURI(String pathname) {
URL url;
try
Expand All @@ -185,7 +188,7 @@ private static FileResource createRegularURI(String pathname) {
// and make file:/a protocol to be file:///a so the second replace does not apply
pathname = pathname.replaceFirst( "file:/([^/])", "file:///$1" );
pathname = pathname.replaceFirst( ":/([^/])", "://$1" );

url = new URL(pathname);
// we do not want to deal with those url here like this though they are valid url/uri
if (url.getProtocol().startsWith("http")){
Expand Down Expand Up @@ -311,5 +314,5 @@ public static URL getResourceURL(Ruby runtime, String location)
throw new RuntimeException("BUG in " + URLResource.class);
}
}

}
Expand Up @@ -718,7 +718,7 @@ private void logScriptResolutionFailure(String path) {
public static void checkGraalVersion() {
if (Options.TRUFFLE_RUNTIME_VERSION_CHECK.load()) {
final String graalVersion = System.getProperty("graal.version", "unknown");
final String expectedGraalVersion = "0.7-dev";
final String expectedGraalVersion = "0.7";

if (graalVersion.equals("unknown")) {
return;
Expand Down
100 changes: 0 additions & 100 deletions lib/ruby/shared/ffi/platform/ppc64le-linux/types.conf

This file was deleted.

0 comments on commit be3b19c

Please sign in to comment.