• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question about abstract and strictfp

 
Brian Nguyen
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
This is something that I read from one of Study book:
Class Modifiers:
- You are free to use strictfp in combination with abstract or final...
Abstract Methods:
- Abstract methods cannot be marked as synchronized, strictfp or native...

So my question here is that why we can have a combination of abstract class and strictfp but not the combination of abstract method and strictfp?

Thanks for your answer in advance.
Brian
 
Bruce Evans
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for the earlier non-reply (hit submit accidentally)

native, synchronized and strictfp describe part of the
implementation of the method.

An abstract method can't say anything about its implementation.

HTH

-Bruce

Originally posted by Brian Nguyen:
Hi,
This is something that I read from one of Study book:
Class Modifiers:
- You are free to use strictfp in combination with abstract or final...
Abstract Methods:
- Abstract methods cannot be marked as synchronized, strictfp or native...

So my question here is that why we can have a combination of abstract class and strictfp but not the combination of abstract method and strictfp?

Thanks for your answer in advance.
Brian
 
Corey McGlone
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bruce Evans:
An abstract method can't say anything about its implementation.


That's true, Bruce, but, at the same time, I got this from the JLS:


The effect of the strictfp modifier is to make all float or double expressions within the class declaration be explicitly FP-strict (�15.4). This implies that all methods declared in the class, and all nested types declared in the class, are implicitly strictfp.


If that's the case, it would seem odd that you can declare a class to be strictfp (and therefore make all of its methods strictfp) but you can still declare one or more of those methods to be abstract. In essence, you've created an abstract, strictfp method. Doing so explicitly, however, produces a compiler error.

I must say that I never use the strictfp modifier so I'm not well versed in its usage, but there does seem to be, in my opinion, anyway, some degree of contradiction here.
 
Mike Gershman
Ranch Hand
Posts: 1272
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Corey Said:
it would seem odd that you can declare a class to be strictfp (and therefore make all of its methods strictfp) but you can still declare one or more of those methods to be abstract. In essence, you've created an abstract, strictfp method. Doing so explicitly, however, produces a compiler error.


A class strictfp modifier does not affect abstract method declarations in that class. Also, a class strictfp modifier is not inherited by subclass declarations, so it won't affect abstract methods when they are implemented in subclasses.

The following compiles OK:
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic