Uploaded image for project: 'Drools'
  1. Drools
  2. DROOLS-6053

Reduce unnecessary classloading by parent classloader

    XMLWordPrintable

    Details

    • Sprint:
      2021 Week 07-09 (from Feb 15), 2021 Week 10-12 (from Mar 8), 2021 Week 13-15 (from Mar 29), 2021 Week 16-18 (from Apr 19), 2021 Week 19-21 (from May 10)
    • Story Points:
      6
    • Docs QE Status:
      NEW
    • QE Status:
      NEW

      Description

      Generated classes by exec-model will be defined by ProjectClassLoader.
      e.g.

      defaultpkg.RulesE4CC7C50982E2CF1DC179E1E3E3D6F82
      defaultpkg.RulesE4CC7C50982E2CF1DC179E1E3E3D6F82RuleMethods0
      defaultpkg.DomainClassesMetadataE4CC7C50982E2CF1DC179E1E3E3D6F82
      defaultpkg.DomainClassesMetadataE4CC7C50982E2CF1DC179E1E3E3D6F82$org_drools_modelcompiler_domain_Person_Metadata
      defaultpkg.P77.LambdaPredicate7795465E4BC69C081E65B427482C98AE
      ...
      

      But they are firstly searched with Class.forName() by its parent classloader which is a waste of time.

      DynamicProjectClassLoader.java

              protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
                  try {
                      return loadType(name, resolve);
                  } catch (ClassNotFoundException cnfe) {
                      try {
                          return projectClassLoader.internalLoadClass(name, resolve);
                      } catch (ClassNotFoundException cnfe2) {
                          return projectClassLoader.tryDefineType(name, cnfe);
                      }
                  }
              }
      

      ProjectClassLoader.java

          public Class<?> internalLoadClass(String name, boolean resolve) throws ClassNotFoundException {
              if (CACHE_NON_EXISTING_CLASSES && nonExistingClasses.contains(name)) {
                  throw dummyCFNE;
              }
      
              if (droolsClassLoader != null) {
                  try {
                      return Class.forName(name, resolve, droolsClassLoader);
                  } catch (ClassNotFoundException e) { }
              }
              try {
                  return super.loadClass(name, resolve);
              } catch (ClassNotFoundException e) {
                  return Class.forName(name, resolve, getParent());
              }
          }
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              tkobayashi Toshiya Kobayashi
              Reporter:
              tkobayashi Toshiya Kobayashi
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: