717 throw new ClassNotFoundException(name);
718 }
719
720 /**
721 * Finds the class with the given <a href="#binary-name">binary name</a>
722 * in a module defined to this class loader.
723 * Class loader implementations that support loading from modules
724 * should override this method.
725 *
726 * @apiNote This method returns {@code null} rather than throwing
727 * {@code ClassNotFoundException} if the class could not be found.
728 *
729 * @implSpec The default implementation attempts to find the class by
730 * invoking {@link #findClass(String)} when the {@code moduleName} is
731 * {@code null}. It otherwise returns {@code null}.
732 *
733 * @param moduleName
734 * The module name; or {@code null} to find the class in the
735 * {@linkplain #getUnnamedModule() unnamed module} for this
736 * class loader
737
738 * @param name
739 * The <a href="#binary-name">binary name</a> of the class
740 *
741 * @return The resulting {@code Class} object, or {@code null}
742 * if the class could not be found.
743 *
744 * @since 9
745 * @spec JPMS
746 */
747 protected Class<?> findClass(String moduleName, String name) {
748 if (moduleName == null) {
749 try {
750 return findClass(name);
751 } catch (ClassNotFoundException ignore) { }
752 }
753 return null;
754 }
755
756
757 /**
|
717 throw new ClassNotFoundException(name);
718 }
719
720 /**
721 * Finds the class with the given <a href="#binary-name">binary name</a>
722 * in a module defined to this class loader.
723 * Class loader implementations that support loading from modules
724 * should override this method.
725 *
726 * @apiNote This method returns {@code null} rather than throwing
727 * {@code ClassNotFoundException} if the class could not be found.
728 *
729 * @implSpec The default implementation attempts to find the class by
730 * invoking {@link #findClass(String)} when the {@code moduleName} is
731 * {@code null}. It otherwise returns {@code null}.
732 *
733 * @param moduleName
734 * The module name; or {@code null} to find the class in the
735 * {@linkplain #getUnnamedModule() unnamed module} for this
736 * class loader
737 * @param name
738 * The <a href="#binary-name">binary name</a> of the class
739 *
740 * @return The resulting {@code Class} object, or {@code null}
741 * if the class could not be found.
742 *
743 * @since 9
744 * @spec JPMS
745 */
746 protected Class<?> findClass(String moduleName, String name) {
747 if (moduleName == null) {
748 try {
749 return findClass(name);
750 } catch (ClassNotFoundException ignore) { }
751 }
752 return null;
753 }
754
755
756 /**
|