On Tue, 16 Jun 2026 21:06:36 GMT, Ferenc Rakoczi <[email protected]> wrote:
>> I believe the method being intrinsified here is the one on the generic class
>> i.e. `IntegerPolynomial::conditionalAssign(int set, long[] a, long[] b)`.
>> So, in theory, it could be called from any subclass of `IntegerPolynomial`,
>> not just for `IntegerPolynomialP256`. Can you provide a more detailed
>> explanation of why it won't be called from other subtypes, including types
>> where the number of limbs may be 0?
>
> It is true that IntegerPolynomial::conditionalAssign() is not only for the
> IntegerPolynomialP256 subclass, but it has a fixed set of permitted
> subclasses, with the number of limbs in the set {5, 10, 14, 16, 19} as one
> can infer from the comment at the beginning of this function. So the 0-check
> is not necessary.
Yes, the definition of Java class `IntegerPolynomial` does limit the possible
subclasses. However, as I mentioned in my earlier comment, that list includes
`IntegerPolynomialModBinP`
public abstract sealed class IntegerPolynomial implements IntegerFieldModuloP
permits IntegerPolynomial1305, IntegerPolynomial25519,
IntegerPolynomial448, IntegerPolynomialP256,
MontgomeryIntegerPolynomialP256, IntegerPolynomialP384,
IntegerPolynomialP521, IntegerPolynomialModBinP, P256OrderField,
P384OrderField, P521OrderField, Curve25519OrderField,
Curve448OrderField {
This specific subclass employs a limb count specified by a caller in the
constructor
public sealed class IntegerPolynomialModBinP extends IntegerPolynomial {
...
public IntegerPolynomialModBinP(int bitsPerLimb,
int numLimbs,
int power,
BigInteger subtrahend) {
super(bitsPerLimb, numLimbs, 1,
BigInteger.valueOf(2).pow(power).subtract(subtrahend));
So, for this class it looks as if a user could specify numLimbs == 0 when
creating an `IntegerPolynomialModBinP` and that same count will be passed on up
to `IntegerPolynomial`.
Now, that doesn't guarantee that any subsequent call to
`IntegerPolynomial::mult` will end up being passed a zero length array but I'd
like to be reassured why this won't happen.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/30941#discussion_r3427760518