Heads up! On March 5, starting at 4:30 PM Central Time, our community will be undergoing scheduled maintenance for a few hours. During this time, you will find the site temporarily inaccessible. Thanks for your patience. Read more.
×Hi,
I have created a custom class in the script editor. Let's assume it is "MyClass" in the package "my.package". When I go to the console, I can import that class with "import my.package.MyClass", instantiate it and run a method on it. So far so good.
What worries me is that when I chance the code in my class, it is not immediately visible to the console as the class is being cached. I learned that I need to clear the Groovy classloader, but when I do that my class actually completely vanishes. If I run the same code in the console (which worked before), it now says, that it cannot find the class.
I explicitly need to run the Groovy class file in the console to get it loaded again. After that the code will start working again.
I am not not sure what I am doing wrong. I do not have an issue with running the Groovy classloader, but the class should then be found again.
Can you help?
Tobias.
In my experience, you can cause the updated class to be re-compiled by changing the console script.
Even adding a space on a blank line suffices.
If your script points to MyClassA, and MyClassA has a dependency to MyClassB. This will only work if MyClassA change. It won't if only MyClassB changes. In this case, you want to make a change to MyClassA as well as the Console. The console change will cause MyClassA to be checked for changes. The change will cause MyClassB to be checked.
Stupid me. The groovy file names in the Script Editor need to carry the exact name of the class they are carrying, so my class needed to be on the file "my/package/MyClass.groovy". Sorry for the fuzz.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.