Skip to content

Commit

Permalink
Merge pull request #10 from marschall/fix-deprecation
Browse files Browse the repository at this point in the history
Fix Deprecation Warnings
  • Loading branch information
headius committed Mar 18, 2015
2 parents 54690bf + c8afe2d commit f8f34e5
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 18 deletions.
22 changes: 16 additions & 6 deletions src/main/java/jnr/unixsocket/Native.java
Expand Up @@ -44,10 +44,10 @@ class Native {
? new String[] { "socket", "nsl", "c" }
: new String[] { "c" };
public static interface LibC {
static final LibC INSTANCE = Library.loadLibrary(LibC.class, libnames);
public static final int F_GETFL = com.kenai.constantine.platform.Fcntl.F_GETFL.value();
public static final int F_SETFL = com.kenai.constantine.platform.Fcntl.F_SETFL.value();
public static final int O_NONBLOCK = com.kenai.constantine.platform.OpenFlags.O_NONBLOCK.value();

public static final int F_GETFL = jnr.constants.platform.Fcntl.F_GETFL.intValue();
public static final int F_SETFL = jnr.constants.platform.Fcntl.F_SETFL.intValue();
public static final int O_NONBLOCK = jnr.constants.platform.OpenFlags.O_NONBLOCK.intValue();

int socket(int domain, int type, int protocol);
int listen(int fd, int backlog);
Expand All @@ -64,13 +64,23 @@ public static interface LibC {
int setsockopt(int s, int level, int optname, @In Timeval optval, int optlen);
String strerror(int error);
}

static final LibC INSTANCE;

static {
LibraryLoader<LibC> loader = LibraryLoader.create(LibC.class);
for (String libraryName : libnames) {
loader.library(libraryName);
}
INSTANCE = loader.load();
}

static final LibC libsocket() {
return LibC.INSTANCE;
return INSTANCE;
}

static final LibC libc() {
return LibC.INSTANCE;
return INSTANCE;
}

static int socket(ProtocolFamily domain, Sock type, int protocol) throws IOException {
Expand Down
22 changes: 11 additions & 11 deletions src/main/java/jnr/unixsocket/SockAddrUnix.java
Expand Up @@ -18,7 +18,7 @@

package jnr.unixsocket;

import com.kenai.constantine.platform.ProtocolFamily;
import jnr.constants.platform.ProtocolFamily;
import jnr.ffi.*;

/**
Expand All @@ -30,17 +30,17 @@ abstract class SockAddrUnix extends Struct {
protected abstract UTF8String getPathField();
protected abstract NumberField getFamilyField();

public SockAddrUnix() {
SockAddrUnix() {
super(jnr.ffi.Runtime.getSystemRuntime());
}

/**
* Sets the protocol family of this unix socket address.
*
* @param family The protocol family, usually {@link com.kenai.constantine.platform.ProtocolFamily.PF_UNIX}
* @param family The protocol family, usually {@link ProtocolFamily#PF_UNIX}
*/
public final void setFamily(ProtocolFamily family) {
getFamilyField().set(family.value());
final void setFamily(ProtocolFamily family) {
getFamilyField().set(family.intValue());
}


Expand All @@ -49,7 +49,7 @@ public final void setFamily(ProtocolFamily family) {
*
* @return The protocol family
*/
public final ProtocolFamily getFamily() {
final ProtocolFamily getFamily() {
return ProtocolFamily.valueOf(getFamilyField().intValue());
}

Expand All @@ -58,7 +58,7 @@ public final ProtocolFamily getFamily() {
*
* @param path The unix socket address
*/
public final void setPath(java.lang.String path) {
final void setPath(java.lang.String path) {
getPathField().set(path);
}

Expand All @@ -67,7 +67,7 @@ public final void setPath(java.lang.String path) {
*
* @return A String
*/
public final java.lang.String getPath() {
final java.lang.String getPath() {
return getPathField().get();
}

Expand All @@ -76,7 +76,7 @@ public final java.lang.String getPath() {
*
* @return The maximum size of the address in bytes
*/
public int getMaximumLength() {
int getMaximumLength() {
return 2 + getPathField().length();
}

Expand All @@ -85,7 +85,7 @@ public int getMaximumLength() {
*
* @return The actual size of this address, in bytes
*/
public int length() {
int length() {
return 2 + strlen(getPathField());
}

Expand All @@ -96,7 +96,7 @@ public int length() {
* @return An instance of <tt>SockAddrUnix</tt>
*/
static SockAddrUnix create() {
return Platform.getPlatform().isBSD() ? new BSDSockAddrUnix() : new DefaultSockAddrUnix();
return Platform.getNativePlatform().isBSD() ? new BSDSockAddrUnix() : new DefaultSockAddrUnix();
}

private static final int strlen(UTF8String str) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/jnr/unixsocket/UnixSocketAddress.java
Expand Up @@ -18,7 +18,7 @@

package jnr.unixsocket;

import com.kenai.constantine.platform.ProtocolFamily;
import jnr.constants.platform.ProtocolFamily;

public class UnixSocketAddress extends java.net.SocketAddress {
private final SockAddrUnix address;
Expand Down

0 comments on commit f8f34e5

Please sign in to comment.