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.
  • Loading branch information
headius committed May 15, 2018
1 parent f26c752 commit 073462d
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 45 deletions.
15 changes: 9 additions & 6 deletions core/src/main/java/org/jruby/Ruby.java
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/RubyArray.java
Expand Up @@ -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");
}
Expand Down
15 changes: 7 additions & 8 deletions core/src/main/java/org/jruby/RubyBasicObject.java
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion core/src/main/java/org/jruby/RubyKernel.java
Expand Up @@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions core/src/main/java/org/jruby/anno/AnnotationBinder.java
Expand Up @@ -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) {
Expand Down
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Up @@ -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);
Expand Down Expand Up @@ -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; }
}
Expand Up @@ -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
Expand Down
10 changes: 3 additions & 7 deletions core/src/main/java/org/jruby/ir/operands/UndefinedValue.java
Expand Up @@ -247,12 +247,6 @@ private RuntimeException undefinedOperation() {
*/
public IRubyObject checkStringType() { throw undefinedOperation(); }

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

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

/**
*
Expand Down Expand Up @@ -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
Expand Up @@ -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
Expand All @@ -259,11 +251,6 @@ public interface IRubyObject {
* @return nil if type check failed
*/
IRubyObject checkStringType();

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

/**
*
Expand Down Expand Up @@ -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
Expand Up @@ -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;
}
Expand Down

0 comments on commit 073462d

Please sign in to comment.