Skip to content

Commit f8833d4

Browse files
committed
Test JRuby 9.4 and fix compatibility
Seems like referencing StringIO directly no longer works. ``` ext/java/org/msgpack/jruby/Unpacker.java:337: error: cannot find symbol if (stream instanceof StringIO) { ``` While I was at it I also fixed most compilation warnings.
1 parent ca6d240 commit f8833d4

6 files changed

Lines changed: 21 additions & 28 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
fail-fast: false
5151
matrix:
5252
os: [ubuntu]
53-
ruby: ['jruby-9.2.19.0', 'jruby-9.3.3.0', 'truffleruby']
53+
ruby: ['jruby-9.2', 'jruby-9.3', 'jruby-9.4', 'truffleruby']
5454
runs-on: ${{ matrix.os }}-latest
5555
steps:
5656
- uses: actions/checkout@v2

ext/java/org/msgpack/jruby/Buffer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
@JRubyClass(name="MessagePack::Buffer")
2323
public class Buffer extends RubyObject {
2424
private static final long serialVersionUID = 8441244627425629412L;
25-
private IRubyObject io;
26-
private ByteBuffer buffer;
25+
private transient IRubyObject io;
26+
private transient ByteBuffer buffer;
2727
private boolean writeMode;
28-
private Encoding binaryEncoding;
28+
private transient Encoding binaryEncoding;
2929

3030
private static final int CACHE_LINE_SIZE = 64;
3131
private static final int ARRAY_HEADER_SIZE = 24;

ext/java/org/msgpack/jruby/ExtensionValue.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
@JRubyClass(name="MessagePack::ExtensionValue")
2727
public class ExtensionValue extends RubyObject {
2828
private static final long serialVersionUID = 8451274621449322492L;
29-
private final Encoding binaryEncoding;
29+
private transient final Encoding binaryEncoding;
3030

3131
private RubyFixnum type;
3232
private RubyString payload;

ext/java/org/msgpack/jruby/Factory.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
@JRubyClass(name="MessagePack::Factory")
2727
public class Factory extends RubyObject {
2828
private static final long serialVersionUID = 8441284623445322492L;
29-
private final Ruby runtime;
30-
private ExtensionRegistry extensionRegistry;
29+
private transient final Ruby runtime;
30+
private transient ExtensionRegistry extensionRegistry;
3131
private boolean hasSymbolExtType;
3232
private boolean hasBigIntExtType;
3333

@@ -82,6 +82,8 @@ public IRubyObject registeredTypesInternal(ThreadContext ctx) {
8282

8383
@JRubyMethod(name = "register_type", required = 2, optional = 1)
8484
public IRubyObject registerType(ThreadContext ctx, IRubyObject[] args) {
85+
testFrozen("MessagePack::Factory");
86+
8587
Ruby runtime = ctx.runtime;
8688
IRubyObject type = args[0];
8789
IRubyObject mod = args[1];
@@ -91,10 +93,6 @@ public IRubyObject registerType(ThreadContext ctx, IRubyObject[] args) {
9193

9294
RubyHash options = null;
9395

94-
if (isFrozen()) {
95-
throw runtime.newFrozenError("MessagePack::Factory");
96-
}
97-
9896
if (args.length == 2) {
9997
packerArg = runtime.newSymbol("to_msgpack_ext");
10098
unpackerArg = runtime.newSymbol("from_msgpack_ext");

ext/java/org/msgpack/jruby/Packer.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@
2828
@JRubyClass(name="MessagePack::Packer")
2929
public class Packer extends RubyObject {
3030
private static final long serialVersionUID = 8451274621499362492L;
31-
public ExtensionRegistry registry;
31+
public transient ExtensionRegistry registry;
3232
private Buffer buffer;
33-
private Encoder encoder;
33+
private transient Encoder encoder;
3434
private boolean hasSymbolExtType;
3535
private boolean hasBigintExtType;
36-
private Encoding binaryEncoding;
36+
private transient Encoding binaryEncoding;
3737

3838
public Packer(Ruby runtime, RubyClass type, ExtensionRegistry registry, boolean hasSymbolExtType, boolean hasBigintExtType) {
3939
super(runtime, type);
@@ -95,10 +95,9 @@ public IRubyObject registeredTypesInternal(ThreadContext ctx) {
9595

9696
@JRubyMethod(name = "register_type", required = 2, optional = 1)
9797
public IRubyObject registerType(ThreadContext ctx, IRubyObject[] args, final Block block) {
98+
testFrozen("MessagePack::Packer");
99+
98100
Ruby runtime = ctx.runtime;
99-
if (isFrozen()) {
100-
throw runtime.newFrozenError("MessagePack::Packer");
101-
}
102101
IRubyObject type = args[0];
103102
IRubyObject mod = args[1];
104103

ext/java/org/msgpack/jruby/Unpacker.java

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,17 @@
2121
import org.jruby.anno.JRubyClass;
2222
import org.jruby.anno.JRubyMethod;
2323
import org.jruby.util.ByteList;
24-
import org.jruby.ext.stringio.StringIO;
2524

2625
import static org.jruby.runtime.Visibility.PRIVATE;
2726

2827
@JRubyClass(name="MessagePack::Unpacker")
2928
public class Unpacker extends RubyObject {
3029
private static final long serialVersionUID = 8451264671199362492L;
31-
private final ExtensionRegistry registry;
30+
private transient final ExtensionRegistry registry;
3231

33-
private IRubyObject stream;
34-
private IRubyObject data;
35-
private Decoder decoder;
32+
private transient IRubyObject stream;
33+
private transient IRubyObject data;
34+
private transient Decoder decoder;
3635
private final RubyClass underflowErrorClass;
3736
private boolean symbolizeKeys;
3837
private boolean freeze;
@@ -129,10 +128,9 @@ public IRubyObject registeredTypesInternal(ThreadContext ctx) {
129128

130129
@JRubyMethod(name = "register_type", required = 1, optional = 2)
131130
public IRubyObject registerType(ThreadContext ctx, IRubyObject[] args, final Block block) {
131+
testFrozen("MessagePack::Unpacker");
132+
132133
Ruby runtime = ctx.runtime;
133-
if (isFrozen()) {
134-
throw runtime.newFrozenError("MessagePack::Unpacker");
135-
}
136134
IRubyObject type = args[0];
137135

138136
RubyModule extModule;
@@ -334,9 +332,7 @@ public IRubyObject getStream(ThreadContext ctx) {
334332
@JRubyMethod(name = "stream=", required = 1)
335333
public IRubyObject setStream(ThreadContext ctx, IRubyObject stream) {
336334
RubyString str;
337-
if (stream instanceof StringIO) {
338-
str = stream.callMethod(ctx, "string").asString();
339-
} else if (stream instanceof RubyIO) {
335+
if (stream instanceof RubyIO) {
340336
str = stream.callMethod(ctx, "read").asString();
341337
} else if (stream.respondsTo("read")) {
342338
str = stream.callMethod(ctx, "read").asString();

0 commit comments

Comments
 (0)