Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Virtual Machine / April 2005

Tip: Looking for answers? Try searching our database.

how does JVM cooperate with outside world?

Thread view: 
cuijustin@yahoo.com - 06 Apr 2005 13:04 GMT
I've read the Java VM spec and wonder how JVM communicate with the host
OS or hardware(in embedded case)? I disassemble some class file and
find that it just calls some system methods to do such things. But how
are these system methods are implemented in JVM? There are many JVM
chip now. How does JVM in these chips control the registers in the
peripheral circuits? If these shall be done by some special JVM
instructions, how can JDK compiler know these instructions?
Also, how does JVM call JNI and be called by outside functions
implemented in c/c++?
Can anybody give some technical details on the whole processes?
Boudewijn Dijkstra - 07 Apr 2005 11:55 GMT
> I've read the Java VM spec and wonder how JVM communicate with the host
> OS or hardware(in embedded case)? I disassemble some class file and
[quoted text clipped - 6 lines]
> implemented in c/c++?
> Can anybody give some technical details on the whole processes?

Most JVM's are written in C.  They interface with the system in the same way
that most C programs do.  Does this answer your questions?
cuijustin@yahoo.com - 07 Apr 2005 15:59 GMT
What I wanna know is whatever JVM instructions are used to trigger some
system call like services of host OS? And what instructions does JVM in
a hardware chip use to read/write registers of peripheral components
and service their interrupts? I browsed the VHDL code of JOP and find
there are some intructions like jopsys_xxx. But JOP just uses standard
JDK as its compiler. How can these special instructions be used, since
java compiler doesn't know them at all?
Boudewijn Dijkstra - 07 Apr 2005 21:53 GMT
> What I wanna know is whatever JVM instructions are used to trigger some
> system call like services of host OS?

None, only Java methods can be called from within the JVM.  The rest is JNI.

> And what instructions does JVM in
> a hardware chip use to read/write registers of peripheral components
> and service their interrupts?

That is not the job of JVM instructions, it is the job of the JVM as a native
program running on the host system.  A JVM is designed to sit on top of a host
system.  In the case of a limited device (e.g. an SBC), this host system will
often be minimal.

> I browsed the VHDL code of JOP and find
> there are some intructions like jopsys_xxx. But JOP just uses standard
> JDK as its compiler. How can these special instructions be used, since
> java compiler doesn't know them at all?

I'm not familiar with JOP.  Could it be that a different compiler was used to
build the JVM?
Andrew Reilly - 08 Apr 2005 01:21 GMT
> I'm not familiar with JOP.  Could it be that a different compiler was used to
> build the JVM?

I'm not familiar with JOP either, but I've read that there was once a GCC
back-end written to target Sun's PicoJava chip, which isn't that
surprising.  Presumably that means that the "extra" instructions that are
present, but which the java compiler won't generate are sufficient to deal
with the semantics of C.  That, in turn, suggests that the low-level
"platform" part was probably written in C, just as it is for most other
sorts of JVM implementations.

On the other hand, I've read (part of) a description of a Java OS system
where almost everything was indeed written in Java.  The only thing that
they added was a class that essentially added "peek()" and "poke()"
semantics.  I.e., something that could judiciously poke a hole through the
java object model to allow access to hardware at specific, known, machine
addresses.

Signature

Andrew

cuijustin@yahoo.com - 11 Apr 2005 06:07 GMT
I disassembled a simple Helloworld java class. The magic instruction
between JVM and the real world is "invokevirtual". What happens inside
the instruction? What's status of JVM when this instruction is
processing? How do JVM deal with the exceptions happening in the
realworld methods?
Also, if I wanna add some special functions to JVM, is JNI the only way
to extend JVM? Is JNI effecient enough to process large blocks of data?
Boudewijn Dijkstra - 11 Apr 2005 21:17 GMT
>I disassembled a simple Helloworld java class. The magic instruction
> between JVM and the real world is "invokevirtual".

This is not magic, and it can occur between normal Java objects.  Look at
this: (one link)

http://java.sun.com/docs/books/vmspec/2nd-edition/html/Instructions2.doc6.html#i
nvokevirtual


> What happens inside the instruction?

If you meant to ask: "What happens when the instruction is executed?", then
the answer is given.

> What's status of JVM when this instruction is processing?

I'm not sure what you meant to ask here.

> How do JVM deal with the exceptions happening in the realworld methods?

They can still be thrown, but not caught.  Check your jni.h for details.

> Also, if I wanna add some special functions to JVM, is JNI the only way
> to extend JVM?

Of course not.  You can also modify the JVM itself, provided that the owner
has granted you permission for that.

> Is JNI effecient enough to process large blocks of data?

JNI is usually actually less efficient for simple tasks.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.