This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes abstract strictfp class legal? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "abstract strictfp class legal?" Watch "abstract strictfp class legal?" New topic
Author

abstract strictfp class legal?

John Brown
Ranch Hand

Joined: Dec 01, 2004
Posts: 35
Isn't it odd that when declaring a method, you can't mix "abstract" with "strictfp", like

abstract strictfp void aMethod(); //won't compile

but you can declare an abstract class which is also strictfp ???, like

public abstract strictfp class aClass { ... } //will compile fine

I understand why the first code won't compile, but not why the second one does compile.
Sasikanth Malladi
Ranch Hand

Joined: Nov 04, 2000
Posts: 175
When you declare a method as strictfp you're saying "This method uses the IEEE754 standard for floating point operations" and hence you can't have a method that's abstract and strictfp as an abstract method isn't doing jack, let along implementing the IEEE 754 standard.
"Abstract methods cannot be marked synchronized, strictfp or native, all of which are modifiers describing something about the implementation of a method" - From the KB book.
"Marking a class as strictfp means that any method code in the class will conform to the IEEE754 standard rules for floating points. Without that
modifier, floating points used in the methods might behave in a platform-dependent way. If you don�t declare a class as strictfp, you can still get strictfp behavior on a method-by-method basis, by declaring a method as strictfp."
Sashi
John Brown
Ranch Hand

Joined: Dec 01, 2004
Posts: 35
Thanks Sashi for your response. Yes, I already knew that when I posted the thread.
Let me put it another way: declaring a class as strictfp is like declaring all its methods as strictfp; i.e.:



is the equivalent of



So, I assumed that



is the equivalent of



But you can't have "abstract strictfp" methods. Then it hit me, an abstract class may have concrete (nonabstract) methods too; so, when declaring an abstract class as strictfp, the compiler makes an exception, and applies the "strictfp" modifier only to concrete methods. Right?
Sasikanth Malladi
Ranch Hand

Joined: Nov 04, 2000
Posts: 175
Yes, if an abstract class has non abstract methods, it is legal to declare the class as abstract and strictfp.


The above is legal and the compiler is happy to accept it.
HTH,
Sashi
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: abstract strictfp class legal?