[ 
https://issues.apache.org/jira/browse/DATASKETCHES-14?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Lee Rhodes updated DATASKETCHES-14:
-----------------------------------
    Issue Type: New Feature  (was: Bug)

> NioBits throws an exception on Java 21.
> ---------------------------------------
>
>                 Key: DATASKETCHES-14
>                 URL: https://issues.apache.org/jira/browse/DATASKETCHES-14
>             Project: Apache Datasketches
>          Issue Type: New Feature
>            Reporter: Claude Warren
>            Assignee: Lee Rhodes
>            Priority: Major
>
> When running on Java 21 the NioBits method throws an exception.  This issue 
> is noted in the NioBits code where indicates there are 2 methods that  in 
> Java 17 and later take a long and not an int.
>  
> It issue is in this code block form NioBits:
>  
> {{ static {}}
> {{    try {}}
> {{      isPageAligned = VirtualMachineMemory.getIsPageAligned();}}
> {{      maxDBBMemory = VirtualMachineMemory.getMaxDBBMemory();}}{{      
> NIO_BITS_CLASS = Class.forName("java.nio.Bits");}}{{      
> NIO_BITS_RESERVE_MEMORY_METHOD = NIO_BITS_CLASS}}
> {{          .getDeclaredMethod("reserveMemory", long.class, int.class); 
> //JD16 requires (long, long)}}
> {{      NIO_BITS_RESERVE_MEMORY_METHOD.setAccessible(true);}}{{      
> NIO_BITS_UNRESERVE_MEMORY_METHOD = NIO_BITS_CLASS}}
> {{          .getDeclaredMethod("unreserveMemory", long.class, int.class); 
> //JD16 requires (long, long)}}
> {{      NIO_BITS_UNRESERVE_MEMORY_METHOD.setAccessible(true);}}{{      final 
> Field countField = 
> NIO_BITS_CLASS.getDeclaredField(NioBitsFields.COUNT_FIELD_NAME);}}
> {{      countField.setAccessible(true);}}
> {{      nioBitsCount = (AtomicLong) (countField.get(null));}}{{      final 
> Field reservedMemoryField = 
> NIO_BITS_CLASS.getDeclaredField(NioBitsFields.RESERVED_MEMORY_FIELD_NAME);}}
> {{      reservedMemoryField.setAccessible(true);}}
> {{      nioBitsReservedMemory = (AtomicLong) 
> (reservedMemoryField.get(null));}}{{      final Field totalCapacityField = 
> NIO_BITS_CLASS.getDeclaredField(NioBitsFields.TOTAL_CAPACITY_FIELD_NAME);}}
> {{      totalCapacityField.setAccessible(true);}}
> {{      nioBitsTotalCapacity = (AtomicLong) 
> (totalCapacityField.get(null));}}{{    } catch (final ClassNotFoundException 
> | NoSuchMethodException |  IllegalAccessException}}
> {{        | IllegalArgumentException | SecurityException |  
> NoSuchFieldException e) {}}
> {{      throw new RuntimeException("Could not acquire java.nio.Bits class: " 
> + e.getClass());}}
> {{    }}}
> {{{}  }{}}}{{{}{}}}
> {{if when NIO_BITS_RESERVE_MEMORY_METHOD and 
> }}{{{}NIO_BITS_UNRESERVE_MEMORY_METHOD were discovered we instead looked for 
> the function name without the parameters and accept a function definition 
> that takes either (long, long) or (long, int) I think this might 
> work.{}}}{{{}{}}}
> {{{}The current code base always passes an int as the second parameter so it 
> should work with the (long, long) version of the method as well as the (long, 
> int).{}}}{{{}{}}}
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@datasketches.apache.org
For additional commands, e-mail: dev-h...@datasketches.apache.org

Reply via email to