public final class IntersectionTypeClassNode
extends ClassNode
Represents a user-written intersection type used as the target of a cast
expression or as coercion, e.g.
(Runnable & Serializable) () -> ...
value as (A & B)
Distinct from the implicit lowest-upper-bound nodes that
StaticTypeCheckingVisitor
synthesizes during inference: an instance of this class records the ordered
list of components exactly as written by the user. That ordering is needed
for cast-conversion checks, error messages and (in later phases) bytecode
generation via LambdaMetafactory.altMetafactory markers.
Lifecycle: at parse time the components have not yet been resolved to
bound ClassNodes, so the constructor places all components in the
inherited interfaces array with Object as
the placeholder superclass. After ResolveVisitor resolves each
component it should call reclassifyComponents() so that the
interfaces array contains only interface components and the superclass is
the (at most one) class component.
| Fields inherited from class | Fields |
|---|---|
class ClassNode |
EMPTY_ARRAY, SUPER, THIS, clazz, isPrimaryNode, lazyInitLock |
| Constructor and description |
|---|
IntersectionTypeClassNode(ClassNode[] components)Creates an intersection type from the given components. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public ClassNode[] |
getComponents()Returns the components of this intersection type in user-written order. |
|
public String |
getText() |
|
public void |
reclassifyComponents()Reclassifies the components after resolution: separates the (at most one) class component from the interface components and updates the inherited superclass and interfaces accordingly. |
|
public String |
toString(boolean showRedirect) |
Creates an intersection type from the given components.
Both the superclass call and this node keep their own clone of
components, so later changes to the caller's array are ignored.
Every component starts in the interfaces array and the superclass is
Object; reclassifyComponents() moves a class component
into the superclass after resolution. Fewer than two components is rejected.
A null components array fails immediately.
components - the intersection members, in user-written order; at least twoReturns the components of this intersection type in user-written order.
Reclassifies the components after resolution: separates the (at most one) class component from the interface components and updates the inherited superclass and interfaces accordingly. Components are resolved in place — callers do not need to substitute new instances.
Copyright © 2003-2026 The Apache Software Foundation. All rights reserved.