Skip to content

Commit

Permalink
Clean up deprecations.
Browse files Browse the repository at this point in the history
This also introduces the first couple default methods in the
IRubyObject interface, to allow ignoring those methods in
implementations.
headius committed May 15, 2018
1 parent f26c752 commit 073462d
Showing 11 changed files with 51 additions and 45 deletions.
15 changes: 9 additions & 6 deletions core/src/main/java/org/jruby/Ruby.java
Original file line number Diff line number Diff line change
@@ -4268,13 +4268,16 @@ private RaiseException newLightweightErrnoException(RubyClass exceptionClass, St
*/
public RaiseException newStopIteration(IRubyObject result, String message) {
final ThreadContext context = getCurrentContext();
if (RubyInstanceConfig.STOPITERATION_BACKTRACE) {
RubyException ex = RubyStopIteration.newInstance(context, result, message);
return ex.toThrowable();
}
if ( message == null ) message = STOPIERATION_BACKTRACE_MESSAGE;

if (message == null) message = STOPIERATION_BACKTRACE_MESSAGE;

RubyException ex = RubyStopIteration.newInstance(context, result, message);
return RaiseException.from(ex, disabledBacktrace());

if (!RubyInstanceConfig.STOPITERATION_BACKTRACE) {
ex.forceBacktrace(disabledBacktrace());
}

return ex.toThrowable();
}

@Deprecated
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/RubyArray.java
Original file line number Diff line number Diff line change
@@ -4601,7 +4601,7 @@ public IRubyObject sumCommon(final ThreadContext context, IRubyObject init, fina
if (result instanceof RubyInteger) {
result = ((RubyInteger) result).op_plus(context, value);
} else if (result instanceof RubyRational) {
result = ((RubyRational) result).op_add(context, value);
result = ((RubyRational) result).op_plus(context, value);
} else {
throw runtime.newTypeError("BUG: unexpected type in rational part of Array#sum");
}
15 changes: 7 additions & 8 deletions core/src/main/java/org/jruby/RubyBasicObject.java
Original file line number Diff line number Diff line change
@@ -1111,14 +1111,6 @@ public synchronized Object dataGetStruct() {
return getInternalVariable("__wrap_struct__");
}

// Equivalent of Data_Get_Struct
// This will first check that the object in question is actually a T_DATA equivalent.
@Override
public synchronized Object dataGetStructChecked() {
TypeConverter.checkData(this);
return getInternalVariable("__wrap_struct__");
}

/** rb_obj_id
*
* Return the internal id of an object.
@@ -3243,6 +3235,13 @@ public final Object getNativeHandle() {
public final void setNativeHandle(Object value) {
}

@Override
@Deprecated
public synchronized Object dataGetStructChecked() {
TypeConverter.checkData(this);
return getInternalVariable("__wrap_struct__");
}

@Deprecated
public static final int FL_USHIFT = 4;
@Deprecated
4 changes: 3 additions & 1 deletion core/src/main/java/org/jruby/RubyKernel.java
Original file line number Diff line number Diff line change
@@ -882,7 +882,9 @@ public static IRubyObject raise(ThreadContext context, IRubyObject recv, IRubyOb
raise = convertToException(runtime, args[0], args[1]).toThrowable();
break;
default:
raise = RaiseException.from(convertToException(runtime, args[0], args[1]), args[2]);
RubyException exception = convertToException(runtime, args[0], args[1]);
exception.forceBacktrace(args[2]);
raise = exception.toThrowable();
break;
}

1 change: 1 addition & 0 deletions core/src/main/java/org/jruby/anno/AnnotationBinder.java
Original file line number Diff line number Diff line change
@@ -125,6 +125,7 @@ public void processType(TypeElement cd) {
out.println("import javax.annotation.Generated;");
out.println("");
out.println("@Generated(\"org.jruby.anno.AnnotationBinder\")");
out.println("@SuppressWarnings(\"deprecation\")");
out.println("public class " + qualifiedName + POPULATOR_SUFFIX + " extends TypePopulator {");
out.println(" public void populate(RubyModule cls, Class clazz) {");
if (DEBUG) {
Original file line number Diff line number Diff line change
@@ -144,11 +144,6 @@ public T visitClassVarAsgnNode(ClassVarAsgnNode node) {
return defaultVisit(node);
}

@Override
public T visitClassVarDeclNode(ClassVarDeclNode node) {
return defaultVisit(node);
}

@Override
public T visitClassVarNode(ClassVarNode node) {
return defaultVisit(node);
@@ -594,4 +589,10 @@ public T visitOther(Node node) {
return defaultVisit(node);
}

@Override
@Deprecated
public T visitClassVarDeclNode(ClassVarDeclNode node) {
return defaultVisit(node);
}

}
4 changes: 3 additions & 1 deletion core/src/main/java/org/jruby/ast/visitor/NodeVisitor.java
Original file line number Diff line number Diff line change
@@ -59,7 +59,6 @@ public interface NodeVisitor<T> {
T visitBreakNode(BreakNode iVisited);
T visitConstDeclNode(ConstDeclNode iVisited);
T visitClassVarAsgnNode(ClassVarAsgnNode iVisited);
T visitClassVarDeclNode(ClassVarDeclNode iVisited);
T visitClassVarNode(ClassVarNode iVisited);
T visitCallNode(CallNode iVisited);
T visitCaseNode(CaseNode iVisited);
@@ -149,4 +148,7 @@ public interface NodeVisitor<T> {
T visitZArrayNode(ZArrayNode iVisited);
T visitZSuperNode(ZSuperNode iVisited);
T visitOther(Node iVisited);

@Deprecated
default T visitClassVarDeclNode(ClassVarDeclNode iVisited) { return null; }
}
Original file line number Diff line number Diff line change
@@ -58,7 +58,7 @@ public static BuildCompoundArrayInstr decode(IRReaderDecoder d) {
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
IRubyObject v1 = (IRubyObject)getAppendingArg().retrieve(context, self, currScope, currDynScope, temp);
IRubyObject v2 = (IRubyObject)getAppendedArg().retrieve(context, self, currScope, currDynScope, temp);
return isArgsPush ? Helpers.argsPush(context, (RubyArray) v1, v2) : Helpers.argsCat(context, v1, v2);
return isArgsPush ? Helpers.argsPush(v1, v2) : Helpers.argsCat(context, v1, v2);
}

@Override
10 changes: 3 additions & 7 deletions core/src/main/java/org/jruby/ir/operands/UndefinedValue.java
Original file line number Diff line number Diff line change
@@ -247,12 +247,6 @@ private RuntimeException undefinedOperation() {
*/
public IRubyObject checkStringType() { throw undefinedOperation(); }

/**
*
* @return
*/
public IRubyObject checkStringType19() { throw undefinedOperation(); }

/**
*
* @return
@@ -314,7 +308,6 @@ private RuntimeException undefinedOperation() {
* @return the object wrapped.
*/
public Object dataGetStruct() { throw undefinedOperation(); }
public Object dataGetStructChecked() { throw undefinedOperation(); }

/**
*
@@ -407,4 +400,7 @@ public String toString() {
public void visit(IRVisitor visitor) {
visitor.UndefinedValue(this);
}

@Deprecated
public Object dataGetStructChecked() { throw undefinedOperation(); }
}
30 changes: 17 additions & 13 deletions core/src/main/java/org/jruby/runtime/builtin/IRubyObject.java
Original file line number Diff line number Diff line change
@@ -227,14 +227,6 @@ public interface IRubyObject {
*/
RubyInteger convertToInteger();

/**
* @param convertMethod
* @param convertMethodIndex
* @see #convertToInteger(String)
*/
@Deprecated
RubyInteger convertToInteger(int convertMethodIndex, String convertMethod);

/**
* Converts this Ruby object to an Integer.
* @param convertMethod method to use e.g. to_i
@@ -259,11 +251,6 @@ public interface IRubyObject {
* @return nil if type check failed
*/
IRubyObject checkStringType();

/**
* @deprecated Use {@link #checkStringType()} instead.
*/
IRubyObject checkStringType19();

/**
*
@@ -409,4 +396,21 @@ public interface IRubyObject {

public Object getVariable(int index);
public void setVariable(int index, Object value);

/**
* @deprecated Use {@link #checkStringType()} instead.
*/
default IRubyObject checkStringType19() {
return checkStringType();
}

/**
* @param convertMethod
* @param convertMethodIndex
* @see #convertToInteger(String)
*/
@Deprecated
default RubyInteger convertToInteger(int convertMethodIndex, String convertMethod) {
return convertToInteger(convertMethod);
}
}
2 changes: 0 additions & 2 deletions core/src/main/java/org/jruby/util/io/PosixShim.java
Original file line number Diff line number Diff line change
@@ -437,8 +437,6 @@ public Channel open(String cwd, String path, ModeFlags flags, int perm) {
errno = Errno.ELOOP;
} catch (ResourceException resourceException) {
throw resourceException.newRaiseException(runtime);
} catch (IOException e) {
errno = Helpers.errnoFromException(e);
}
return null;
}

0 comments on commit 073462d

Please sign in to comment.