On Wed, 17 Sep 2025 10:17:33 GMT, Magnus Ihse Bursie <[email protected]> wrote:
> The only remaining shell script that is being used in the gensrc phase to
> generate Java code is for the nio exceptions. This should be removed as well,
> and replaced with a standard solution (Java buildtool or makefile API calls).
Some implementation notes:
I considered writing a Java buildtool to read the existing `exceptions` files,
but that seemed like a lot of work to keep up with a format that was not really
ideal anyway, but was in fact a shell script snippet, disguised as a data file.
The `*.java.template` method aligns better with most other gensrc solutions.
This also makes it easier to get a better understanding of how the resulting
file will look. As a matter of fact, the generated file with the old solution
did not match up with how our files should look. I modified the template to
follow this pattern. As an effect of this, all generated files has a diff (in
whitespace or comments only) with this code compared to the old, like this:
--- ReadOnlyBufferException.java 2025-09-11 11:55:45
+++ NEW/ReadOnlyBufferException.java 2025-09-12 17:40:57
@@ -1,6 +1,5 @@
/*
- * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
- *
+ * Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -22,14 +21,10 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
-// -- This file was mechanically generated: Do not edit! -- //
-
package java.nio;
-
/**
* Unchecked exception thrown when a content-mutation method such as
* <code>put</code> or <code>compact</code> is invoked upon a read-only buffer.
@@ -48,5 +43,4 @@
* Constructs an instance of this class.
*/
public ReadOnlyBufferException() { }
-
}
I consider this an improvement, not a bug.
I also discovered a real bug. Due to how the old `exceptions` files were
actually shell script snippets that were included and executed, proper care
needed to be taken in how to handle quotes. This was not done for
`IllegalCharsetNameException.java`. The `"` were eaten by the shell, so the
generated Java code was:
* <a href=Charset.html#names>legal charset name</a> is used as such.
instead of (the intended, and correct)
* <a href="Charset.html#names">legal charset name</a> is used as such.
That is fixed with this PR.
Apart from these changes, the generated files are identical before and after
this PR.
I don't understand what is going on with GHA. It works perfectly well on my
local computer and Oracle's internal CI system.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/27338#issuecomment-3302348906
PR Comment: https://git.openjdk.org/jdk/pull/27338#issuecomment-3302581306