为什么SecurityException是一个运行时异常? 您所在的位置:网站首页 ioexception有哪些 为什么SecurityException是一个运行时异常?

为什么SecurityException是一个运行时异常?

2023-01-16 07:02| 来源: 网络整理| 查看: 265

SecurityException是RuntimeException的子类,所以在运行过程中所抛出的SecurityException都应是预期之外的,相关的程序若使用不当可能会存在某些危险的操作从而引发安全问题。

比如这个:

package sun.misc; /** * A collection of methods for performing low-level, unsafe operations. * Although the class and all methods are public, use of this class is * limited because only trusted code can obtain instances of it. * * @author John R. Rose * @see #getUnsafe */ public final class Unsafe { private static native void registerNatives(); static { registerNatives(); sun.reflect.Reflection.registerMethodsToFilter(Unsafe.class, "getUnsafe"); } private Unsafe() {} private static final Unsafe theUnsafe = new Unsafe(); /** * Provides the caller with the capability of performing unsafe * operations. * * @exception SecurityException if a security manager exists and its * checkPropertiesAccess method doesn't allow * access to the system properties. */ @CallerSensitive public static Unsafe getUnsafe() { Class caller = Reflection.getCallerClass(); if (!VM.isSystemDomainLoader(caller.getClassLoader())) throw new SecurityException("Unsafe"); return theUnsafe; } // TODO: ... }



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有