Re: RFR: 8286390: Address possibly lossy conversions in jdk.incubator.foreign moved to java.base [v2]

2022-05-13 Thread Daniel Fuchs
On Fri, 13 May 2022 12:06:45 GMT, Jorn Vernee  wrote:

>> Address possible lossy conversion warning in `ProgrammableInvoker`.
>> 
>> Testing: `run-test-jdk_foreign`, testing with patch from 
>> https://github.com/openjdk/jdk/pull/8599 to see if the warning is gone.
>
> Jorn Vernee has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   Use plain int cast instead

Marked as reviewed by dfuchs (Reviewer).

-

PR: https://git.openjdk.java.net/jdk/pull/8697


Re: RFR: 8286390: Address possibly lossy conversions in jdk.incubator.foreign moved to java.base [v2]

2022-05-13 Thread Jorn Vernee
On Fri, 13 May 2022 11:17:20 GMT, Jorn Vernee  wrote:

>> src/java.base/share/classes/jdk/internal/foreign/abi/ProgrammableInvoker.java
>>  line 215:
>> 
>>> 213: for (int i = 0; i < highLevelType.parameterCount(); i++) {
>>> 214: List bindings = 
>>> callingSequence.argumentBindings(i);
>>> 215: argInsertPos += 
>>> Math.toIntExact(bindings.stream().filter(Binding.VMStore.class::isInstance).count())
>>>  + 1;
>> 
>> My gut feeling in this case would be that it's a bit strange to use 
>> `Math.toIntExact` to do a safe cast when you don't do `Math.addExact` to 
>> ensure that the result of the addition will not overflow. I wonder if a 
>> simple cast wouldn't be more appropriate - unless you really think that you 
>> might have more than Integer.MAX_VALUE bindings (which I doubt :-) ). But 
>> that's just my feeling...
>
> Yeah, that's true. I don't really expect this to ever overflow, that would 
> create issues in other cases as well (since the limit on argument count is 
> 255 for instance).
> 
> Okay, I'll switch this to a regular cast. (It doesn't matter too much I think 
> because I'm also planning to remove this code: 
> https://github.com/openjdk/jdk/pull/8685)

Fixed.

-

PR: https://git.openjdk.java.net/jdk/pull/8697


Re: RFR: 8286390: Address possibly lossy conversions in jdk.incubator.foreign moved to java.base [v2]

2022-05-13 Thread Jorn Vernee
> Address possible lossy conversion warning in `ProgrammableInvoker`.
> 
> Testing: `run-test-jdk_foreign`, testing with patch from 
> https://github.com/openjdk/jdk/pull/8599 to see if the warning is gone.

Jorn Vernee has updated the pull request incrementally with one additional 
commit since the last revision:

  Use plain int cast instead

-

Changes:
  - all: https://git.openjdk.java.net/jdk/pull/8697/files
  - new: https://git.openjdk.java.net/jdk/pull/8697/files/da907697..d207f515

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=jdk=8697=01
 - incr: https://webrevs.openjdk.java.net/?repo=jdk=8697=00-01

  Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod
  Patch: https://git.openjdk.java.net/jdk/pull/8697.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/8697/head:pull/8697

PR: https://git.openjdk.java.net/jdk/pull/8697