1207 * null if this class or interface is not a member of any other class. If |
1207 * null if this class or interface is not a member of any other class. If |
1208 * this {@code Class} object represents an array class, a primitive |
1208 * this {@code Class} object represents an array class, a primitive |
1209 * type, or void,then this method returns null. |
1209 * type, or void,then this method returns null. |
1210 * |
1210 * |
1211 * @return the declaring class for this class |
1211 * @return the declaring class for this class |
|
1212 * @throws SecurityException |
|
1213 * If a security manager, <i>s</i>, is present and the caller's |
|
1214 * class loader is not the same as or an ancestor of the class |
|
1215 * loader for the declaring class and invocation of {@link |
|
1216 * SecurityManager#checkPackageAccess s.checkPackageAccess()} |
|
1217 * denies access to the package of the declaring class |
1212 * @since JDK1.1 |
1218 * @since JDK1.1 |
1213 */ |
1219 */ |
1214 public native Class<?> getDeclaringClass(); |
1220 @CallerSensitive |
|
1221 public Class<?> getDeclaringClass() throws SecurityException { |
|
1222 final Class<?> candidate = getDeclaringClass0(); |
|
1223 |
|
1224 if (candidate != null) |
|
1225 candidate.checkPackageAccess( |
|
1226 ClassLoader.getClassLoader(Reflection.getCallerClass()), true); |
|
1227 return candidate; |
|
1228 } |
|
1229 |
|
1230 private native Class<?> getDeclaringClass0(); |
1215 |
1231 |
1216 |
1232 |
1217 /** |
1233 /** |
1218 * Returns the immediately enclosing class of the underlying |
1234 * Returns the immediately enclosing class of the underlying |
1219 * class. If the underlying class is a top level class this |
1235 * class. If the underlying class is a top level class this |