Skip to content

Commit

Permalink
Convert DOS to Java time without consulting time zone offset quarkusi…
Browse files Browse the repository at this point in the history
…o#9792

* To avoid side-effects when building debug symbol source cache.
  • Loading branch information
galderz committed Jun 29, 2020
1 parent 21059df commit 0699f21
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.quarkus.runtime.graal;

import java.io.ObjectStreamClass;
import java.util.Date;

import com.oracle.svm.core.annotate.Substitute;
import com.oracle.svm.core.annotate.TargetClass;
Expand All @@ -23,3 +24,20 @@ private Target_java_io_ObjectStreamClass() {
}

}

@TargetClass(className = "jdk.nio.zipfs.ZipUtils")
final class Target_jdk_nio_zipfs_ZipUtils {

// Use ZipUtils.overflowDosToJavaTime implementation to avoid consulting time zone offset
@Substitute
private static long dosToJavaTime(long dtime) {
int year = (int) (((dtime >> 25) & 0x7f) + 1980);
int month = (int) ((dtime >> 21) & 0x0f);
int day = (int) ((dtime >> 16) & 0x1f);
int hour = (int) ((dtime >> 11) & 0x1f);
int minute = (int) ((dtime >> 5) & 0x3f);
int second = (int) ((dtime << 1) & 0x3e);
return new Date(year - 1900, month - 1, day, hour, minute, second).getTime();
}

}

0 comments on commit 0699f21

Please sign in to comment.