Skip to content

Commit

Permalink
Remove cleanOldsJDK method.
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasrosdal committed Dec 27, 2023
1 parent 5a4e6d5 commit 5a81749
Showing 1 changed file with 2 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,8 @@ public static boolean clean(final java.nio.ByteBuffer buffer) {
if (buffer == null || !buffer.isDirect()) {
return false;
}
if (cleanJava9(buffer)) {
return true;
}
return cleanOldsJDK(buffer);
return cleanJava9(buffer);

}

private static boolean cleanJava9(final java.nio.ByteBuffer buffer) {
Expand All @@ -233,27 +231,5 @@ private static boolean cleanJava9(final java.nio.ByteBuffer buffer) {

return b;
}

private static boolean cleanOldsJDK(final java.nio.ByteBuffer buffer) {
Boolean b = AccessController.doPrivileged((PrivilegedAction<Boolean>) () -> {
Boolean success = Boolean.FALSE;
try {
Method getCleanerMethod = buffer.getClass()
.getMethod("cleaner", (Class[]) null);
if (!getCleanerMethod.isAccessible()) {
getCleanerMethod.setAccessible(true);
}
Object cleaner = getCleanerMethod.invoke(buffer, (Object[])null);
Method clean = cleaner.getClass().getMethod("clean", (Class[])null);
clean.invoke(cleaner, (Object[])null);
success = Boolean.TRUE;
} catch (Exception e) {
// Ignore
}
return success;
});

return b;
}

}

0 comments on commit 5a81749

Please sign in to comment.