question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

java_plugin header compilation failure

See original GitHub issue

Description of the problem / feature request:

Two parts to this issue:

First, I ran into an exception during Java header compilation. Turbine does an unsafe cast here, which caused an annotation processor to fail during header compilation. This seems like a straightforward bug – I’m not sure if there’s a better place to report it since the turbine repo does not allow issues.

Second, and more bazel-specific, I only ran into this issue upon upgrading to JDK 15. I followed the process outlined here to use the JDK 15 release of the remote tools. For some reason, this failure only happens with that toolchain, not with Java 8 or 11. Is there something different about the turbine jar it uses or how it invokes it? I could not figure out the difference.

Bugs: what’s the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Full reproducer here: https://github.com/jfancher/bazel-issues/tree/turbine-elements

The basic setup is:

  • Have an annotation processor (and java_plugin) P that calls the offending method (note: with generates_api flag)
  • Have a lib A that uses P
  • Have a lib B that references A
  • Build B

What operating system are you running Bazel on?

macOS

What’s the output of bazel info release?

release 3.7.0

Have you found anything relevant by searching the web?

Nope.

Any other information, logs, or outputs that you want to share?

Full build log:

$ bazel build --config=jdk15 //:C2
INFO: Build options --host_java_toolchain, --host_javabase, --java_toolchain, and 1 more have changed, discarding analysis cache.
INFO: Analyzed target //:C2 (1 packages loaded, 714 targets configured).
INFO: Found 1 target...
INFO: From Compiling Java headers libAnno-hjar.jar (1 source file):
OpenJDK 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release.
INFO: From Compiling Java headers libAnno-hjar.jar (1 source file):
OpenJDK 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release.
INFO: From Building libC1.jar (1 source file) and running annotation processors (Proc):
warning: deprecated

ERROR: /Users/jfancher/github/jfancher/bazel-issues/BUILD.bazel:14:13: Compiling Java headers libC1-hjar.jar (1 source file) and running annotation processors (Proc) failed (Exit 1): java failed: error executing command external/jdk15_macos/bin/java -Xverify:none '--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED' '--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED' ... (remaining 12 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox java failed: error executing command external/jdk15_macos/bin/java -Xverify:none '--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED' '--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED' ... (remaining 12 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox
OpenJDK 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release.
<>: error: java.lang.ClassCastException: class com.google.turbine.processing.TurbineElement$TurbineExecutableElement cannot be cast to class com.google.turbine.processing.TurbineElement$TurbineTypeElement (com.google.turbine.processing.TurbineElement$TurbineExecutableElement and com.google.turbine.processing.TurbineElement$TurbineTypeElement are in unnamed module of loader 'app')
	at com.google.turbine.processing.TurbineElements.isDeprecated(TurbineElements.java:133)
	at ex.Proc.process(Proc.java:22)
	at com.google.turbine.binder.Processing.process(Processing.java:181)
	at com.google.turbine.binder.Binder.bind(Binder.java:102)
	at com.google.turbine.main.Main.bind(Main.java:246)
	at com.google.turbine.main.Main.fallback(Main.java:221)
	at com.google.turbine.main.Main.compile(Main.java:165)
	at com.google.turbine.main.Main.compile(Main.java:127)
	at com.google.turbine.main.Main.main(Main.java:84)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
comiuscommented, Dec 9, 2020

This is currently marked as an open release blocker for Bazel 4.0 - is this still the case?

Not blocker, it was cherrypicked for 4.0. Still need to release java_tools at @head before I can close it.

1reaction
comiuscommented, Dec 7, 2020

When you say it happens on all versions, do you mean at Bazel head? Or with that tools release?

It worked for you because of double failure. java_tools release 10.1 incorrectly uses Turbine instead of TurbineDirect on some OS, JDK combinations.

With newer java_tools TurbineDirect is correctly used and fails for all JDK versions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

compileJava task fails to generate native headers · Issue #5973
When I run gradle build I expect the JNI header file to be created at src/main/headers/foo_Foo.h. Current Behavior.
Read more >
How to fix Maven invalid end header - java - Stack Overflow
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project gsn-editor: ...
Read more >
CompileOptions - Gradle DSL Version 7.6
Tells whether to fail the build when compilation fails. ... to the Java compiler's `-h` option, prompting it to generate native headers to...
Read more >
Maven compiling error - zip END header not found | SpigotMC
I've tried re-installing maven, clearing cache (/.m2/repository/junit/ and the whole folder), a version behind the latest maven (3.6.0 ...
Read more >
Java Rules | Bazel
Overrides --java_header_compilation to disable header compilation on platforms that do not support it, e.g. JDK 7 Bazel. genclass. List of labels; required.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found