Skip to content

Commit

Permalink
Merge branch 'ruby-2.3' into ruby-2.3+socket
Browse files Browse the repository at this point in the history
headius committed Jan 3, 2016
2 parents 78c8657 + dd5fe2f commit 5064892
Showing 116 changed files with 5,148 additions and 749 deletions.
2 changes: 0 additions & 2 deletions core/pom.rb
Original file line number Diff line number Diff line change
@@ -73,8 +73,6 @@
jar 'org.jruby:joda-timezones:${tzdata.version}', :scope => '${tzdata.scope}'
jar 'joda-time:joda-time:${joda.time.version}'

jar 'com.boundary:high-scale-lib:1.0.6'

plugin_management do
plugin( 'org.eclipse.m2e:lifecycle-mapping:1.0.0',
'lifecycleMappingMetadata' => {
5 changes: 0 additions & 5 deletions core/pom.xml
Original file line number Diff line number Diff line change
@@ -263,11 +263,6 @@ DO NOT MODIFIY - GENERATED CODE
<artifactId>joda-time</artifactId>
<version>${joda.time.version}</version>
</dependency>
<dependency>
<groupId>com.boundary</groupId>
<artifactId>high-scale-lib</artifactId>
<version>1.0.6</version>
</dependency>
</dependencies>
<build>
<defaultGoal>package</defaultGoal>
36 changes: 19 additions & 17 deletions core/src/main/java/org/jruby/RubyException.java
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@
* Copyright (C) 2004 Stefan Matthias Aust <sma@3plus4.de>
* Copyright (C) 2005 David Corbin <dcorbin@users.sf.net>
* Copyright (C) 2006 Michael Studman <codehaus@michaelstudman.com>
*
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
@@ -68,7 +68,7 @@ protected RubyException(Ruby runtime, RubyClass rubyClass) {

public RubyException(Ruby runtime, RubyClass rubyClass, String message) {
super(runtime, rubyClass);

this.message = message == null ? runtime.getNil() : runtime.newString(message);
}

@@ -83,12 +83,16 @@ public IRubyObject initialize(IRubyObject[] args, Block block) {

@JRubyMethod
public IRubyObject backtrace() {
IRubyObject bt = getBacktrace();
return bt;
return getBacktrace();
}

@JRubyMethod(required = 1)
public IRubyObject set_backtrace(IRubyObject obj) {
setBacktrace(obj);
return backtrace();
}

private void setBacktrace(IRubyObject obj) {
if (obj.isNil()) {
backtrace = null;
} else if (isArrayOfStrings(obj)) {
@@ -98,15 +102,13 @@ public IRubyObject set_backtrace(IRubyObject obj) {
} else {
throw getRuntime().newTypeError("backtrace must be Array of String or a single String");
}

return backtrace();
}

@JRubyMethod(omit = true)
public IRubyObject backtrace_locations(ThreadContext context) {
Ruby runtime = context.runtime;
RubyStackTraceElement[] elements = backtraceData.getBacktrace(runtime);

return RubyThread.Location.newLocationArray(runtime, elements);
}

@@ -239,17 +241,17 @@ public void prepareIntegratedBacktrace(ThreadContext context, StackTraceElement[
}

public void forceBacktrace(IRubyObject backtrace) {
backtraceData = BacktraceData.EMPTY;
set_backtrace(backtrace);
backtraceData = (backtrace != null && backtrace.isNil()) ? null : BacktraceData.EMPTY;
setBacktrace(backtrace);
}

public IRubyObject getBacktrace() {
if (backtrace == null) {
initBacktrace();
}
return backtrace;
}

public void initBacktrace() {
Ruby runtime = getRuntime();
if (backtraceData == null) {
@@ -300,16 +302,16 @@ public void printBacktrace(PrintStream errorStream, int skip) {
private void printStackTraceLine(PrintStream errorStream, IRubyObject stackTraceLine) {
errorStream.print("\tfrom " + stackTraceLine + '\n');
}

private boolean isArrayOfStrings(IRubyObject backtrace) {
if (!(backtrace instanceof RubyArray)) return false;
if (!(backtrace instanceof RubyArray)) return false;

IRubyObject[] elements = ((RubyArray) backtrace).toJavaArray();

for (int i = 0 ; i < elements.length ; i++) {
if (!(elements[i] instanceof RubyString)) return false;
}

return true;
}

51 changes: 27 additions & 24 deletions core/src/main/java/org/jruby/RubyModule.java
Original file line number Diff line number Diff line change
@@ -38,6 +38,24 @@
package org.jruby;

import org.jcodings.Encoding;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.security.AccessControlException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;

import org.jruby.anno.AnnotationBinder;
import org.jruby.anno.AnnotationHelper;
import org.jruby.anno.JRubyClass;
@@ -97,24 +115,8 @@
import org.jruby.util.log.Logger;
import org.jruby.util.log.LoggerFactory;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.security.AccessControlException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;

import static org.jruby.anno.FrameField.*;
import static org.jruby.anno.FrameField.VISIBILITY;
import static org.jruby.runtime.Visibility.*;


@@ -3119,10 +3121,6 @@ public IRubyObject const_get_2_0(ThreadContext context, IRubyObject[] args) {
@JRubyMethod(name = "const_set", required = 2)
public IRubyObject const_set(IRubyObject symbol, IRubyObject value) {
IRubyObject constant = setConstant(validateConstant(symbol).intern(), value);

if (constant instanceof RubyModule) {
((RubyModule)constant).calculateName();
}
return constant;
}

@@ -3635,27 +3633,32 @@ private IRubyObject setConstantCommon(String name, IRubyObject value, boolean hi
if (warn) {
getRuntime().getWarnings().warn(ID.CONSTANT_ALREADY_INITIALIZED, "already initialized constant " + name);
}
setParentForModule(name, value);
// might just call storeConstant(name, value, hidden) but to maintain
// backwards compatibility with calling #storeConstant overrides
if (hidden) storeConstant(name, value, true);
else storeConstant(name, value);
}
} else {
setParentForModule(name, value);
if (hidden) storeConstant(name, value, true);
else storeConstant(name, value);
}

invalidateConstantCache(name);
return value;
}

private void setParentForModule(final String name, final IRubyObject value) {
// if adding a module under a constant name, set that module's basename to the constant name
if (value instanceof RubyModule) {
RubyModule module = (RubyModule)value;
if ( value instanceof RubyModule ) {
RubyModule module = (RubyModule) value;
if (module != this && module.getBaseName() == null) {
module.setBaseName(name);
module.setParent(this);
}
module.calculateName();
}
return value;
}

@Deprecated
8 changes: 4 additions & 4 deletions core/src/main/java/org/jruby/RubyObjectSpace.java
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@
* Copyright (C) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se>
* Copyright (C) 2004 Thomas E Enebo <enebo@acm.org>
* Copyright (C) 2004 Stefan Matthias Aust <sma@3plus4.de>
*
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
@@ -51,12 +51,12 @@
public class RubyObjectSpace {

/** Create the ObjectSpace module and add it to the Ruby runtime.
*
*
*/
public static RubyModule createObjectSpaceModule(Ruby runtime) {
RubyModule objectSpaceModule = runtime.defineModule("ObjectSpace");
runtime.setObjectSpaceModule(objectSpaceModule);

objectSpaceModule.defineAnnotatedMethods(RubyObjectSpace.class);

WeakMap.createWeakMap(runtime);
@@ -118,7 +118,7 @@ public static IRubyObject id2ref(IRubyObject recv, IRubyObject id) {
}
}
}

public static IRubyObject each_objectInternal(final ThreadContext context, IRubyObject recv, IRubyObject[] args, final Block block) {
RubyModule tmpClass;
if (args.length == 0) {
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/ast/StarNode.java
Original file line number Diff line number Diff line change
@@ -55,7 +55,7 @@ public NodeType getNodeType() {
* @see Node#accept(NodeVisitor)
*/
public Object accept(NodeVisitor visitor) {
return null; // never visited, should be fine
return visitor.visitStarNode(this);
}

public List<Node> childNodes() {
Original file line number Diff line number Diff line change
@@ -503,6 +503,11 @@ public T visitSplatNode(SplatNode node) {
return defaultVisit(node);
}

@Override
public T visitStarNode(StarNode node) {
return defaultVisit(node);
}

@Override
public T visitStrNode(StrNode node) {
return defaultVisit(node);
1 change: 1 addition & 0 deletions core/src/main/java/org/jruby/ast/visitor/NodeVisitor.java
Original file line number Diff line number Diff line change
@@ -130,6 +130,7 @@ public interface NodeVisitor<T> {
public T visitSClassNode(SClassNode iVisited);
public T visitSelfNode(SelfNode iVisited);
public T visitSplatNode(SplatNode iVisited);
public T visitStarNode(StarNode iVisited);
public T visitStrNode(StrNode iVisited);
public T visitSuperNode(SuperNode iVisited);
public T visitSValueNode(SValueNode iVisited);
13 changes: 7 additions & 6 deletions core/src/main/java/org/jruby/exceptions/RaiseException.java
Original file line number Diff line number Diff line change
@@ -131,13 +131,13 @@ public RaiseException(Ruby runtime, RubyClass excptnClass, String msg, IRubyObje
preRaise(context, backtrace);
}

public RaiseException(RubyException exception, boolean isNativeException) {
public RaiseException(RubyException exception, boolean nativeException) {
super(exception.message.toString());
if (DEBUG) {
Thread.dumpStack();
}
this.nativeException = isNativeException;
setException(exception, isNativeException);
this.nativeException = nativeException;
setException(exception, nativeException);
preRaise(exception.getRuntime().getCurrentContext());
}

@@ -201,7 +201,7 @@ private void preRaise(ThreadContext context, StackTraceElement[] javaTrace) {
doSetLastError(context);
doCallEventHook(context);

if (RubyInstanceConfig.LOG_EXCEPTIONS) TraceType.dumpException(exception);
if (RubyInstanceConfig.LOG_EXCEPTIONS) TraceType.logException(exception);

if (requiresBacktrace(context)) {
exception.prepareIntegratedBacktrace(context, javaTrace);
@@ -213,22 +213,23 @@ private boolean requiresBacktrace(ThreadContext context) {
// We can only omit backtraces of descendents of Standard error for 'foo rescue nil'
return context.exceptionRequiresBacktrace ||
(debugMode != null && debugMode.isTrue()) ||
!exception.kind_of_p(context, context.runtime.getStandardError()).isTrue();
! context.runtime.getStandardError().isInstance(exception);
}

private void preRaise(ThreadContext context, IRubyObject backtrace) {
context.runtime.incrementExceptionCount();
doSetLastError(context);
doCallEventHook(context);

if (RubyInstanceConfig.LOG_EXCEPTIONS) TraceType.dumpException(exception);
if (RubyInstanceConfig.LOG_EXCEPTIONS) TraceType.logException(exception);

// We can only omit backtraces of descendents of Standard error for 'foo rescue nil'
if (requiresBacktrace(context)) {
if (backtrace == null) {
exception.prepareBacktrace(context, nativeException);
} else {
exception.forceBacktrace(backtrace);
if ( backtrace.isNil() ) return;
}

// call Throwable.setStackTrace so that when RaiseException appears nested inside another exception,
Loading

0 comments on commit 5064892

Please sign in to comment.