aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes native abstract method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "native abstract method" Watch "native abstract method" New topic
Author

native abstract method

Serge Plourde
Ranch Hand

Joined: Jun 23, 2000
Posts: 140
In the book by Sierran and Bates, it is written (p.90) <b>Native Methods</b>... native can <i>never</i> be combined with abstract...

But, in the self test that follows the chapter, "private native void m1();" is shown as legal! I tested it, and it is true.

I know, the abstract keyword is not shown, but I thought that ending a method declaration with ";" after the "()" was indicating the compiler as abstract. If this is an abstract method declaration, why does the compiler not complain that it must be declared as abstract?
Ariel Ortiz
Ranch Hand

Joined: May 14, 2004
Posts: 121
I know, the abstract keyword is not shown, but I thought that ending a method declaration with ";" after the "()" was indicating the compiler as abstract. If this is an abstract method declaration, why does the compiler not complain that it must be declared as abstract?


This is not so. When the method body is missing it means that it is defined else where. In the case of abstract methods, the subclasses are responsible for providing the implementation. In the case of native methods, the code is implemented in another language (usaually C/C++) and made available through a dynamic link library at runtime.

...Ariel
Serge Plourde
Ranch Hand

Joined: Jun 23, 2000
Posts: 140
Thanks!

Finally, what is important to know here is
A method that is native is implemented in platform-dependent code
JLS 3rd edition, 8.4.3.4 native Methods.

Even though the code of the method declaration looks abstract a native method is implemented!
amit taneja
Ranch Hand

Joined: Mar 14, 2003
Posts: 810
Originally posted by Serge Plourde:
In the book by Sierran and Bates, it is written (p.90) <b>Native Methods</b>... native can <i>never</i> be combined with abstract...

But, in the self test that follows the chapter, "private native void m1();" is shown as legal! I tested it, and it is true.

I know, the abstract keyword is not shown, but I thought that ending a method declaration with ";" after the "()" was indicating the compiler as abstract. If this is an abstract method declaration, why does the compiler not complain that it must be declared as abstract?


Thanks and Regards, Amit Taneja
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: native abstract method