Skip to content

Commit ed42e07

Browse files
author
Adam Hrbac
committed
Move mimeType check to a static method
1 parent 14b6ab3 commit ed42e07

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/PythonLanguage.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,8 @@ public final class PythonLanguage extends TruffleLanguage<PythonContext> {
229229
// a dash follows after the opt flag pair
230230
static final int MIME_KIND_START = MIME_PREFIX.length() + OPT_FLAGS_LEN + 1;
231231

232-
static {
232+
private static boolean mimeTypesComplete(ArrayList<String> mimeJavaStrings) {
233233
ArrayList<String> mimeTypes = new ArrayList<>();
234-
ArrayList<String> mimeJavaStrings = new ArrayList<>();
235234
FutureFeature[] all = FutureFeature.values();
236235
for (int flagset = 0; flagset < (1 << all.length); ++flagset) {
237236
int flags = 0;
@@ -248,9 +247,12 @@ public final class PythonLanguage extends TruffleLanguage<PythonContext> {
248247
}
249248
}
250249
HashSet<String> currentMimeTypes = new HashSet<>(List.of(PythonLanguage.class.getAnnotation(Registration.class).characterMimeTypes()));
251-
if (!currentMimeTypes.containsAll(mimeTypes)) {
252-
assert false : "Expected all of {" + String.join(", ", mimeJavaStrings) + "} in the PythonLanguage characterMimeTypes";
253-
}
250+
return currentMimeTypes.containsAll(mimeTypes);
251+
}
252+
253+
static {
254+
ArrayList<String> mimeJavaStrings = new ArrayList<>();
255+
assert mimeTypesComplete(mimeJavaStrings) : "Expected all of {" + String.join(", ", mimeJavaStrings) + "} in the PythonLanguage characterMimeTypes";
254256
}
255257

256258
public static final String MIME_TYPE_BYTECODE = "application/x-python-bytecode";

0 commit comments

Comments
 (0)