diff --git a/judger/uoj_judger/include/uoj_judger.h b/judger/uoj_judger/include/uoj_judger.h index 81ef382..8938b6f 100644 --- a/judger/uoj_judger/include/uoj_judger.h +++ b/judger/uoj_judger/include/uoj_judger.h @@ -592,12 +592,6 @@ struct RunProgramConfig { type = "python2"; } else if (lang == "Python3") { type = "python3"; - } else if (lang == "Java8") { - program_name += "." + conf_str(name + "_main_class"); - type = "java8"; - } else if (lang == "Java11") { - program_name += "." + conf_str(name + "_main_class"); - type = "java11"; } set_argv(program_name.c_str(), NULL); @@ -977,163 +971,6 @@ bool has_illegal_keywords_in_file(const string &name) { return false; } -RunCompilerResult prepare_java_source(const string &name, const string &path = work_path) { - FILE *f = fopen((path + "/" + name + ".code").c_str(), "r"); - - const int L = 1024; - - std::string s; - char buf[L + 1]; - - int mode = 0; - - while (!feof(f)) { - buf[fread(buf, 1, L, f)] = '\0'; - - for (char *p = buf; *p; p++) { - s += *p; - switch (mode) { - case 0: - switch (*p) { - case '/': - mode = 1; - break; - case '\'': - mode = 5; - break; - case '\"': - mode = 6; - break; - } - break; - case 1: - switch (*p) { - case '/': - mode = 2; - s.resize(s.length() - 2); - break; - case '*': - mode = 3; - s.resize(s.length() - 2); - break; - } - break; - case 2: - s.resize(s.length() - 1); - switch (*p) { - case '\n': - s += '\n'; - mode = 0; - break; - } - break; - case 3: - s.resize(s.length() - 1); - switch (*p) { - case '*': - mode = 4; - break; - } - break; - case 4: - s.resize(s.length() - 1); - switch (*p) { - case '/': - s += ' '; - mode = 0; - break; - } - break; - case 5: - switch (*p) { - case '\'': - mode = 0; - break; - case '\\': - mode = 7; - break; - } - case 6: - switch (*p) { - case '\"': - mode = 0; - break; - case '\\': - mode = 8; - break; - } - case 7: - mode = 5; - break; - case 8: - mode = 6; - break; - } - } - } - - bool valid[256]; - fill(valid, valid + 256, false); - for (int c = 'a'; c <= 'z'; c++) - valid[c] = true; - for (int c = 'A'; c <= 'Z'; c++) - valid[c] = true; - valid['.'] = true; - valid['_'] = true; - - vector tokens; - for (int p = 0, np = 0; p < (int)s.length(); p = np) { - while (np < (int)s.length() && valid[(unsigned char)s[np]]) { - np++; - } - if (np == p) { - np++; - } else { - tokens.push_back(s.substr(p, np - p)); - } - } - if (tokens.size() > 0 && tokens[0] == "package") { - RunCompilerResult res; - res.type = RS_WA; - res.ust = -1; - res.usm = -1; - res.succeeded = false; - res.info = "Please don't specify the package."; - return res; - } - - for (int i = 0; i + 1 < (int)tokens.size(); i++) { - if (tokens[i] == "class") { - if (tokens[i + 1].length() <= 100) { - config[name + "_main_class"] = tokens[i + 1]; - - RunCompilerResult res; - res.type = RS_AC; - res.ust = 0; - res.usm = 0; - res.succeeded = true; - return res; - } else { - RunCompilerResult res; - res.type = RS_WA; - res.ust = -1; - res.usm = -1; - res.succeeded = false; - res.info = "The name of the main class is too long."; - return res; - } - } - } - - RunCompilerResult res; - res.type = RS_WA; - res.ust = -1; - res.usm = -1; - res.succeeded = false; - res.info = "Can't find the main class."; - return res; -} - RunCompilerResult compile_c(const string &name, const string &path = work_path) { return run_compiler(path.c_str(), "/usr/bin/gcc", "-o", name.c_str(), "-x", "c", (name + ".code").c_str(), "-lm", "-O2", "-DONLINE_JUDGE", NULL); @@ -1159,32 +996,6 @@ RunCompilerResult compile_python3(const string &name, const string &path = work_ return run_compiler(path.c_str(), "/usr/bin/python3.8", "-I", "-B", "-O", "-c", ("import py_compile\nimport sys\ntry:\n py_compile.compile('" + name + ".code'" + ", '" + name + "', doraise=True)\n sys.exit(0)\nexcept Exception as e:\n print(e)\n sys.exit(1)").c_str(), NULL); } -RunCompilerResult compile_java8(const string &name, const string &path = work_path) { - RunCompilerResult ret = prepare_java_source(name, path); - if (!ret.succeeded) - return ret; - - string main_class = conf_str(name + "_main_class"); - - executef("rm %s/%s -rf 2>/dev/null; mkdir %s/%s", path.c_str(), name.c_str(), path.c_str(), name.c_str()); - executef("echo package %s\\; | cat - %s/%s.code >%s/%s/%s.java", name.c_str(), path.c_str(), name.c_str(), path.c_str(), name.c_str(), main_class.c_str()); - - return run_compiler((path + "/" + name).c_str(), - "/usr/lib/jvm/java-8-openjdk-amd64/bin/javac", (main_class + ".java").c_str(), NULL); -} -RunCompilerResult compile_java11(const string &name, const string &path = work_path) { - RunCompilerResult ret = prepare_java_source(name, path); - if (!ret.succeeded) - return ret; - - string main_class = conf_str(name + "_main_class"); - - executef("rm %s/%s -rf 2>/dev/null; mkdir %s/%s", path.c_str(), name.c_str(), path.c_str(), name.c_str()); - executef("echo package %s\\; | cat - %s/%s.code >%s/%s/%s.java", name.c_str(), path.c_str(), name.c_str(), path.c_str(), name.c_str(), main_class.c_str()); - - return run_compiler((path + "/" + name).c_str(), - "/usr/lib/jvm/java-11-openjdk-amd64/bin/javac", (main_class + ".java").c_str(), NULL); -} RunCompilerResult compile(const char *name) { string lang = conf_str(string(name) + "_language"); @@ -1212,12 +1023,6 @@ RunCompilerResult compile(const char *name) { if (lang == "Python3") { return compile_python3(name); } - if (lang == "Java8") { - return compile_java8(name); - } - if (lang == "Java11") { - return compile_java11(name); - } if (lang == "C") { return compile_c(name); } diff --git a/judger/uoj_judger/run/run_program.cpp b/judger/uoj_judger/run/run_program.cpp index 62aac9f..b7abcd4 100644 --- a/judger/uoj_judger/run/run_program.cpp +++ b/judger/uoj_judger/run/run_program.cpp @@ -221,11 +221,8 @@ void parse_args(int argc, char **argv) { } } - if (run_program_config.type == "java8" || run_program_config.type == "java11") { - run_program_config.program_name = run_program_config.argv[0]; - } else { - run_program_config.program_name = realpath(run_program_config.argv[0]); - } + run_program_config.program_name = realpath(run_program_config.argv[0]); + if (run_program_config.work_path.empty()) { run_program_config.work_path = dirname(run_program_config.program_name); run_program_config.program_basename = basename(run_program_config.program_name); @@ -242,12 +239,6 @@ void parse_args(int argc, char **argv) { } else if (run_program_config.type == "python3") { string pre[3] = {"/usr/bin/python3.8", "-I", "-B"}; run_program_config.argv.insert(run_program_config.argv.begin(), pre, pre + 3); - } else if (run_program_config.type == "java8") { - string pre[3] = {"/usr/lib/jvm/java-8-openjdk-amd64/bin/java", "-Xmx1024m", "-Xss1024m"}; - run_program_config.argv.insert(run_program_config.argv.begin(), pre, pre + 3); - } else if (run_program_config.type == "java11") { - string pre[3] = {"/usr/lib/jvm/java-11-openjdk-amd64/bin/java", "-Xmx1024m", "-Xss1024m"}; - run_program_config.argv.insert(run_program_config.argv.begin(), pre, pre + 3); } } diff --git a/judger/uoj_judger/run/run_program_conf.h b/judger/uoj_judger/run/run_program_conf.h index bf1e32c..7bce162 100644 --- a/judger/uoj_judger/run/run_program_conf.h +++ b/judger/uoj_judger/run/run_program_conf.h @@ -297,16 +297,7 @@ void init_conf(const RunProgramConfig &config) { } statable_file_name_set.insert(config.work_path + "/"); - if (config.type != "java8" && config.type != "java11") { - add_file_permission(config.program_name, 'r'); - } else { - int p = config.program_name.find('.'); - if (p == string::npos) { - readable_file_name_set.insert(config.work_path + "/"); - } else { - readable_file_name_set.insert(config.work_path + "/" + config.program_name.substr(0, p) + "/"); - } - } + add_file_permission(config.program_name, 'r'); add_file_permission(config.work_path, 'r'); for (vector::const_iterator it = config.extra_readable_files.begin(); it != config.extra_readable_files.end(); it++) { @@ -398,112 +389,6 @@ void init_conf(const RunProgramConfig &config) { # ifdef UOJ_JUDGER_BASESYSTEM_UBUNTU1804 statable_file_name_set.insert("/usr/lib/python38.zip"); # endif - } else if (config.type == "java8") { - syscall_max_cnt[__NR_gettid ] = -1; - syscall_max_cnt[__NR_set_tid_address] = 1; - syscall_max_cnt[__NR_set_robust_list] = 14; - syscall_max_cnt[__NR_futex ] = -1; - - syscall_max_cnt[__NR_uname ] = 1; - - syscall_max_cnt[__NR_clone ] = 13; - - syscall_max_cnt[__NR_getdents ] = 4; - syscall_max_cnt[__NR_getdents64 ] = 4; - - syscall_max_cnt[__NR_clock_getres ] = 2; - - syscall_max_cnt[__NR_setrlimit ] = 1; - - syscall_max_cnt[__NR_sched_getaffinity] = -1; - syscall_max_cnt[__NR_sched_yield ] = -1; - - # ifdef UOJ_JUDGER_BASESYSTEM_UBUNTU1804 - syscall_max_cnt[__NR_prlimit64 ] = -1; - syscall_max_cnt[__NR_getpid ] = -1; - syscall_max_cnt[__NR_sysinfo ] = -1; - syscall_max_cnt[__NR_clone ] = -1; - syscall_max_cnt[__NR_set_robust_list] = -1; - syscall_max_cnt[__NR_prctl ] = -1; - # endif - - syscall_should_soft_ban[__NR_socket ] = true; - syscall_should_soft_ban[__NR_connect ] = true; - syscall_should_soft_ban[__NR_geteuid ] = true; - syscall_should_soft_ban[__NR_getuid ] = true; - - soft_ban_file_name_set.insert("/etc/nsswitch.conf"); - soft_ban_file_name_set.insert("/etc/passwd"); - - add_file_permission("/usr/lib/jvm/java-8-openjdk-amd64/", 'r'); - readable_file_name_set.insert("/sys/devices/system/cpu/"); - readable_file_name_set.insert("/proc/"); - # ifdef UOJ_JUDGER_BASESYSTEM_UBUNTU1804 - readable_file_name_set.insert("/sys/fs/cgroup/cpu/"); - readable_file_name_set.insert("/sys/fs/cgroup/cpu,cpuacct/"); - readable_file_name_set.insert("/sys/fs/cgroup/memory/"); - readable_file_name_set.insert("/usr/lib/locale/"); - # endif - statable_file_name_set.insert("/usr/java/"); - statable_file_name_set.insert("/tmp/"); - } else if (config.type == "java11") { - syscall_max_cnt[__NR_gettid ] = -1; - syscall_max_cnt[__NR_set_tid_address] = 1; - syscall_max_cnt[__NR_set_robust_list] = 15; - syscall_max_cnt[__NR_futex ] = -1; - - syscall_max_cnt[__NR_uname ] = 1; - - syscall_max_cnt[__NR_clone ] = 14; - - syscall_max_cnt[__NR_getdents ] = 4; - syscall_max_cnt[__NR_getdents64 ] = 4; - - syscall_max_cnt[__NR_clock_getres ] = 2; - - syscall_max_cnt[__NR_setrlimit ] = 1; - - syscall_max_cnt[__NR_sched_getaffinity] = -1; - syscall_max_cnt[__NR_sched_yield ] = -1; - - # ifdef UOJ_JUDGER_BASESYSTEM_UBUNTU1804 - syscall_max_cnt[__NR_prlimit64 ] = -1; - syscall_max_cnt[__NR_getpid ] = -1; - syscall_max_cnt[__NR_sysinfo ] = -1; - syscall_max_cnt[__NR_clone ] = -1; - syscall_max_cnt[__NR_set_robust_list] = -1; - syscall_max_cnt[__NR_uname ] = -1; - syscall_max_cnt[__NR_clock_getres ] = -1; - syscall_max_cnt[__NR_pread64 ] = -1; - syscall_max_cnt[__NR_prctl ] = -1; - syscall_max_cnt[__NR_nanosleep ] = -1; - syscall_max_cnt[__NR_clock_nanosleep] = -1; - # endif - - syscall_should_soft_ban[__NR_socket ] = true; - syscall_should_soft_ban[__NR_connect ] = true; - syscall_should_soft_ban[__NR_geteuid ] = true; - syscall_should_soft_ban[__NR_getuid ] = true; - - soft_ban_file_name_set.insert("/etc/nsswitch.conf"); - soft_ban_file_name_set.insert("/etc/passwd"); - - add_file_permission("/usr/lib/jvm/java-11-openjdk-amd64/", 'r'); - readable_file_name_set.insert("/sys/devices/system/cpu/"); - readable_file_name_set.insert("/proc/"); - # ifdef UOJ_JUDGER_BASESYSTEM_UBUNTU1804 - readable_file_name_set.insert("/sys/fs/cgroup/cpu/"); - readable_file_name_set.insert("/sys/fs/cgroup/cpu,cpuacct/"); - readable_file_name_set.insert("/sys/fs/cgroup/memory/"); - readable_file_name_set.insert("/usr/share/java/"); - readable_file_name_set.insert("/usr/lib/locale/"); - readable_file_name_set.insert("/etc/oracle/java/usagetracker.properties"); - # endif - statable_file_name_set.insert("/usr/java/"); - statable_file_name_set.insert("/tmp/"); - # ifdef UOJ_JUDGER_BASESYSTEM_UBUNTU1804 - statable_file_name_set.insert("/usr/share/"); - # endif } else if (config.type == "compiler") { syscall_max_cnt[__NR_gettid ] = -1; syscall_max_cnt[__NR_set_tid_address] = -1; @@ -535,13 +420,13 @@ void init_conf(const RunProgramConfig &config) { syscall_max_cnt[__NR_chdir ] = -1; syscall_max_cnt[__NR_fchdir ] = -1; - syscall_max_cnt[__NR_ftruncate ] = -1; // for javac = = + syscall_max_cnt[__NR_ftruncate ] = -1; - syscall_max_cnt[__NR_sched_getaffinity] = -1; // for javac = = - syscall_max_cnt[__NR_sched_yield ] = -1; // for javac = = + syscall_max_cnt[__NR_sched_getaffinity] = -1; + syscall_max_cnt[__NR_sched_yield ] = -1; - syscall_max_cnt[__NR_uname ] = -1; // for javac = = - syscall_max_cnt[__NR_sysinfo ] = -1; // for javac = = + syscall_max_cnt[__NR_uname ] = -1; + syscall_max_cnt[__NR_sysinfo ] = -1; # ifdef UOJ_JUDGER_BASESYSTEM_UBUNTU1804 syscall_max_cnt[__NR_prlimit64 ] = -1; @@ -553,10 +438,10 @@ void init_conf(const RunProgramConfig &config) { syscall_max_cnt[__NR_socketpair ] = -1; # endif - syscall_should_soft_ban[__NR_socket ] = true; // for javac - syscall_should_soft_ban[__NR_connect ] = true; // for javac - syscall_should_soft_ban[__NR_geteuid ] = true; // for javac - syscall_should_soft_ban[__NR_getuid ] = true; // for javac + syscall_should_soft_ban[__NR_socket ] = true; + syscall_should_soft_ban[__NR_connect ] = true; + syscall_should_soft_ban[__NR_geteuid ] = true; + syscall_should_soft_ban[__NR_getuid ] = true; writable_file_name_set.insert("/tmp/"); @@ -582,8 +467,8 @@ void init_conf(const RunProgramConfig &config) { readable_file_name_set.insert("/sys/devices/system/cpu/"); readable_file_name_set.insert("/proc/"); - soft_ban_file_name_set.insert("/etc/nsswitch.conf"); // for javac = = - soft_ban_file_name_set.insert("/etc/passwd"); // for javac = = + soft_ban_file_name_set.insert("/etc/nsswitch.conf"); + soft_ban_file_name_set.insert("/etc/passwd"); readable_file_name_set.insert("/etc/timezone"); # ifdef UOJ_JUDGER_FPC_VERSION diff --git a/web/app/controllers/faq.php b/web/app/controllers/faq.php index c404e07..b7a7c1e 100644 --- a/web/app/controllers/faq.php +++ b/web/app/controllers/faq.php @@ -50,8 +50,6 @@

默认的测评环境是 Ubuntu Linux 20.04 LTS x64。

C的编译器是 gcc 9.4.0,编译命令:gcc code.c -o code -lm -O2 -DONLINE_JUDGE

C++的编译器是 g++ 9.4.0,编译命令:g++ code.cpp -o code -lm -O2 -DONLINE_JUDGE。如果选择C++11会在编译命令后面添加-std=c++11

-

Java8的JDK版本是 openjdk 1.8.0_312,编译命令:javac code.java

-

Java11的JDK版本是 openjdk 11.0.14,编译命令:javac code.java

Pascal的编译器是 fpc 3.0.4,编译命令:fpc code.pas -O2

Python会先编译为优化过的字节码.pyo文件。支持的Python版本分别为Python 2.7和3.8。

diff --git a/web/app/libs/uoj-html-lib.php b/web/app/libs/uoj-html-lib.php index fbf6981..c9c2280 100644 --- a/web/app/libs/uoj-html-lib.php +++ b/web/app/libs/uoj-html-lib.php @@ -457,10 +457,6 @@ HTML; case 'Python3': $sh_class = 'sh_python'; break; - case 'Java8': - case 'Java11': - $sh_class = 'sh_java'; - break; case 'C': $sh_class = 'sh_c'; break; @@ -509,10 +505,6 @@ function echoSubmissionContent($submission, $requirement) { case 'Python3': $sh_class = 'sh_python'; break; - case 'Java8': - case 'Java11': - $sh_class = 'sh_java'; - break; case 'C': $sh_class = 'sh_c'; break; diff --git a/web/app/libs/uoj-judger-lib.php b/web/app/libs/uoj-judger-lib.php index c86f26f..db46221 100644 --- a/web/app/libs/uoj-judger-lib.php +++ b/web/app/libs/uoj-judger-lib.php @@ -1,6 +1,6 @@ ')) var div_help_language = $('
'); - var show_help_lang = function() { - if ($(this).val() == 'Java8' || $(this).val() == 'Java11') { - div_help_language.text('注意:Java 程序源代码中不应指定所在的 package。我们会在源代码中找到第一个被定义的类并以它的 main 函数为程序入口点。'); - } else { - div_help_language.text(''); - } - }; - var advanced_editor = null; var advanced_editor_init = function() { require_codemirror({}, function() { @@ -770,8 +758,6 @@ $.fn.source_code_form_group = function(name, text, langs_options_html) { } } - input_language.each(show_help_lang); - input_language.change(show_help_lang); input_language.change(function() { if (advanced_editor != null) { var mode = get_codemirror_mode(input_language.val());