Skip to content
Snippets Groups Projects
Commit 4589ac03 authored by Stepan Sindelar's avatar Stepan Sindelar
Browse files

[GR-2311] RFFIFactory: initialize in static block.

parents 32bdb565 ec810a6e
Branches
No related tags found
No related merge requests found
...@@ -71,7 +71,6 @@ public final class TruffleRLanguage extends TruffleLanguage<RContext> { ...@@ -71,7 +71,6 @@ public final class TruffleRLanguage extends TruffleLanguage<RContext> {
*/ */
private static void initialize() { private static void initialize() {
try { try {
RFFIFactory.initialize();
Locale.setDefault(Locale.ROOT); Locale.setDefault(Locale.ROOT);
RAccuracyInfo.initialize(); RAccuracyInfo.initialize();
} catch (Throwable t) { } catch (Throwable t) {
......
...@@ -30,7 +30,11 @@ import com.oracle.truffle.r.runtime.context.RContext.ContextState; ...@@ -30,7 +30,11 @@ import com.oracle.truffle.r.runtime.context.RContext.ContextState;
* Factory class for the different possible implementations of the {@link RFFI} interface. * Factory class for the different possible implementations of the {@link RFFI} interface.
* *
* The RFFI may need to do special things in the case of multiple contexts, hence any given factory * The RFFI may need to do special things in the case of multiple contexts, hence any given factory
* must support the {@link #newContextState()} method. * must support the {@link #newContextState()} method. Initialization of factory state that is
* dependent on the system being properly initialized <b>must</b> be done in the
* {@link ContextState#initialize} method and not in the constructor or {@link #createRFFI} method
* as they are invoked in the static block and the system is not typically initialized at that
* point.
*/ */
public abstract class RFFIFactory { public abstract class RFFIFactory {
private enum Factory { private enum Factory {
...@@ -57,7 +61,7 @@ public abstract class RFFIFactory { ...@@ -57,7 +61,7 @@ public abstract class RFFIFactory {
@CompilationFinal protected static RFFI theRFFI; @CompilationFinal protected static RFFI theRFFI;
public static RFFIFactory initialize() { static {
if (instance == null) { if (instance == null) {
String klassName = getFactoryClassName(); String klassName = getFactoryClassName();
try { try {
...@@ -67,7 +71,6 @@ public abstract class RFFIFactory { ...@@ -67,7 +71,6 @@ public abstract class RFFIFactory {
throw Utils.rSuicide("Failed to instantiate class: " + klassName + ": " + ex); throw Utils.rSuicide("Failed to instantiate class: " + klassName + ": " + ex);
} }
} }
return instance;
} }
private static String getFactoryClassName() { private static String getFactoryClassName() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment