CLASSES
Method Modifiers
8.4.3
Such inlining cannot be done at compile time unless it can be guaranteed that
Test
and
Point
will always be recompiled together, so that whenever
Point
and specifically its
move
method changes, the code for
Test.main
will also be
updated.
8.4.3.4
native
Methods
A method that is
native
is implemented in platform dependent code, typically
written in another programming language such as C, C++,
FORTRAN
, or assembly
language. The body of a
native
method is given as a semicolon only, indicating
that the implementation is omitted, instead of a block.
A compile time error occurs if a
native
method is declared
abstract
.
For example, the class
RandomAccessFile
of the standard package
java.io
might declare the following
native
methods:
package java.io;
public class RandomAccessFile
implements DataOutput, DataInput
{
. . .
public native void open(String name, boolean writeable)
throws IOException;
public native int readBytes(byte[] b, int off, int len)
throws IOException;
public native void writeBytes(byte[] b, int off, int len)
throws IOException;
public native long getFilePointer() throws IOException;
public native void seek(long pos) throws IOException;
public native long length() throws IOException;
public native void close() throws IOException;
}
8.4.3.5
synchronized
Methods
A
synchronized
method acquires a lock ( 17.1) before it executes. For a class
(
static)
method, the lock associated with the
Class
object ( 20.3) for the
method's class is used. For an instance method, the lock associated with
this
(the
object for which the method was invoked) is used. These are the same locks that
can be used by the
synchronized
statement ( 14.17); thus, the code:
class Test {
int count;
synchronized void bump() { count++; }
static int classCount;
static synchronized void classBump() {
classCount++;
}
}
161
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Inexpensive Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Jsp Hosting
Cheap Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved