371 * <P>
372 * Primitive classes (for example, <code>java.lang.Integer.TYPE</code>)
373 * and array classes are never modifiable.
374 *
375 * @param theClass the class to check for being modifiable
376 * @return whether or not the argument class is modifiable
377 * @throws java.lang.NullPointerException if the specified class is <code>null</code>.
378 *
379 * @see #retransformClasses
380 * @see #isRetransformClassesSupported
381 * @see #redefineClasses
382 * @see #isRedefineClassesSupported
383 * @since 1.6
384 */
385 boolean
386 isModifiableClass(Class<?> theClass);
387
388 /**
389 * Returns an array of all classes currently loaded by the JVM.
390 *
391 * @return an array containing all the classes loaded by the JVM, zero-length if there are none
392 */
393 @SuppressWarnings("rawtypes")
394 Class[]
395 getAllLoadedClasses();
396
397 /**
398 * Returns an array of all classes for which <code>loader</code> is an initiating loader.
399 * If the supplied loader is <code>null</code>, classes initiated by the bootstrap class
400 * loader are returned.
401 *
402 * @param loader the loader whose initiated class list will be returned
403 * @return an array containing all the classes for which loader is an initiating loader,
404 * zero-length if there are none
405 */
406 @SuppressWarnings("rawtypes")
407 Class[]
408 getInitiatedClasses(ClassLoader loader);
409
410 /**
411 * Returns an implementation-specific approximation of the amount of storage consumed by
412 * the specified object. The result may include some or all of the object's overhead,
413 * and thus is useful for comparison within an implementation but not between implementations.
414 *
415 * The estimate may change during a single invocation of the JVM.
416 *
417 * @param objectToSize the object to size
418 * @return an implementation-specific approximation of the amount of storage consumed by the specified object
419 * @throws java.lang.NullPointerException if the supplied Object is <code>null</code>.
420 */
421 long
422 getObjectSize(Object objectToSize);
423
|
371 * <P>
372 * Primitive classes (for example, <code>java.lang.Integer.TYPE</code>)
373 * and array classes are never modifiable.
374 *
375 * @param theClass the class to check for being modifiable
376 * @return whether or not the argument class is modifiable
377 * @throws java.lang.NullPointerException if the specified class is <code>null</code>.
378 *
379 * @see #retransformClasses
380 * @see #isRetransformClassesSupported
381 * @see #redefineClasses
382 * @see #isRedefineClassesSupported
383 * @since 1.6
384 */
385 boolean
386 isModifiableClass(Class<?> theClass);
387
388 /**
389 * Returns an array of all classes currently loaded by the JVM.
390 *
391 * <p>
392 * A class or interface creation can be triggered by one of the following:
393 * <ul>
394 * <li>by loading and deriving a class from a `class` file representation
395 * using class loader (see JVMS {@jvms 5.3}).
396 * <li>by invoking {@link java.lang.invoke.MethodHandles.Lookup#defineHiddenClass(byte[], boolean, java.lang.invoke.MethodHandles.Lookup.ClassOption...)
397 * Lookup::defineHiddenClass} that creates a {@link Class#isHidden
398 * hidden class or interface} from a {@code class} file representation.
399 * <li>by invoking methods in certain reflection APIs such as
400 * {@link Class#forName(String) Class::forName}.
401 * </ul>
402 * <p>
403 * An array class is created directly by Java virtual machine. An array
404 * class creation can be triggered by using class loaders or by invoking
405 * methods in certain reflection APIs such as
406 * {@link java.lang.reflect.Array#newInstance(Class, int) Array::newInstance}
407 * and {@link Class#arrayType() Class::arrayType}.
408 * <p>
409 * The returned array includes all classes and interfaces, including
410 * {@link Class#isHidden hidden classes or interfaces}, and array classes
411 * of all types.
412 *
413 * @return an array containing all the classes loaded by the JVM, zero-length if there are none
414 */
415 @SuppressWarnings("rawtypes")
416 Class[]
417 getAllLoadedClasses();
418
419 /**
420 * Returns an array of all classes which {@code loader} can find by name
421 * via {@link ClassLoader#loadClass(String, boolean) ClassLoader::loadClass},
422 * {@link Class#forName(String) Class::forName} and bytecode linkage.
423 * That is, {@code loader} has been recorded as an initiating loader
424 * of these classes. If the supplied {@code loader} is {@code null},
425 * classes that the bootstrap class loader can find by name are returned.
426 *
427 * <p>
428 * The returned array does not include {@link Class#isHidden()
429 * <em>hidden</em>} classes or interfaces that are created by the invocation of
430 * {@link java.lang.invoke.MethodHandles.Lookup#defineHiddenClass(byte[], boolean, java.lang.invoke.MethodHandles.Lookup.ClassOption...)
431 * Lookup::defineHiddenClass} because:
432 * <ul>
433 * <li>A hidden class or interface cannot be referenced by the constant pools
434 * of other classes and interfaces.
435 * <li>A hidden class or interface cannot be discovered by any class loader.
436 * </ul>
437 * In addition, the returned array does not include array classes whose
438 * {@linkplain Class#componentType() element type} is a
439 * {@link Class#isHidden() hidden class or interface} as they cannot
440 * be discovered by {@code loader}.
441 *
442 * @param loader the loader whose initiated class list will be returned
443 * @return an array containing all classes which {@code loader} can find by name;
444 * zero-length if there are none
445 */
446 @SuppressWarnings("rawtypes")
447 Class[]
448 getInitiatedClasses(ClassLoader loader);
449
450 /**
451 * Returns an implementation-specific approximation of the amount of storage consumed by
452 * the specified object. The result may include some or all of the object's overhead,
453 * and thus is useful for comparison within an implementation but not between implementations.
454 *
455 * The estimate may change during a single invocation of the JVM.
456 *
457 * @param objectToSize the object to size
458 * @return an implementation-specific approximation of the amount of storage consumed by the specified object
459 * @throws java.lang.NullPointerException if the supplied Object is <code>null</code>.
460 */
461 long
462 getObjectSize(Object objectToSize);
463
|