Skip to content
This repository was archived by the owner on Oct 23, 2023. It is now read-only.

Commit e58768e

Browse files
committed
Add support for Java with Graal AOT compilation
1 parent 41152a6 commit e58768e

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

Diff for: python/languages/java.py

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from typing import List
2+
import os
3+
4+
from task_maker.args import Arch
5+
from task_maker.languages import CompiledLanguage, CommandType, LanguageManager
6+
7+
8+
class LanguageJava(CompiledLanguage):
9+
@property
10+
def name(self):
11+
return "Java"
12+
13+
@property
14+
def source_extensions(self):
15+
return [".java"]
16+
17+
def get_compilation_command(self, source_filenames: List[str],
18+
exe_name: str, unit_name: str,
19+
for_evaluation: bool,
20+
target_arch: Arch) -> (CommandType, List[str]):
21+
GRAAL_PATH = os.getenv("TM_GRAAL_PATH") or "/usr/lib/jvm/java-8-graal/bin/"
22+
main_class = "grader" if "grader.java" in source_filenames else unit_name
23+
commands = [
24+
f"{GRAAL_PATH}javac {' '.join(source_filenames)}",
25+
f"{GRAAL_PATH}native-image {main_class} {exe_name}",
26+
]
27+
return CommandType.SYSTEM, ["sh", "-c", "&&".join(commands)]
28+
29+
30+
def register():
31+
LanguageManager.register_language(LanguageJava())

0 commit comments

Comments
 (0)