Arjun Thakur
Arjun Thakur

Reputation: 345

What is a VMObject?

I was reading source code of Object class in classpath project http://fuseyism.com/classpath/doc/ and in wait() and other methods there was a reference to VMObject.

public final void wait()
throws IllegalMonitorStateException, InterruptedException {
   VMObject.wait(this, 0, 0);
}

I tried searching answer on Google and asking on #java channel but no one has an answer.

Upvotes: 0

Views: 596

Answers (1)

Luxspes
Luxspes

Reputation: 6750

Well in the OpenJDK wait() looks like this:

public final native void wait(long timeout) throws InterruptedException;

Using google I found the code for VMObject

In there, VMObject.wait() looks like this:

static native void wait(Object o, long ms, int ns) throws IllegalMonitorStateException, InterruptedException;

I am only guessing, but I think VMObject is an implementation detail, specific of GNUClassPath, for some unknown reason they decided not to use native calls directly on "Object" and instead decided to have an extra layer of abstraction with the native calls in static methods in this "VMObject" class.}

From the Java Language and Virtual Machine Specification:

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.

If you would like to know more on what a native method is, you can read this.

Upvotes: 1

Related Questions