Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build the JSpecify JDK #114

Merged
merged 23 commits into from
Dec 17, 2024
Merged

Build the JSpecify JDK #114

merged 23 commits into from
Dec 17, 2024

Conversation

wmdietl
Copy link
Collaborator

@wmdietl wmdietl commented Dec 17, 2024

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...

@wmdietl
Copy link
Collaborator Author

wmdietl commented Dec 17, 2024

@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.

Copy link
Collaborator

@cpovirk cpovirk left a comment

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:

src/java.base/share/classes/java/util/Objects.java Outdated Show resolved Hide resolved
@@ -1515,7 +1515,7 @@ public synchronized Object computeIfAbsent(Object key,

@Override
public synchronized @Nullable Object compute(Object key,
BiFunction<? super Object, ?, ?> remappingFunction) {
BiFunction<? super Object, ? super Object, ? extends @Nullable Object> remappingFunction) {
Copy link
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
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?

Copy link
Collaborator

@cpovirk cpovirk left a comment

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
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
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
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
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
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
19 checks passed
@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
…ullable.

This matches [what we have for
`Map.compute`](https://github.com/jspecify/jdk/blob/7cc2fbd5f404bf5403bd1375b47024a855838fef/src/java.base/share/classes/java/util/Map.java#L1247),
noting that `Properties` is a `Hashtable<Object, Object>` and so a
`Map<Object, Object>.

See previous discussion in
#114 (comment)
cpovirk added a commit that referenced this pull request Dec 19, 2024
…ullable.

This matches [what we have for
`Map.compute`](https://github.com/jspecify/jdk/blob/7cc2fbd5f404bf5403bd1375b47024a855838fef/src/java.base/share/classes/java/util/Map.java#L1247),
noting that `Properties` is a `Hashtable<Object, Object>` and so a
`Map<Object, Object>`.

See previous discussion in
#114 (comment)
cpovirk added a commit that referenced this pull request Dec 19, 2024
…ullable. (#117)

This matches [what we have for
`Map.compute`](https://github.com/jspecify/jdk/blob/7cc2fbd5f404bf5403bd1375b47024a855838fef/src/java.base/share/classes/java/util/Map.java#L1247),
noting that `Properties` is a `Hashtable<Object, Object>` and so a
`Map<Object, Object>`.

See previous discussion in
#114 (comment)
@cpovirk cpovirk mentioned this pull request Dec 20, 2024
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