<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    <p>Hi Aggelos, I did a pass on the primitive pattern JEP:</p>
    <p><a class="moz-txt-link-freetext" href="https://cr.openjdk.org/~abimpoudis/instanceof/instanceof-20230913/specs/instanceof-jls.html">https://cr.openjdk.org/~abimpoudis/instanceof/instanceof-20230913/specs/instanceof-jls.html</a></p>
    <p>Here are some comments:</p>
    <p>* `A widening primitive conversion of a byte to an int is
      unconditionally exact. Any value that b holds is representable
      exactly in an int. As a result, the value of i will always
      represent, exactly the same information that the variable b
      holds:`</p>
    <p>Here it is not very clear where does "b" comes from. It is shown
      in the code snippet, of course, but the text reads funny because
      it comes before the snippet. One simple fix would be to move the
      snippet around:</p>
    <p>```<br>
      A widening primitive conversion of a byte to an int is
      unconditionally exact:<br>
      <br>
          byte b = ...<br>
          int i = (int) b;<br>
      <br>
      Any value that b holds is representable exactly in an int. As a
      result, the value of i will always represent, exactly the same
      information that the variable b holds.<br>
      ```<br>
    </p>
    <p>* `A conversion C from a type S to a type P for a value x is
      exact if ...` - I presume you mean that "x" has type S ? If so,
      would be helpful to spell it out clearly?</p>
    <p>* `... then <code>C</code> is exact
      if the run-time test <code>S instanceof P</code> returns
      <code>true</code>.` - should't this be `x instanceof P` ?</p>
    <p>* In general, when you deal with multiple conversions (e.g.
      boxing followed by narrowing followed by XYZ), it is not clear to
      me that it's worth spelling out all of the combinations? You have
      defined when a widening is exact. And, we are also defining when
      an unboxing is exact (e.g. if the source object is not null).
      Boxing is always exact. As for narrowing you are defining that
      using instanceof. So... can't we just say that any conversion that
      is composed of multiple exact conversions is itself exact? (if so,
      the text can be simplified quite a bit?)</p>
    <p>* `... if <code>S</code> and <code>P</code> are both integral
      types and
      either of them is <code>char</code>,` isn't it the case that this
      must also be a narrowing conversion? Because if it's widening you
      already have said that going from any integral to any integral is
      also exact.</p>
    <p>* `Otherwise, if both S and P are primitive types, then:` - does
      this section have to spell out all cases? Or can we say that,
      again we just issue `x instanceof P` and then we explain how this
      behaves somewhere else (e.g. in chapter 15) ?</p>
    <p>* `An inexact conversion may either result in an exception and
      will not yield any value or may in no exceptions and will yield a
      value. In the latter case, loss of information has occured.` -
      this sentence seems to have some issues, especially in the second
      part (missing "result"?)<br>
    </p>
    <p>* `The narrowing reference conversion` -> `A narrowing
      reference conversion` (same for the para below)</p>
    <p>* `<em>P</em> contains a pattern with a primitive type <em>p` </em>where
      do we say that e.g. `int x` covers `int` ? This para seems to be
      about boxing</p>
    <p>* In 14.11.1.2, I see many references to "T", which is not
      introduced in this section</p>
    <p>* "then the result is true if the value of the
      RelationalExpression could be cast to the primitive type exactly,
      and false otherwise." Maybe add a reference to the section on
      exact conversion?</p>
    <p>Cheers<br>
      Maurizio<br>
      <em></em></p>
    <p><br>
    </p>
  </body>
</html>