Re: Towards a JSON API for the JDK

2025-05-21 Thread Ethan McCue
I think what has been proposed so far is powerful enough to perform that task *if* there is an intermediate object in the mix. if ( // Assuming a dual pattern for JsonString.of and the SAP // strategy outlined in the doc json instanceof index(0, JsonString::of).decode(var firstName) )

Re: Towards a JSON API for the JDK

2025-05-21 Thread Ethan McCue
I think you missed a 2.5 which is to use the information in DOM objects to perform useful work. On Wed, May 21, 2025, 1:04 PM Archie Cobbs wrote: > On Wed, May 21, 2025 at 11:30 AM Paul Sandoz > wrote: > >> I consider this a “known unknown” (in the words of Mr. Rumsfeld). We >> would need to ex

Re: Towards a JSON API for the JDK

2025-05-21 Thread Ethan McCue
In the my world - which I am again very interested in revisiting once there is a version of patterns I can touch - you may approach that problem in the following way: sealed interface Content extends JsonEncodable { static Content fromJson(Json json) { return switch (json) {

Re: Towards a JSON API for the JDK

2025-05-19 Thread Ethan McCue
What I mean by central in this context isn't that it's at the core of things and features are built on top of it - as you note it is a valid transformation of the hierarchy. What I mean is that absent other construction/deconstruction apis it is the most convenient avenue for those tasks. So code

Re: Towards a JSON API for the JDK

2025-05-17 Thread Ethan McCue
I think it's worth noting that the way you used the prospective API in your ONNX code is not representative of how the API would generally be used in a jdk-only scenario. Custom making a general transformation from JsonValue -> Record is outside the ken of i'd say most. I'd be interested in an expe

Re: Towards a JSON API for the JDK

2025-05-17 Thread Ethan McCue
I think we should pull apart those concerns a little: I am of the opinion that the API is more important at this stage than the actual implementation, save for the places where having an API of a particular shape mandates implementation choices. > The JsonNull/JsonNumber/JsonString/JsonValue here

Re: Towards a JSON API for the JDK

2025-05-16 Thread Ethan McCue
something implementing an interface differently). On Fri, May 16, 2025 at 2:26 PM wrote: > > > ------ > > *From: *"Ethan McCue" > *To: *"Remi Forax" > *Cc: *"Paul Sandoz" , "core-libs-dev" < > core-libs-

Re: Towards a JSON API for the JDK

2025-05-15 Thread Ethan McCue
I present for your consideration the library I made when spiraling about this problem space a few years ago https://github.com/bowbahdoe/json https://javadoc.io/doc/dev.mccue/json/latest/dev.mccue.json/dev/mccue/json/package-summary.html Notably missing during the design process here were patter

Re: Factory methods for SequencedSet and SequencedMap

2025-01-17 Thread Ethan McCue
Just so there are some strawman arguments against: * Does altering Set.of to maintain order increase its memory footprint? If the answer is yes, does that matter? If the answer is no, is there a new standalone collection type to add? SetThatIsOrderedInTheSameMannerAsPythonsSetIsOrderedAndThusHasNo

Re: API for determining the hash of a module

2024-12-16 Thread Ethan McCue
esentable in module infos regardless. On Mon, Dec 16, 2024 at 10:40 PM Peter Firmstone < peter.firmst...@zeus.net.au> wrote: > If you don't wish to use version numbers, why not generate a SHA256 hash > of each module instead? > > -- > Regards, > > Peter > > O

Re: API for determining the hash of a module

2024-12-16 Thread Ethan McCue
ory. On Mon, Dec 16, 2024 at 2:26 AM Alan Bateman wrote: > On 16/12/2024 02:12, Ethan McCue wrote: > > I am experimenting with making a package repository where modules are > > the artifacts (bundled as JMODs) and not jars. In this context we lack > > information about what ve

Re: API for determining the hash of a module

2024-12-15 Thread Ethan McCue
p. On Sat, Dec 14, 2024 at 12:20 AM Alan Bateman wrote: > On 14/12/2024 08:02, Ethan McCue wrote: > > Hi all, > > > > Not sure if this is best for core-libs or langtools, but best I can > > tell there is no way to determine the hash of a module programmatically. > &g

API for determining the hash of a module

2024-12-14 Thread Ethan McCue
Hi all, Not sure if this is best for core-libs or langtools, but best I can tell there is no way to determine the hash of a module programmatically. Hashes of dependent modules are recorded in JMOD files jmod describe jdks/aarch64_windows/jmods/java.base.jmod java.base@23.0.1 platform linu

Re: High cost of failed Math.*Exact calls

2024-12-12 Thread Ethan McCue
Placement in the standard library aside, I think Java needs value types and patterns before a non-throwing version of Math.multiplyExact can be made that achieves the same semantic goals. switch (Maths.multiplyExact(a, b)) { case Product.of(long result) -> {} case Product.overflow() -> {}

Does anyone have context on jdk.httpserver?

2024-01-21 Thread Ethan McCue
Hi all, Elliot[1] and I have been digging into the HTTP(S) server implementation provided by the jdk.httpserver module. It hasn't taken long to notice that the provided implementation is...lacking. Both in performance, as it places extremely low and errors out on benchmarks [2][3], and in polish,

Should we actually make Connection a TemplateProcessor?

2023-09-15 Thread Ethan McCue
One of the examples in the String Template JEPs, and a stated motivating factor behind its design, is SQL. Template processors are objects so that use cases like constructing SQL statements aren't injection prone. The questions I want to pose are: * Should java.sql provide an implementation of Te

Re: The introduction of Sequenced collections is not a source compatible change

2023-05-17 Thread Ethan McCue
tests are using 'var' and different collections > heavily. > > And the situation is a little worst than that because in between now and > the time people will use Java 21, a lot of codes will be written using Java > 11 and 17 and may found incompatible later. > > A

Re: The introduction of Sequenced collections is not a source compatible change

2023-05-04 Thread Ethan McCue
ufficiently disruptive, we > conduct a corpus experiment to evaluate the impact on the change on many > public Java libraries. Back in Project Coin in JDK 7, that basic approach > was used to help quantify various language design choices and the > infrastructure to run such experiments h

Re: The introduction of Sequenced collections is not a source compatible change

2023-05-04 Thread Ethan McCue
I guess this a good time to ask, ignoring the benefit part of a cost benefit analysis, what mechanisms do we have to measure the number of codebases relying on type inference this will break? Iirc Adoptium built/ran the unit tests of a bunch of public repos, but it's also a bit shocking if the jtr

Re: JEP-198 - Lets start talking about JSON

2023-02-28 Thread Ethan McCue
Link to the proxy which I forgot to include https://gist.github.com/bowbahdoe/eb29d172351162408eab5e4ee9d84fec On Tue, Feb 28, 2023 at 12:16 PM Ethan McCue wrote: > As an update to my character arc, I documented and wrote up an explanation > for the prototype library I was working

Re: JEP-198 - Lets start talking about JSON

2023-02-28 Thread Ethan McCue
.reveddit.com/y/rzwitserloot/?after=t1_jacpsj6&limit=1&sort=new&show=t1_jaa3x0q&removal_status=all On Fri, Dec 16, 2022 at 6:23 PM Ethan McCue wrote: > Sidenote about "Project Galahad" - I know Graal uses json for a few things > including a reflection-config.js

Re: JEP-198 - Lets start talking about JSON

2022-12-16 Thread Ethan McCue
bad, actually. [1]: I do apologize for the code sketches consistently being "what I think an interaction with a tree api should look like." That is what I have been thinking about for a while so it's hard to resist. [2]: https://youtu.be/dOgfWXw9VrI?t=1225 On Thu, Dec 15, 2022 at 6:

Re: JEP-198 - Lets start talking about JSON

2022-12-15 Thread Ethan McCue
On Thu, Dec 15, 2022 at 6:26 PM Ethan McCue wrote: > > The 95%+ use case for working with JSON for your average java coder is > best done with data binding. > > To be brave yet controversial: I'm not sure this is neccesarily true. > > I will elaborate and respond to

Re: JEP-198 - Lets start talking about JSON

2022-12-15 Thread Ethan McCue
>>it, that is that number, as long. >>- If the element is a string, parse it into a long, then get me a >>list with this one long value (because IEEE double rules mean sometimes >> you >>have to put these things in string form or they get mangled by

JEP-198 - Lets start talking about JSON

2022-12-15 Thread Ethan McCue
I'm writing this to drive some forward motion and to nerd-snipe those who know better than I do into putting their thoughts into words. There are three ways to process JSON[1] - Streaming (Push or Pull) - Traversing a Tree (Realized or Lazy) - Declarative Databind (N ways) Of these, JEP-198 expli

Re: Boilerplate to add a new module

2022-12-14 Thread Ethan McCue
Subtract one negative from that last clause On Wed, Dec 14, 2022 at 12:02 PM Ethan McCue wrote: > Thank you! > > And yeah - I'll send a separate email opining on the directions that can > go. > > The features that should be incorporated/designed for (value > classe

Re: Boilerplate to add a new module

2022-12-14 Thread Ethan McCue
more real than in 2014 when the JEP was made - so I don't think this isn't a horrible time to start some movement. On Wed, Dec 14, 2022 at 3:14 AM Alan Bateman wrote: > On 14/12/2022 03:36, Ethan McCue wrote: > > Hey all, > > > > I'm doodling on JEP-198, an

Boilerplate to add a new module

2022-12-13 Thread Ethan McCue
Hey all, I'm doodling on JEP-198, and I was wondering if anyone had a line on the boilerplate needed to add a new module to the build. Just adding src/ java.json/ share/ classes/ module-info.java java/ json/ Json.java ... was enough

Re: What is meant by "document context" in JEP 198?

2022-11-25 Thread Ethan McCue
users avoid allocations. [1]: https://mail.openjdk.org/pipermail/core-libs-dev/2022-September/094231.html [2]: https://docs.gradle.org/current/userguide/publishing_gradle_module_metadata.html On Fri, Nov 25, 2022 at 9:08 AM Alan Bateman wrote: > On 25/11/2022 13:27, Ethan McCue wrote:

Re: What is meant by "document context" in JEP 198?

2022-11-25 Thread Ethan McCue
ng to. On Fri, Nov 25, 2022 at 2:52 AM Alan Bateman wrote: > On 25/11/2022 02:04, Ethan McCue wrote: > > I suppose while I'm asking questions - what exactly are the parts of > > the JDK making use of ad-hoc json? Maybe we could ship *something* as > > a jdk.internal mo

Re: What is meant by "document context" in JEP 198?

2022-11-24 Thread Ethan McCue
I suppose while I'm asking questions - what exactly are the parts of the JDK making use of ad-hoc json? Maybe we could ship *something* as a jdk.internal module for those use cases? On Thu, Nov 24, 2022 at 8:55 PM Ethan McCue wrote: > I'm reading JEP 198 and sketching out what an i

What is meant by "document context" in JEP 198?

2022-11-24 Thread Ethan McCue
I'm reading JEP 198 and sketching out what an implementation could look like pursuant to this old conversation. https://mail.openjdk.org/pipermail/discuss/2020-April/005401.html My biggest question right now is what does the JEP mean exactly by "document context" - Parsing APIs which allow a

Re: What are the policies for internal modules?

2022-11-24 Thread Ethan McCue
(always so hard to remember to reply all) On Thu, Nov 24, 2022 at 8:26 PM Ethan McCue wrote: > The use here is giving help to the user on > misspelled classes/methods/fields like "new ArayList". > > For now we've just copy pasted the class since that seems the leas

What are the policies for internal modules?

2022-11-20 Thread Ethan McCue
There are some modules like jdk.internal.le which contain no publicly exported packages. In some of the experimentation we are doing, We want to use the jdk.internal.org.jline.utils.Levenshtien class from jdk.compiler. Mechanically, we can do this without creating any new modules by adding a quali

Re: Task for an aspiring JDK contributor

2022-11-18 Thread Ethan McCue
t; On Fri, Nov 18, 2022 at 6:23 PM Ethan McCue wrote: > >> I think there is potentially actionable feedback in that the exception >> thrown when users bump into this limitation kinda sucks >> >> jshell> Arrays.asList(1, 2, 3).add(4); >> | Exception j

Re: Task for an aspiring JDK contributor

2022-11-18 Thread Ethan McCue
st regards, >> >> -- daniel >> >> On 18/11/2022 16:29, Andreas Røsdal wrote: >> > Yes, the exception comes when adding objects to the returned list. So I >> > would like a convenient way to use Arrays to convert an array to a >> > normal modifiable j

Re: Task for an aspiring JDK contributor

2022-11-18 Thread Ethan McCue
at 11:29 AM Andreas Røsdal wrote: > Yes, the exception comes when adding objects to the returned list. So I > would like a convenient way to use Arrays to convert an array to a normal > modifiable java.util.ArrayList, instead of this AbstractList. > > > On Fri, Nov 18, 2022 at 5:2

Re: Standard Artifact Resolution API

2022-09-10 Thread Ethan McCue
s://xkcd.com/927/). For example, if the JDK were to adopt Gradle as > the tool to use to build the JDK, it could de-facto become the “JDK build > tool”. Other projects formerly part of the JDK, like JavaFX, are already > using Gradle (though not as effectively as they could). > > Any

Re: Standard Artifact Resolution API

2022-09-09 Thread Ethan McCue
rent philosophies such that > agreeing on a single dependency management tool may be too ambitious. > > Scott > > > On Sep 9, 2022, at 9:59 AM, Ethan McCue wrote: > > This email is mostly to test the waters, I expect some hostility. > > Say, as a premise, that an A

Standard Artifact Resolution API

2022-09-09 Thread Ethan McCue
This email is mostly to test the waters, I expect some hostility. Say, as a premise, that an API for resolving external dependencies was something that the JDK concerned itself with providing. I think the foundation for that is there - the POM v4 format is more or less around forever, maven style

Re: Proposal: Collection mutability marker interfaces

2022-08-26 Thread Ethan McCue
ich from the conversation so far isn't that unrealistic On Fri, Aug 26, 2022 at 11:20 AM John Hendrikx wrote: > > On 24/08/2022 15:38, Ethan McCue wrote: > > A use case that doesn't cover is adding to a collection. > > Say as part of a method's contract you state

Re: Proposal: Collection mutability marker interfaces

2022-08-26 Thread Ethan McCue
ote: > > > -- > > *From: *"Ethan McCue" > *To: *"Remi Forax" > *Cc: *"John Hendrikx" , "core-libs-dev" < > core-libs-dev@openjdk.org> > *Sent: *Wednesday, August 24, 2022 4:27:01 PM > *Subject: *Re: Proposal: C

Re: Proposal: Collection mutability marker interfaces

2022-08-24 Thread Ethan McCue
ew owners > back. > > Its cleaner to design the APIs to be defensive, either the API should > handle the List creation itself (and only expose immutable Lists) or make > defensive copies before using or saving it. > > $0.02, Roger > > > On 8/24/22 9:38 AM, Etha

Re: Proposal: Collection mutability marker interfaces

2022-08-24 Thread Ethan McCue
} } } } On Wed, Aug 24, 2022 at 10:03 AM Remi Forax wrote: > > > -- > > *From: *"Ethan McCue" > *To: *"John Hendrikx" > *Cc: *"core-libs-dev" > *Sent: *Wednesday, August 24, 2022 3:38:26 PM >

Re: Proposal: Collection mutability marker interfaces

2022-08-24 Thread Ethan McCue
but I think that's an acceptable trade-off. > > --John > > PS. Chosen names are just for illustration; there is some discussion as > what "unmodifiable" vs "immutable" means in the context of collections that > may contain elements that are mutable. In this

Re: Proposal: Collection mutability marker interfaces

2022-08-23 Thread Ethan McCue
er/src/java.base/share/classes/java/util/List.java#L1068 > > https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/java/util/ImmutableCollections.java#L168 > > Paul. > > > On Aug 23, 2022, at 4:49 PM, Ethan McCue wrote: > > > > Hi all, > >

Proposal: Collection mutability marker interfaces

2022-08-23 Thread Ethan McCue
Hi all, I am running into an issue with the collections framework where I have to choose between good semantics for users and performance. Specifically I am taking a java.util.List from my users and I need to choose to either * Not defensively copy and expose a potential footgun when I pass that