Uploaded image for project: 'Red Hat Decision Manager'
  1. Red Hat Decision Manager
  2. RHDM-1728

Reduce unnecessary classloading by parent classloader

    XMLWordPrintable

Details

    • Task
    • Status: Verified (View Workflow)
    • Major
    • Resolution: Done
    • 7.10.1.GA
    • 7.12.0.GA
    • BRE
    • ER1
    • 1
    • Release Notes
    • 2021 Week 22-24 (from May 31)
    • +

    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

              rhn-support-tkobayas Toshiya Kobayashi
              rhn-support-mputz Martin Weiler
              Paolo Bizzarri Paolo Bizzarri
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: