Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Question about abstract and strictfp

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1272
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:
 
Do not meddle in the affairs of dragons - for you are crunchy and good with ketchup. Crunchy tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic