0

I've been trying to get sqrt method's source code from the class Math, I opened the class math from src folder, which contains the source code of Java. I looked up the method and it turned out that it returns from the other method sqrt from the class StrictMath. Again I open StrictMath. I was surprised that I didn't get the source code of the method itself but I found bunch of comments that are not helpful for me. I am wondering how to get the source code of the method.

EDIT: I also looked up Oracle docs and didn't find anything. Same happened with Google.

YoZo
  • 129
  • 1
  • 2
  • 7
  • If you're wondering how I found a post from all the way back in 2009... I just googled the exact text of this question's summary line. Did you try to search for this question before you posted it here? – yshavit Aug 30 '15 at 00:33
  • You're talking like it has the answer in it. :) – YoZo Aug 30 '15 at 00:35
  • That answer quotes documentation explaining why it's native, says what the library it uses is, and even copies the relevant part of that library. Not sure what more you'd want. – yshavit Aug 30 '15 at 02:17

2 Answers2

1

If you look at its signature in StrictMath:

 public static native double More ...sqrt(double a);

You see the native keyword which indicates that the method is probably not implemented in Java.

For more details see this: Where can I find the source code for Java's Square Root function?

Community
  • 1
  • 1
Zarwan
  • 5,537
  • 4
  • 30
  • 48
0

Most (if not all) methods in StrictMath are native. That means they are implemented not in java but they are JNI calls.

krzydyn
  • 1,012
  • 9
  • 19