Skip to content

Commit 7d2617f

Browse files
committed
Update some warnings to deprecated
This also marks syscall as not implemented (warns of pending deletion in CRuby) and modifies all RubyWarnings.warning* forms to no-op on verbose, as they used to (unsure when this changed).
1 parent d56f620 commit 7d2617f

File tree

7 files changed

+32
-11
lines changed

7 files changed

+32
-11
lines changed

core/src/main/java/org/jruby/RubyArray.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2210,7 +2210,7 @@ private IRubyObject getDefaultSeparator(Ruby runtime) {
22102210
IRubyObject sep;
22112211
sep = runtime.getGlobalVariables().get("$,");
22122212
if (!sep.isNil()) {
2213-
runtime.getWarnings().warn("$, is set to non-nil value");
2213+
runtime.getWarnings().warningDeprecated("$, is set to non-nil value");
22142214
}
22152215
return sep;
22162216
}

core/src/main/java/org/jruby/RubyGlobal.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -829,13 +829,13 @@ public NonEffectiveGlobalVariable(Ruby runtime, String name, IRubyObject value)
829829

830830
@Override
831831
public IRubyObject set(IRubyObject value) {
832-
runtime.getWarnings().warn(ID.INEFFECTIVE_GLOBAL, "warning: variable " + name + " is no longer effective; ignored");
832+
runtime.getWarnings().warnDeprecated(ID.INEFFECTIVE_GLOBAL, "warning: variable " + name + " is no longer effective; ignored");
833833
return value;
834834
}
835835

836836
@Override
837837
public IRubyObject get() {
838-
runtime.getWarnings().warn(ID.INEFFECTIVE_GLOBAL, "warning: variable " + name + " is no longer effective");
838+
runtime.getWarnings().warnDeprecated(ID.INEFFECTIVE_GLOBAL, "warning: variable " + name + " is no longer effective");
839839
return value;
840840
}
841841
}

core/src/main/java/org/jruby/RubyIO.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1819,15 +1819,18 @@ public static IRubyObject print(ThreadContext context, IRubyObject out, IRubyObj
18191819
int i;
18201820
IRubyObject line;
18211821
int argc = args.length;
1822+
IRubyObject outputFS = runtime.getGlobalVariables().get("$,");
18221823

18231824
/* if no argument given, print `$_' */
18241825
if (argc == 0) {
18251826
argc = 1;
18261827
line = context.getLastLine();
18271828
args = new IRubyObject[]{line};
18281829
}
1830+
if (argc > 1 && !outputFS.isNil()) {
1831+
runtime.getWarnings().warnDeprecated("$, is set to non-nil value");
1832+
}
18291833
for (i=0; i<argc; i++) {
1830-
IRubyObject outputFS = runtime.getGlobalVariables().get("$,");
18311834
if (!outputFS.isNil() && i>0) {
18321835
write(context, out, outputFS);
18331836
}
@@ -2403,7 +2406,7 @@ public IRubyObject close_on_exec_set(ThreadContext context, IRubyObject arg) {
24032406

24042407
if (fptr == null || (fd = fptr.fd().realFileno) == -1
24052408
|| !posix.isNative() || Platform.IS_WINDOWS ) {
2406-
runtime.getWarnings().warning("close_on_exec is not implemented on this platform for this stream type: " + fptr.fd().ch.getClass().getSimpleName());
2409+
runtime.getWarnings().warningDeprecated("close_on_exec is not implemented on this platform for this stream type: " + fptr.fd().ch.getClass().getSimpleName());
24072410
return context.nil;
24082411
}
24092412

@@ -2858,7 +2861,7 @@ private static void warnWrite(final Ruby runtime, IRubyObject maybeIO) {
28582861
} else {
28592862
sep = '#';
28602863
}
2861-
runtime.getWarnings().warning(klass.toString() + sep + "write is outdated interface which accepts just one argument");
2864+
runtime.getWarnings().warningDeprecated(klass.toString() + sep + "write is outdated interface which accepts just one argument");
28622865
}
28632866

28642867
@JRubyMethod

core/src/main/java/org/jruby/RubyKernel.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1933,7 +1933,7 @@ public static RubyFixnum spawn(ThreadContext context, IRubyObject recv, IRubyObj
19331933
return RubyProcess.spawn(context, recv, args);
19341934
}
19351935

1936-
@JRubyMethod(required = 1, optional = 9, checkArity = false, module = true, visibility = PRIVATE)
1936+
@JRubyMethod(required = 1, optional = 9, checkArity = false, module = true, notImplemented = true, visibility = PRIVATE)
19371937
public static IRubyObject syscall(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
19381938
throw context.runtime.newNotImplementedError("Kernel#syscall is not implemented in JRuby");
19391939
}
@@ -2493,7 +2493,7 @@ public static IRubyObject nil_p(ThreadContext context, IRubyObject self) {
24932493
// Writes backref due to decendant calls ending up in Regexp#=~
24942494
@JRubyMethod(name = "=~", writes = FrameField.BACKREF)
24952495
public static IRubyObject op_match(ThreadContext context, IRubyObject self, IRubyObject arg) {
2496-
context.runtime.getWarnings().warn(ID.DEPRECATED_METHOD,
2496+
context.runtime.getWarnings().warnDeprecated(ID.DEPRECATED_METHOD,
24972497
"deprecated Object#=~ is called on " + ((RubyBasicObject) self).type() +
24982498
"; it always returns nil");
24992499
return ((RubyBasicObject) self).op_match(context, arg);

core/src/main/java/org/jruby/RubyModule.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3000,7 +3000,7 @@ public IRubyObject attr(ThreadContext context, IRubyObject[] args) {
30003000
Ruby runtime = context.runtime;
30013001

30023002
if (args.length == 2 && (args[1] == runtime.getTrue() || args[1] == runtime.getFalse())) {
3003-
runtime.getWarnings().warning(ID.OBSOLETE_ARGUMENT, "optional boolean argument is obsoleted");
3003+
runtime.getWarnings().warnDeprecated(ID.OBSOLETE_ARGUMENT, "optional boolean argument is obsoleted");
30043004
boolean writeable = args[1].isTrue();
30053005
RubySymbol sym = TypeConverter.checkID(args[0]);
30063006
addAccessor(context, sym, getCurrentVisibilityForDefineMethod(context), args[0].isTrue(), writeable);

core/src/main/java/org/jruby/RubyRegexp.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,7 @@ public IRubyObject initialize_m(IRubyObject arg0, IRubyObject arg1, IRubyObject
934934
newOptions.setEncodingNone(true);
935935
return regexpInitialize(arg0.convertToString().getByteList(), ASCIIEncoding.INSTANCE, newOptions);
936936
} else {
937-
metaClass.runtime.getWarnings().warn("encoding option is ignored - " + kcodeBytes);
937+
metaClass.runtime.getWarnings().warnDeprecated("encoding option is ignored - " + kcodeBytes);
938938
}
939939
}
940940
return regexpInitializeString(arg0.convertToString(), newOptions);

core/src/main/java/org/jruby/common/RubyWarnings.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,10 @@ public void warnDeprecated(ID id, String message) {
191191
if (runtime.getWarningCategories().contains(Category.DEPRECATED)) warn(id, message);
192192
}
193193

194+
public void warnDeprecated(String message) {
195+
if (runtime.getWarningCategories().contains(Category.DEPRECATED)) warn(message);
196+
}
197+
194198
public void warnDeprecatedAlternate(String name, String alternate) {
195199
if (runtime.getWarningCategories().contains(Category.DEPRECATED)) warn(ID.DEPRECATED_METHOD, name + " is deprecated; use " + alternate + " instead");
196200
}
@@ -208,22 +212,36 @@ public void warnOnce(ID id, String message) {
208212
}
209213

210214
/**
211-
* Verbose mode warning methods, their contract is that consumer must explicitly check for runtime.isVerbose() before calling them
215+
* Verbose mode warning methods, only warn in verbose mode
212216
*/
213217
public void warning(String message) {
214218
warning(ID.MISCELLANEOUS, message);
215219
}
216220

221+
public void warningDeprecated(String message) {
222+
warningDeprecated(ID.MISCELLANEOUS, message);
223+
}
224+
217225
@Override
218226
public void warning(ID id, String message) {
227+
if (!isVerbose()) return;
228+
219229
warn(id, message);
220230
}
221231

232+
public void warningDeprecated(ID id, String message) {
233+
if (!isVerbose()) return;
234+
235+
warnDeprecated(id, message);
236+
}
237+
222238
/**
223239
* Prints a warning, only in verbose mode.
224240
*/
225241
@Override
226242
public void warning(ID id, String fileName, int lineNumber, String message) {
243+
if (!isVerbose()) return;
244+
227245
warn(id, fileName, lineNumber, message);
228246
}
229247

0 commit comments

Comments
 (0)