-
Notifications
You must be signed in to change notification settings - Fork 26
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
Make sure that our multi-release jar actually lets people use module-scope @NullMarked #245
Comments
On the Gradle front, I found a bug that sound potentially related: gradle/gradle#19587. I also wasn't surprised to find that the Gradle people recommend that library authors instead use their mechanism for separate jars, the thing that I continually feel guilty for not enabling for Guava. Separate jars is certainly a possible fallback option, though Guava users are familiar with some of the resulting pain, and Gradle's work to eliminate that pain won't help users of other build systems. Also, to be clear: @KengoTODA had added some tests to make sure that the right version of And that problem was:
...when I tried to make this change to Caffeine. |
At least in a small repo that doesn't have much code, adding the
that
is printed as output. |
Also I grabbed the source (and generated sources) from caffeine, pulled them into a new project and was able to compile with the NullMarked annotation. Not sure why the upstream caffeine project can't. |
Thank you very much for checking that! The Caffeine finding is still a little concerning: Whatever is going on with the Gradle configuration, clearly that particular compiler invocation is targeting Java 9 or higher, since it's compiling a module-info. But it's great to know that a more vanilla configuration works: The problem isn't quite so bad, and we have an idea of where we could start looking for the problem. |
Perhaps there's a bug in javac? Or in how gradle invokes javac? I was able to get your branch to build by removing the |
Ah, that's very interesting! I had been thinking of "targeting Java 9 or higher" as a single yes/no question. But in fact, |
(Sorry, my post is a bit cryptic -- trying to post quickly at the end of my day.) |
Fwiw, in my personal mini caffiene testing project, it's about as minimal as it gets, and I can reproduce the issue just by uncommenting the |
Which might suggest it's not specific to caffiene's build script, but potentially in gradle itself. |
Ouch! At minimum, it is quite surprising that To be fair:
So, to recap, we're now seeing trouble in IntelliJ and sometimes Gradle, and I'm not sure we're getting anything out of it. We may well still need our multi-compilation setup so that we can build Java 8 bytecode for our main classes while still building a |
No, wait, we still get the warning, at least in the testing I'm doing right now:
We may still have to live with that, given the alternative.... |
…o` out. Fixes jspecify#245. But introduces a compile warning for users targeting old versions of Java, and introduces runtime problems if a user tries to read _the annotations on `@NullMarked` itself_. Fixes jspecify#172. I didn't really need to do this in the same commit. I just happened to get things working that way first, and we've talked about at least trying this change, so here goes.... It's clear that there's no great option for `MODULE`. But given that we've already encountered problems in the wild with our old approach, let's try this new approach instead.
…o` out. Fixes jspecify#245. But introduces a compile warning for users targeting old versions of Java, and introduces [runtime problems](https://bugs.openjdk.java.net/browse/JDK-8247797) if a user tries to read _the annotations on `@NullMarked` itself_. Fixes jspecify#172. I didn't really need to do this in the same commit. I just happened to get things working that way first, and we've talked about at least trying this change, so here goes.... It's clear that there's no great option for `MODULE`. But given that we've already encountered problems in the wild with our old approach, let's try this new approach instead.
I put together #246 to include If Java 8 users do have a problem with the artifact we release after #246, they may at least have the option of defining an annotation that |
I looked into javac code, and the current behaviour for unknown Similarly, an unknown enum constant in an annotation array value causes the whole array to be invalid23 when viewed using reflection. Footnotes
|
Thanks. javac's And the reflection source code suggests that the problem you likely already saw in https://github.com/jspecify/jspecify/pull/246/files#diff-6a22a6ede57062df5613483ebcc3fd278316078440bc35c7bf253ef49e89ee12R58 is still around even today. |
…o` out. (#246) Fixes #245. But introduces a compile warning for users targeting old versions of Java, and introduces [runtime problems](https://bugs.openjdk.java.net/browse/JDK-8247797) if a user tries to read _the annotations on `@NullMarked` itself_. Fixes #172. I didn't really need to do this in the same commit. I just happened to get things working that way first, and we've talked about at least trying this change, so here goes.... It's clear that there's no great option for `MODULE`. But given that we've already encountered problems in the wild with our old approach, let's try this new approach instead.
I was just tempted to summarize our findings here as "the idea seems to be that a compiler should be able to look at whichever version it wants." I probably still will do that, but I want to note a small caveat: We seem to be able to put |
I had found that it works for plain javac invocations, and I believe eamonnmcmanus was the one who confirmed for us that it works with NetBeans. But we had seen a report that it doesn't work with IntelliJ, and we haven't tried Eclipse.
And now... I tried to use module-scope
@NullMarked
in a Gradle project that uses--release 11
, and:That's happening even though I see a
jspecify-0.2.0.jar
(with what looks like the right contents) on the--module-path
when I pass-d
to Gradle.[edit: Apparently kotlinc doesn't look under
META-INF/versions
, either. But that's mostly academic: Users won't need to write JSpecify annotations in Kotlin sources (except in rare cases until KT-47417 is implemented), and even if they do, they won't be putting an annotation on a module.][edit: I wonder what Turbine does....]
The text was updated successfully, but these errors were encountered: