[ https://issues.apache.org/jira/browse/PDFBOX-5758?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17813894#comment-17813894 ]
Axel Howind commented on PDFBOX-5758: ------------------------------------- Sorry, this fixes only part of the problem. I will create an updated patch. > ExceptionInInitializerError when unmapping is not supported > ----------------------------------------------------------- > > Key: PDFBOX-5758 > URL: https://issues.apache.org/jira/browse/PDFBOX-5758 > Project: PDFBox > Issue Type: Bug > Components: IO > Reporter: Axel Howind > Priority: Major > Labels: patch > Attachments: > PDFBOX-5758__ExceptionInInitializerError_when_unmapping_is_not_supported.patch > > > When unmapping is not supported, PdfBox throws an ExceptionInInitializerError > that is not recoverable. The reason is that in IOUtils, the UNMAPPER static > field is initialized before the Logger is created and when the unmapper can > not be created, PdfBox tries to write an error message to the log: > > {code:java} > public final class IOUtils > { > ... > static > { > UNMAPPER = Optional.ofNullable(AccessController > .doPrivileged((PrivilegedAction<Consumer<ByteBuffer>>) > IOUtils::unmapper)); > } > /** > * Log instance. > */ > private static final Logger LOG = LogManager.getLogger(IOUtils.class); > ... > private static Consumer<ByteBuffer> unmapper() > { > final Lookup lookup = lookup(); > try > { > ... > } > catch (SecurityException se) > { > LOG.error( > "Unmapping is not supported because of missing permissions. > Please grant at least the following permissions: > RuntimePermission(\"accessClassInPackage.sun.misc\") " > + " and ReflectPermission(\"suppressAccessChecks\")", > se); > } > catch (ReflectiveOperationException | RuntimeException e) > { > LOG.error("Unmapping is not supported.", e); > } > return null; > }{code} > -- This message was sent by Atlassian Jira (v8.20.10#820010) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org For additional commands, e-mail: dev-h...@pdfbox.apache.org