Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: ffdf5300541e
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: df078686fa9e
Choose a head ref
  • 15 commits
  • 25 files changed
  • 1 contributor

Commits on Sep 16, 2015

  1. Copy the full SHA
    5b3b943 View commit details
  2. Copy the full SHA
    f735a17 View commit details
  3. Copy the full SHA
    47ef73b View commit details
  4. Copy the full SHA
    703f39a View commit details
  5. Copy the full SHA
    d3d8f48 View commit details
  6. [find-bugs] inefficient string buffering - avoid passing concatenatin…

    …g string to builder
    kares committed Sep 16, 2015
    Copy the full SHA
    3a6e538 View commit details
  7. Copy the full SHA
    a9f4703 View commit details
  8. Copy the full SHA
    112af38 View commit details
  9. Copy the full SHA
    9ff8805 View commit details
  10. [find-bugs] use local map instead of calling the same method again in…

    … ScriptingContainer
    kares committed Sep 16, 2015
    Copy the full SHA
    0671de6 View commit details
  11. Copy the full SHA
    c534948 View commit details
  12. Copy the full SHA
    ce51328 View commit details
  13. Copy the full SHA
    a0fe3f1 View commit details
  14. Copy the full SHA
    aad352c View commit details
  15. Copy the full SHA
    df07868 View commit details
Showing with 148 additions and 127 deletions.
  1. +3 −3 core/src/main/java/org/jruby/BasicObjectStub.java
  2. +9 −16 core/src/main/java/org/jruby/NativeException.java
  3. +1 −1 core/src/main/java/org/jruby/Ruby.java
  4. +4 −4 core/src/main/java/org/jruby/RubyBasicObject.java
  5. +4 −4 core/src/main/java/org/jruby/RubyClassPathVariable.java
  6. +3 −3 core/src/main/java/org/jruby/RubyDir.java
  7. +1 −1 core/src/main/java/org/jruby/RubyException.java
  8. +12 −16 core/src/main/java/org/jruby/RubyFile.java
  9. +3 −3 core/src/main/java/org/jruby/RubyFileStat.java
  10. +1 −1 core/src/main/java/org/jruby/RubyHash.java
  11. +6 −4 core/src/main/java/org/jruby/RubyModule.java
  12. +33 −31 core/src/main/java/org/jruby/RubyProc.java
  13. +3 −3 core/src/main/java/org/jruby/embed/ScriptingContainer.java
  14. +10 −8 core/src/main/java/org/jruby/exceptions/RaiseException.java
  15. +6 −7 core/src/main/java/org/jruby/ext/ffi/CallbackInfo.java
  16. +2 −2 core/src/main/java/org/jruby/ext/ffi/MappedType.java
  17. +3 −3 core/src/main/java/org/jruby/ext/ffi/StructByValue.java
  18. +6 −0 core/src/main/java/org/jruby/java/proxies/JavaProxy.java
  19. +1 −1 core/src/main/java/org/jruby/javasupport/JavaSupport.java
  20. +3 −6 core/src/main/java/org/jruby/runtime/ThreadContext.java
  21. +2 −2 core/src/main/java/org/jruby/runtime/load/LoadService.java
  22. +1 −1 core/src/main/java/org/jruby/runtime/marshal/UnmarshalStream.java
  23. +1 −1 core/src/main/java/org/jruby/util/cli/ArgumentProcessor.java
  24. +12 −0 spec/java_integration/fixtures/InnerClasses.java
  25. +18 −6 spec/java_integration/types/retrieval_spec.rb
6 changes: 3 additions & 3 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;
}

@@ -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);
}
}
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/Ruby.java
Original file line number Diff line number Diff line change
@@ -543,7 +543,7 @@ public void runFromMain(InputStream inputStream, String filename) {
} else {
varvalue = getTrue();
}
getGlobalVariables().set("$" + entry.getKey().toString(), varvalue);
getGlobalVariables().set('$' + entry.getKey().toString(), varvalue);
}

if (filename.endsWith(".class")) {
8 changes: 4 additions & 4 deletions core/src/main/java/org/jruby/RubyBasicObject.java
Original file line number Diff line number Diff line change
@@ -750,7 +750,7 @@ public RubyInteger convertToInteger() {
*/
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;
}
@@ -1087,11 +1087,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;
}

8 changes: 4 additions & 4 deletions core/src/main/java/org/jruby/RubyClassPathVariable.java
Original file line number Diff line number Diff line change
@@ -51,7 +51,7 @@ public static void createClassPathVariable(Ruby runtime) {
private RubyClassPathVariable(Ruby runtime) {
super(runtime, runtime.getObject());
}

@Deprecated
public IRubyObject append(IRubyObject obj) {
return append(obj.getRuntime().getCurrentContext(), obj);
@@ -65,7 +65,7 @@ public IRubyObject append(ThreadContext context, IRubyObject obj) {
} else {
paths = context.runtime.newArray(obj).toJavaArray();
}

boolean is1_8 = context.getRuntime().is1_8();
for (IRubyObject path: paths) {
try {
@@ -79,7 +79,7 @@ public IRubyObject append(ThreadContext context, IRubyObject obj) {
} catch (MalformedURLException mue) {
throw getRuntime().newArgumentError(mue.getLocalizedMessage());
}

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

return runtime.newString(part.toString());
}
@@ -679,8 +679,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);
}

2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/RubyException.java
Original file line number Diff line number Diff line change
@@ -169,7 +169,7 @@ public IRubyObject inspect(ThreadContext context) {

if (exception.size() == 0) 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());
}

28 changes: 12 additions & 16 deletions core/src/main/java/org/jruby/RubyFile.java
Original file line number Diff line number Diff line change
@@ -509,7 +509,7 @@ public IRubyObject inspect() {
if(!openFile.isOpen()) {
val.append(" (closed)");
}
val.append(">");
val.append('>');
return getRuntime().newString(val.toString());
}

@@ -720,7 +720,7 @@ public static String dirname(ThreadContext context, String jfilename) {

if (index == -1) {
if (startsWithDriveLetterOnWindows) {
return jfilename.substring(0, 2) + ".";
return jfilename.substring(0, 2) + '.';
} else {
return ".";
}
@@ -740,7 +740,7 @@ public static String dirname(ThreadContext context, String jfilename) {
String[] splitted = jfilename.split(Pattern.quote("\\"));
int last = splitted.length-1;
if (splitted[last].contains(".")) {
index = jfilename.lastIndexOf("\\");
index = jfilename.lastIndexOf('\\');
}

}
@@ -777,7 +777,7 @@ public static IRubyObject extname(ThreadContext context, IRubyObject recv, IRuby
String filename = RubyString.stringValue(baseFilename).getUnicodeValue();
String result = "";

int dotIndex = filename.lastIndexOf(".");
int dotIndex = filename.lastIndexOf('.');
if (dotIndex > 0 && dotIndex != (filename.length() - 1)) {
// Dot is not at beginning and not at end of filename.
result = filename.substring(dotIndex);
@@ -1493,7 +1493,7 @@ public static ZipEntry getDirOrFileEntry(String jar, String path) throws IOExcep
}

public static ZipEntry getDirOrFileEntry(ZipFile zf, String path) throws IOException {
String dirPath = path + "/";
String dirPath = path + '/';
ZipEntry entry = zf.getEntry(dirPath); // first try as directory
if (entry == null) {
if (dirPath.length() == 1) {
@@ -1568,7 +1568,7 @@ static String adjustRootPathOnWindows(Ruby runtime, String path, String dir) {
}
} else if (startsWithDriveLetterOnWindows(path) && path.length() == 2) {
// compensate for missing slash after drive letter on windows
path += "/";
path += '/';
}

return path;
@@ -1899,14 +1899,10 @@ public static String canonicalize(String path) {

private static String canonicalize(String canonicalPath, String remaining) {
if (remaining == null) {
if ("".equals(canonicalPath)) {
return "/";
} else {
// compensate for missing slash after drive letter on windows
if (startsWithDriveLetterOnWindows(canonicalPath)
&& canonicalPath.length() == 2) {
canonicalPath += "/";
}
if ("".equals(canonicalPath)) return "/";
// compensate for missing slash after drive letter on windows
if (startsWithDriveLetterOnWindows(canonicalPath) && canonicalPath.length() == 2) {
canonicalPath += '/';
}
return canonicalPath;
}
@@ -1925,7 +1921,7 @@ private static String canonicalize(String canonicalPath, String remaining) {
// no canonical path yet or length is zero, and we have a / followed by a dot...
if (slash == -1) {
// we don't have another slash after this, so replace /. with /
if (canonicalPath != null && canonicalPath.length() == 0 && slash == -1) canonicalPath += "/";
if (canonicalPath != null && canonicalPath.length() == 0 && slash == -1) canonicalPath += '/';
} else {
// we do have another slash; omit both / and . (JRUBY-1606)
}
@@ -1944,7 +1940,7 @@ private static String canonicalize(String canonicalPath, String remaining) {
} else if (canonicalPath == null) {
canonicalPath = child;
} else {
canonicalPath += "/" + child;
canonicalPath += '/' + child;
}

return canonicalize(canonicalPath, remaining);
6 changes: 3 additions & 3 deletions core/src/main/java/org/jruby/RubyFileStat.java
Original file line number Diff line number Diff line change
@@ -116,7 +116,7 @@ private void setup(String filename, boolean lstat) {

if (Platform.IS_WINDOWS && filename.length() == 2
&& filename.charAt(1) == ':' && Character.isLetter(filename.charAt(0))) {
filename += "/";
filename += '/';
}

file = JRubyFile.createResource(runtime.getPosix(), runtime.getCurrentDirectory(), filename);
@@ -280,7 +280,7 @@ public IRubyObject inspect() {
if (stat == null) {
buf.append(": uninitialized");
} else {
buf.append(" ");
buf.append(' ');
// FIXME: Obvious issue that not all platforms can display all attributes. Ugly hacks.
// Using generic posix library makes pushing inspect behavior into specific system impls
// rather painful.
@@ -299,7 +299,7 @@ public IRubyObject inspect() {
buf.append("mtime=").append(mtime()).append(", ");
buf.append("ctime=").append(ctime());
}
buf.append(">");
buf.append('>');

return getRuntime().newString(buf.toString());
}
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/RubyHash.java
Original file line number Diff line number Diff line change
@@ -2073,7 +2073,7 @@ public void clear() {
public boolean equals(Object other) {
if (!(other instanceof RubyHash)) return false;
if (this == other) return true;
return op_equal(getRuntime().getCurrentContext(), (RubyHash)other).isTrue() ? true : false;
return op_equal(getRuntime().getCurrentContext(), (RubyHash)other).isTrue();
}

public Set keySet() {
10 changes: 6 additions & 4 deletions core/src/main/java/org/jruby/RubyModule.java
Original file line number Diff line number Diff line change
@@ -533,7 +533,8 @@ private String calculateName() {
private String calculateAnonymousName() {
if (anonymousName == null) {
// anonymous classes get the #<Class:0xdeadbeef> format
StringBuilder anonBase = new StringBuilder("#<" + metaClass.getRealClass().getName() + ":0x");
StringBuilder anonBase = new StringBuilder(24);
anonBase.append("#<").append(metaClass.getRealClass().getName()).append(":0x");
anonBase.append(Integer.toHexString(System.identityHashCode(this))).append('>');
anonymousName = anonBase.toString();
}
@@ -938,8 +939,9 @@ public void removeMethod(ThreadContext context, String name) {

// We can safely reference methods here instead of doing getMethods() since if we
// are adding we are not using a IncludedModuleWrapper.
synchronized(getMethodsForWrite()) {
DynamicMethod method = (DynamicMethod) getMethodsForWrite().remove(name);
Map<String, DynamicMethod> methodsForWrite = getMethodsForWrite();
synchronized (methodsForWrite) {
DynamicMethod method = (DynamicMethod) methodsForWrite.remove(name);
if (method == null) {
throw runtime.newNameError("method '" + name + "' not defined in " + getName(), name);
}
@@ -3809,7 +3811,7 @@ public ConstantEntry dup() {
* 'Module#autoload' creates this object and stores it in autoloadMap.
* This object can be shared with multiple threads so take care to change volatile and synchronized definitions.
*/
private class Autoload {
private static final class Autoload {
// A ThreadContext which is executing autoload.
private volatile ThreadContext ctx;
// The lock for test-and-set the ctx.
Loading