Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialize sun.nio.ch.Iocp at runtime on Windows with JDK 11 #7587

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

import java.io.IOException;
import java.net.URL;
import java.nio.channels.spi.AsynchronousChannelProvider;
import java.util.function.Function;

import com.oracle.svm.core.annotate.Alias;
import com.oracle.svm.core.annotate.InjectAccessors;
import com.oracle.svm.core.annotate.Substitute;
import com.oracle.svm.core.annotate.TargetClass;
import com.oracle.svm.core.jdk.JDK11OrLater;
Expand Down Expand Up @@ -88,6 +90,47 @@ public String apply(TargetClass annotation) {
}
}

@Substitute
@TargetClass(className = "sun.nio.ch.WindowsAsynchronousFileChannelImpl", innerClass = "DefaultIocpHolder", onlyWith = JDK11OrLater.class)
final class Target_sun_nio_ch_WindowsAsynchronousFileChannelImpl_DefaultIocpHolder {

@Alias
@InjectAccessors(DefaultIocpAccessor.class)
static Target_sun_nio_ch_Iocp defaultIocp;
}

@TargetClass(className = "sun.nio.ch.Iocp", onlyWith = JDK11OrLater.class)
final class Target_sun_nio_ch_Iocp {

@Alias
Target_sun_nio_ch_Iocp(AsynchronousChannelProvider provider, Target_sun_nio_ch_ThreadPool pool) throws IOException {
}

@Alias
Target_sun_nio_ch_Iocp start() {
return null;
}
}

@TargetClass(className = "sun.nio.ch.ThreadPool", onlyWith = JDK11OrLater.class)
final class Target_sun_nio_ch_ThreadPool {

@Alias
static Target_sun_nio_ch_ThreadPool createDefault() {
return null;
}
}

final class DefaultIocpAccessor {
static Target_sun_nio_ch_Iocp get() {
try {
return new Target_sun_nio_ch_Iocp(null, Target_sun_nio_ch_ThreadPool.createDefault()).start();
} catch (IOException ioe) {
throw new InternalError(ioe);
}
}
}

class JdkSubstitutions {

}