• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Interface non-access modifiers.

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Folks,

I've been stuyding up on interfaces recently and noticed that in the K&B book it explicitly states that interface methods are abstract, and therefore they cannot be marked as strictfp. This is true. However, the interface itself can be marked as strictfp. Also, abstract classes can also be marked as strictfp. However, abstract methods in an abstract class cannot be marked strictp. So I googled (wow, it's a verb now) to see what I could find. This was the explanation

strictfp is okay on an interface. It is okay because you can evaluate compile-time constants using strictfp rules within an interface.

Can somebody explain this to me? I'm a bit confused now as to why abstract classes/interfaces can have the non-access modifier strictfp but not methods. Thanks!

Andreas
[ September 27, 2005: Message edited by: Andreas Sandberg ]
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Andreas,

You can have a compile time static constant in an interface that can be evaluated with strictfp rules. For example, you could have the following in an interface:

double strictDouble = 4.13 * 9.0;

This is a constant, yet it will still be evaluated with strictfp rules if the interface is marked as strictfp.

You cannot mark methods in the interface with strictfp because, for methods, strictfp is an implementation specific modifier. Since interface methods have no implementation, they cannot be marked as strictfp (likewise with synchronized). There is no such thing as a strict fp method that has no body.
 
reply
    Bookmark Topic Watch Topic
  • New Topic