Java flow check

I reflected while playing with some code. In the Thread class, I met the following method: checkAccess() .

The documentation (literally) says: "Does nothing." Why is this possible in the Thread class if it does nothing? - Perhaps we are dealing with developer trolls?

Screenshot:

enter image description here

+4
source share
1 answer

Thread.checkAccess() is the basic Java API, so it exists in Android , however, it is not implemented.

Android java.lang.Thread.checkAccess () does not provide this implementation because it does not trust SecurityManager s.

Security managers do not provide a secure environment for executing untrusted code. Incorrect code cannot be safely isolated in VM Dalvik.

And this is how Thread.checkAccess is implemented inside OpenJDK.

 public final void checkAccess() { SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkAccess(this); } } 
+2
source

Source: https://habr.com/ru/post/1438293/


All Articles