One problem with using errors from javac is that in theory it could recompile to a function that behaves differently. I think the bytecode should probably be compared instead.
There might be changes in the bytecode if the compiler major/minor version is different, so it'd be up to the user to make sure they're using the same one.
It's basically impossible to decompile to source code which will produce the same classfile, even in ideal circumstances. If you want roundtripping, you need to use the Krakatau diassembler.
If you're doing code complexity, you'll probably want to add a check that the method isn't just comments or an error message.
As for verifying the correctness of the code, that's obviously a Turing Hard problem. For arbitrary bytecode, you're most likely to get accurate results from Krakatau for a certain definition of accurate. If you don't, you should file a bug.