I was working with the StrictMath class. I needed to find the hyperbolic tangent and i could not find any suitable method in that class. So i just went thru the source code, only to find that Sun uses native methods to find cos,sin,tan etc.,
Firstly, they are using a C library fdlibm and it actually has tanh implementation in it . I was puzzled why Sun had just left it not done in their class.(If any specific reasons pls let me know). Secondly, guys any idea about what dll is being used by the StrictMath class, and at what time does these dll's get loaded into memory. Is there any particular class which does all these work. Looking forward to your replies.
I don't know about dll's offhand, but the hyperbolic tangent (like all hyperbolic functions) can be defined in terms of the exponential function, which is provided by StrictMath: tanh(x) = (exp(2*x) - 1) / (exp(2*x) + 1)
dll gets loaded by System.loadLibrary("dllname") method. ClassLoader calls this method. I don't know which dll is being used by StrictMath but you can get a list of dlls used by JDK1.3 in JDK1.3\bin\jre\bin directory. [ June 26, 2002: Message edited by: Snigdha Solanki ]
Snigdha<br />Sun Certified Programmer for the Java™ 2 Platform
With respect to the dll's in the query asked by Rajesh is my question. There is no static initialization block in the StrictMath class, so as we can consider that dlls are getting loaded. So i was also wondering actually how is this accomplished. I think there should be surely a way by which Sun is accomplishing this. It would be good if we all get to know this. Guru
Joined: Jan 30, 2000
gurubaran - please take a moment to read our display name policy and modify your display name to include both a first and last name. Thanks. There is no static initialization block in the StrictMath class, so as we can consider that dlls are getting loaded. Why is a static initialization block necessary to load DLLs? This is done implicitly anytime you load a class that contains native methods - the JVM searches a list of possible DLL locations to find matching method implementations. You can review the steps to implementing native methods here. No static initialization block is necessary - the JVM figures out it needs to load DLLs when it sees a class has native methods. To see how Sun implements the native functions behind methods like StrictMath.pow(), you can go to Sun and follow links for Community Source Licensing to download a free copy of all the source code for reference implementations of the various SDKs. The StrictMath methods seem to just call Math methods, which are upoltimately implemented in various C files in j2se\src\share\native\java\lang\fdlibm\src I note that there are implementations here for various hyperbolic functions, but it looks like they were never connected to Math and StrictMath. It's possible to connect to these from other classes using your own JNI code - but I wouldn't without good reason, since the native implementations are not part of the API and so are implementation-dependant. You can't count on them being present in other JVMs.