Skip to content

Commit

Permalink
Fix for birth time support
Browse files Browse the repository at this point in the history
It avoids the JDK version specific conditional as this new JNI registration is only needed for JDKs having the sun.nio.fs.UnixFileAttributes.st_birthtime_nsec field new with JDK-8316304-carrying base JDKs.

(cherry picked from commit 2e17e19)
  • Loading branch information
jerboaa authored and zakkak committed Mar 11, 2024
1 parent f24e1ce commit f616d6b
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
*/
package com.oracle.svm.hosted.jdk;

import java.lang.reflect.Field;
import java.net.InetAddress;
import java.net.SocketAddress;
import java.nio.ByteBuffer;
Expand All @@ -38,6 +39,7 @@
import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature;
import com.oracle.svm.core.feature.InternalFeature;
import com.oracle.svm.core.jdk.JNIRegistrationUtil;
import com.oracle.svm.util.ReflectionUtil;

/**
* Registration of classes, methods, and fields accessed via JNI by C code of the JDK.
Expand Down Expand Up @@ -155,9 +157,14 @@ private static void registerUnixNativeDispatcherInit(DuringAnalysisAccess a) {
RuntimeJNIAccess.register(fields(a, "sun.nio.fs.UnixFileAttributes",
"st_mode", "st_ino", "st_dev", "st_rdev", "st_nlink", "st_uid", "st_gid", "st_size",
"st_atime_sec", "st_atime_nsec", "st_mtime_sec", "st_mtime_nsec", "st_ctime_sec", "st_ctime_nsec"));
if (isDarwin()) {
// See JDK-8316304, new in JDK 17.0.11+1
Field unixCreationTimeField = ReflectionUtil.lookupField(true, clazz(a, "sun.nio.fs.UnixFileAttributes"), "st_birthtime_nsec");
if (isDarwin() || unixCreationTimeField != null) {
RuntimeJNIAccess.register(fields(a, "sun.nio.fs.UnixFileAttributes", "st_birthtime_sec"));
}
if (unixCreationTimeField != null) {
RuntimeJNIAccess.register(fields(a, "sun.nio.fs.UnixFileAttributes", "st_birthtime_nsec"));
}

RuntimeJNIAccess.register(clazz(a, "sun.nio.fs.UnixFileStoreAttributes"));
RuntimeJNIAccess.register(fields(a, "sun.nio.fs.UnixFileStoreAttributes", "f_frsize", "f_blocks", "f_bfree", "f_bavail"));
Expand Down

0 comments on commit f616d6b

Please sign in to comment.