Skip to content

Commit

Permalink
Showing 84 changed files with 534 additions and 449 deletions.
8 changes: 4 additions & 4 deletions core/src/main/java/org/jruby/BasicObjectStub.java
Original file line number Diff line number Diff line change
@@ -179,7 +179,7 @@ public static RubyInteger convertToInteger(IRubyObject self, int convertMethodIn

public static RubyInteger convertToInteger(IRubyObject self, String convertMethod) {
IRubyObject val = TypeConverter.convertToType(self, getRuntime(self).getInteger(), convertMethod, true);
if (!(val instanceof RubyInteger)) throw getRuntime(self).newTypeError(getMetaClass(self).getName() + "#" + convertMethod + " should return Integer");
if (!(val instanceof RubyInteger)) throw getRuntime(self).newTypeError(getMetaClass(self).getName() + '#' + convertMethod + " should return Integer");
return (RubyInteger)val;
}

@@ -190,7 +190,7 @@ public static RubyString convertToString(IRubyObject self) {
public static IRubyObject anyToString(IRubyObject self) {
String cname = getMetaClass(self).getRealClass().getName();
/* 6:tags 16:addr 1:eos */
RubyString str = getRuntime(self).newString("#<" + cname + ":0x" + Integer.toHexString(System.identityHashCode(self)) + ">");
RubyString str = getRuntime(self).newString("#<" + cname + ":0x" + Integer.toHexString(System.identityHashCode(self)) + '>');
str.setTaint(isTaint(self));
return str;
}
@@ -255,11 +255,11 @@ private static StringBuilder inspectObj(IRubyObject self, StringBuilder part) {
String sep = "";

for (Variable<IRubyObject> ivar : getInstanceVariables(self).getInstanceVariableList()) {
part.append(sep).append(" ").append(ivar.getName()).append("=");
part.append(sep).append(' ').append(ivar.getName()).append('=');
part.append(invokedynamic(context, ivar.getValue(), INSPECT));
sep = ",";
}
part.append(">");
part.append('>');
return part;
}

25 changes: 9 additions & 16 deletions core/src/main/java/org/jruby/NativeException.java
Original file line number Diff line number Diff line change
@@ -88,19 +88,14 @@ public IRubyObject backtrace() {
StackTraceElement[] stackTrace = cause.getStackTrace();
for (int i = stackTrace.length - 1; i >= 0; i--) {
StackTraceElement element = stackTrace[i];
String className = element.getClassName();
String line = null;
final String className = element.getClassName();
final String line;
if (element.getFileName() == null) {
line = className + ":" + element.getLineNumber() + ":in `" + element.getMethodName() + "'";
line = className + ':' + element.getLineNumber() + ":in `" + element.getMethodName() + '\'';
} else {
int index = className.lastIndexOf(".");
String packageName = null;
if (index == -1) {
packageName = "";
} else {
packageName = className.substring(0, index) + "/";
}
line = packageName.replace(".", "/") + element.getFileName() + ":" + element.getLineNumber() + ":in `" + element.getMethodName() + "'";
final int index = className.lastIndexOf('.');
final String packageName = index == -1 ? "" : className.substring(0, index) + '/';
line = packageName.replace('.', '/') + element.getFileName() + ':' + element.getLineNumber() + ":in `" + element.getMethodName() + '\'';
}
RubyString string = runtime.newString(line);
array.unshift(string);
@@ -139,11 +134,9 @@ public void trimStackTrace(Member target) {
}
}
if (skip > 0) {
StackTraceElement[] newStackTrace =
new StackTraceElement[origStackTrace.length - skip];
for (int i = 0; i < newStackTrace.length; ++i) {
newStackTrace[i] = origStackTrace[i];
}
final int len = origStackTrace.length - skip;
StackTraceElement[] newStackTrace = new StackTraceElement[len];
System.arraycopy(origStackTrace, 0, newStackTrace, 0, len);
cause.setStackTrace(newStackTrace);
}
}
17 changes: 11 additions & 6 deletions core/src/main/java/org/jruby/Ruby.java
Original file line number Diff line number Diff line change
@@ -472,7 +472,7 @@ public IRubyObject evalScriptlet(String script, DynamicScope scope) {
context.preEvalScriptlet(scope);

try {
return Interpreter.getInstance().execute(this, rootNode, context.getFrameSelf());
return interpreter.execute(this, rootNode, context.getFrameSelf());
} finally {
context.postEvalScriptlet();
}
@@ -535,7 +535,7 @@ public void runFromMain(InputStream inputStream, String filename) {
} else {
varvalue = getTrue();
}
getGlobalVariables().set("$" + entry.getKey(), varvalue);
getGlobalVariables().set('$' + entry.getKey(), varvalue);
}

if (filename.endsWith(".class")) {
@@ -835,7 +835,7 @@ public IRubyObject runInterpreter(ThreadContext context, ParseResult parseResult
throw new UnsupportedOperationException();
}

return Interpreter.getInstance().execute(this, parseResult, self);
return interpreter.execute(this, parseResult, self);
}

public IRubyObject runInterpreter(ThreadContext context, Node rootNode, IRubyObject self) {
@@ -849,7 +849,7 @@ public IRubyObject runInterpreter(ThreadContext context, Node rootNode, IRubyObj
Main.printTruffleTimeMetric("after-run");
return getNil();
} else {
return Interpreter.getInstance().execute(this, rootNode, self);
return interpreter.execute(this, rootNode, self);
}
}

@@ -2864,7 +2864,7 @@ public RubyModule getClassFromPath(String path) {

IRubyObject cc = c.getConstant(str);
if(!(cc instanceof RubyModule)) {
throw newTypeError("" + path + " does not refer to class/module");
throw newTypeError(path + " does not refer to class/module");
}
c = (RubyModule)cc;
}
@@ -3348,7 +3348,10 @@ public void tearDown(boolean systemExit) {
* release the runtime loader but not otherwise - you should do that manually.
*/
public void releaseClassLoader() {
if ( jrubyClassLoader != null ) getJRubyClassLoader().close();
if ( jrubyClassLoader != null ) {
getJRubyClassLoader().close();
jrubyClassLoader = null;
}
}

/**
@@ -5134,6 +5137,8 @@ public void addToObjectSpace(boolean useObjectSpace, IRubyObject object) {

private final FilenoUtil filenoUtil = new FilenoUtil();

private Interpreter interpreter = new Interpreter();

/**
* A representation of this runtime as a JIT-optimizable constant. Used for e.g. invokedynamic binding of runtime
* accesses.
1 change: 0 additions & 1 deletion core/src/main/java/org/jruby/RubyArray.java
Original file line number Diff line number Diff line change
@@ -2545,7 +2545,6 @@ public IRubyObject delete_if(ThreadContext context, Block block) {
@JRubyMethod(optional = 1, rest = true)
public IRubyObject zip(ThreadContext context, IRubyObject[] args, Block block) {
final Ruby runtime = context.runtime;
final int aLen = args.length + 1;
RubyClass array = runtime.getArray();

final IRubyObject[] newArgs = new IRubyObject[args.length];
8 changes: 4 additions & 4 deletions core/src/main/java/org/jruby/RubyBasicObject.java
Original file line number Diff line number Diff line change
@@ -748,7 +748,7 @@ public RubyInteger convertToInteger() {
@Override
public RubyInteger convertToInteger(String convertMethod) {
IRubyObject val = TypeConverter.convertToType(this, getRuntime().getInteger(), convertMethod, true);
if (!(val instanceof RubyInteger)) throw getRuntime().newTypeError(getMetaClass().getName() + "#" + convertMethod + " should return Integer");
if (!(val instanceof RubyInteger)) throw getRuntime().newTypeError(getMetaClass().getName() + '#' + convertMethod + " should return Integer");
return (RubyInteger)val;
}

@@ -769,7 +769,7 @@ public RubyString convertToString() {
public IRubyObject anyToString() {
String cname = getMetaClass().getRealClass().getName();
/* 6:tags 16:addr 1:eos */
RubyString str = getRuntime().newString("#<" + cname + ":0x" + Integer.toHexString(System.identityHashCode(this)) + ">");
RubyString str = getRuntime().newString("#<" + cname + ":0x" + Integer.toHexString(System.identityHashCode(this)) + '>');
str.setTaint(isTaint());
return str;
}
@@ -1123,11 +1123,11 @@ private StringBuilder inspectObj(StringBuilder part) {
Object value = entry.getValue().get(this);
if (value == null || !(value instanceof IRubyObject) || !IdUtil.isInstanceVariable(entry.getKey())) continue;

part.append(sep).append(" ").append(entry.getKey()).append("=");
part.append(sep).append(' ').append(entry.getKey()).append('=');
part.append(invokedynamic(context, (IRubyObject)value, INSPECT));
sep = ",";
}
part.append(">");
part.append('>');
return part;
}

2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/RubyClassPathVariable.java
Original file line number Diff line number Diff line change
@@ -92,7 +92,7 @@ private URL getURL(String target) throws MalformedURLException {
String path = target;
if (f.exists() && f.isDirectory() && !path.endsWith("/")) {
// URLClassLoader requires that directories end with slashes
path = path + "/";
path = path + '/';
}
return new URL("file", null, path);
}
14 changes: 5 additions & 9 deletions core/src/main/java/org/jruby/RubyDir.java
Original file line number Diff line number Diff line change
@@ -560,9 +560,9 @@ public IRubyObject inspect() {
Ruby runtime = getRuntime();
StringBuilder part = new StringBuilder();
String cname = getMetaClass().getRealClass().getName();
part.append("#<").append(cname).append(":");
part.append("#<").append(cname).append(':');
if (path != null) { part.append(path.asJavaString()); }
part.append(">");
part.append('>');

return runtime.newString(part.toString());
}
@@ -701,8 +701,8 @@ protected static JRubyFile getDirForRmdir(final Ruby runtime, final String path)
// dir can't be read, so we check permissions first

// no permission
if (directory.getParentFile().exists() &&
!directory.getParentFile().canWrite()) {
File parentFile = directory.getParentFile();
if (parentFile.exists() && ! parentFile.canWrite()) {
throw runtime.newErrnoEACCESError(path);
}

@@ -807,11 +807,7 @@ public static RubyString getHomeDirectoryPath(ThreadContext context) {
Ruby runtime = context.runtime;
IRubyObject systemHash = runtime.getObject().getConstant("ENV_JAVA");
RubyHash envHash = (RubyHash) runtime.getObject().getConstant("ENV");
IRubyObject home = null;

if (home == null || home.isNil()) {
home = envHash.op_aref(context, runtime.newString("HOME"));
}
IRubyObject home = envHash.op_aref(context, runtime.newString("HOME"));

if (home == null || home.isNil()) {
home = systemHash.callMethod(context, "[]", runtime.newString("user.home"));
1 change: 0 additions & 1 deletion core/src/main/java/org/jruby/RubyEnumerable.java
Original file line number Diff line number Diff line change
@@ -1667,7 +1667,6 @@ public static IRubyObject zipCommon(ThreadContext context, IRubyObject self,
public static IRubyObject zipCommon19(ThreadContext context, IRubyObject self,
IRubyObject[] args, final Block block) {
final Ruby runtime = context.runtime;
final int aLen = args.length + 1;
RubyClass array = runtime.getArray();

final IRubyObject[] newArgs = new IRubyObject[args.length];
8 changes: 0 additions & 8 deletions core/src/main/java/org/jruby/RubyEnumerator.java
Original file line number Diff line number Diff line change
@@ -218,10 +218,6 @@ public IRubyObject initialize19(ThreadContext context, IRubyObject object, IRuby

@JRubyMethod(name = "initialize", visibility = PRIVATE)
public IRubyObject initialize20(ThreadContext context, IRubyObject object, IRubyObject method, Block block) {
Ruby runtime = context.runtime;

IRubyObject size = context.nil;

if (block.isGiven()) {
throw context.runtime.newArgumentError(2, 1);
} else {
@@ -239,10 +235,6 @@ public IRubyObject initialize19(ThreadContext context, IRubyObject object, IRuby

@JRubyMethod(name = "initialize", visibility = PRIVATE)
public IRubyObject initialize20(ThreadContext context, IRubyObject object, IRubyObject method, IRubyObject methodArg, Block block) {
Ruby runtime = context.runtime;

IRubyObject size = context.nil;

if (block.isGiven()) {
throw context.runtime.newArgumentError(3, 1);
} else {
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/RubyException.java
Original file line number Diff line number Diff line change
@@ -157,7 +157,7 @@ public IRubyObject inspect(ThreadContext context) {

if (exception.isEmpty()) return getRuntime().newString(rubyClass.getName());
StringBuilder sb = new StringBuilder("#<");
sb.append(rubyClass.getName()).append(": ").append(exception.getByteList()).append(">");
sb.append(rubyClass.getName()).append(": ").append(exception.getByteList()).append('>');
return getRuntime().newString(sb.toString());
}

Loading

0 comments on commit 3fdeac3

Please sign in to comment.