bc-java icon indicating copy to clipboard operation
bc-java copied to clipboard

Build fails due to Java API or CPU architecture incompatibility

Open DDvO opened this issue 1 year ago • 2 comments

Looking at the README.md, I found it confusing how multiple Java versions are mentioned there. Please point out that, non-intuitively, really all of Java 8, 11, 17, and 21 need to be installed, not just one of choice.

So I installed all four Azul Zulu Java arm64 JDKs from, e.g., https://www.azul.com/downloads/?version=java-8-lts&os=macos&architecture=arm-64-bit&package=jdk#zulu set up all four environment variables, and executed

gradle -x test clean jar

which gave me:

> Configure project :
Environment setup:
Looking for JDK ENV 'BC_JDK8' found  /Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home
Looking for JDK ENV 'BC_JDK11' found  /Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home
Looking for JDK ENV 'BC_JDK17' found  /Library/Java/JavaVirtualMachines/zulu-17.jdk/Contents/Home
Looking for JDK ENV 'BC_JDK21' found  /Library/Java/JavaVirtualMachines/zulu-21.jdk/Contents/Home

> Task :core:compileJava
warning: [options] source value 8 is obsolete and will be removed in a future release
warning: [options] target value 8 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
/proj/bc-java/core/src/main/java/org/bouncycastle/crypto/CryptoServicesRegistrar.java:4: warning: [removal] AccessController in java.security has been deprecated and marked for removal
import java.security.AccessController;
                    ^
...
error: An unhandled exception was thrown by the Error Prone static analysis plugin.
     Please report this at https://github.com/google/error-prone/issues/new and include the following:
  
     error-prone version: 2.24.1
     BugPattern: (see stack trace)
     Stack Trace:
     java.lang.NoSuchFieldError: Class com.sun.tools.javac.parser.Tokens$Comment$CommentStyle does not have member field 'com.sun.tools.javac.parser.Tokens$Comment$CommentStyle JAVADOC'
        at com.google.errorprone.bugpatterns.javadoc.NotJavadoc.matchCompilationUnit(NotJavadoc.java:65)
        at com.google.errorprone.scanner.ErrorProneScanner.processMatchers(ErrorProneScanner.java:449)
...
        at java.base/java.lang.Thread.run(Thread.java:1575)
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
26 warnings

> Task :core:compileJava FAILED
...

DDvO avatar Oct 04 '24 06:10 DDvO

You can remove the use of the error-prone plugin.

dghgit avatar Oct 13 '24 18:10 dghgit

You can remove the use of the error-prone plugin.

Thanks for your response - yet I don't now how to do that, while fortunately it seems no more needed. I'm very unexperienced with BC and current Java tooling.

Nice that the README meanwhile says that setting BC_JDK8, BC_JDK11, and BC_JDK17 is optional, and both gradlew clean build and gradle -x test clean jar no more insist in using them. So I unset all BC_JDK8, BC_JDK11, BC_JDK17, and BC_JDK21 and use just

export JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-21.jdk/Contents/Home

Now

 gradle -x test clean jar

runs successfully (with just many warnings).

Yet using ./gradlew clean build I now get several warnings and apparently an architecture mismatch error:

* What went wrong:
Execution failed for task ':core:test'.
> Error while evaluating property 'javaLauncher' of task ':core:test'.
   > Failed to calculate the value of task ':core:test' property 'javaLauncher'.
      > Cannot find a Java installation on your machine matching this tasks requirements: {languageVersion=8, vendor=any, implementation=vendor-specific} for MAC_OS on aarch64.
         > No locally installed toolchains match and toolchain auto-provisioning is not enabled.

DDvO avatar Oct 20 '24 17:10 DDvO