[jira] [Commented] (GEODE-9466) ByteBufferInputStream.OffHeapByteSource fails on Java 16 and later

2022-04-21 Thread ASF subversion and git services (Jira)


[ 
https://issues.apache.org/jira/browse/GEODE-9466?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17526103#comment-17526103
 ] 

ASF subversion and git services commented on GEODE-9466:


Commit ad615d16ccc071354521a8c921fa23ccdb5dda14 in geode's branch 
refs/heads/develop from Darrel Schneider
[ https://gitbox.apache.org/repos/asf?p=geode.git;h=ad615d16cc ]

GEODE-9466: change offheap to not use Bits.unaligned (#7611)

offheap no longer depends on java.nio.Bits.unaligned

> ByteBufferInputStream.OffHeapByteSource fails on Java 16 and later
> --
>
> Key: GEODE-9466
> URL: https://issues.apache.org/jira/browse/GEODE-9466
> Project: Geode
>  Issue Type: Bug
>  Components: offheap
>Reporter: Darrel Schneider
>Assignee: Darrel Schneider
>Priority: Major
>  Labels: Java16, Java17, pull-request-available
>
> ByteBufferInputStream.OffHeapByteSource has a method determineUnaligned that 
> will always fail on java 16 and later. This is because it calls 
> Method.setAccessible which is not allowed under normal conditions starting 
> with java 16 (see: 
> [https://softwaregarden.dev/en/posts/new-java/illegal-access-in-java-16]).
> The method is called when the class is loaded so it will cause the class load 
> to fail. It tries to handle exceptions on return false but the exception java 
> 16 throws is a RuntimeException and that is not caught. The exception it will 
> fail with is java.lang.reflect.InaccessibleObjectException.
> A workaround for this bug is to start the jvm with  --illegal-access=permit
> This causes ByteBufferInputStream to do a bunch of its work a byte at a time 
> instead of using the optimal multi-byte methods like readShort, readInt, and 
> readLong.
> It would be simple to change determineUnaligned to catch RuntimeException 
> from setAccessible and then to read the "os.arch" system property and if it 
> is any of the following to return true:
> {code:java}
> arch.equals("i386") || arch.equals("x86")
>  || arch.equals("amd64") || arch.equals("x86_64")
>  || arch.equals("ppc64") || arch.equals("ppc64le")
> {code}
> This is what the Bits class does in jdk 8. In jdk 16 this logic has moved to 
> UnsafeConstants and its value is injected by the JVM so it is unclear if the 
> list has grown.



--
This message was sent by Atlassian Jira
(v8.20.7#820007)


[jira] [Commented] (GEODE-9466) ByteBufferInputStream.OffHeapByteSource fails on Java 16 and later

2022-04-19 Thread Darrel Schneider (Jira)


[ 
https://issues.apache.org/jira/browse/GEODE-9466?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17524629#comment-17524629
 ] 

Darrel Schneider commented on GEODE-9466:
-

For this code to work on jdk17 in the 1.15 release "java.nio" needs to be 
opened.

> ByteBufferInputStream.OffHeapByteSource fails on Java 16 and later
> --
>
> Key: GEODE-9466
> URL: https://issues.apache.org/jira/browse/GEODE-9466
> Project: Geode
>  Issue Type: Bug
>  Components: offheap
>Reporter: Darrel Schneider
>Priority: Major
>  Labels: Java16, Java17
>
> ByteBufferInputStream.OffHeapByteSource has a method determineUnaligned that 
> will always fail on java 16 and later. This is because it calls 
> Method.setAccessible which is not allowed under normal conditions starting 
> with java 16 (see: 
> [https://softwaregarden.dev/en/posts/new-java/illegal-access-in-java-16]).
> The method is called when the class is loaded so it will cause the class load 
> to fail. It tries to handle exceptions on return false but the exception java 
> 16 throws is a RuntimeException and that is not caught. The exception it will 
> fail with is java.lang.reflect.InaccessibleObjectException.
> A workaround for this bug is to start the jvm with  --illegal-access=permit
> This causes ByteBufferInputStream to do a bunch of its work a byte at a time 
> instead of using the optimal multi-byte methods like readShort, readInt, and 
> readLong.
> It would be simple to change determineUnaligned to catch RuntimeException 
> from setAccessible and then to read the "os.arch" system property and if it 
> is any of the following to return true:
> {code:java}
> arch.equals("i386") || arch.equals("x86")
>  || arch.equals("amd64") || arch.equals("x86_64")
>  || arch.equals("ppc64") || arch.equals("ppc64le")
> {code}
> This is what the Bits class does in jdk 8. In jdk 16 this logic has moved to 
> UnsafeConstants and its value is injected by the JVM so it is unclear if the 
> list has grown.



--
This message was sent by Atlassian Jira
(v8.20.7#820007)