[
https://issues.apache.org/jira/browse/MNEMONIC-640?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17324331#comment-17324331
]
Wang, Gang commented on MNEMONIC-640:
-------------------------------------
I found out the following code snippets that might be helpful to fix this
upgrading issue for your reference.
{code:java}
final Class<?> unsafeClass = Class.forName("sun.misc.Unsafe");
final Field theUnsafeField = unsafeClass.getDeclaredField("theUnsafe");
theUnsafeField.setAccessible(true); final Object
theUnsafe = theUnsafeField.get(null); final Method
invokeCleanerMethod = unsafeClass.getMethod("invokeCleaner",
java.nio.ByteBuffer.class);
invokeCleanerMethod.invoke(theUnsafe, buffer);{code}
[https://github.com/albfernandez/OpenPDF/blob/5a0854b0743d09f7870baa98f5d04a27b04eeea0/openpdf/src/main/java/com/lowagie/text/pdf/MappedRandomAccessFile.java#L210]
> [JDK11] Upgrade issue about object is not an instance of declaring class
> ------------------------------------------------------------------------
>
> Key: MNEMONIC-640
> URL: https://issues.apache.org/jira/browse/MNEMONIC-640
> Project: Mnemonic
> Issue Type: Bug
> Components: Example, JDK Upgrade
> Affects Versions: 0.15.0
> Reporter: Wang, Gang
> Priority: Major
> Fix For: 0.15.0
>
>
>
> The following issue is caused by deprecated buffer cleaner on higher version
> of JDK11, it needs to be investigated and refactor the code logic according
> to new method for native memory backed bytebuffer cleaning.
> {code:java}
> Manually destroy Buffer at 759EBB3D.
> Reclaim Memory Buffer: 759EBB3D Size: 1329017
> Exception in thread "main" java.lang.IllegalArgumentException: object is not
> an instance of declaring class
> at
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at
> java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.base/java.lang.reflect.Method.invoke(Method.java:566)
> at
> org.apache.mnemonic.SysMemAllocator$1.reclaim(SysMemAllocator.java:106)
> at
> org.flowcomputing.commons.resgc.ResCollector.destroyRes(ResCollector.java:158)
> at
> org.flowcomputing.commons.resgc.ResHolder.destroy(ResHolder.java:132)
> at
> org.flowcomputing.commons.resgc.ResHolder.destroy(ResHolder.java:118)
> at org.apache.mnemonic.examples.Main.main(Main.java:155)
> {code}
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)