Do all Java arithmetic for strictfp at runtime using javassist?

Given a Java application that was written in terms of performance (that is, methods are not intentionally declared "strictfp" in the source code), is it possible to allow users to run the entire application in strict mode?

It seems like a rude approach would be to simply add the strictfp attribute to all methods of all classes using a custom class loader written with javassist. It will be like:

http://www.verious.com/qa/no-strictfp-in-scala-workarounds/

However, the class loader will need to add the strictpf attribute to all class methods in the application, including private ones. (The application is simply too large and complex to explicitly list all possible methods that may require the strictfp attribute.)

The javassist reflection API does not seem to support listing private methods:

http://www.csg.ci.iu-tokyo.ac.jp/~chiba/javassist/html/javassist/CtClass.html#getMethods ()

I want to do this in javassist (or generally using a user-friendly approach to loading classes)?

+6
source share
1 answer

I don't know if this will help you, but if you can switch to using the Oracle JRockit JVM, it has a JVM option to enable strictfp globally - '-XX +: - StrictFP`

(There is the option "-XX +: - UseStrictFP" in the Hotspot JVM, but it has the opposite effect for what you want.)

Link:

+2
source

Source: https://habr.com/ru/post/948152/


All Articles