Hello,
I tried to create native image with https://github.com/mangstadt/biweekly library. I have a problem, connected with resources.
The block of code is:
public final class Biweekly {
static {
InputStream in = null;
try {
in = Biweekly.class.getResourceAsStream("biweekly.properties");
Properties props = new Properties();
props.load(in);
// ....
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
IOUtils.closeQuietly(in);
}
}
// .......
}
Steps to reproduce:
import biweekly.Biweekly;
import biweekly.ICalendar;
import biweekly.component.VEvent;
public class Main {
public static void main(String[] args) {
String str =
"BEGIN:VCALENDAR\r\n" +
"VERSION:2.0\r\n" +
"PRODID:-//Microsoft Corporation//Outlook 14.0 MIMEDIR//EN\r\n" +
"BEGIN:VEVENT\r\n" +
"UID:0123\r\n" +
"DTSTAMP:20130601T080000Z\r\n" +
"SUMMARY;LANGUAGE=en-us:Team Meeting\r\n" +
"DTSTART:20130610T120000Z\r\n" +
"DURATION:PT1H\r\n" +
"RRULE:FREQ=WEEKLY;INTERVAL=2\r\n" +
"END:VEVENT\r\n" +
"END:VCALENDAR\r\n";
ICalendar ical = Biweekly.parse(str).first();
VEvent event = ical.getEvents().get(0);
String summary = event.getSummary().getValue();
System.out.println(summary);
}
}
javac -cp /folder/src:/folder/src/biweekly-0.6.4.jar:/folder/src/vinnie-2.0.2.jar Main.java
native-image -cp /folder/src:/folder/src/biweekly-0.6.4.jar:/folder/src/vinnie-2.0.2.jar --no-fallback Main
Build logs:
[main:1018] classlist: 2,211.90 ms, 0.96 GB
[main:1018] (cap): 2,183.62 ms, 0.96 GB
[main:1018] setup: 4,017.10 ms, 0.96 GB
[main:1018] (clinit): 338.99 ms, 2.28 GB
[main:1018] (typeflow): 12,889.48 ms, 2.28 GB
[main:1018] (objects): 14,835.50 ms, 2.28 GB
[main:1018] (features): 1,722.08 ms, 2.28 GB
[main:1018] analysis: 30,291.73 ms, 2.28 GB
[main:1018] universe: 841.77 ms, 2.28 GB
[main:1018] (parse): 3,170.74 ms, 2.29 GB
[main:1018] (inline): 2,366.88 ms, 3.18 GB
[main:1018] (compile): 19,990.10 ms, 4.09 GB
[main:1018] compile: 26,738.77 ms, 4.09 GB
[main:1018] image: 2,030.61 ms, 4.09 GB
[main:1018] write: 1,044.76 ms, 4.09 GB
[main:1018] [total]: 67,475.42 ms, 4.09 GB
Run log:
src$ ./main
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:291)
at Main.main(Main.java:23)
Caused by: java.lang.NullPointerException: inStream parameter is null
at java.util.Objects.requireNonNull(Objects.java:246)
at java.util.Properties.load(Properties.java:403)
at biweekly.Biweekly.<clinit>(Biweekly.java:245)
at com.oracle.svm.core.classinitialization.ClassInitializationInfo.invokeClassInitializer(ClassInitializationInfo.java:351)
at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:271)
... 1 more
My version is:
$ java --version
openjdk 11.0.8 2020-07-14
OpenJDK Runtime Environment GraalVM CE 20.2.0 (build 11.0.8+10-jvmci-20.2-b03)
OpenJDK 64-Bit Server VM GraalVM CE 20.2.0 (build 11.0.8+10-jvmci-20.2-b03, mixed mode, sharing)
@Hixon10 thanks for reporting the issue.
We will look into it
@Hixon10 I have filed the bug with our Dev team, once its fixed, I will let you know