-
Notifications
You must be signed in to change notification settings - Fork 3
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
Conversation
…cify/jdk into jspecify-annotations-for-ci-2
…annotations-for-ci-2
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.
@cpovirk The CI task now compiles the java files, but then also fails with
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. |
There was a problem hiding this 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:
@@ -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) { |
There was a problem hiding this comment.
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 theBiFunction
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 with1: #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-levelAtomic
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 theBiFunction
) seems strange in another way: That parameter is normally nullable (including inMap
and inHashtable
). 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).
There was a problem hiding this comment.
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?
There was a problem hiding this 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.
There was a problem hiding this comment.
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.)
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
Co-authored-by: Chris Povirk <[email protected]>
There was a problem hiding this comment.
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?
…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)
…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)
…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)
This helps ensure all
.java
files successfully compile.The basic java compilation is successful for me locally.
The final
make jdk
fails with: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...