Question: Can the following snippet be successfully converted to Java?

```
u64 magic_table[5] = {
  0x1000000010000000ull,
  0x1000000000010000ull,
  0x1000000000000001ull,
  0x0100000001000000ull,
  0x0000000100000001ull
};

u64 test(u64 magic_sum, int index) {
  u64 before = magic_sum & 0x4444444444444444ull;
  u64 after = (magic_sum + magic_table[index]) & 0x4444444444444444ull;
  return after & ~before;
}

```

Answer: 
A long in Java is 64-bit, but signed. However the 64-bits are still there for you to do whatever you would like with. So yes, I would say you can convert the C++ code to Java.
If you don't have time to deal with the differences in the languages(C++ vs. Java), just use [JNI](http://en.wikipedia.org/wiki/Java_Native_Interface) and you can run whatever C/C++ code in Java easily and efficiently.