Skip to content

Crash during compilation on JDK 8 when using JSpecify 0.3.0-alpha-1 #302

Open

Description

@msridhar

NullAway branch is here:

https://github.com/uber/NullAway/tree/update-jspecify

This is the crash (see here), which comes when running ./gradlew :test-java-lib:compileJava on a JDK 8 JVM:

warning: unknown enum constant java.lang.annotation.ElementType.MODULE
warning: unknown enum constant java.lang.annotation.ElementType.MODULE
An exception has occurred in the compiler (1.8.0_345). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program and the following diagnostic in your report. Thank you.
java.lang.AssertionError: annotationType(): unrecognized Attribute name MODULE (class com.sun.tools.javac.util.UnsharedNameTable$NameImpl)
        at com.sun.tools.javac.util.Assert.error(Assert.java:133)
        at com.sun.tools.javac.code.TypeAnnotations.annotationType(TypeAnnotations.java:231)
        at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.separateAnnotationsKinds(TypeAnnotations.java:294)
        at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.visitMethodDef(TypeAnnotations.java:1066)
        at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:778)
        at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
        at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.scan(TypeAnnotations.java:275)
        at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:57)

From #34 I can't tell if this was intended or not. Do we not support using JSpecify annotations when building on JDK 8? Building on JDK 8 is not a requirement for NullAway (we're planning to remove JDK 8 support soon); I am just wondering if this was intentional.

Activity

  1. msridhar commented on Oct 8, 2022

    @msridhar
    CollaboratorAuthor
  2. msridhar commented on Oct 10, 2022

    @msridhar
    CollaboratorAuthor

    After further thought I realized we probably want to have NullAway support JDK 8 for some time longer, to support more open-source projects that haven't updated. So having JSpecify support building with JDK 8 would be helpful to us.

  3. cpovirk commented on Oct 10, 2022

    @cpovirk
    Collaborator

    Thanks very much for testing this and for the repro instructions.

    This is new: We'd known that building with Java 8 could produce a warning (which becomes an error under -Werror), and we'd known that reflection under Java 8 could lead to exceptions at runtime. But I don't think we'd known of build-time crashes.

    Brain dump follows.

    Testing notes

    It does appear that the code compiles fine if the usages of @NullMarked and @NullUnmarked appear only on classes, at least in the testing I've done so far.

    (I would say "And the code compiles fine with the 0.2.0 release," but: In order to test with 0.2.0, I have to change the test code such that... the usages of @NullMarked and @NullUnmarked appear only on classes :) And we already know that that's enough to eliminate the error.)

    One annotation of either type on a method is enough to produce the error. That's true even if the annotation is redundant on account of a matching annotation on the enclosing class.

    Removing MODULE from the @Target of the all annotations that are used in the file being compiled eliminates the problem. Removing it from any annotations that aren't used doesn't, though it eliminates the relevant "unknown enum constant ElementType.MODULE" warning. (I didn't test this all exhaustively, but that appears to be what's going on.) Moving MODULE to come after PACKAGE in NullUnmarked.java (as it already was in NullMarked.java) does not help.

    It also appears that the code compiles fine if I build with JDK11 but with --release 8 (options.compilerArgs += ["--release", "8"] in test-java-lib/build.gradle)... well, aside from the usual "unknown enum constant" warning, the one that becomes an error under -Werror until I turn that off in build.gradle.

    Finally, it appears that NullAway is not necessary for the crash: A build of your Methods.java with plain javac8 likewise crashes.

    Why this is happening

    Part of the story here is almost certainly #245: We used to have the MODULE target on @NullMarked only in a Java-9+ copy in the jar. But that turned out to not always let people actually use the annotation on a module. So 0.3.0-alpha-1 switched us to having only a single copy of @NullMaked, which naturally includes the MODULE target.

    It's still a bit of a mystery as to why this error appears only with certain test code. [edit: I believe msridhar suggested that it has something to do with which cases javac needs to ask "Is this a type-use annotation, an annotation applicable to this element, or both?] But it's not surprising in general that a "missing" internal class could cause problems for javac, and it's not surprising that that could cause crashes that appear and disappear for mysterious reasons.

    How to avoid it

    In an ideal world, everyone would build with a newer JDK, even if they target Java 8, typically by using --release. (See, for example, #271 (comment).) But using --release can be kind of a pain. (See, for example, google/guava#3990.) And beyond that, upgrading javac is often easy but can sometimes require some work.

    A theoretical way for a project to continue to be able to build with javac8 to use a @ModulelessNullMarked alias that @Implies(NullMarked.class) but does not include MODULE in its @Target. (My naive reading of javac is that it might be OK for dependencies of that project to continue using plain @NullMarked: The specific crash here is in code that I don't think runs on binary deps, only on source code. However, it's possible that there's similar code that does run when looking at binary deps. We'd have to test. If binary deps produce a similar issue, then all the JSpecify-using libraries that that project depends on would also need to use a @ModulelessNullMarked alias. And "unfortunately," those libraries' developers wouldn't notice that they need to use the special annotation that unless they built with javac8 themselves. If we did end up wanting to go this direction, then we could consider providing a standard "@ModulelessNullMarked" annotation.) Note that this alias might also help with runtime reflection, but I wouldn't say that confidently until we'd actually implemented it :) For that matter, I'm not even sure if the build-time crash would necessarily go away. Ah, we could probably make most (all?) of the problems go away if tools had a special case for this standard "@ModulelessNullMarked" annotation (as opposed to relying on normal @Implies logic). But that's a little gross.

    Another spin on that possibility is for the main @NullMarked to be the one to not contain MODULE in its @Target. We'd then probably want to supply a standard alias that does target modules. (Or maybe the aliasing would run in the reverse direction, as in my previous option: Then the canonical annotation would be @NullMarked.NullMarkedModule, and @NullMarked would imply it. That way, we avoid having an annotation with @Target(MODULE) imply one without @Target(MODULE), which I think we've been assuming would be unrecognized (1, 2)? But maybe giving @NullMarked.NullMarkedModule @Target(MODULE) reintroduces many of the problems I was trying to avoid?) The hope then would be that eventually we could add MODULE to the @Target of @NullMarked once javac8 use is really dead. This has the advantage that the negative experience is mostly limited to people who try to put @NullMarked on a module, get a clear error, and hopefully read enough of our docs to see that @NullMarked.NullMarkedModule is available as a workaround.

    A different approach is to omit @Target entirely. But that has the obvious downsides. Plus, it sounds like it still doesn't actually work how it's intended to: #34 (comment).

    This continues to need more thought

    Yuck. But thanks again.

  4. added this to the 0.3 milestone on Oct 10, 2022
  5. cpovirk commented on Oct 10, 2022

    @cpovirk
    Collaborator

    Oh, this is a good place to recall that MODULE makes annotations usable elsewhere under some versions of javac. That is a small and gross but practical reason to avoid it on the main annotation. It would also be a reason for tools to more carefully validate the locations on which annotations appear... which in turn could make the no-@Target approach more appealing, if only that approach, you know, worked :)

  6. msridhar commented on Oct 10, 2022

    @msridhar
    CollaboratorAuthor

    Thanks so much for investigating, @cpovirk. I have one question. Based on the stack trace and error message, I don't think this crash in JDK 8 javac is intended behavior. Also it looks like one can at least still backport fixes to JDK 8 for future patch releases. Here is the line of code throwing the assertion error:

    https://github.com/openjdk/jdk8u-dev/blob/d285382278fcb76ceddfb61cf8bb047ff269de44/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java#L231

    I wonder if we could submit a PR that changes this assertion to something less crash-y? Like maybe emit another warning instead for an unknown enum constant? Then at least this issue could be fixed in a future JDK 8 release, which gives us more options (like leaving things the way they are and telling users to update their JDK 8 release). Of course this doesn't help with working around the current crash.

    It looks like someone submitted an issue on this before:

    https://bugs.openjdk.org/browse/JDK-8279557

    They didn't have a reproducer so it got closed, but we have one now. If we think it's worthwhile, I can try to re-open that issue or submit a new one, to see if we get feedback on the possibility of a change. Let me know if we think that's worth a try.

  7. cpovirk commented on Oct 10, 2022

    @cpovirk
    Collaborator

    Thank you! That is a better thought than any of the thoughts in my post :)

    It does seem likely that upstream would like the compiler to not crash, regardless of how strange the code we feed it is.

    It's possible that they could respond by changing the crash into a more normal but still fatal error, or it's possible that they don't deem this fix worth backporting. But maybe they'll see the value in making it easier for libraries to use the MODULE target. (As noted in #245, we tried solving this problem with multi-release jars instead. But it's not clear if multi-release jars are supposed to solve this problem, and regardless, they don't under some major tools today.)

    Reproducing does look easy. If you're up for taking things to upstream, that would be terrific.

    $ tail -n +1 *.java 
    ==> A.java <==
    import static java.lang.annotation.ElementType.METHOD;
    import static java.lang.annotation.ElementType.MODULE;
    
    import java.lang.annotation.Target;
    
    @Target({METHOD, MODULE})
    @interface A {}
    
    ==> B.java <==
    class B {
      @A void b() {}
    }
    $ $HOME/openjdk-11.0.16/bin/javac -source 8 -target 8 -sourcepath doesnotexist A.java && $HOME/openjdk-8u342/bin/javac -cp . -sourcepath doesnotexist B.java
    warning: [options] bootstrap class path not set in conjunction with -source 8
    1 warning
    warning: unknown enum constant ElementType.MODULE
    An exception has occurred in the compiler (1.8.0_342). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program and the following diagnostic in your report. Thank you.
    java.lang.AssertionError: annotationType(): unrecognized Attribute name MODULE (class com.sun.tools.javac.util.SharedNameTable$NameImpl)
            at com.sun.tools.javac.util.Assert.error(Assert.java:133)
            at com.sun.tools.javac.code.TypeAnnotations.annotationType(TypeAnnotations.java:231)
            at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.separateAnnotationsKinds(TypeAnnotations.java:294)
            at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.visitMethodDef(TypeAnnotations.java:1066)
            at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:778)
            at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
            at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.scan(TypeAnnotations.java:275)
            at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:57)
            at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.visitClassDef(TypeAnnotations.java:1042)
            at com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:693)
            at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
            at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.scan(TypeAnnotations.java:275)
            at com.sun.tools.javac.code.TypeAnnotations$1.run(TypeAnnotations.java:127)
            at com.sun.tools.javac.comp.Annotate.flush(Annotate.java:152)
            at com.sun.tools.javac.comp.Annotate.enterDone(Annotate.java:129)
            at com.sun.tools.javac.comp.Enter.complete(Enter.java:512)
            at com.sun.tools.javac.comp.Enter.main(Enter.java:471)
            at com.sun.tools.javac.main.JavaCompiler.enterTrees(JavaCompiler.java:982)
            at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:857)
            at com.sun.tools.javac.main.Main.compile(Main.java:523)
            at com.sun.tools.javac.main.Main.compile(Main.java:381)
            at com.sun.tools.javac.main.Main.compile(Main.java:370)
            at com.sun.tools.javac.main.Main.compile(Main.java:361)
            at com.sun.tools.javac.Main.compile(Main.java:56)
            at com.sun.tools.javac.Main.main(Main.java:42)
    
  8. msridhar commented on Oct 10, 2022

    @msridhar
    CollaboratorAuthor

    I will report this upstream and then report back. Let's hope for a positive response :-)

  9. msridhar commented on Oct 14, 2022

    @msridhar
    CollaboratorAuthor

    The bug report got created:

    https://bugs.openjdk.org/browse/JDK-8295314

    However, it got erroneously closed as "Cannot reproduce" because the repro instructions were not followed correctly (JDK 17 was used to compile B.java instead of JDK 8).

    I will try to use a link they provided to "submit additional info" to clarify. But @cpovirk @kevinb9n if we know someone with a JDK bug system account who could comment directly, that might be more effective.

  10. cpovirk commented on Oct 14, 2022

    @cpovirk
    Collaborator

    Thanks. I think @eamonnmcmanus said that he had The Power? Éamonn, are you up for it?

  11. eamonnmcmanus commented on Oct 14, 2022

    @eamonnmcmanus
    Collaborator

    I do indeed have an openjdk.org account. Let me know if "submit additional info" doesn't produce the desired results and I can comment on the bug.

  12. msridhar commented on Oct 15, 2022

    @msridhar
    CollaboratorAuthor

    Update: it looks like "submit additional info" worked as the bug has been re-opened. Not sure who would look at this / prioritize it. I'll wait a bit and see what happens.

  13. msridhar commented on Oct 20, 2022

    @msridhar
    CollaboratorAuthor

    For those familiar with the JDK bug reporting process: is there any way to know if JDK-8295314 has or will be triaged? I am wondering how we can get the right eyes on it. I think we have a good case that it's worth fixing, but probably we need someone involved with JDK 8 maintenance to see it for it to get noticed, and I'm not sure if that will happen automatically.

    We're about to add a one-off @NullUnmarked annotation to a project because of this issue 😐

  14. msridhar commented on Oct 27, 2022

    @msridhar
    CollaboratorAuthor

    Update: thanks to help from @cushon and @cpovirk, we discovered this bug still exists in the latest version of javac if you create a .class file for an annotation with an invalid ElementType in its @Target meta-annotation. This has been filed as a new bug against JDK 19:

    https://bugs.openjdk.org/browse/JDK-8296010

    Our hope is that the new bug gets fixed in the latest Java version, and that eventually we can backport the fix all the way to JDK 8.

  15. removed this from the 0.3 milestone on Nov 9, 2022
  16. 12 remaining items

  17. cpovirk commented on Mar 18, 2024

    @cpovirk
    Collaborator

    Sorry, I lost track of this thread... among others recently... :(

    We had tried a multi-release jar for this purpose a couple years ago, and it turns out that it doesn't achieve that purpose. The idea of a multi-release jar is that the API of the classes is supposed to match across versions. The definition of "API" was left a little fuzzy AFAICT, but the idea seems to (mostly?) be that a compiler should be able to look at whichever version it wants. That means that we can't count on it to look at the version that contains MODULE in its @Target, and indeed multiple tools currently don't do that.

    Or maybe the tools are buggy. Even if so, we probably don't want to take an approach that will cause problems for those tools in order to work around a problem with a tool (javac) that is probably at least easier to migrate off of (by upgrading to javac 9+, even while still targeting older versions of Java).

  18. cpovirk commented on Mar 18, 2024

    @cpovirk
    Collaborator

    (But thank you for raising that suggestion! I wish that it had worked out....)

  19. cpovirk commented on Jul 12, 2024

    @cpovirk
    Collaborator

    I should write down a clarification here, since I was missing it myself:

    There are two distinct problems that the @Target(MODULE, ...) on NullMarked can cause:

    1. java.lang.AssertionError: annotationType(): unrecognized Attribute name MODULE
    2. warning: unknown enum constant ElementType.MODULE

    (OK, users could also have trouble reading the @Target values at runtime under Java 8, but that seems less likely to come up.)

    This issue is nominally about (1) but for NullUnmarked. (It's true that the output in the first post of this issue also contains the second warning, but the two problems are separable.) We have solved the problem for that annotation by removing MODULE from the target of that annotation. (That change doesn't reduce functionality: "Unmarked" is already the "default default." Thus, setting it explicitly on the module would always be a no-op.)

    Problem (1) still exists for NullMarked, but note that it can arise only when you apply the annotation at the method level, not the class or package level. We don't expect it to be applied at the method level as often as the other two levels, but occasionally it will be.

    Also note that problem (1) exists only when building with a JDK 8 javac. Building with a newer JDK, even when targeting an older version of Java (as with --release 8), does not trigger this problem.

    (We were able to get new versions of javac changed to produce a better error for unrecognized @Target values, rather than a crash. But that doesn't help people who build with JDK 8 at all—unless that change is someday backported, in which case their builds will still fail but in a slightly nicer way :))

    Then there's problem (2). That problem exists not only under the JDK 8 javac but also under newer versions of javac but only with --release 8 and then only sometimes, notably with Error Prone. (The Error Prone problem began with a change I made that was released in Error Prone 2.20.0, but a fix will be coming in the next release, whether that's numbered 2.28.1 or 2.29.0. In the meantime, you can work around it by disabling the offending check with -Xep:NullArgumentForNonNullParameter:OFF.) I think we have also seen it without Error Prone, as demonstrated in a simplified example in #50 (comment) (and maybe seen other times, like in #245 (comment) or in a report by @SimY4 or others), but I'm not sure of the exact circumstances required to trigger it. My guess would be that:

    • When you use an affected version of Error Prone, you can see the warning even for annotations used only your dependencies.
    • When you don't use an affected version of Error Prone, you can see the warning only if you use @NullMarked in the code you're compiling with --release 8.
  20. SimY4 commented on Jul 13, 2024

    @SimY4

    @cpovirk TBH, this problem could be solve in two ways.

    a. you can roll with multi-release jars (because as I said before, you'll face this issue EVERY time when Java will introduce new annotation target)

    b. you can roll new artefact release for jspecify specific for Java 8. (smth like jspecify-jdk8

    For my personal self I'm thinking of forking jspecify and roll my own version for only JDK 8 annotation targets specifically (b).

  21. sdavids commented on Aug 26, 2024

    @sdavids

    This still can be reproduced:

    $ mkdir -p /tmp/test/example && cd "$_/.."
    $ echo 'java=21.0.4-tem' > .sdkmanrc && sdk env
    $ printf '@NullMarked\npackage example;\nimport org.jspecify.annotations.NullMarked;\n' > example/package-info.java
    $ EP_VERSION=2.30.0
    $ DATAFLOW_VERSION=3.41.0-eisop1
    $ JSPECIFY_VERSION=1.0.0
    $ curl -L -O -s https://repo1.maven.org/maven2/com/google/errorprone/error_prone_core/${EP_VERSION?}/error_prone_core-${EP_VERSION?}-with-dependencies.jar
    $ curl -L -O -s https://repo1.maven.org/maven2/io/github/eisop/dataflow-errorprone/${DATAFLOW_VERSION?}/dataflow-errorprone-${DATAFLOW_VERSION?}.jar
    $ curl -L -O -s https://repo1.maven.org/maven2/org/jspecify/jspecify/${JSPECIFY_VERSION?}/jspecify-${JSPECIFY_VERSION?}.jar
    $ javac \
      -J--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \
      -J--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED \
      -J--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED \
      -J--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED \
      -J--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED \
      -J--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED \
      -J--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED \
      -J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED \
      -J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED \
      -J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED \
      -XDcompilePolicy=simple \
      --release 8 \
      -Xlint:-options \
      -Werror \
      -cp jspecify-${JSPECIFY_VERSION?}.jar \
      -processorpath error_prone_core-${EP_VERSION?}-with-dependencies.jar:dataflow-errorprone-${DATAFLOW_VERSION?}.jar \
      '-Xplugin:ErrorProne' \
      example/package-info.java
    warning: unknown enum constant ElementType.MODULE
    warning: unknown enum constant ElementType.MODULE
    error: warnings found and -Werror specified
    1 error
    2 warnings
  22. cpovirk commented on Aug 26, 2024

    @cpovirk
    Collaborator

    Thanks for the easy repro instructions! I should really get around to testing all my guesses from July....

    It looks like the problem reproduces even without Error Prone, so I think this one falls under:

    When you don't use an affected version of Error Prone, you can see the warning only if you use @NullMarked in the code you're compiling with --release 8.

    We haven't found any way to avoid that error without breaking support for using @NullMarked on modules (even if we use multi-release jars), so all we've got is workarounds. You can drop -Werror for the build that contains package-info. Or, if you can compile package-info separately from the rest of your files, you can keep -Werror but use -source 8 -target 8 instead of --release 8 for it. (That is very likely to be safe in practice, but it's not fully safe, at least not without additional enforcement like that from Animal Sniffer.) For a --release 8/-source 8 build, it might be possible to substitute in a Java 9+ copy of javax.lang.model.element.ElementKind during the build, but I haven't tried that. (Or you could make your own copy of the JSpecify NullMarked annotation without MODULE in its @Target list if you have that level of control over your build....)

    The long-term hope is of course that Java 8 usage will continue to shrink. Given the choice between better Java 8 support and better Java 9+ support, we went with the latter, but it's been frustrating that we had to make that choice.

  23. sdavids commented on Aug 26, 2024

    @sdavids

    Would a separate jspecify-jdk8 artifact not suffice?—This has been mentioned several times…


    The long-term hope is of course that Java 8 usage will continue to shrink.

    JetBrains - Java Programming - The State of Developer Ecosystem in 2023

    50% - Java 8

  24. cpovirk commented on Aug 26, 2024

    @cpovirk
    Collaborator

    There unfortunately is no particularly user-friendly way to ensure that the artifact that users want is the one that ends up appearing first on the classpath in general. And even if the right one ends up first, tools sometimes report errors when different versions of a class exists in multiple jars on the classpath.

    Given that, the approach could work well for users who exclusively use the Java 8 version, but it would introduce those potential problems for users who use a mix of that and the Java 9+ version.

  25. sdavids commented on Aug 26, 2024

    @sdavids

    Would it not be a similar situation to google/guava#3683

  26. cpovirk commented on Aug 26, 2024

    @cpovirk
    Collaborator

    Yes, but based on how that's gone, it's not a situation that I'm overly comfortable with: We've been kind of lost in helping users who have run into problems. Additionally, that helps only users of Gradle.

  27. cushon commented on Aug 26, 2024

    @cushon
    Collaborator

    I was curious what the jetbrains numbers for Java 8 usage looked like historically, according to their survey it peaked in 2018 and the decrease in usage has been accelerating.

    I am curious how common using -Werror is in general, but my sense is that there are enough javac diagnostics that can't be selectively disabled that using -Werror is challenging for many projects.

    Year Usage
    2023 50%
    2022 60%
    2021 72%
    2020 75%
    2019 83%
    2018 84%
    2017 79%
  28. scordio commented on Jun 7, 2025

    @scordio

    I encountered the same issue when adopting JSpecify and NullAway in jimfs-junit-jupiter, a JUnit extension that targets Java 8 and has a module descriptor. I achieve this by having two compile executions, as Maven suggests.

    Eventually, I dropped -Werror from the compile execution targeting Java 8.

  29. cpovirk commented on Jun 9, 2025

    @cpovirk
    Collaborator

    Thanks for letting us know. It sounds like you were seeing the "warning: unknown enum constant ElementType.MODULE" message (which appears with --release 8), which then failed your build because of -Werror, and not the outright crash ("unrecognized Attribute name MODULE") that happens when trying to build with a javac binary from JDK 8, right?

    (I hope that we end up seeing enough usage of @NullMarked at the module level to justify this annoyance for people who support Java 8 :\)

  30. scordio commented on Jun 9, 2025

    @scordio

    It sounds like you were seeing the "warning: unknown enum constant ElementType.MODULE" message (which appears with --release 8), which then failed your build because of -Werror

    Yes, exactly. I only now realize how well documented this was; sorry for the noise 🙂

  31. cpovirk commented on Jun 9, 2025

    @cpovirk
    Collaborator

    I'm happy to have the report: It's a useful reminder that we need to eventually promote things out of the wiki and onto jspecify.dev itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    dev

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions