Top Description Constructors Methods
com.headius.backport9.buffer

public Class Buffers

extends Object
Class Inheritance
Imports
java.nio.Buffer

Utility functions to help avoid binary incompatibility due to variadic return types on Java 9. Java 9 introduced new overloads of several Buffer methods on its subclasses. Because those methods return the actual type of the subclass, they are incompatible with Java 8 where no such overloads exist. This utility casts all buffers to Buffer and makes the call from there, avoiding binding directly to the overloads that don't exist on Java 8.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static <
any java.nio.Buffer type
T extends Buffer
>
T

Returns:

the buffer
clearBuffer
(T
the buffer
buf
)

Invoke Buffer.clear always using Buffer as the target, to avoid binary incompatibility on Java 8.

public static <
any java.nio.Buffer type
T extends Buffer
>
T

Returns:

the buffer
flipBuffer
(T
the buffer
buf
)

Invoke Buffer.flip always using Buffer as the target, to avoid binary incompatibility on Java 8.

public static <
any java.nio.Buffer type
T extends Buffer
>
T

Returns:

the buffer
limitBuffer
(T
the buffer
buf
,
int
the new limit
limit
)

Invoke Buffer.limit always using Buffer as the target, to avoid binary incompatibility on Java 8.

public static <
any java.nio.Buffer type
T extends Buffer
>
T

Returns:

the buffer
markBuffer
(T
the buffer
buf
)

Invoke Buffer.mark always using Buffer as the target, to avoid binary incompatibility on Java 8.

public static <
any java.nio.Buffer type
T extends Buffer
>
T

Returns:

the buffer
positionBuffer
(T
the buffer
buf
,
int
the new limit
limit
)

Invoke Buffer.position always using Buffer as the target, to avoid binary incompatibility on Java 8.

public static <
any java.nio.Buffer type
T extends Buffer
>
T

Returns:

the buffer
rewindBuffer
(T
the buffer
buf
)

Invoke Buffer.rewind always using Buffer as the target, to avoid binary incompatibility on Java 8.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Buffersback to summary
public Buffers()

Method Detail

clearBufferback to summary
public static <T extends Buffer> T clearBuffer(T buf)

Invoke Buffer.clear always using Buffer as the target, to avoid binary incompatibility on Java 8.

Parameters
<T>
any java.nio.Buffer type
buf:T

the buffer

Returns:T

the buffer

See Also
Buffer#clear()
flipBufferback to summary
public static <T extends Buffer> T flipBuffer(T buf)

Invoke Buffer.flip always using Buffer as the target, to avoid binary incompatibility on Java 8.

Parameters
<T>
any java.nio.Buffer type
buf:T

the buffer

Returns:T

the buffer

See Also
Buffer#flip()
limitBufferback to summary
public static <T extends Buffer> T limitBuffer(T buf, int limit)

Invoke Buffer.limit always using Buffer as the target, to avoid binary incompatibility on Java 8.

Parameters
<T>
any java.nio.Buffer type
buf:T

the buffer

limit:int

the new limit

Returns:T

the buffer

See Also
Buffer#limit(int)
markBufferback to summary
public static <T extends Buffer> T markBuffer(T buf)

Invoke Buffer.mark always using Buffer as the target, to avoid binary incompatibility on Java 8.

Parameters
<T>
any java.nio.Buffer type
buf:T

the buffer

Returns:T

the buffer

See Also
Buffer#mark()
positionBufferback to summary
public static <T extends Buffer> T positionBuffer(T buf, int limit)

Invoke Buffer.position always using Buffer as the target, to avoid binary incompatibility on Java 8.

Parameters
<T>
any java.nio.Buffer type
buf:T

the buffer

limit:int

the new limit

Returns:T

the buffer

See Also
Buffer#position()
rewindBufferback to summary
public static <T extends Buffer> T rewindBuffer(T buf)

Invoke Buffer.rewind always using Buffer as the target, to avoid binary incompatibility on Java 8.

Parameters
<T>
any java.nio.Buffer type
buf:T

the buffer

Returns:T

the buffer

See Also
Buffer#rewind()