File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes java.lang.StrictMath class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "java.lang.StrictMath class" Watch "java.lang.StrictMath class" New topic
Author

java.lang.StrictMath class

Rajesh Menon
Greenhorn

Joined: Dec 06, 2000
Posts: 15
Hi everybody,

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.
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
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)

[ June 26, 2002: Message edited by: Jim Yingst ]

"I'm not back." - Bill Harding, Twister
Snigdha Solanki
Ranch Hand

Joined: Sep 07, 2000
Posts: 128
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
gurubaran
Greenhorn

Joined: Jun 26, 2002
Posts: 1
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
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.lang.StrictMath class