Re: JEP 370 - text example leads to exception

2020-02-18 Thread Maurizio Cimadamore
On 18/02/2020 03:52, Chris T wrote: Maurizio, thank you for your suggestion! One of my coworkers suggested also using padding instead of keeping a compact/packed memory layout. The reason my example worked was because Java char is 2 bytes and int is 4... So using 16-bit alignment for

Re: JEP 370 - text example leads to exception

2020-02-17 Thread Chris T
Maurizio, thank you for your suggestion! One of my coworkers suggested also using padding instead of keeping a compact/packed memory layout. The reason my example worked was because Java char is 2 bytes and int is 4... So using 16-bit alignment for "creditScore" the was the common denominator.

Re: JEP 370 - text example leads to exception

2020-02-17 Thread Maurizio Cimadamore
Hi Chris, thanks for the links - took a look at your first test and, more specifically at example03SSNToCreditScore: MemoryLayout ssnAndCreditStruct = MemoryLayout.ofStruct(     MemoryLayout.ofSequence(9, MemoryLayout.ofValueBits(Character.SIZE, order)).withName("ssn"),    

Re: JEP 370 - text example leads to exception

2020-02-16 Thread Chris T
Maurizio, thanks for pointing the bug out - however I don't think I was impacted by it. I agree with you that a more complex examples might distract the audience from the main presentation points. As mentioned in one of my previous email, I finalized some examples myself: 1. One example for

Re: JEP 370 - text example leads to exception

2020-02-14 Thread Maurizio Cimadamore
On 13/02/2020 03:39, Chris T wrote: No problem! Nice talk at FOSDEM, Maurizio ;-)! One suggestion, for future talks - when it comes to memory layouts please construct an example that is a little bit more complex (by end of the upcoming weekend I will publish one that can be used). I had

Re: JEP 370 - text example leads to exception

2020-02-12 Thread Chris T
No problem! Nice talk at FOSDEM, Maurizio ;-)! One suggestion, for future talks - when it comes to memory layouts please construct an example that is a little bit more complex (by end of the upcoming weekend I will publish one that can be used). I had trouble with bit alignment when working on

Re: JEP 370 - text example leads to exception

2020-02-11 Thread Maurizio Cimadamore
Thanks Paul! Maurizio On 10/02/2020 17:58, Paul Sandoz wrote: I modified the JEP with updated code snippets that compile against the latest API in JDK 14 [*].

Re: JEP 370 - text example leads to exception

2020-02-11 Thread Maurizio Cimadamore
Thanks Chris, both for catching the mistake and for testing out the feature - as you can imagine we'd like to collect as much feedback as possible to make sure the API gets finalized right. Cheers Maurizio On 11/02/2020 02:12, Chris T wrote: Paul, thank you very much! In the meantime I

Re: JEP 370 - text example leads to exception

2020-02-10 Thread Chris T
Paul, thank you very much! In the meantime I did more reading about VarHandles and understood better the "philosophy" of coordinates and it made sense (eventually I was able to fix my own issues). Also, thank you for sharing Maurizio's talk - I will refer it in my examples. Speaking of

Re: JEP 370 - text example leads to exception

2020-02-10 Thread Paul Sandoz
Thanks for pointing out the inconsistencies. I modified the JEP with updated code snippets that compile against the latest API in JDK 14 [*]. The handle created “withStride” requires an additional coordinate the is an offset from the base address. You may find Maurizio’s recent talk at Fosdem

JEP 370 - text example leads to exception

2020-02-07 Thread Chris T
I tried to build an example on top of this code snippet (from the JEP text): VarHandle intHandle = MemoryHandles.varHandle(int.class); VarHandle intElemHandle = MemoryHandles.withStride(intHandle, 4); try (MemorySegment segment = MemorySegment.allocateNative(100)) { MemoryAddress base =