Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Save to My Library
Look up keyword
Like this
2Activity
0 of .
Results for:
No results containing your search query
P. 1
What Is a Native Method

What Is a Native Method

Ratings: (0)|Views: 57 |Likes:
Published by api-3777165

More info:

Published by: api-3777165 on Oct 16, 2008
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PPT, PDF, TXT or read online from Scribd
See more
See less

03/18/2014

pdf

text

original

What Is a Native Method?

\ue000A native method is the Java interface to non-Java code .
\ue000It is Java's link to the "outside world .
\ue000More specifically, a native method is a Java method whose

implementation is provided by non-Java code
\ue000Most languages provide some mechanism to call routines

written in another language. In C++, you must use the extern "C" stmt to signal that the C++ compiler is making a call to C functions

\ue000In Java, this is done via native methods. In your Java class,

you mark the methods you wish to implement outside of Java with the native method modifier-much like you would use the public or static modifiers

What Is a Native Method?
\ue000In Java, this is done via native methods. In your Java class,

you mark the methods you wish to implement outside of Java with the native method modifier-much like you would use the public or static modifiers

\ue000 Then, rather than supplying the method's body, you simply
place a semicolon in its place. As an example, the following
class defines a variety of native methods
public class IHaveNatives

{
native public void Native1( int x ) ;
native static public long Native2() ;
native synchronized private float Native3( Object o ) ;
native void Native4( int[] ary ) throws Exception ;

}
What Is a Native Method?
\ue000native methods look much like any other Java method,
except a single semicolon is in the place of the method body .
\ue000Naturally, the body of the method is implemented outside of
Java. What you basically define is the interface into this
externalm ethod
\ue000Every other Java method modifier can be used along with
native, except abstract
\ue000native methods can be static methods, thus not requiring
the creation of an object (or instance of a class)
\ue000native methods can limit their visibility with the public,
private, private protected, protected, or unspecifieddefault
access.
\ue000Native methods can also be synchronized

You're Reading a Free Preview

Download
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->