Package com.headius.backport9.buffer
Class Buffers
- java.lang.Object
-
- com.headius.backport9.buffer.Buffers
-
public class Buffers extends java.lang.Object
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
Constructors Constructor Description Buffers()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T extends java.nio.Buffer>
TclearBuffer(T buf)
Invoke Buffer.clear always using Buffer as the target, to avoid binary incompatibility on Java 8.static <T extends java.nio.Buffer>
TflipBuffer(T buf)
Invoke Buffer.flip always using Buffer as the target, to avoid binary incompatibility on Java 8.static <T extends java.nio.Buffer>
TlimitBuffer(T buf, int limit)
Invoke Buffer.limit always using Buffer as the target, to avoid binary incompatibility on Java 8.static <T extends java.nio.Buffer>
TmarkBuffer(T buf)
Invoke Buffer.mark always using Buffer as the target, to avoid binary incompatibility on Java 8.static <T extends java.nio.Buffer>
TpositionBuffer(T buf, int limit)
Invoke Buffer.position always using Buffer as the target, to avoid binary incompatibility on Java 8.static <T extends java.nio.Buffer>
TrewindBuffer(T buf)
Invoke Buffer.rewind always using Buffer as the target, to avoid binary incompatibility on Java 8.
-
-
-
Method Detail
-
clearBuffer
public static <T extends java.nio.Buffer> T clearBuffer(T buf)
Invoke Buffer.clear always using Buffer as the target, to avoid binary incompatibility on Java 8.- Type Parameters:
T
- any java.nio.Buffer type- Parameters:
buf
- the buffer- Returns:
- the buffer
- See Also:
Buffer.clear()
-
flipBuffer
public static <T extends java.nio.Buffer> T flipBuffer(T buf)
Invoke Buffer.flip always using Buffer as the target, to avoid binary incompatibility on Java 8.- Type Parameters:
T
- any java.nio.Buffer type- Parameters:
buf
- the buffer- Returns:
- the buffer
- See Also:
Buffer.flip()
-
limitBuffer
public static <T extends java.nio.Buffer> T limitBuffer(T buf, int limit)
Invoke Buffer.limit always using Buffer as the target, to avoid binary incompatibility on Java 8.- Type Parameters:
T
- any java.nio.Buffer type- Parameters:
buf
- the bufferlimit
- the new limit- Returns:
- the buffer
- See Also:
Buffer.limit(int)
-
positionBuffer
public static <T extends java.nio.Buffer> T positionBuffer(T buf, int limit)
Invoke Buffer.position always using Buffer as the target, to avoid binary incompatibility on Java 8.- Type Parameters:
T
- any java.nio.Buffer type- Parameters:
buf
- the bufferlimit
- the new limit- Returns:
- the buffer
- See Also:
Buffer.position()
-
markBuffer
public static <T extends java.nio.Buffer> T markBuffer(T buf)
Invoke Buffer.mark always using Buffer as the target, to avoid binary incompatibility on Java 8.- Type Parameters:
T
- any java.nio.Buffer type- Parameters:
buf
- the buffer- Returns:
- the buffer
- See Also:
Buffer.mark()
-
rewindBuffer
public static <T extends java.nio.Buffer> T rewindBuffer(T buf)
Invoke Buffer.rewind always using Buffer as the target, to avoid binary incompatibility on Java 8.- Type Parameters:
T
- any java.nio.Buffer type- Parameters:
buf
- the buffer- Returns:
- the buffer
- See Also:
Buffer.rewind()
-
-