microtony's blog

By microtony, history, 9 years ago, In English

UPD: arti commented that they will be using Oracle JDK. Thanks!

I maintain a online judge which uses the CMS isolate sandbox. I was trying to support Java so I looked at CMS itself, and found that they are using gcj (GNU Compiler for Java) as you can see in this commit.

https://github.com/cms-dev/cms/commit/cf949952424677e0b0762eec5e461e33f85eecb3

Of course this doesn't mean they will definitely use gcj and we should wait for their announcement. Disclaimer: I am not a IOI participant nor use Java in competitive programming. But I don't think they will support OpenJDK/Oracle as I (almost always) get memory allocation error when running JVM within isolate sandbox.

gcj is the default java installation in Ubuntu. So far I faced two bugs. (These bugs are related to I/O and since IOI uses interface file so it may not be a problem.)

1) Formatted floating point numbers will become empty

public class Task {
  public static void main(String[] args) {
    System.out.format("$%.3f\n", 0.9876);
  }
}
Expected output: $0.988
Program output: $

2) Scanner class does not work with Scanner.in.read(). Even if you are trying to scan integers only, you have to press enter several times. This does not happen when you use file redirection.

import java.util.*;
import java.io.*;
public class Task {
  public static void main(String[] args) throws IOException {
    Scanner in = new Scanner(System.in);
    System.out.print((char) System.in.read());
    System.out.println(in.nextInt());
  }
}
Input: A5
Expected Output: A5
Program: 
(strange character)Exception in thread "main" java.util.InputMismatchException: "A5" is not an integer
   at java.util.Scanner.myNextInt(libgcj.so.15)
   at java.util.Scanner.nextInt(libgcj.so.15)
   at java.util.Scanner.nextInt(libgcj.so.15)
   at Task.main(Task.java)
  • Vote: I like it
  • +11
  • Vote: I do not like it

»
9 years ago, # |
  Vote: I like it +5 Vote: I do not like it

Hello, microtony. We will use Oracle JDK on IOI 2015. Hope our patch will soon be available in the repo.

»
9 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by microtony (previous revision, new revision, compare).