• 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
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

keywords

 
Ranch Hand
Posts: 333
Firefox Browser Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why aren't strictfp and native allowed with abstract ?

Thanks.
 
Greenhorn
Posts: 12
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Whenever you use the keyword abstract either on a class or a method it means that they are not concrete. What will we do by restricting floating point arithmetic on something that is not concrete? Once those are implemented by an immediate concrete class then it would make sense to use strictfp. Similarly for native.
 
Marshal
Posts: 76440
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How on earth could you have a native method which is abstract? If it is abstract it has no body, and native means its body is written in C/C++.
Not sure about strictfp and abstract. Maybe strictfp is applying too strict a constraint on subsequent implementations. Maybe strictfp implies an implementation which includes arithmetic.
 
Enkita mody
Ranch Hand
Posts: 333
Firefox Browser Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:How on earth could you have a native method which is abstract? If it is abstract it has no body, and native means its body is written in C/C++.
Not sure about strictfp and abstract. Maybe strictfp is applying too strict a constraint on subsequent implementations. Maybe strictfp implies an implementation which includes arithmetic.



I don't understand your reason.If i write it's body in c/c++ so what's problem here to declare it abstract ? .

interface Bounceable{
native void jump();
}
class Ball implements Bounceable{
public void jump(){
// c/c++ codes here....
}
}
 
author
Posts: 23928
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

ankita modi. wrote:
I don't understand your reason.If i write it's body in c/c++ so what's problem here to declare it abstract ? .

interface Bounceable{
native void jump();
}



So, what you are asking for is the ability for an interface to enforce how it will be implemented. Question. For what purpose? What will it buy you?

I am intrigue to know.... and I guess if you can come up with a strong enough argument, you can send it to Oracle -- for possible addition into the language.

Henry
 
Enkita mody
Ranch Hand
Posts: 333
Firefox Browser Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Henry Wong wrote:
you can send it to Oracle -- for possible addition into the language.
Henry


I want to know only reason, so i can tell if anyone ask, not like same thing as it is written in book so doesn't work.
 
Henry Wong
author
Posts: 23928
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

ankita modi. wrote:
I want to know only reason, so i can tell if anyone ask, not like same thing as it is written in book so doesn't work.




The problem with "why" questions is that we can only speculate, as the Java designers don't visit the ranch very often.... So.... if you don't want to speculate, then the only "why" response is the Java language specification. In this case, section 8.4.3 of the JLS...

http://docs.oracle.com/javase/specs/jls/se7/html/jls-8.html#jls-8.4.3

Henry
 
Campbell Ritchie
Marshal
Posts: 76440
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

ankita modi. wrote: . . . If i write it's body in c/c++ so what's problem here to declare it abstract ? . . .

You are not actually declaring it abstract in the snippet you posted.

If it is abstract it cannot have a body. Not in Java, C, C++ or whatever.
 
If we don't do the shopping, we won't have anything for dinner. And I've invited this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic