Skip to content

Build the JSpecify JDK - #114

Merged
wmdietl merged 23 commits into
mainfrom
jspecify-annotations-for-ci-2
Dec 17, 2024
Merged

wmdietl merged 23 commits into
mainfrom
jspecify-annotations-for-ci-2

Conversation

@wmdietl

@wmdietl wmdietl commented Dec 17, 2024

Copy link
Copy Markdown
Collaborator

This helps ensure all .java files successfully compile.

The basic java compilation is successful for me locally.
The final make jdk fails with:

=== Output from failing command(s) repeated here ===
* For target buildtools_create_symbols_javac__the.COMPILE_CREATE_SYMBOLS_batch:
Error occurred during initialization of boot layer
java.lang.StackOverflowError

I do not get that error when I compile eisop/jdk at https://github.com/eisop/jdk/tree/jdk-24 ... Something in a merge in this repo must have gone wrong...

cpovirk and others added 18 commits October 7, 2024 10:57
This needs to be checked against j2cl: b/201433789.
Otherwise, we get errors like this one:
src/java.base/share/classes/org/jspecify/annotations/Nullable.java:39: error: unmappable character (0x80) for encoding ascii
 * List<@nullable String> getList() { ��� }
java/time/zone/ZoneOffsetTransitionRule.java is compiled for the
bootstrap tools, so must not contain JSpecify annotations.
@wmdietl

wmdietl commented Dec 17, 2024

Copy link
Copy Markdown
Collaborator Author

@cpovirk The CI task now compiles the java files, but then also fails with

Creating support/modules_libs/jdk.security.auth/libjaas.so from 1 file(s)
Compiling up to 4 files for COMPILE_CREATE_SYMBOLS
Error occurred during initialization of boot layer
java.lang.StackOverflowError
gmake[3]: *** [Gendata.gmk:64: /home/runner/work/jdk/jdk/build/linux-x86_64-server-release/buildtools/create_symbols_javac/_the.COMPILE_CREATE_SYMBOLS_batch] Error 1
gmake[2]: *** [make/Main.gmk:139: jdk.compiler-gendata] Error 2
gmake[2]: *** Waiting for unfinished jobs....

Some earlier merge must have mixed something up... maybe you see what's going wrong?

Some of the OpenJDK GHA seem to pass. I found a simple way to disable them all, to avoid wasting cycles. Let me know if you want me to do that.

I tried to break down my changes into meaningful chunks, please have a look through my comments. In particular, you need to check whether this change is a problem.

@cpovirk cpovirk left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

I will look at the rest in more detail, but one quick response:

@Override
public synchronized @Nullable Object compute(Object key,
BiFunction<? super Object, ?, ?> remappingFunction) {
BiFunction<? super Object, ? super Object, ? extends @Nullable Object> remappingFunction) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Is the change from ? to ? extends @Nullable Object (for the BiFunction output) necessary for technical reasons? I would expect that we'd want to stick with ? to match what the JDK has: With the annotation on the wildcard bound, which doesn't exist in the JDK class file, we end up with 1: #8(): METHOD_FORMAL_PARAMETER, param_index=1, location=[TYPE_ARGUMENT(2), WILDCARD], i.e., an annotation for a bound that doesn't exist. (We had trouble with bogus annotation locations previously in Remove method-level Atomic annotations. #56.) Now maybe the JDK has had different types at different times (though I checked JDK 11 and JDK 17, and both had the bare ?).
  • The change from ? to ? super Object (for the second input of the BiFunction) seems strange in another way: That parameter is normally nullable (including in Map and in Hashtable). I could understand ? super @Nullable Object if we needed that instead of ? (as discussed in the previous bullet), but the non-null type is stranger.

If it turns out that we do need the types written this way here and need them written differently inside Google, we can accomplish it with a patch easily enough. I just want to understand where we stand (and be ready to warn NullAway or others if we learn of problems).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original signature produces a Java error:

src/java.base/share/classes/java/util/Properties.java:1517: error: name clash: compute(Object,BiFunction<? super Object,?,?>) in Properties and compute(Object,BiFunction<? super Object,? super Object,? extends Object>) in Hashtable have the same erasure, yet neither overrides the other
    public synchronized @Nullable Object compute(Object key,
                                         ^

I need to change it to at least BiFunction<? super Object,? super Object,?> to make Java happy. I removed the @Nullable, I added that too eagerly.
Is the new signature okay?

@cpovirk cpovirk left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can talk more about Properties. Everything else looks great. Thanks again.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We had dropped this intentionally. But I'm actually all for restoring it: We changed the way we use these stubs inside Google so that we drop all files without JSpecify annotations, including this one. So it doesn't matter what we have in this file :) (Now, if we someday add JSpecify annotations to the class, then we'd have an issue. But we might be better off solving that by manually omitting the file inside Google, which we have multiple ways to do.)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to restore that file's history? Maybe by reverting that earlier commit?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried git revert 0d2d6b6e5515313d48478d39115e689cd13a3767 and that fails, at least in this branch.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect that we're out of luck for blame output. I can still see history with...

git log src/java.desktop/share/classes/java/awt/color/ICC_Profile.java

...or even more with...

git log --full-history -- src/java.desktop/share/classes/java/awt/color/ICC_Profile.java

Maybe that's good enough?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect that we're out of luck for blame output. I can still see history with...

git log src/java.desktop/share/classes/java/awt/color/ICC_Profile.java

...or even more with...

git log --full-history -- src/java.desktop/share/classes/java/awt/color/ICC_Profile.java

Maybe that's good enough?

@wmdietl
wmdietl merged commit c9befbc into main Dec 17, 2024
@wmdietl
wmdietl deleted the jspecify-annotations-for-ci-2 branch December 17, 2024 23:50
cpovirk added a commit that referenced this pull request Dec 19, 2024
cpovirk added a commit that referenced this pull request Dec 19, 2024
cpovirk added a commit that referenced this pull request Dec 19, 2024
@cpovirk cpovirk mentioned this pull request Dec 20, 2024
cpovirk added a commit that referenced this pull request Nov 10, 2026
This should address the error that just popped up, as [seen](https://github.com/jspecify/jdk/actions/runs/42861855071/job/129989794061?pr=179) in #179:

```
Reading package lists...
Building dependency tree...
Reading state information...
Package g++-10 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Unable to locate package gcc-10
E: Package 'g++-10' has no installation candidate
```

It turns out that we haven't been using GCC 10 all this time, anyway, so it's safe to remove, Gemini explains:

> Yes, this is directly caused by GitHub's `ubuntu-latest` migration from Ubuntu 24.04 to Ubuntu 26.04 ([actions/runner-images#14748](actions/runner-images#14748), rolling out October 19 – November 19, 2026):
>
> 1. **Why it failed:** [jspecify.yml](https://github.com/jspecify/jdk/blob/main/.github/workflows/jspecify.yml#L11-L30) uses `runs-on: ubuntu-latest` and runs `sudo apt-get install gcc-10 g++-10 ...`. Ubuntu 26.04 dropped `gcc-10` and `g++-10` from its APT repositories.
> 2. **Why we don't even need `gcc-10` / `g++-10`:** When [jspecify.yml](https://github.com/jspecify/jdk/blob/main/.github/workflows/jspecify.yml) was originally created (#114), the `apt-get install gcc-10 g++-10` line was copied from upstream OpenJDK's [build-linux.yml](https://github.com/jspecify/jdk/blob/main/.github/workflows/build-linux.yml#L128-L141)—**without** the accompanying `update-alternatives` command (or `CC`/`CXX` configure arguments). As a result, `./configure` in `jspecify.yml` has never actually used `gcc-10`/`g++-10`; it has always just used the runner's pre-installed default `/usr/bin/gcc` and `/usr/bin/g++` (GCC 13 on Ubuntu 24.04, and GCC 15 on Ubuntu 26.04).
> 3. **Recommended fix:** Simply drop `gcc-10 g++-10` from the `apt-get install` line in [jspecify.yml](https://github.com/jspecify/jdk/blob/main/.github/workflows/jspecify.yml#L29). Current OpenJDK 28 sources in this branch already support GCC 15 (which is also what your local workstation has configured in `build/linux-x86_64-server-release`), and `jspecify.yml` already passes `--disable-warnings-as-errors`. (If anything else in Ubuntu 26.04 ever causes trouble, you could also pin `runs-on: ubuntu-24.04` to match upstream [main.yml](https://github.com/jspecify/jdk/blob/main/.github/workflows/main.yml#L60).)

(Maybe we *should* find the version that upstream uses, install that, and run `update-alternatives` for that. But for now, I'm happy to get the build working again, and we can cross that bridge when we come to it.)
cpovirk added a commit that referenced this pull request Nov 10, 2026
They started failing recently because of a non-hermetic build, and we've never wanted them.

Gemini on all that:

> ### 1. Do we want this CI job? (No—it’s already half-disabled and does nothing useful)
>
> * The failing job (`Prepare the run`) is in [main.yml](https://github.com/jspecify/jdk/blob/main/.github/workflows/main.yml#L58-L91) (`OpenJDK GHA Sanity Checks`), which is upstream OpenJDK's CI workflow.
> * Back in PR #114 (c9befbc), `WMD` disabled all of the actual build/test jobs in [main.yml](https://github.com/jspecify/jdk/blob/main/.github/workflows/main.yml#L126-L129) by making `check_platform()` output `false` when `platforms` is empty:
>   ```bash
>   # echo 'true'
>   # WMD: Assume empty means no platforms
>   echo 'false'
>   return
>   ```
> * However, `main.yml` still triggers `on: push` (both on `main` and on any branch pushed directly to `jspecify/jdk`, such as `gcc` in PR #180) and still runs the `prepare` job before checking which platform jobs to run.
> * All `prepare` does is run [build-jtreg/action.yml](https://github.com/jspecify/jdk/blob/main/.github/actions/build-jtreg/action.yml) to build JTReg from source and upload a `bundles-jtreg-8.3+1` artifact, and then output `false` for every platform so all downstream jobs are skipped and nothing ever uses the artifact. (Meanwhile, JSpecify's actual CI in [jspecify.yml](https://github.com/jspecify/jdk/blob/main/.github/workflows/jspecify.yml#L31-L34) downloads prebuilt `jtreg` from `builds.shipilev.net`.)
>
> ---
>
> ### 2. Why did it start failing on PR #177?
>
> The `actions/setup-java` bump in PR #177 was a coincidence (`setup-java` is only used in [jspecify.yml](https://github.com/jspecify/jdk/blob/main/.github/workflows/jspecify.yml#L21), whereas [build-jtreg/action.yml](https://github.com/jspecify/jdk/blob/main/.github/actions/build-jtreg/action.yml#L56) uses the runner's preinstalled `$JAVA_HOME_17_X64`):
>
> 1. [build-jtreg/action.yml](https://github.com/jspecify/jdk/blob/main/.github/actions/build-jtreg/action.yml#L38-L61) caches the built JTReg directory under `key: jtreg-8.3+1` (from `JTREG_VERSION` in [github-actions.conf](https://github.com/jspecify/jdk/blob/main/make/conf/github-actions.conf#L29)) and skips downloading/building JTReg whenever there is a cache hit.
> 2. When you merged upstream OpenJDK on Sep 21 (`e89cf6d97e5`), `build-jtreg` built `jtreg-8.3+1` once and populated that cache. Every push to `main` through PR #176 (`Oct 13, 18:48 EDT`) hit that cache entry and refreshed its 7-day GitHub Actions TTL.
> 3. PR #177 was merged on `Oct 20, 21:01 EDT`—**7 days and ~2 hours** after PR #176—just after GitHub Actions evicted the `jtreg-8.3+1` cache entry for inactivity.
> 4. On the cache miss, `build-jtreg` tried to build JTReg from source, which runs `wget https://git.openjdk.org/jtharness/archive/jt6.0-b24.zip`. `git.openjdk.org` is returning an HTTP error response (`wget` exit code 8) to GitHub Actions runner requests. Because the build fails, the cache is never repopulated, so every subsequent push fails the same way.
>
> ---
>
> ### 3. How to get rid of the red X
>
> There are two clean ways to stop `OpenJDK GHA Sanity Checks` from running on pushes:
>
> 1. **In `.github/workflows/main.yml` (recommended if you want it tracked in git):**
>    Comment out or remove the `push:` trigger in [main.yml](https://github.com/jspecify/jdk/blob/main/.github/workflows/main.yml#L28-L32) so only `workflow_dispatch:` remains (right next to the existing local diff at lines 36–37):
>    ```yaml
>    on:
>    #  push:
>    #    branches-ignore:
>    #      - pr/*
>      workflow_dispatch:
>    ```
> 2. **In GitHub repo settings (zero diff against upstream):**
>    Disable the `OpenJDK GHA Sanity Checks` workflow in the GitHub Actions UI (or via `gh workflow disable "OpenJDK GHA Sanity Checks" -R jspecify/jdk`).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants