diff --git a/Readme.md b/Readme.md index c7b9e58..4491b71 100644 --- a/Readme.md +++ b/Readme.md @@ -1,31 +1,29 @@ # Reproducer for native-image issue +Reproducer of https://github.com/oracle/graal/issues/1725 + ``` cd /tmp -git clone --branch unreachable-unresolved-code https://github.com/zakkak/issue-reproducers reproducers +git clone --branch 2024-09-13-delete-no-class-def-found https://github.com/zakkak/issue-reproducers reproducers cd reproducers mvn package -export JAVA_HOME=/opt/jvms/graalvm-ce-java11-22.1.0 # run with Unreachable on the classpath -$JAVA_HOME/bin/java -cp target/classes Main +java -cp target/classes Main # run with Unreachable not on the classpath -$JAVA_HOME/bin/java \ +java \ -jar target/reproducer-1.0-SNAPSHOT.jar # generate native-image with Unreachable not on the classpath -$JAVA_HOME/bin/native-image \ - --link-at-build-time \ - --initialize-at-build-time=. \ +native-image \ + --no-fallback \ + -H:+ReportExceptionStackTraces \ -jar target/reproducer-1.0-SNAPSHOT.jar -# Run the generated image +# Run binary ./reproducer-1.0-SNAPSHOT +# generate native-image with Unreachable not on the classpath and pass --report-unsupported-elements-at-runtime +native-image \ + --no-fallback \ + --report-unsupported-elements-at-runtime \ + -H:+ReportExceptionStackTraces \ + -jar target/reproducer-1.0-SNAPSHOT.jar +# Build fails ``` - -To generate the IGV graph for main use -``` -native-image --initialize-at-build-time=. --no-fallback -H:Dump=:1 -H:MethodFilter=Main.main -jar target/reproducer-1.0-SNAPSHOT.jar -``` - -and render it with -``` -seafoam graal_dumps/2022.06.17.16.02.27.868/SubstrateHostedCompilation-3596\[Main.main\(String\[\]\)void\].bgv:0 render -``` \ No newline at end of file diff --git a/pom.xml b/pom.xml index bd826c9..c89e036 100644 --- a/pom.xml +++ b/pom.xml @@ -9,15 +9,15 @@ 1.0-SNAPSHOT - 11 - 11 + 17 + 17 - org.graalvm.nativeimage - svm - 22.1.0 + org.graalvm.sdk + nativeimage + 23.1.0 @@ -55,7 +55,7 @@ - org.graalvm.nativeimage:* + org.graalvm.*:* *:*:tar.gz: diff --git a/src/main/java/Main.java b/src/main/java/Main.java index 0c11f16..d5bcef3 100644 --- a/src/main/java/Main.java +++ b/src/main/java/Main.java @@ -1,35 +1,15 @@ -import java.util.Random; - -import com.oracle.svm.core.annotate.NeverInline; +import com.oracle.svm.core.annotate.Delete; +import com.oracle.svm.core.annotate.TargetClass; public class Main { - static final ClassNotFoundException CNFE; - - static - { - ClassNotFoundException cnfe; - - try { - Class.forName("Unreachable"); - cnfe = null; - } catch (ClassNotFoundException e) { - cnfe = e; - } - - CNFE = cnfe; - } - - @NeverInline("I want to see the BGV") public static void main(String[] args) { - if (unreachableIsReachable()) { - Unreachable.reached(); - } - System.out.println("Hello world!"); } +} + +@Delete +@TargetClass(className = "Foo") +final class Target_Foo { - private static boolean unreachableIsReachable() { - return CNFE == null; - } } \ No newline at end of file