Skip to content

Commit

Permalink
[GR-19762] Class java.net.TwoStacksPlainSocketImpl not found on Windows.
Browse files Browse the repository at this point in the history
PullRequest: graal/5037
  • Loading branch information
pejovica committed Dec 13, 2019
2 parents 0599786 + fd45f65 commit 123a027
Show file tree
Hide file tree
Showing 4 changed files with 162 additions and 111 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,23 @@
package com.oracle.svm.core.jdk;

/* Checkstyle: allow reflection */

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Collections;
import java.util.IdentityHashMap;
import java.util.Set;
import java.util.function.Consumer;

import com.oracle.svm.core.util.VMError;
import org.graalvm.nativeimage.ImageSingletons;
import org.graalvm.nativeimage.Platform;
import org.graalvm.nativeimage.hosted.Feature.DuringAnalysisAccess;
import org.graalvm.nativeimage.hosted.Feature.FeatureAccess;
import org.graalvm.nativeimage.impl.RuntimeClassInitializationSupport;

import com.oracle.svm.core.jni.JNIRuntimeAccess;
import com.oracle.svm.core.util.VMError;
import com.oracle.svm.util.ReflectionUtil;

/**
Expand Down Expand Up @@ -95,4 +101,15 @@ protected static void registerForThrowNew(FeatureAccess access, String... except
JNIRuntimeAccess.register(constructor(access, exceptionClassName, String.class));
}
}

private static Set<Consumer<DuringAnalysisAccess>> runOnceCallbacks = Collections.newSetFromMap(new IdentityHashMap<>());

/** Intended to be used from within a callback to ensure that it is run only once. */
protected static boolean isRunOnce(Consumer<DuringAnalysisAccess> callback) {
return !runOnceCallbacks.add(callback);
}

public void cleanup() {
runOnceCallbacks.clear();
}
}
Loading

0 comments on commit 123a027

Please sign in to comment.