* java/lang/natClass.cc (initializeClass): Re-throw
SecurityExceptions.
* java/lang/natVMClassLoader.cc (loadClass): checkPackageAccess.
* java/lang/ClassLoader.java: (loadClass): Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@121285
138bc75d-0d04-0410-961f-
82ee72b054a4
protected synchronized Class loadClass(String name, boolean resolve)
throws ClassNotFoundException
{
+ SecurityManager sm = SecurityManager.current;
+ if (sm != null)
+ {
+ int lastDot = name.lastIndexOf('.');
+ if (lastDot != -1)
+ sm.checkPackageAccess(name.substring(0, lastDot));
+ }
+
// Arrays are handled specially.
Class c;
if (name.length() > 0 && name.charAt(0) == '[')
#include <java/lang/NullPointerException.h>
#include <java/lang/RuntimePermission.h>
#include <java/lang/System.h>
+#include <java/lang/SecurityException.h>
#include <java/lang/SecurityManager.h>
#include <java/lang/StringBuffer.h>
#include <java/lang/VMClassLoader.h>
{
_Jv_Linker::wait_for_state(this, JV_STATE_LINKED);
}
+ catch (java::lang::SecurityException *x)
+ {
+ throw x;
+ }
catch (java::lang::Throwable *x)
{
// Turn into a NoClassDefFoundError.
{
_Jv_InitClass (superclass);
}
+ catch (java::lang::SecurityException *x)
+ {
+ throw x;
+ }
catch (java::lang::Throwable *except)
{
// Caught an exception.
if (meth)
((void (*) (void)) meth->ncode) ();
}
+ catch (java::lang::SecurityException *x)
+ {
+ throw x;
+ }
catch (java::lang::Throwable *except)
{
if (! java::lang::Error::class$.isInstance(except))
#include <java/security/ProtectionDomain.h>
#include <java/lang/ClassFormatError.h>
#include <java/lang/StringBuffer.h>
+#include <java/lang/SecurityManager.h>
#include <java/lang/Runtime.h>
#include <java/util/HashSet.h>
+#include <java/lang/SecurityException.h>
#include <java/lang/VirtualMachineError.h>
java::lang::Class *
jclass
java::lang::VMClassLoader::loadClass(jstring name, jboolean resolve)
{
+ using namespace ::java::lang;
+
+ SecurityManager *sm = (SecurityManager *)SecurityManager::current;
+ if (sm)
+ {
+ jint lastDot = name->lastIndexOf('.');
+ if (lastDot != -1)
+ sm->checkPackageAccess(name->substring(0, lastDot));
+ }
+
// We try the boot loader first, so that the endorsed directory
// overrides compiled-in classes.
jclass klass = NULL;