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: 0a4be2d255e8
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: a07697364174
Choose a head ref
  • 3 commits
  • 5 files changed
  • 1 contributor

Commits on Dec 20, 2017

  1. Copy the full SHA
    477b2eb View commit details

Commits on Dec 21, 2017

  1. Copy the full SHA
    6a3bff9 View commit details
  2. Copy the full SHA
    a076973 View commit details
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -12,9 +12,8 @@ before_install:
- unset _JAVA_OPTIONS
- rm ~/.m2/settings.xml
- export MAVEN_SKIP_RC=true
- mvn -Xmx32M -v | grep 1.7.0; if [ $? = 0 ]; then export MAVEN_OPTS="-XX:MaxPermSize=160M"; else export MAVEN_OPTS="-XX:MaxMetaspaceSize=144M -XX:CompressedClassSpaceSize=96M"; fi
- export MAVEN_OPTS="-Xms64M -Xmx512M $MAVEN_OPTS"
- export JAVA_OPTS="$JAVA_OPTS"
- export MAVEN_OPTS="-Xmn64M -Xmx512M -XX:MaxMetaspaceSize=144M -XX:CompressedClassSpaceSize=96M"
- export JAVA_OPTS="$JAVA_OPTS -XX:MaxMetaspaceSize=96M -XX:CompressedClassSpaceSize=96M"

before_script:
- unset GEM_PATH GEM_HOME IRBRC JRUBY_OPTS
27 changes: 18 additions & 9 deletions core/src/main/java/org/jruby/RubyModule.java
Original file line number Diff line number Diff line change
@@ -3367,8 +3367,6 @@ 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 shortName = rubyName.asJavaString();
String longName;

if (this != runtime.getObject()) {
throw runtime.newNameError("uninitialized constant %2$s::%1$s", this, rubyName);
@@ -3378,28 +3376,39 @@ public IRubyObject const_missing(ThreadContext context, IRubyObject rubyName, Bl

}

@JRubyMethod(name = "constants")
public RubyArray constants(ThreadContext context) {
return constants19(context);
return constantsCommon(context, true, true);
}

@JRubyMethod(name = "constants")
public RubyArray constants(ThreadContext context, IRubyObject allConstants) {
return constantsCommon(context, false, allConstants.isTrue());
}

@Deprecated
public RubyArray constants19(ThreadContext context) {
return constantsCommon19(context, true, true);
return constants(context);
}

@JRubyMethod(name = "constants")
@Deprecated
public RubyArray constants19(ThreadContext context, IRubyObject allConstants) {
return constantsCommon19(context, false, allConstants.isTrue());
return constants(context, allConstants);
}

@Deprecated // no longer used
public RubyArray constantsCommon19(ThreadContext context, boolean replaceModule, boolean allConstants) {
return constantsCommon(context, replaceModule, allConstants);
}

private RubyArray constantsCommon(ThreadContext context, boolean replaceModule, boolean allConstants) {
Ruby runtime = context.runtime;
RubyArray array = runtime.newArray();

Collection<String> constantNames = constantsCommon(runtime, replaceModule, allConstants, false);
RubyArray array = runtime.newArray(constantNames.size());

for (String name : constantNames) {
array.add(runtime.newSymbol(name));
array.append(runtime.newSymbol(name));
}
return array;
}
@@ -3419,7 +3428,7 @@ public Collection<String> constantsCommon(Ruby runtime, boolean replaceModule, b
if ((replaceModule && runtime.getModule() == this) || objectClass == this) {
constantNames = objectClass.getConstantNames(includePrivate);
} else {
Set<String> names = new HashSet<String>();
Set<String> names = new HashSet<>();
for (RubyModule module = this; module != null && module != objectClass; module = module.getSuperClass()) {
names.addAll(module.getConstantNames(includePrivate));
}
27 changes: 15 additions & 12 deletions core/src/main/java/org/jruby/RubyRegexp.java
Original file line number Diff line number Diff line change
@@ -226,17 +226,21 @@ public IRubyObject allocate(Ruby runtime, RubyClass klass) {
}
};

public static int matcherSearch(Ruby runtime, Matcher matcher, int start, int range, int option) {
public static int matcherSearch(ThreadContext context, Matcher matcher, int start, int range, int option) {
try {
ThreadContext context = runtime.getCurrentContext();
RubyThread thread = context.getThread();
SearchMatchTask task = new SearchMatchTask(thread, start, range, option, false);
return thread.executeTask(context, matcher, task);
} catch (InterruptedException e) {
throw runtime.newInterruptedRegexpError("Regexp Interrupted");
throw context.runtime.newInterruptedRegexpError("Regexp Interrupted");
}
}

@Deprecated // not-used
public static int matcherSearch(Ruby runtime, Matcher matcher, int start, int range, int option) {
return matcherSearch(runtime.getCurrentContext(), matcher, start, range, option);
}

@Deprecated // not-used
public static int matcherMatch(Ruby runtime, Matcher matcher, int start, int range, int option) {
try {
@@ -1201,8 +1205,9 @@ final int search(ThreadContext context, RubyString str, int pos, boolean reverse
int result = -1;
IRubyObject match;
// Region regs = null;
ByteList strBL = str.getByteList();
int range = strBL.begin();
final ByteList strBL = str.getByteList();
final int beg = strBL.begin();
int range = beg;
boolean tmpreg;

if (pos > str.size() || pos < 0) {
@@ -1229,10 +1234,10 @@ final int search(ThreadContext context, RubyString str, int pos, boolean reverse
if (!reverse) {
range += str.size();
}
Matcher matcher = reg.matcher(strBL.unsafeBytes(), strBL.begin(), strBL.begin() + strBL.realSize());
Matcher matcher = reg.matcher(strBL.unsafeBytes(), beg, beg + strBL.realSize());
JOniException exception = null;
try {
result = matcherSearch(runtime, matcher, strBL.begin() + pos, range, RE_OPTION_NONE);
result = matcherSearch(context, matcher, beg + pos, range, RE_OPTION_NONE);
} catch (JOniException je) {
exception = je;
}
@@ -1253,15 +1258,13 @@ final int search(ThreadContext context, RubyString str, int pos, boolean reverse
if (result < 0) {
if (result == -1) {
setBackRefInternal(context, holder, context.nil);
return result;
}
else {
throw runtime.newRegexpError(exception == null ? "FIXME: missing message" : exception.getMessage());
return -1;
}
throw context.runtime.newRegexpError(exception == null ? "FIXME: missing message" : exception.getMessage());
}

final RubyMatchData matchData;
if (match.isNil()) {
if (match == context.nil) {
matchData = createMatchData(context, str, matcher, reg);
}
else {
10 changes: 5 additions & 5 deletions core/src/main/java/org/jruby/RubyString.java
Original file line number Diff line number Diff line change
@@ -2562,15 +2562,15 @@ private IRubyObject subBangNoIter(Ruby runtime, ThreadContext context, IRubyObje
int range = begin + value.getRealSize();
final Matcher matcher = prepared.matcher(value.getUnsafeBytes(), begin, range);

if (RubyRegexp.matcherSearch(runtime, matcher, begin, range, Option.NONE) >= 0) {
if (RubyRegexp.matcherSearch(context, matcher, begin, range, Option.NONE) >= 0) {
repl = RubyRegexp.regsub19(context, repl, this, matcher, pattern);
RubyMatchData match = RubyRegexp.createMatchData(context, this, matcher, pattern);
match.regexp = regexp;
context.setBackRef(match);

return subBangCommon(context, matcher.getBegin(), matcher.getEnd(), repl, repl.flags);
}
return context.setBackRef(runtime.getNil());
return context.setBackRef(context.nil);
}

private IRubyObject subBangCommon(ThreadContext context, final int beg, final int end,
@@ -2709,7 +2709,7 @@ private IRubyObject gsubCommon19(ThreadContext context, Block block, RubyString

final Matcher matcher = prepared.matcher(spBytes, spBeg, spBeg + spLen);

int beg = RubyRegexp.matcherSearch(runtime, matcher, spBeg, spBeg + spLen, Option.NONE);
int beg = RubyRegexp.matcherSearch(context, matcher, spBeg, spBeg + spLen, Option.NONE);
if (beg < 0) {
if (useBackref) context.setBackRef(context.nil);
return bang ? context.nil : strDup(runtime); /* bang: true, no match, no substitution */
@@ -2758,7 +2758,7 @@ private IRubyObject gsubCommon19(ThreadContext context, Block block, RubyString
}
cp = spBeg + offset;
if (offset > spLen) break;
beg = RubyRegexp.matcherSearch(runtime, matcher, cp, spBeg + spLen, Option.NONE);
beg = RubyRegexp.matcherSearch(context, matcher, cp, spBeg + spLen, Option.NONE);
} while (beg >= 0);

if (spLen > offset) dest.cat(spBytes, cp, spLen - offset, str_enc);
@@ -3690,7 +3690,7 @@ private RubyArray regexSplit19(ThreadContext context, RubyRegexp pattern, boolea

int ptr = value.getBegin();
int len = value.getRealSize();
byte[]bytes = value.getUnsafeBytes();
byte[] bytes = value.getUnsafeBytes();

RubyArray result = runtime.newArray();
Encoding enc = value.getEncoding();
Original file line number Diff line number Diff line change
@@ -275,7 +275,7 @@ private IRubyObject scan(ThreadContext context, IRubyObject regex, boolean succp
throw runtime.newInterruptedRegexpError("Regexp Interrupted");
}
} else {
ret = RubyRegexp.matcherSearch(runtime, matcher, value.getBegin() + pos, value.getBegin() + value.getRealSize(), Option.NONE);
ret = RubyRegexp.matcherSearch(context, matcher, value.getBegin() + pos, value.getBegin() + value.getRealSize(), Option.NONE);
}

regs = matcher.getRegion();
@@ -287,7 +287,7 @@ private IRubyObject scan(ThreadContext context, IRubyObject regex, boolean succp
end = regs.end[0];
}

if (ret < 0) return runtime.getNil();
if (ret < 0) return context.nil;
setMatched();

lastPos = pos;