Created
March 28, 2012 11:35
-
-
Save melix/2225551 to your computer and use it in GitHub Desktop.
Never change the generics types of a cached class node!
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
// This is very WRONG because it changes the generics type of the primary class node. | |
// It means that future instances of ArrayList without generic types specified would be ArrayList<Foo> | |
def listenerListType = ClassHelper.make(ArrayList) | |
listenerListType.setGenericsTypes(types) | |
// Instead, you MUST acquire a class node for which the redirect class node is the primary node | |
// This can be easily done using the getPlainNodeReference() method | |
def listenerListType = ClassHelper.make(ArrayList).plainNodeReference | |
listenerListType.setGenericsTypes(types) | |
// Not doing so can lead to very nasty and difficult to debug side effects! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment