battlecode/battlecode-server-2017

Inject strictfp into player code

Opened this issue · 8 comments

Not sure how to do this

Possibly a dumb thought, but since server the class running robotplayer is strictfp, shouldn't all functions (including player code) within it be run with strictfp restrictions as well?

Server isn't really 'running' RobotPlayer, as the JVM understands it. Server is a loaded class, and RobotPlayer is also a loaded class. (RobotPlayer is loaded by a custom classloader, but that doesn't tell it anything about Server.)

Not exactly a fix (at all), but I just made examplefuncsplayer strictfp because I know a lot of teams use that file as a template.

Is it possible to use gradle to literally just iterate through all classes in a folder and insert strictfp into each class line?

I believe it would be better to accomplish this with the instrumenter somehow.

I can look into this now

I found a way to force strictfp by setting Opcodes.ACC_STRICT in MethodVisitor. This has an interesting consequence of making testLambdas() fail, as Method test in class instrumented/java/util/function/Predicate has illegal modifiers: 0xC01. I'm assuming this means java.util.function.Predicate is not compatible with strictfp, which means we either have to disallow Predicate or just not have fully-enforced strictfp.

Pear0 commented

This is sort of a shot in the dark, but what if you set Opcodes.ACC_STRICT on the classes instead of the methods.

According to JLS §15.4:

If a class, interface, or method, X, is declared strictfp, then X and any class, interface, method, constructor, instance initializer, static initializer, or variable initializer within X is said to be FP-strict.

That would mean that all methods and lambdas which are really inner classes should also be evaluated with fpstrict rules.