• Post Reply Bookmark Topic Watch Topic
  • New Topic

View Of Native Functions of JAVA  RSS feed

 
Shaan Shar
Ranch Hand
Posts: 1249
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys, I have seen a function in System class mentioned below as :


could anyone tell me or guide me where these native function are written or can we have a look on that . I should mention that I am using JDK 1.4. Please help me out there are so many function which are native. I am basically understanding the Basic functionality of JVM. Thats why I really needed it. Please help me out.
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Native methods in the JDK often provide an interface to functions in the operating system. Such functions, by their nature, cannot be reproduced by native Java code. System.currentTimeMillis() is an example of that. A few native methods in the JDK are things that could be done by native Java code, but are done as native methods for speed. System.arraycopy() is one of these.

I think one may be able to get hold of the source code of Sun's JDK. Of course, this is not in the Java source code that comes with the JDK. But I think you can get the native (C, C++ ...?) code somewhere. It will vary between platforms, of course. I seem to remember having to sign up to something, to get some source code for something else in the past. Sorry to be vague.

That said, I'm confused why you want this source code? Can you explain what you want to do with it?
 
Shaan Shar
Ranch Hand
Posts: 1249
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually I am trying to understand the JVM completly for that I have to understand the Native code too. Could you please specify from where we can get this native code.
 
Chetan Parekh
Ranch Hand
Posts: 3640
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Read The Java Virtual Machine Specification first.
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ankur Sharma:
Actually I am trying to understand the JVM completly for that I have to understand the Native code too. Could you please specify from where we can get this native code.


I told you all I could remember. I'm not going to do a search that you could do.

Alternatively, maybe someone else knows?
 
Henry Wong
author
Sheriff
Posts: 23291
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ankur Sharma:
Actually I am trying to understand the JVM completly for that I have to understand the Native code too. Could you please specify from where we can get this native code.


The Java source code is available from java.sun.com. Just look for source code SCSL.

A word of warning though... you have to know C.

Henry
 
Timothy Sam
Ranch Hand
Posts: 751
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Uhmm... I couldn't help but say... When you say native functions, this is a term used in a non-oop perspective(or at least in java). If you're doing Java, I suggest you get used to the term "method". Because java is purely object oriented... There are no room for native functions but only object methods...
 
Paul Clapham
Sheriff
Posts: 22704
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ankur Sharma:
Actually I am trying to understand the JVM completly for that I have to understand the Native code too.
Do you mean you are going to "understand the JVM" by reading all the source code for all the classes in the standard Java API? There are over 12,000 classes in Java 5.
 
Rick O'Shay
Ranch Hand
Posts: 531
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Actually I am trying to understand the JVM completly for that I have to understand the Native code too.


The JVM executes translates virtual machine instructions in to native machine instructions. Now you understand the JVM completely -- specific details notwithstanding.

I think if you seriously want to understand the JVM completely you should start with the general theory of operation and work your way down through specifics. You can understand the JVM completely without ever seeing a line of native code.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And I sure as heck don't see how seeing something like



is going to help you understand how the JVM works! (Disclaimer: I just made this up. Should be approximately right on a POSIX system though.)
 
Shaan Shar
Ranch Hand
Posts: 1249
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well ya this was I really want to check this will give me how the function is actually working. Thankx a lot for this stuff. Now if anyone know the actually source pls let me check. I am good enough in C in my knowledge atleast I can understand the code. If I have.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you do what Henry said, way back toward the top of this thread, and look for "SCSL source code" at Sun's Java web site? In any case, the JDK 1.5 downloads page includes a link for the JDK source code, about halfway down.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!