Top Inners Fields Constructors Methods
org.codehaus.groovy.classgen.asm

public Class MopWriter

extends Object
Class Inheritance
Known Direct Subclasses
org.codehaus.groovy.classgen.asm.sc.StaticCompilationMopWriter
Imports
org.codehaus.groovy.ast.ClassHelper, .ClassNode, .MethodNode, .Parameter, org.codehaus.groovy.ast.tools.ParameterUtils, org.objectweb.asm.MethodVisitor, java.lang.reflect.Modifier, java.util.Collections, .HashMap, .LinkedList, .List, .Map, .Objects, .Set, java.util.stream.Collectors

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
private static class

Field Summary

Modifier and TypeField and Description
private final WriterController
public static final MopWriter.Factory

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
public static boolean
equalParameterTypes(Parameter[] p1, Parameter[] p2)

Deprecated
protected void
generateMopCalls(LinkedList<MethodNode>
list of methods a mop call method should be generated for
mopCalls
,
boolean
true if "this" should be used for the naming
useThis
)

Generates a Meta Object Protocol method, that is used to call a non public method, or to make a call to super.

public static String

Returns:

the mop method name
getMopMethodName
(MethodNode
the method to be called by the mop method
method
,
boolean
if true, then it is a call on "this", "super" else
useThis
)

Creates a MOP method name from a method.

public static boolean

Returns:

true if the method is a MOP method
isMopMethod
(String
name of the method to test
methodName
)

Determines if a method is a MOP method.

private void
visitMopMethodList(List<MethodNode>
unfiltered list of methods for MOP
methods
,
boolean
if true, then we are creating a MOP method on "this", "super" else
isThis
,
Set<MopWriter.MopKey> useOnlyIfDeclaredHereToo, List<String> orNameMentionedHere)

Filters a list of method for MOP methods.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

controllerback to summary
private final WriterController controller
FACTORYback to summary
public static final MopWriter.Factory FACTORY

Constructor Detail

MopWriterback to summary
public MopWriter(WriterController controller)

Method Detail

createMopMethodsback to summary
public void createMopMethods()
equalParameterTypesback to summary
public static boolean equalParameterTypes(Parameter[] p1, Parameter[] p2)

Deprecated

Annotations
@Deprecated
generateMopCallsback to summary
protected void generateMopCalls(LinkedList<MethodNode> mopCalls, boolean useThis)

Generates a Meta Object Protocol method, that is used to call a non public method, or to make a call to super.

Parameters
mopCalls:LinkedList<MethodNode>

list of methods a mop call method should be generated for

useThis:boolean

true if "this" should be used for the naming

getMopMethodNameback to summary
public static String getMopMethodName(MethodNode method, boolean useThis)

Creates a MOP method name from a method.

Parameters
method:MethodNode

the method to be called by the mop method

useThis:boolean

if true, then it is a call on "this", "super" else

Returns:String

the mop method name

isMopMethodback to summary
public static boolean isMopMethod(String methodName)

Determines if a method is a MOP method. This is done by the method name. If the name starts with "this$" or "super$" but does not contain "$dist$", then it is an MOP method.

Parameters
methodName:String

name of the method to test

Returns:boolean

true if the method is a MOP method

visitMopMethodListback to summary
private void visitMopMethodList(List<MethodNode> methods, boolean isThis, Set<MopWriter.MopKey> useOnlyIfDeclaredHereToo, List<String> orNameMentionedHere)

Filters a list of method for MOP methods. For all methods that are no MOP methods a MOP method is created if the method is not public and the call would be a call on "this" (isThis == true). If the call is not on "this", then the call is a call on "super" and all methods are used, unless they are already a MOP method.

Parameters
methods:List<MethodNode>

unfiltered list of methods for MOP

isThis:boolean

if true, then we are creating a MOP method on "this", "super" else

See Also
generateMopCalls(LinkedList, boolean)
org.codehaus.groovy.classgen.asm back to summary

public Interface MopWriter.Factory

Annotations
@FunctionalInterface

Method Summary

Modifier and TypeMethod and Description
public MopWriter

Method Detail

createback to summary
public MopWriter create(WriterController controller)
org.codehaus.groovy.classgen.asm back to summary

private Class MopWriter.MopKey

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv final int
pack-priv final String
pack-priv final Parameter[]

Constructor Summary

AccessConstructor and Description
pack-priv
MopKey(String name, Parameter[] params)

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

hashback to summary
pack-priv final int hash
nameback to summary
pack-priv final String name
paramsback to summary
pack-priv final Parameter[] params

Constructor Detail

MopKeyback to summary
pack-priv MopKey(String name, Parameter[] params)

Method Detail

equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.