You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by te...@apache.org on 2006/11/08 11:30:23 UTC
svn commit: r472443 -
/incubator/harmony/enhanced/classlib/trunk/modules/suncompat/src/main/java/sun/misc/Unsafe.java
Author: tellison
Date: Wed Nov 8 02:30:23 2006
New Revision: 472443
URL: http://svn.apache.org/viewvc?view=rev&rev=472443
Log:
Added Unsafe security check comment.
Modified:
incubator/harmony/enhanced/classlib/trunk/modules/suncompat/src/main/java/sun/misc/Unsafe.java
Modified: incubator/harmony/enhanced/classlib/trunk/modules/suncompat/src/main/java/sun/misc/Unsafe.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/suncompat/src/main/java/sun/misc/Unsafe.java?view=diff&rev=472443&r1=472442&r2=472443
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/suncompat/src/main/java/sun/misc/Unsafe.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/suncompat/src/main/java/sun/misc/Unsafe.java Wed Nov 8 02:30:23 2006
@@ -41,9 +41,14 @@
* @return An instance of Unsafe.
*/
public static Unsafe getUnsafe() {
+ /* Check that the caller of this method is in system code (i.e. on the
+ * bootclasspath). Unsafe methods are not designed to be called directly
+ * by applications. We assume that system code will not reveal the instance.
+ */
if (VM.callerClassLoader() != null) {
throw new SecurityException("Unsafe");
}
+
return AccessController.doPrivileged(new PrivilegedAction<Unsafe>() {
public Unsafe run() {
return INSTANCE;