0

I was checking LockSupport.class (from eclipse, which is part of rt.jar) and came to know this class internally uses sun.misc.Unsafe for its implementation.

In general, for most of the packages which are present in rt.jar, I can see the source, for example can see LockSupport.class , String.class (and see their code).

However, when I tried to see sun.misc.Unsafe, it didn't show anything. I see a similar question on SO here - old question with same doubt. Of course , experts suggested to use GrepCode. However, my question is why can't we see the source when we can see for other packages in rt.jar?

In the same SO question, it was suggested not to rely upon sun.misc.*, but it is still widely used.

How can I see the exact code which is applicable for a specific JDK?

CuriousMind
  • 6,665
  • 12
  • 49
  • 95
  • 1
    *"why can't we see the source when we can see for other packages in rt.jar?"* Because `sun.misc` classes are considered internal, and you shouldn't be using them. – Andreas May 14 '20 at 20:58
  • 1
    Source code for `Unsafe`: http://hg.openjdk.java.net/jdk8/jdk8/jdk/file/43cb25339b55/src/share/classes/sun/misc/Unsafe.java – Andreas May 14 '20 at 20:59
  • @Andreas: Thanks for your comment. But it is there since ages. My intention is to see the code and know a little more. – CuriousMind May 14 '20 at 21:00
  • @Andreas: Thanks for providing the link. If the source is available freely, then why isn't is made part of rt.jar so that it can be seen like any other class? – CuriousMind May 14 '20 at 21:02
  • @Andreas: Thanks for your reply. Got the jist of it. – CuriousMind May 14 '20 at 21:09

0 Answers0