-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create minimal reproducer for Quarkus issue 37862
- Loading branch information
Showing
4 changed files
with
28 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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=. | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
} | ||
} |