Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions ext/java/org/jruby/ext/stringio/StringIO.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ static class StringIOData {
volatile Object owner;
}
private StringIOData ptr;
private byte flags;

// MRI: get_strio, StringIO macro
private StringIOData getPtr() {
Expand All @@ -103,9 +104,9 @@ private StringIOData getPtr() {
private static final String
STRINGIO_VERSION = "3.1.9";

private static final int STRIO_READABLE = ObjectFlags.registry.newFlag(StringIO.class);
private static final int STRIO_WRITABLE = ObjectFlags.registry.newFlag(StringIO.class);
private static final int STRIO_READWRITE = (STRIO_READABLE | STRIO_WRITABLE);
private static final byte STRIO_READABLE = 1;
private static final byte STRIO_WRITABLE = 2;
private static final byte STRIO_READWRITE = (STRIO_READABLE | STRIO_WRITABLE);

private static final AtomicReferenceFieldUpdater<StringIOData, Object> LOCKED_UPDATER = AtomicReferenceFieldUpdater.newUpdater(StringIOData.class, Object.class, "owner");

Expand Down Expand Up @@ -412,7 +413,7 @@ public IRubyObject initialize_copy(ThreadContext context, IRubyObject other) {
if (this == otherIO) return this;

ptr = otherIO.getPtr();
flags = flags & ~STRIO_READWRITE | otherIO.flags & STRIO_READWRITE;
flags = (byte) (flags & ~STRIO_READWRITE | otherIO.flags & STRIO_READWRITE);

return this;
}
Expand Down Expand Up @@ -483,7 +484,7 @@ public IRubyObject close_read(ThreadContext context) {
}
int flags = this.flags;
if ( ( flags & STRIO_READABLE ) != 0 ) {
this.flags = flags & ~STRIO_READABLE;
this.flags = (byte) (flags & ~STRIO_READABLE);
}
return context.nil;
}
Expand All @@ -503,7 +504,7 @@ public IRubyObject close_write(ThreadContext context) {
}
int flags = this.flags;
if ( ( flags & STRIO_WRITABLE ) != 0 ) {
this.flags = flags & ~STRIO_WRITABLE;
this.flags = (byte) (flags & ~STRIO_WRITABLE);
}
return context.nil;
}
Expand Down
Loading