Changes:
- $Id: access.c 2096 2005-03-27 18:57:00Z edwin $
+ $Id: access.c 3451 2005-10-19 22:01:25Z twisti $
*/
#include <assert.h>
+
+#include "config.h"
+#include "vm/types.h"
+
#include "vm/access.h"
#include "vm/builtin.h"
+#include "vm/class.h"
+
/****************************************************************************/
/* DEBUG HELPERS */
/* ACCESS CHECKS */
/****************************************************************************/
-/* for documentation see access.h */
-bool
-is_accessible_class(classinfo *referer,classinfo *cls)
+/* access_is_accessible_class **************************************************
+
+ Check if a class is accessible from another class
+
+ IN:
+ referer..........the class containing the reference
+ cls..............the result of resolving the reference
+
+ RETURN VALUE:
+ true.............access permitted
+ false............access denied
+
+ NOTE:
+ This function performs the checks listed in section 5.4.4.
+ "Access Control" of "The Java(TM) Virtual Machine Specification,
+ Second Edition".
+
+*******************************************************************************/
+
+bool access_is_accessible_class(classinfo *referer, classinfo *cls)
{
ACCESS_ASSERT(referer);
ACCESS_ASSERT(cls);
- /* XXX specially check access to array classes? (vmspec 5.3.3) */
-
/* public classes are always accessible */
- if ((cls->flags & ACC_PUBLIC) != 0)
+ if (cls->flags & ACC_PUBLIC)
return true;
/* a class in the same package is always accessible */
- if (SAME_PACKAGE(referer,cls))
+ if (SAME_PACKAGE(referer, cls))
return true;
/* a non-public class in another package is not accessible */
return false;
}
-/* for documentation see access.h */
-bool
-is_accessible_member(classinfo *referer,classinfo *declarer,s4 memberflags)
+
+
+
+/* access_is_accessible_member *************************************************
+
+ Check if a field or method is accessible from a given class
+
+ IN:
+ referer..........the class containing the reference
+ declarer.........the class declaring the member
+ memberflags......the access flags of the member
+
+ RETURN VALUE:
+ true.............access permitted
+ false............access denied
+
+ NOTE:
+ This function only performs the checks listed in section 5.4.4.
+ "Access Control" of "The Java(TM) Virtual Machine Specification,
+ Second Edition".
+
+ In particular a special condition for protected access with is
+ part of the verification process according to the spec is not
+ checked in this function.
+
+*******************************************************************************/
+
+bool access_is_accessible_member(classinfo *referer, classinfo *declarer,
+ s4 memberflags)
{
ACCESS_ASSERT(referer);
ACCESS_ASSERT(declarer);
/* public members are accessible */
- if ((memberflags & ACC_PUBLIC) != 0)
+ if (memberflags & ACC_PUBLIC)
return true;
/* {declarer is not an interface} */
/* private members are only accessible by the class itself */
- if ((memberflags & ACC_PRIVATE) != 0)
+ if (memberflags & ACC_PRIVATE)
return (referer == declarer);
/* {the member is protected or package private} */
return true;
/* package private members are not accessible outside the package */
- if ((memberflags & ACC_PROTECTED) == 0)
+ if (!(memberflags & ACC_PROTECTED))
return false;
/* {the member is protected and declarer is in another package} */
return false;
}
+
/*
* These are local overrides for various environment variables in Emacs.
* Please do not remove this and leave it at the end of the file, where