Skip to content

Commit

Permalink
Merge pull request #7587 from gwenneg/issue-7269-iocp-runtime-initial…
Browse files Browse the repository at this point in the history
…ization

Initialize sun.nio.ch.Iocp at runtime on Windows with JDK 11
  • Loading branch information
gsmet authored Mar 5, 2020
2 parents eef6e0d + 903ad1d commit f7f0aea
Showing 1 changed file with 43 additions and 0 deletions.
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 {

}

0 comments on commit f7f0aea

Please sign in to comment.