<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">
<div>Those extending the non-sealed subtypes of JsonValue must conform to the requirements that are specified. The current documentation could be more clearly written as to what those requirements are. Of course we cannot enforce those requirements any more
than we can enforce the requirements specified for implementations of List.</div>
<div>
<div>
<div><br>
</div>
<div>Paul.<br id="lineBreakAtBeginningOfMessage">
<div><br>
<blockquote type="cite">
<div>On May 19, 2025, at 1:56 PM, forax@univ-mlv.fr wrote:</div>
<br class="Apple-interchange-newline">
<div>
<div style="caret-color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 16px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">
<br class="Apple-interchange-newline">
<br>
</div>
<hr id="zwchr" data-marker="__DIVIDER__" style="font-family: arial, helvetica, sans-serif; font-size: 16px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">
<div data-marker="__HEADERS__" style="caret-color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 16px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">
<blockquote style="border-left-width: 2px; border-left-style: solid; border-left-color: rgb(16, 16, 255); margin-left: 5px; padding-left: 5px; font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica, Arial, sans-serif; font-size: 12pt;">
<b>From:<span class="Apple-converted-space"> </span></b>"Paul Sandoz" <paul.sandoz@oracle.com><br>
<b>To:<span class="Apple-converted-space"> </span></b>"Remi Forax" <forax@univ-mlv.fr><br>
<b>Cc:<span class="Apple-converted-space"> </span></b>"Brian Goetz" <brian.goetz@oracle.com>, "core-libs-dev" <core-libs-dev@openjdk.org><br>
<b>Sent:<span class="Apple-converted-space"> </span></b>Monday, May 19, 2025 10:02:50 PM<br>
<b>Subject:<span class="Apple-converted-space"> </span></b>Re: Towards a JSON API for the JDK<br>
</blockquote>
</div>
<div data-marker="__QUOTED_TEXT__" style="caret-color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 16px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">
<blockquote style="border-left-width: 2px; border-left-style: solid; border-left-color: rgb(16, 16, 255); margin-left: 5px; padding-left: 5px; font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica, Arial, sans-serif; font-size: 12pt;">
<br id="lineBreakAtBeginningOfMessage">
<div><br>
<blockquote>
<div>On May 19, 2025, at 8:16 AM, Remi Forax <forax@univ-mlv.fr> wrote:</div>
<br class="Apple-interchange-newline">
<div>
<div>
<div style="font-family: arial, helvetica, sans-serif; font-size: 12pt;">
<div>Okay,</div>
<div>i've taken a look to the design and this is not pretty.</div>
<div><br>
</div>
</div>
</div>
</div>
</blockquote>
<div><br>
</div>
That seems an exaggerated statement to me. It's a trade-off, a compromise, allowing others to implement their own parsers, perhaps from non-textual representations. So of course we cannot enforce certain constraints and we need to specify how implementations
must behave.</div>
<div><br>
</div>
<div><br>
<blockquote>
<div>
<div>
<div style="font-family: arial, helvetica, sans-serif; font-size: 12pt;">
<div>The main issue is that the javadoc claims that</div>
<div> "Both<span class="Apple-converted-space"> </span><code>JsonValue</code><span class="Apple-converted-space"> </span>instances and their underlying values are immutable."</div>
<div>but at the same time any subtypes of JsonValue is non-sealed so anyone can implement let say JsonString and adds it's own mutable implementation.</div>
</div>
</div>
</div>
</blockquote>
</div>
</blockquote>
<div><br>
</div>
<div>You can not claim that JsonValue instances are immutable while obviously they are not.</div>
<div>You can not claim that JsonValue subtypes are ADTs while obviously JsonValue is not algebraic.</div>
<div><br data-mce-bogus="1">
</div>
<div>You allow anybody to write their own class inside the JsonValue hierarchy, so there is no safety, strings can be not escaped correctly, number can represent invalid values, etc.</div>
<div><br data-mce-bogus="1">
</div>
<div>The minute I write a method that takes a JsonValue as parameter i'm writing unsafe code,<span class="Apple-converted-space"> </span><br>
</div>
<div><br data-mce-bogus="1">
</div>
<div>You are hoping that nobody will ever extend JsonValue subtypes, that's wishful thinking, this is not a safe design ... this is not pretty.</div>
<div><br data-mce-bogus="1">
</div>
<div>Rémi</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</body>
</html>