diff --git a/Readme.md b/Readme.md index 8f4152f..da2f74a 100644 --- a/Readme.md +++ b/Readme.md @@ -2,12 +2,11 @@ ``` cd /tmp -git clone --branch serialization-registration https://github.com/zakkak/issue-reproducers reproducers +git clone --branch 2023-04-05-delayed-error-reporting-causing-issues https://github.com/zakkak/issue-reproducers reproducers cd reproducers mvn package -export JAVA_HOME=/opt/jvms/graalvm-ce-java11-21.2.0 -$JAVA_HOME/bin/native-image --initialize-at-build-time \ +export JAVA_HOME=/opt/jvms/graalvm-ce-java17-22.3.1 +$JAVA_HOME/bin/native-image --initialize-at-build-time=. \ --no-fallback -H:+ReportExceptionStackTraces \ -jar target/reproducer-1.0-SNAPSHOT.jar -./reproducer-1.0-SNAPSHOT ``` diff --git a/pom.xml b/pom.xml index cc51543..f21de4c 100644 --- a/pom.xml +++ b/pom.xml @@ -17,42 +17,14 @@ org.apache.maven.plugins - maven-shade-plugin - 3.2.1 - - - package - - shade - - - - - - Main - 1.0 - - - - - - *:* - - META-INF/*.SF - META-INF/*.DSA - META-INF/*.RSA - - - - - - org.graalvm.nativeimage:* - *:*:tar.gz: - - - - - + maven-jar-plugin + + + + Main + + + @@ -61,12 +33,12 @@ org.graalvm.sdk graal-sdk - 21.3.0-SNAPSHOT + 22.3.1 org.graalvm.nativeimage svm - 21.3.0-SNAPSHOT + 22.3.1 diff --git a/src/main/java/AbstractParent.java b/src/main/java/AbstractParent.java deleted file mode 100644 index 0f284bc..0000000 --- a/src/main/java/AbstractParent.java +++ /dev/null @@ -1,14 +0,0 @@ -import java.io.Serializable; - -abstract class AbstractPerson implements Serializable { - - private String name; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } -} diff --git a/src/main/java/ExternalizablePerson.java b/src/main/java/ExternalizablePerson.java deleted file mode 100644 index 1667280..0000000 --- a/src/main/java/ExternalizablePerson.java +++ /dev/null @@ -1,32 +0,0 @@ -import java.io.Externalizable; -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; - -public class ExternalizablePerson implements Externalizable { - - private String name; - - public ExternalizablePerson() { - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - @Override - public void writeExternal(ObjectOutput out) throws IOException { - out.writeUTF(name); - } - - @Override - public void readExternal(ObjectInput in) - throws IOException, ClassNotFoundException { - this.name = in.readUTF(); - } - -} diff --git a/src/main/java/Main.java b/src/main/java/Main.java index 8293eaa..8a6dd6b 100644 --- a/src/main/java/Main.java +++ b/src/main/java/Main.java @@ -1,40 +1,14 @@ -import org.graalvm.home.Version; +public class Main { -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; + static { + dontCallMe(); + } -public class Main { + private static void dontCallMe() { + throw new IllegalArgumentException("Don't call me!"); + } public static void main(String[] args) { - // we don't test serialization for GraalVM < 21.3 - if (Version.getCurrent().compareTo(21, 3) < 0) { - System.out.println("Please use GraalVM >21.3"); - return; - } - - try { - SomeSerializationObject instance = new SomeSerializationObject(); - instance.setPerson(new Person("Sheldon")); - ExternalizablePerson ep = new ExternalizablePerson(); - ep.setName("Sheldon 2.0"); - instance.setExternalizablePerson(ep); - ByteArrayOutputStream out = new ByteArrayOutputStream(); - ObjectOutputStream os = new ObjectOutputStream(out); - os.writeObject(instance); - ByteArrayInputStream bais = new ByteArrayInputStream(out.toByteArray()); - ObjectInputStream is = new ObjectInputStream(bais); - SomeSerializationObject result = (SomeSerializationObject) is.readObject(); - if (result.getPerson().getName().equals("Sheldon") - && result.getExternalizablePerson().getName().equals("Sheldon 2.0")) { - System.out.println("OK"); - } else { - System.out.println("Ooops"); - } - } catch (Exception e) { - System.out.println("Ooops2"); - e.printStackTrace(); - } + System.out.println("Hello World!"); } } diff --git a/src/main/java/Person.java b/src/main/java/Person.java deleted file mode 100644 index de22859..0000000 --- a/src/main/java/Person.java +++ /dev/null @@ -1,8 +0,0 @@ -public class Person extends AbstractPerson { - public Person() { - } - - public Person(String name) { - setName(name); - } -} diff --git a/src/main/java/SerializationFeature.java b/src/main/java/SerializationFeature.java deleted file mode 100644 index afc0ffb..0000000 --- a/src/main/java/SerializationFeature.java +++ /dev/null @@ -1,18 +0,0 @@ -import com.oracle.svm.core.annotate.*; -import org.graalvm.nativeimage.hosted.Feature; - -import org.graalvm.nativeimage.hosted.RuntimeSerialization; - -@AutomaticFeature -public class SerializationFeature implements Feature { - - @Override - public void beforeAnalysis(BeforeAnalysisAccess access) { - RuntimeSerialization.register(String.class); - RuntimeSerialization.register(Person.class); - RuntimeSerialization.register(SomeSerializationObject.class); - RuntimeSerialization.register(AbstractPerson.class); - RuntimeSerialization.register(ExternalizablePerson.class); - } - -} \ No newline at end of file diff --git a/src/main/java/SomeSerializationObject.java b/src/main/java/SomeSerializationObject.java deleted file mode 100644 index 1f28a7c..0000000 --- a/src/main/java/SomeSerializationObject.java +++ /dev/null @@ -1,23 +0,0 @@ -import java.io.Serializable; - -public class SomeSerializationObject implements Serializable { - - private Person person; - private ExternalizablePerson externalizablePerson; - - public Person getPerson() { - return person; - } - - public void setPerson(Person person) { - this.person = person; - } - - public ExternalizablePerson getExternalizablePerson() { - return externalizablePerson; - } - - public void setExternalizablePerson(ExternalizablePerson externalizablePerson) { - this.externalizablePerson = externalizablePerson; - } -} diff --git a/src/main/java/Target_Main.java b/src/main/java/Target_Main.java new file mode 100644 index 0000000..d7cfc27 --- /dev/null +++ b/src/main/java/Target_Main.java @@ -0,0 +1,12 @@ +import com.oracle.svm.core.annotate.Delete; +import com.oracle.svm.core.annotate.TargetClass; + +@TargetClass(Main.class) +public final class Target_Main { + + @Delete + private static void dontCallMe() { + // Do nothing; + } + +} \ No newline at end of file