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

Reduce unnecessary classloading by parent classloader

XMLWordPrintable

    • Icon: Task Task
    • Resolution: Done
    • Icon: Major Major
    • 7.12.0.GA
    • 7.10.1.GA
    • BRE
    • 1
    • False
    • False
    • Release Notes
    • ER1
    • +
    • Undefined
    • 2021 Week 22-24 (from May 31)

      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());
              }
          }
      

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

                Created:
                Updated:
                Resolved: