File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
src/main/java/org/truffleruby/core/rope Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change 9
9
*/
10
10
package org .truffleruby .core .rope ;
11
11
12
+ import java .lang .management .ManagementFactory ;
12
13
import java .util .Arrays ;
14
+ import java .util .List ;
13
15
14
16
import com .oracle .truffle .api .profiles .ConditionProfile ;
15
17
import org .jcodings .Encoding ;
@@ -158,10 +160,23 @@ public byte get(int index) {
158
160
return getByteSlow (index );
159
161
}
160
162
163
+ private static boolean isJavaDebuggerAttached () {
164
+ final List <String > inputArguments = ManagementFactory .getRuntimeMXBean ().getInputArguments ();
165
+ for (String arg : inputArguments ) {
166
+ if (arg .contains ("jdwp" )) {
167
+ return true ;
168
+ }
169
+ }
170
+ return false ;
171
+ }
172
+
173
+ static final boolean JAVA_DEBUGGER = isJavaDebuggerAttached ();
174
+
161
175
/** This is designed to not have any side effects - compare to {@link #getJavaString} - but this makes it
162
176
* inefficient - for debugging only */
163
177
@ Override
164
178
public String toString () {
179
+ assert JAVA_DEBUGGER : "Rope#toString() should only be called by Java debuggers, use RubyStringLibrary or RopeOperations.decodeRope() instead" ;
165
180
return RopeOperations .decode (encoding , RopeOperations .flattenBytes (this ));
166
181
}
167
182
You can’t perform that action at this time.
0 commit comments