code: public void detectChanges() {
          if (engine.isProdMode()) return;
          // Now check for file modification
          List<TemplateClass> modifieds = new ArrayList<TemplateClass>();
          for (TemplateClass tc : engine.classes().all()) {
              if (tc.refresh()) modifieds.add(tc);
          }
          Set<TemplateClass> modifiedWithDependencies = new HashSet<TemplateClass>();
          modifiedWithDependencies.addAll(modifieds);
          List<ClassDefinition> newDefinitions = new ArrayList<ClassDefinition>();
          boolean dirtySig = false;
          for (TemplateClass tc : modifiedWithDependencies) {
              if (tc.compile() == null) {
                  engine.classes().remove(tc);
                  currentState = new TemplateClassloaderState();//show others that we have changed..
              } else {
                  int sigChecksum = tc.sigChecksum;
                  tc.enhance();
                  if (sigChecksum != tc.sigChecksum) {
                      dirtySig = true;
                  }
                  newDefinitions.add(new ClassDefinition(tc.javaClass, tc.enhancedByteCode));
                  currentState = new TemplateClassloaderState();//show others that we have changed..
              }
          }
          if (!newDefinitions.isEmpty()) {
              throw new ClassReloadException("Need Reload");
          }
          // Check signature (variable name & annotations aware !)
          if (dirtySig) {
              throw new ClassReloadException("Signature change !");
          }
  
          // Now check if there is new classCache or removed classCache
          int hash = computePathHash();
          if (hash != this.pathHash) {
              // Remove class for deleted files !!
              for (TemplateClass tc : engine.classes().all()) {
                  if (!tc.templateResource.isValid()) {
                      engine.classes().remove(tc);
                      currentState = new TemplateClassloaderState();//show others that we have changed..
                  }
              }
              throw new ClassReloadException("Path has changed");
          }
      }
docs: Detect Template changes