Last active
February 11, 2024 15:52
-
-
Save neelsmith/8359546 to your computer and use it in GitHub Desktop.
groovy: get an instance of a class from its name as a string
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def objectInstance = Class.forName("NAME.AS.STRING").newInstance() |
I'm assuming the name is fully qualified
๐
newInstance is depricated since java V9. be careful
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
๐