Package com.headius.backport9.buffer
Class Buffers
java.lang.Object
com.headius.backport9.buffer.Buffers
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 -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends Buffer>
TclearBuffer
(T buf) Invoke Buffer.clear always using Buffer as the target, to avoid binary incompatibility on Java 8.static <T extends Buffer>
TflipBuffer
(T buf) Invoke Buffer.flip always using Buffer as the target, to avoid binary incompatibility on Java 8.static <T extends 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 Buffer>
TmarkBuffer
(T buf) Invoke Buffer.mark always using Buffer as the target, to avoid binary incompatibility on Java 8.static <T extends 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 Buffer>
TrewindBuffer
(T buf) Invoke Buffer.rewind always using Buffer as the target, to avoid binary incompatibility on Java 8.
-
Constructor Details
-
Buffers
public Buffers()
-
-
Method Details
-
clearBuffer
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:
-
flipBuffer
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:
-
limitBuffer
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:
-
positionBuffer
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:
-
markBuffer
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:
-
rewindBuffer
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:
-