Skip to content

Instantly share code, notes, and snippets.

@melix
Created March 28, 2012 11:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save melix/2225551 to your computer and use it in GitHub Desktop.
Save melix/2225551 to your computer and use it in GitHub Desktop.
Never change the generics types of a cached class node!
// 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