Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No strictfp in Scala - workarounds?

Tags:

People also ask

What is strictfp modifier?

strictfp is a modifier that stands for strict floating-point which was not introduced in the base version of java as it was introduced in Java version 1.2.

Is it possible to declare a variable with strictfp?

strictfp can be applied to class, method or on interfaces but cannot be applied to abstract methods, variable or on constructors.

What is the use of strictfp keyword?

strictfp is a keyword in java used for restricting floating-point calculations and ensuring same result on every platform while performing operations in the floating-point variable.


I searched the web for how to enforce srictfp in Scala but could not find any hint of it. There are some people complaining about it, but real solutions cannot be found. There is a bugtracker entry about it which is almost two years old. As it seems there is no elegant fix for it on the way I'm looking for workarounds.

My current idea is to set the appropiate method flag ACC_STRICT in the generated bytecode by myself somehow but I have no idea what would be the best solution to do so. A Scala Compiler Plugin comes to mind or just hacking flags in a hex editor. Maybe someone faced the same challenge and can tell me his or her solution?