Skip to content

Commit

Permalink
Revert abstract/NotAllocatable changes
Browse files Browse the repository at this point in the history
Make RubyBasicSocket and RubyIPSocket allocatable to match MRI behaviour
  • Loading branch information
etehtsea committed Sep 14, 2016
1 parent b31c953 commit 8802bb0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
10 changes: 8 additions & 2 deletions core/src/main/java/org/jruby/ext/socket/RubyBasicSocket.java
Expand Up @@ -78,14 +78,20 @@
* Implementation of the BasicSocket class from Ruby.
*/
@JRubyClass(name="BasicSocket", parent="IO")
public abstract class RubyBasicSocket extends RubyIO {
public class RubyBasicSocket extends RubyIO {
static void createBasicSocket(Ruby runtime) {
RubyClass rb_cBasicSocket = runtime.defineClass("BasicSocket", runtime.getIO(), ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR);
RubyClass rb_cBasicSocket = runtime.defineClass("BasicSocket", runtime.getIO(), BASICSOCKET_ALLOCATOR);

rb_cBasicSocket.defineAnnotatedMethods(RubyBasicSocket.class);
rb_cBasicSocket.undefineMethod("initialize");
}

private static ObjectAllocator BASICSOCKET_ALLOCATOR = new ObjectAllocator() {
public IRubyObject allocate(Ruby runtime, RubyClass klass) {
return new RubyBasicSocket(runtime, klass);
}
};

public RubyBasicSocket(Ruby runtime, RubyClass type) {
super(runtime, type);
doNotReverseLookup = true;
Expand Down
11 changes: 9 additions & 2 deletions core/src/main/java/org/jruby/ext/socket/RubyIPSocket.java
Expand Up @@ -48,15 +48,22 @@
* @author <a href="mailto:ola.bini@ki.se">Ola Bini</a>
*/
@JRubyClass(name="IPSocket", parent="BasicSocket")
public abstract class RubyIPSocket extends RubyBasicSocket {
public class RubyIPSocket extends RubyBasicSocket {
static void createIPSocket(Ruby runtime) {
RubyClass rb_cIPSocket = runtime.defineClass("IPSocket", runtime.getClass("BasicSocket"), ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR);
RubyClass rb_cIPSocket = runtime.defineClass("IPSocket", runtime.getClass("BasicSocket"), IPSOCKET_ALLOCATOR);

rb_cIPSocket.defineAnnotatedMethods(RubyIPSocket.class);
rb_cIPSocket.undefineMethod("initialize");

runtime.getObject().setConstant("IPsocket",rb_cIPSocket);
}

private static ObjectAllocator IPSOCKET_ALLOCATOR = new ObjectAllocator() {
public IRubyObject allocate(Ruby runtime, RubyClass klass) {
return new RubyIPSocket(runtime, klass);
}
};

public RubyIPSocket(Ruby runtime, RubyClass type) {
super(runtime, type);
}
Expand Down

0 comments on commit 8802bb0

Please sign in to comment.