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.

Native image contains over 2 thousand BouncyCastle classes by default

See original GitHub issue

Describe the bug

My native image contains BouncyCastle classes, but I don’t think I need all of them. Quarkus Security registers BouncyCastle classes for reflection here https://github.com/quarkusio/quarkus/blob/main/extensions/security/deployment/src/main/java/io/quarkus/security/deployment/SecurityProcessor.java#L164, here https://github.com/quarkusio/quarkus/blob/main/extensions/security/deployment/src/main/java/io/quarkus/security/deployment/SecurityProcessor.java#L142 and here https://github.com/quarkusio/quarkus/blob/main/extensions/security/deployment/src/main/java/io/quarkus/security/deployment/SecurityProcessor.java#L128, however all relevant integration test modules (bouncycastle, bouncycastle-fips, bouncycastle-fips-jsse, bouncycastle-jsse) are passing in native mode even when you completely remove these registrations as native image contains all of these classes anyway (and abundance of others).

Expected behavior

Native image only contains classes I really need.

Actual behavior

2586 classes, f.e. ecgost package classes, elgamal package classes that I don’t really need.

How to Reproduce?

Reproducer:

Steps to reproduce the behavior:

  1. git clone https://github.com/quarkusio/quarkus.git
  2. cd quarkus/integration-tests/bouncycastle
  3. mvn clean verify -Dnative -Dquarkus.native.additional-build-args=-H:IncludeResources=.*\\.pem,-H:+PrintClassInitialization -Dquarkus.native.enable-reports
  4. checkout:
  • target/quarkus-integration-test-bouncycastle-999-SNAPSHOT-native-image-source-jar/reports/class_initialization_report_20221119_205609.csv and look for org.bouncycastle and see 2586 results
  • target/quarkus-integration-test-bouncycastle-999-SNAPSHOT-native-image-source-jar/reports/used_classes_quarkus-integration-test-bouncycastle-999-SNAPSHOT-runner_20221119_205621.txt says 2096 org.bouncycastle classes are used

Output of uname -a or ver

Linux fedora 5.19.16-200.fc36.x86_64 #1 SMP PREEMPT_DYNAMIC Sun Oct 16 22:50:04 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Output of java -version

openjdk 17.0.5 2022-10-18

GraalVM version (if different from Java)

OpenJDK Runtime Environment GraalVM CE 22.3.0 (build 17.0.5+8-jvmci-22.3-b08)

Quarkus version or git rev

999-SNAPSHOT

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.8.6

Additional information

No response

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
michalvavrikcommented, Nov 20, 2022

Thanks for feedback

0reactions
sberyozkincommented, Nov 20, 2022

Hi @michalvavrik I think what matters is how much the native image size is affected, I’d not be surprised if some other 3rd party libraries were having a similar impact. BC has a lot of nested classes, a single outer class can have 10 or so number of micro size nested classes, and perhaps the real impact is not that critical… Thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

Native Image Compatibility and Optimization Guide - GraalVM
See native-image --help for details. Classes that are members of the JDK class libraries are initialized by default.
Read more >
Security Tips and Tricks - Quarkus
io.quarkus:quarkus-security module contains the core Quarkus security classes. In most cases, it does not have to be added directly to your project's build ......
Read more >
GraalVM native-image EE JDK11 - VM Options Explorer
Perform trivial method inlining in the AOT compiled native image. ... Class containing the default entry point method. ... Should be a power...
Read more >
org/bouncycastle/jce/provider/BouncyCastleProvider - Stack ...
Running the application with intelliJ doesnt throw this problem. But happens when running from command line.
Read more >
Apache Karaf Container 4.x - Documentation
By default, all Apache Karaf files are "gathered" in one directory: ... bundles. bundle:classes Displays a list of classes/resources contained in the bundle ......
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