Skip to content

Commit

Permalink
Create minimal reproducer for Quarkus issue 37862
Browse files Browse the repository at this point in the history
  • Loading branch information
zakkak committed Jan 10, 2024
1 parent 3eceeb4 commit c4534cd
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 88 deletions.
19 changes: 9 additions & 10 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# Reproducer for native-image issue with bouncycastle provider
# Reproducer for native-image issue with fields in classes with substituted methods

```
See https://github.com/quarkusio/quarkus/issues/37862

```shell
cd /tmp
git clone --branch bouncycastle-services-not-included https://github.com/zakkak/issue-reproducers bouncycastle-services-not-included
cd bouncycastle-services-not-included
git clone --branch 2024-01-10-subst-analysis-issue https://github.com/zakkak/issue-reproducers reproducer
cd reproducer
mvn package
java -agentlib:native-image-agent=config-output-dir=META-INF/native-image -jar target/graal-issue-bouncycastle-1.0-SNAPSHOT.jar
native-image --initialize-at-build-time \
--no-fallback -H:+ReportExceptionStackTraces \
-jar target/graal-issue-bouncycastle-1.0-SNAPSHOT.jar
./graal-issue-bouncycastle-1.0-SNAPSHOT
```
java -jar ./target/reproducer-1.0-SNAPSHOT.jar
native-image -cp target/classes/ Main --no-fallback --initialize-at-build-time=.
```
9 changes: 2 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>

<groupId>org.example</groupId>
<artifactId>graal-issue-bouncycastle</artifactId>
<artifactId>reproducer</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
Expand Down Expand Up @@ -58,15 +58,10 @@
</build>

<dependencies>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<version>1.65</version>
</dependency>
<dependency>
<groupId>org.graalvm.nativeimage</groupId>
<artifactId>svm</artifactId>
<version>21.3.1</version>
<version>23.1.0</version>
</dependency>
</dependencies>

Expand Down
44 changes: 0 additions & 44 deletions src/main/java/BouncyCastleFeature.java

This file was deleted.

44 changes: 17 additions & 27 deletions src/main/java/Main.java
Original file line number Diff line number Diff line change
@@ -1,34 +1,24 @@
import org.bouncycastle.jce.provider.BouncyCastleProvider;

import javax.crypto.Cipher;
import javax.crypto.NoSuchPaddingException;

// import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.Security;
import com.oracle.svm.core.annotate.Alias;
import com.oracle.svm.core.annotate.RecomputeFieldValue;
import com.oracle.svm.core.annotate.Substitute;
import com.oracle.svm.core.annotate.TargetClass;

public class Main {

static {
System.out.println("Hello!!!!");

// Too late... providers need to be registered before the analysis, but
// static initialization takes plave after it.

Security.addProvider(new BouncyCastleProvider());
public static void main(String[] args) {
Substituted substituted = Substituted.INSTANCE;
System.out.println(substituted.getMessage());
}
}

public static void main(String[] args) {
@TargetClass(Substituted.class)
final class Target_Substituted {
@RecomputeFieldValue(kind = RecomputeFieldValue.Kind.FromAlias)
@Alias
public static Target_Substituted INSTANCE = new Target_Substituted();

try {
// KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA", "BC");
// keyPairGenerator.generateKeyPair();
// System.out.println("Success");
Cipher rsaInstance = Cipher.getInstance("AES/CBC/PKCS7Padding", "BC");
System.out.println(rsaInstance.getAlgorithm());
} catch (NoSuchAlgorithmException | NoSuchPaddingException | NoSuchProviderException e) {
e.printStackTrace();
}
@Substitute
public String getMessage() {
return new String("Substituted");
}
}
}

0 comments on commit c4534cd

Please sign in to comment.