<commit_before>package groovy.lang

class ClassReloadingTest extends GroovyTestCase {

	public void testRealoding() {
		def file = File.createTempFile("TestReload",".groovy", new File("target"))
		file.deleteOnExit()
		def className = file.name-".groovy"

		def cl = new GroovyClassLoader(this.class.classLoader);
		def currentDir = file.parentFile.absolutePath
		cl.addClasspath(currentDir)
			
		
        try {
     		file.write """
    		  class $className {
    		    @Property hello = "hello"
    		  }
    		  """
    		def groovyClass = cl.loadClass(className,true,false)
    		def object = groovyClass.newInstance()
    		assert "hello"== object.hello
    					
    		// change class
    		file.write """
    		  class $className {
    		    @Property hello = "goodbye"
    		  }
    		  """
    		
    		// reload		
    		groovyClass = cl.loadClass(className,true,false)
    		object  = groovyClass.newInstance()
    		assert "goodbye" == object.hello
    	} finally {
		  file.delete()
		}
	}
}<commit_msg>Add delay time before modifying the file so that the last Modified timestamps are different.<commit_after>package groovy.lang

class ClassReloadingTest extends GroovyTestCase {

	public void testRealoding() {
		def file = File.createTempFile("TestReload",".groovy", new File("target"))
		file.deleteOnExit()
		def className = file.name-".groovy"

		def cl = new GroovyClassLoader(this.class.classLoader);
		def currentDir = file.parentFile.absolutePath
		cl.addClasspath(currentDir)
			
		
        try {
     		file.write """
    		  class $className {
    		    @Property hello = "hello"
    		  }
    		  """
    		def groovyClass = cl.loadClass(className,true,false)
    		def object = groovyClass.newInstance()
    		assert "hello"== object.hello

                Thread.sleep(1000)
    					
    		// change class
    		file.write """
    		  class $className {
    		    @Property hello = "goodbye"
    		  }
    		  """
    		
    		// reload		
    		groovyClass = cl.loadClass(className,true,false)
    		object  = groovyClass.newInstance()
    		assert "goodbye" == object.hello
    	} finally {
		  file.delete()
		}
	}
}
{'fraction_non_alphanumeric': 0.10898928737773637, 'fraction_numerical': 0.0018630647414997672, 'mean_word_length': 2.3302325581395347, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '817205', 'n_tokens_mistral': 784, 'n_tokens_neox': 691, 'n_words': 135}