/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/** Common utility routines used by both java.lang and
java.lang.reflect */
public class Reflection {
/** Used to filter out fields and methods from certain classes from public
view, where they are sensitive or they may contain VM-internal objects.
These Maps are updated very rarely. Rather than synchronize on
each access, we use copy-on-write */
static {
}
/** Returns the class of the caller of the method calling this method,
ignoring frames associated with java.lang.reflect.Method.invoke()
and its implementation. */
/**
* @deprecated No replacement. This method will be removed in the next
* JDK 7 update release.
*/
}
throw new UnsupportedOperationException("This method is in the sun.* " +
"namespace so it is not a supported, public interface. " +
"The 7u40 release notes describe a temporary mechanism " +
"to reenable the historical functionality of this method. " +
"Update code to function properly and this method will be " +
"removed without further warning in a subsequent 7 update release.");
}
// If the VM enforces getting caller class with @CallerSensitive,
// this will fail anyway.
/** Retrieves the access flags written to the class file. For
inner classes these flags may differ from those returned by
Class.getModifiers(), which searches the InnerClasses
attribute to find the source-level access flags. This is used
instead of Class.getModifiers() for run-time access checks due
to compatibility reasons; see 4471811. Only the values of the
low 13 bits (i.e., a mask of 0x1FFF) are guaranteed to be
valid. */
/** A quick "fast-path" check to try to avoid getCallerClass()
calls. */
int modifiers)
{
}
int modifiers)
throws IllegalAccessException
{
throw new InternalError();
}
" can not access a member of class " +
memberClass.getName() +
" with modifiers \"" +
"\"");
}
}
// Declaring class of field
// or method
// May be NULL in case of statics
int modifiers)
{
// Verify that currentClass can access a field, method, or
// constructor of memberClass, where that member's access bits are
// "modifiers".
boolean gotIsSameClassPackage = false;
boolean isSameClassPackage = false;
if (currentClass == memberClass) {
// Always succeeds
return true;
}
gotIsSameClassPackage = true;
if (!isSameClassPackage) {
return false;
}
}
// At this point we know that currentClass can access memberClass.
return true;
}
boolean successSoFar = false;
// See if currentClass is a subclass of memberClass
successSoFar = true;
}
}
if (!gotIsSameClassPackage) {
gotIsSameClassPackage = true;
}
if (isSameClassPackage) {
successSoFar = true;
}
}
if (!successSoFar) {
return false;
}
// Additional test for protected members: JLS 6.6.2
if (targetClass != currentClass) {
if (!gotIsSameClassPackage) {
gotIsSameClassPackage = true;
}
if (!isSameClassPackage) {
return false;
}
}
}
}
return true;
}
}
/** Returns true if two classes are in the same package; classloader
and classname information is enough to determine a class's package */
{
return false;
} else {
// One of the two doesn't have a package. Only return true
// if the other one also doesn't have a package.
} else {
int idx1 = 0;
int idx2 = 0;
// Skip over '['s
do {
idx1++;
// Something is terribly wrong. Shouldn't be here.
}
}
do {
idx2++;
// Something is terribly wrong. Shouldn't be here.
}
}
// Check that package part is identical
return false;
}
}
}
}
{
while (queryClass != null) {
if (queryClass == ofClass) {
return true;
}
}
return false;
}
// fieldNames must contain only interned Strings
String ... fieldNames) {
}
// methodNames must contain only interned Strings
String ... methodNames) {
}
throw new IllegalArgumentException
("Filter already registered: " + containingClass);
}
return map;
}
if (fieldFilterMap == null) {
// Bootstrapping
return fields;
}
}
if (methodFilterMap == null) {
// Bootstrapping
return methods;
}
}
return members;
}
int numNewMembers = 0;
boolean shouldSkip = false;
shouldSkip = true;
break;
}
}
if (!shouldSkip) {
}
}
Member[] newMembers =
int destIdx = 0;
boolean shouldSkip = false;
shouldSkip = true;
break;
}
}
if (!shouldSkip) {
}
}
return newMembers;
}
/**
* Tests if the given method is caller-sensitive and the declaring class
* is defined by either the bootstrap class loader or extension class loader.
*/
return m.isAnnotationPresent(CallerSensitive.class);
}
return false;
}
return true;
}
}
return false;
}
}