• Post Reply Bookmark Topic Watch Topic
  • New Topic

keywords  RSS feed

 
Enkita mody
Ranch Hand
Posts: 333
Firefox Browser Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why aren't strictfp and native allowed with abstract ?

Thanks.
 
Achint Verma
Greenhorn
Posts: 12
Java
  • Mark post as helpful
  • send pies
  • 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.
 
Campbell Ritchie
Marshal
Posts: 56578
172
  • Mark post as helpful
  • send pies
  • 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 Java Windows XP
  • Mark post as helpful
  • send pies
  • 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....
}
}
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • 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 Java Windows XP
  • Mark post as helpful
  • send pies
  • 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
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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: 56578
172
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!