1

I use Java 8.0 (IDE Eclipse). And sometimes want to drill-down into specific implementation (fields, methods) of which original developers (of language internals itself) have chosen. In many times Wikipedia is too general (helps, but not enough), while other sources answer to just-near, but not exact my question. And besides it - I am sometimes curious to see by myself (for both "want to be more independent" and "seeing by myself eyes is best to understand and be convinced" reasons).

How can I see inside, like this ?

My specific questions for now (as example and I ask to really know how-to): How internally random numbers generated in Java, I mean what the exact algorithm for output Java uses (using Math.random()) ?

  • 1
    The sources come with the JDK (src.zip). Look at them. – JB Nizet Aug 21 '14 at 14:35
  • See the answers to [Where can I see the Sun Java source code?](http://stackoverflow.com/q/261015/44522). – MicSim Aug 21 '14 at 14:38
  • It seems The Math.random is kind of complex. If you don't find any detailed information on stackoverflow or google, you can type Math.random() in a Java application in eclipse, click on the "random()" and press the F3 button to see what code gets called. Keep pressing F3 to keep going down the rabbit hole. :) – Rami Del Toro Aug 21 '14 at 14:41

3 Answers3

0

You could look at something like this implementation, but keep in mind that it is not guaranteed to be implemented the same way across different implementations. Ideally, as a user of an API, you should not need to know how it is implemented; the implementation may change in future versions, as long as the API stays the same.

Jon Newmuis
  • 25,722
  • 2
  • 45
  • 57
  • *In general, as a user of an API, you should not need to know how it is implemented* you may want to check this if you spot this is your bottleneck or for learning purposes. – Luiggi Mendoza Aug 21 '14 at 14:39
0

simply clicking on methods and classes of your choice while holding down CTRL reveals the sourcecode. As long as you installed the JDK you will see even the most basic implementations - without exception. If you cant open an implementation you will have to install the appropriate sourcecode.

specializt
  • 1,913
  • 15
  • 26
0

For Eclipse , you can do this be ctrl+click on the method name or pressing f3. You can also hold shift and hover over the method or class.

Tom Jonckheere
  • 1,630
  • 3
  • 20
  • 37