Skip to content

@strictfp annotation causes ClassFormatError for abstract classes and traits #7954

@scabug

Description

@scabug

The @Strictfp annotation is intended to standardize floating-point behavior across platforms, which I need for an application I'm developing. It can be applied to classes and concrete methods. Unfortunately, it currently fails when applied to abstract classes and traits. The attached .scala file demonstrates the problem. At runtime it fails with the error "java.lang.ClassFormatError: Method g in class A has illegal modifiers: 0xC01" or
"java.lang.ClassFormatError: Method f in class C has illegal modifiers: 0xC01". It appears that the Scala compiler is attempting to apply @Strictfp to abstract methods, which doesn't make sense and causes the JVM to throw an exception.

This bug can be worked around by applying @Strictfp to methods instead of classes. However, that would require applying it to every single concrete method, which would be very tedious, and it would be easy to miss some of them, which wouldn't cause any immediately obvious problems but might produce subtly different results on different platforms.

This bug occurs both when running the code in SBT and when compiling using scalac.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions