Java class files only ever contain scope specifiers of "public" or
"package". For top-level classes, this is expected: it is not possible
to have a top-level protected or private class.
However nested classes can be declared as protected or private. The
way to tell the real scope of a nested class is to ignore the scope in
the actual class file itself, and instead look in the "InnerClasses"
attribute stored on the enclosing class. This is exactly what the java
compiler does when compiling, and what the jvm does when verifying class
linkage at runtime.
For a "top-level" class, this method just returns the access scope for
the class itself. For nested classes, the enclosing class of the
specified class is retrieved and its InnerClasses attribute checked to
find the true scope for the specified class.
throws: CheckerException - if the specified class is a nested class andthe enclosing class could not be found, or if the supposedly enclosingclass has no reference to the nested class. This exception is notexpected to occur in practice, unless a truly screwed-up jar file ispassed to clirr for inspection. |