Created
January 11, 2017 13:30
-
-
Save torstenwerner/a89b206b7264f35e1d4db55d6c86b6c1 to your computer and use it in GitHub Desktop.
invoke java method dynamically in groovy code
This file contains 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 iClass = 'java.lang.Integer' as Class | |
assert iClass.newInstance(26) == 26 | |
def greeting = 'Hello' | |
def method = 'length' | |
assert greeting."$method"() == 5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment