Skip to content

Commit dcdf917

Browse files
committed
Make all RubyString and ImmutableRubyString messages protected
* So they are not called directly, but the library is used instead.
1 parent a1053e5 commit dcdf917

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

src/main/java/org/truffleruby/core/string/RubyString.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public String toString() {
4949

5050
// region RubyStringLibrary messages
5151
@ExportMessage
52-
public boolean isRubyString() {
52+
protected boolean isRubyString() {
5353
return true;
5454
}
5555

@@ -59,31 +59,31 @@ protected Rope getRope() {
5959
}
6060

6161
@ExportMessage
62-
public String getJavaString() {
62+
protected String getJavaString() {
6363
return RopeOperations.decodeRope(rope);
6464
}
6565
// endregion
6666

6767
// region RubyLibrary messages
6868
@ExportMessage
69-
public void freeze() {
69+
protected void freeze() {
7070
frozen = true;
7171
}
7272

7373
@ExportMessage
74-
public boolean isFrozen() {
74+
protected boolean isFrozen() {
7575
return frozen;
7676
}
7777
// endregion
7878

7979
// region String messages
8080
@ExportMessage
81-
public boolean isString() {
81+
protected boolean isString() {
8282
return true;
8383
}
8484

8585
@ExportMessage
86-
public String asString(
86+
protected String asString(
8787
@Cached ToJavaStringNode toJavaStringNode) {
8888
return toJavaStringNode.executeToJavaString(this);
8989
}

src/main/java/org/truffleruby/language/ImmutableRubyString.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public String toString() {
4545

4646
// region RubyStringLibrary messages
4747
@ExportMessage
48-
public boolean isRubyString() {
48+
protected boolean isRubyString() {
4949
return true;
5050
}
5151

@@ -55,14 +55,14 @@ protected Rope getRope() {
5555
}
5656

5757
@ExportMessage
58-
public String getJavaString() {
58+
protected String getJavaString() {
5959
return RopeOperations.decodeRope(rope);
6060
}
6161
// endregion
6262

6363
// region InteropLibrary messages
6464
@ExportMessage
65-
public Object toDisplayString(boolean allowSideEffects,
65+
protected Object toDisplayString(boolean allowSideEffects,
6666
@Cached DispatchNode dispatchNode,
6767
@Cached KernelNodes.ToSNode kernelToSNode) {
6868
if (allowSideEffects) {
@@ -73,25 +73,25 @@ public Object toDisplayString(boolean allowSideEffects,
7373
}
7474

7575
@ExportMessage
76-
public boolean hasMetaObject() {
76+
protected boolean hasMetaObject() {
7777
return true;
7878
}
7979

8080
@ExportMessage
81-
public RubyClass getMetaObject(
81+
protected RubyClass getMetaObject(
8282
@CachedContext(RubyLanguage.class) RubyContext context) {
8383
return context.getCoreLibrary().stringClass;
8484
}
8585
// endregion
8686

8787
// region String messages
8888
@ExportMessage
89-
public boolean isString() {
89+
protected boolean isString() {
9090
return true;
9191
}
9292

9393
@ExportMessage
94-
public String asString(
94+
protected String asString(
9595
@Cached ToJavaStringNode toJavaStringNode) {
9696
return toJavaStringNode.executeToJavaString(this);
9797
}

0 commit comments

Comments
 (0)