diff --git a/openpdf/src/main/java/com/lowagie/text/pdf/MappedRandomAccessFile.java b/openpdf/src/main/java/com/lowagie/text/pdf/MappedRandomAccessFile.java index ac8eb869f..57bfb67e2 100644 --- a/openpdf/src/main/java/com/lowagie/text/pdf/MappedRandomAccessFile.java +++ b/openpdf/src/main/java/com/lowagie/text/pdf/MappedRandomAccessFile.java @@ -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) { @@ -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 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; - } }