Skip to content

Commit 648d661

Browse files
committed
Deprecate all public RubyString constructors
We would like to make RubyString abstract, so it can be represented more efficiently when containing a single character or a Java String. In order to do so, we need users to stop using the public constructors. This patch deprecates all of the constructors for removal. They will not prevent compilation, but they should show up a bit more boldly and most Java editing tools will highlight them as errors. See jruby#9369 for the attempt to abstract RubyString. This effort will be put on hold for now due to the many exposed constructors. See jruby/jruby-openssl#355 for an example of an external library that was using these constructors directly.
1 parent 49dda12 commit 648d661

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,14 +419,17 @@ public void verifyAsciiCompatible() {
419419
if (!getEncoding().isAsciiCompatible()) throw getRuntime().newEncodingCompatibilityError("ASCII incompatible encoding: " + getEncoding());
420420
}
421421

422+
@Deprecated(since = "10.1.0.0", forRemoval = true)
422423
public RubyString(Ruby runtime, RubyClass rubyClass) {
423424
this(runtime, rubyClass, ByteList.NULL_ARRAY);
424425
}
425426

427+
@Deprecated(since = "10.1.0.0", forRemoval = true)
426428
public RubyString(Ruby runtime, RubyClass rubyClass, CharSequence value) {
427429
this(runtime, rubyClass, value, UTF8);
428430
}
429431

432+
@Deprecated(since = "10.1.0.0", forRemoval = true)
430433
public RubyString(Ruby runtime, RubyClass rubyClass, CharSequence value, Encoding enc) {
431434
super(runtime, rubyClass);
432435
assert value != null;
@@ -451,40 +454,47 @@ private RubyString(Ruby runtime, RubyClass rubyClass, String value, Encoding enc
451454
this.value = encodeBytelist(value, enc);
452455
}
453456

457+
@Deprecated(since = "10.1.0.0", forRemoval = true)
454458
public RubyString(Ruby runtime, RubyClass rubyClass, byte[] value) {
455459
super(runtime, rubyClass);
456460
assert value != null;
457461
this.value = new ByteList(value);
458462
}
459463

464+
@Deprecated(since = "10.1.0.0", forRemoval = true)
460465
public RubyString(Ruby runtime, RubyClass rubyClass, ByteList value) {
461466
super(runtime, rubyClass);
462467
assert value != null;
463468
this.value = value;
464469
}
465470

471+
@Deprecated(since = "10.1.0.0", forRemoval = true)
466472
public RubyString(Ruby runtime, RubyClass rubyClass, ByteList value, boolean objectSpace) {
467473
super(runtime, rubyClass, objectSpace);
468474
assert value != null;
469475
this.value = value;
470476
}
471477

478+
@Deprecated(since = "10.1.0.0", forRemoval = true)
472479
public RubyString(Ruby runtime, RubyClass rubyClass, ByteList value, Encoding encoding, boolean objectSpace) {
473480
this(runtime, rubyClass, value, objectSpace);
474481
value.setEncoding(encoding);
475482
}
476483

484+
@Deprecated(since = "10.1.0.0", forRemoval = true)
477485
protected RubyString(Ruby runtime, RubyClass rubyClass, ByteList value, Encoding enc, int cr) {
478486
this(runtime, rubyClass, value);
479487
flags |= cr;
480488
value.setEncoding(enc);
481489
}
482490

491+
@Deprecated(since = "10.1.0.0", forRemoval = true)
483492
protected RubyString(Ruby runtime, RubyClass rubyClass, ByteList value, Encoding enc) {
484493
this(runtime, rubyClass, value);
485494
value.setEncoding(enc);
486495
}
487496

497+
@Deprecated(since = "10.1.0.0", forRemoval = true)
488498
protected RubyString(Ruby runtime, RubyClass rubyClass, ByteList value, int cr) {
489499
this(runtime, rubyClass, value);
490500
flags |= cr;

0 commit comments

Comments
 (0)