Module io.github.sugarcubes.cloner
Class ClassHierarchy
java.lang.Object
io.github.sugarcubes.cloner.enhancement.ClassHierarchy
Classes as the build tools or the cloner agent see them: which classes get copy constructors in this enhancement (the
classes of a build, or the classes which a class loader loads) and which superclasses have them.
A class gets a copy constructor if it is enhanced, matches the masks, is a class (not an interface,
an enum, an annotation, a module or package descriptor), and its superclass is Object, Record or a
class with a copy constructor: the constructor calls the copy constructor of the superclass.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract ClassInfoFinds the class.booleanhasCopyConstructor(String name) Tells whether the class has a copy constructor or gets it in this enhancement.static booleanTells whether the class is a class, the only kind which gets copy constructors.protected abstract booleanTells whether the class is enhanced: compiled in this build, or loaded after the agent started.isSerializable(String name) Tells whether instances of the class are serializable.booleanTells whether the class matches the masks.neverCopied(String name) Tells why the cloner never copies instances of the class, so it needs no copy constructor: singletons of Kotlin (object,data object,companion object, lambda classes capturing nothing) and Scala (object,case object, cases of Scala 3 enums), meta classes of Groovy, which the cloner shares; Kotlin file facades and synthetic classes, which have no instances; jobs of Kotlin coroutines and futures of Scala, which the cloner does not copy.Explains why an enhanced class which matches the masks cannot get a copy constructor.targetProblem(String name) Explains why an enhanced class which matches the masks and is a class cannot get a copy constructor.
-
Field Details
-
OBJECT
Internal name ofjava.lang.Object.- See Also:
-
RECORD
Internal name ofjava.lang.Record.- See Also:
-
-
Constructor Details
-
ClassHierarchy
Constructor.- Parameters:
targets- classes which get copy constructors
-
-
Method Details
-
find
Finds the class.- Parameters:
name- internal name- Returns:
- class information or
nullif the class is not found
-
isLocal
Tells whether the class is enhanced: compiled in this build, or loaded after the agent started.- Parameters:
name- internal name- Returns:
truefor enhanced classes
-
isTarget
Tells whether the class matches the masks.- Parameters:
name- internal name- Returns:
trueif it matches
-
neverCopied
Tells why the cloner never copies instances of the class, so it needs no copy constructor: singletons of Kotlin (object,data object,companion object, lambda classes capturing nothing) and Scala (object,case object, cases of Scala 3 enums), meta classes of Groovy, which the cloner shares; Kotlin file facades and synthetic classes, which have no instances; jobs of Kotlin coroutines and futures of Scala, which the cloner does not copy.- Parameters:
name- internal name- Returns:
- the reason or empty if instances of the class may be copied
-
isClass
Tells whether the class is a class, the only kind which gets copy constructors.- Parameters:
info- class- Returns:
falsefor interfaces, enums, annotations, module and package descriptors
-
targetProblem
Explains why an enhanced class which matches the masks and is a class cannot get a copy constructor.- Parameters:
name- internal name- Returns:
- problem or empty if the class gets a copy constructor, is not a target or not a class
-
problem
Explains why an enhanced class which matches the masks cannot get a copy constructor.- Parameters:
name- internal name- Returns:
- problem or empty if the class gets a copy constructor
-
hasCopyConstructor
Tells whether the class has a copy constructor or gets it in this enhancement.- Parameters:
name- internal name- Returns:
trueif instances of subclasses can call it
-
isSerializable
Tells whether instances of the class are serializable.- Parameters:
name- internal name- Returns:
trueorfalse,nullif a supertype is not found
-