• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

raphw / byte-buddy / #818

07 Nov 2025 11:24AM UTC coverage: 83.01% (+0.05%) from 82.964%
#818

push

raphw
[release] Release new version.

29613 of 35674 relevant lines covered (83.01%)

0.83 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.76
/byte-buddy-dep/src/main/java/net/bytebuddy/dynamic/scaffold/InstrumentedType.java
1
/*
2
 * Copyright 2014 - Present Rafael Winterhalter
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *     http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
package net.bytebuddy.dynamic.scaffold;
17

18
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
19
import net.bytebuddy.ClassFileVersion;
20
import net.bytebuddy.description.annotation.AnnotationDescription;
21
import net.bytebuddy.description.annotation.AnnotationList;
22
import net.bytebuddy.description.annotation.AnnotationValue;
23
import net.bytebuddy.description.field.FieldDescription;
24
import net.bytebuddy.description.field.FieldList;
25
import net.bytebuddy.description.method.MethodDescription;
26
import net.bytebuddy.description.method.MethodList;
27
import net.bytebuddy.description.method.ParameterDescription;
28
import net.bytebuddy.description.modifier.ModifierContributor;
29
import net.bytebuddy.description.module.ModuleDescription;
30
import net.bytebuddy.description.type.PackageDescription;
31
import net.bytebuddy.description.type.RecordComponentDescription;
32
import net.bytebuddy.description.type.RecordComponentList;
33
import net.bytebuddy.description.type.TypeDescription;
34
import net.bytebuddy.description.type.TypeList;
35
import net.bytebuddy.description.type.TypeVariableToken;
36
import net.bytebuddy.dynamic.TargetType;
37
import net.bytebuddy.dynamic.Transformer;
38
import net.bytebuddy.implementation.LoadedTypeInitializer;
39
import net.bytebuddy.implementation.bytecode.ByteCodeAppender;
40
import net.bytebuddy.matcher.ElementMatcher;
41
import net.bytebuddy.utility.CompoundList;
42
import net.bytebuddy.utility.JavaType;
43
import net.bytebuddy.utility.nullability.MaybeNull;
44
import org.objectweb.asm.Opcodes;
45

46
import java.lang.annotation.ElementType;
47
import java.util.ArrayList;
48
import java.util.Arrays;
49
import java.util.Collections;
50
import java.util.HashMap;
51
import java.util.HashSet;
52
import java.util.List;
53
import java.util.Map;
54
import java.util.Set;
55

56
import static net.bytebuddy.matcher.ElementMatchers.is;
57
import static net.bytebuddy.matcher.ElementMatchers.not;
58

59
/**
60
 * Implementations of this interface represent an instrumented type that is subject to change. Implementations
61
 * should however be immutable and return new instance when its builder methods are invoked.
62
 */
63
public interface InstrumentedType extends TypeDescription {
64

65
    /**
66
     * Creates a new instrumented type that defines the provided module metadata or no such metadata
67
     * if {@code null} is provided.
68
     *
69
     * @param moduleDescription The metadata to include or {@code null}.
70
     * @return A new instrumented type that is equal to this instrumented type but with adjusted module metadata.
71
     */
72
    InstrumentedType withModuleDescription(@MaybeNull ModuleDescription moduleDescription);
73

74
    /**
75
     * Creates a new instrumented type that includes a new field.
76
     *
77
     * @param token A token that represents the field's shape.
78
     * @return A new instrumented type that is equal to this instrumented type but with the additional field.
79
     */
80
    InstrumentedType withField(FieldDescription.Token token);
81

82
    /**
83
     * Creates a new instrumented type that includes a new field.
84
     *
85
     * @param token A token that represents the field's shape.
86
     * @param value The value that this assigned to this field.
87
     * @return A new instrumented type that is equal to this instrumented type but with the additional field.
88
     */
89
    InstrumentedType withAuxiliaryField(FieldDescription.Token token, Object value);
90

91
    /**
92
     * Creates a new instrumented type that includes a new method or constructor.
93
     *
94
     * @param token A token that represents the method's shape.
95
     * @return A new instrumented type that is equal to this instrumented type but with the additional method.
96
     */
97
    InstrumentedType withMethod(MethodDescription.Token token);
98

99
    /**
100
     * Creates a new instrumented type that includes a new record component.
101
     *
102
     * @param token A token that represents the record component's shape.
103
     * @return A new instrumented type that is equal to this instrumented type but with the additional record component.
104
     */
105
    InstrumentedType withRecordComponent(RecordComponentDescription.Token token);
106

107
    /**
108
     * Creates a new instrumented type with changed modifiers.
109
     *
110
     * @param modifiers The instrumented type's modifiers.
111
     * @return A new instrumented type that is equal to this instrumented type but with the given modifiers.
112
     */
113
    InstrumentedType withModifiers(int modifiers);
114

115
    /**
116
     * Creates a new instrumented type with the given interfaces implemented.
117
     *
118
     * @param interfaceTypes The interface types to implement.
119
     * @return A new instrumented type that is equal to this instrumented type but with the given interfaces implemented.
120
     */
121
    InstrumentedType withInterfaces(TypeList.Generic interfaceTypes);
122

123
    /**
124
     * Creates a new instrumented type with the given type variable defined.
125
     *
126
     * @param typeVariable The type variable to declare.
127
     * @return A new instrumented type that is equal to this instrumented type but with the given type variable declared.
128
     */
129
    InstrumentedType withTypeVariable(TypeVariableToken typeVariable);
130

131
    /**
132
     * Creates a new instrumented type with the given annotations.
133
     *
134
     * @param annotationDescriptions The annotations to add to the instrumented type.
135
     * @return A new instrumented type that is equal to this instrumented type but annotated with the given annotations
136
     */
137
    InstrumentedType withAnnotations(List<? extends AnnotationDescription> annotationDescriptions);
138

139
    /**
140
     * Creates a new instrumented type with the supplied nest host. An instrumented type can be its own nest host.
141
     * Setting a nest host removes all nest members from the instrumented type.
142
     *
143
     * @param nestHost The nest host of the created instrumented type.
144
     * @return A new instrumented type with the supplied type as its nest host.
145
     */
146
    InstrumentedType withNestHost(TypeDescription nestHost);
147

148
    /**
149
     * Creates a new instrumented types with the supplied nest members added to this instrumented type. The instrumented
150
     * type is defined as a nest host if this method is invoked. Any previous nest members are prepended to the supplied types.
151
     *
152
     * @param nestMembers The nest members to add to the created instrumented type.
153
     * @return A new instrumented type that applies the supplied nest members.
154
     */
155
    InstrumentedType withNestMembers(TypeList nestMembers);
156

157
    /**
158
     * Creates a new instrumented type with the supplied enclosing type.
159
     *
160
     * @param enclosingType The type to define as the created instrumented type's enclosing type.
161
     * @return A new instrumented type with the supplied type as its enclosing type.
162
     */
163
    InstrumentedType withEnclosingType(TypeDescription enclosingType);
164

165
    /**
166
     * Creates a new instrumented type with the supplied enclosing method.
167
     *
168
     * @param enclosingMethod The method to define as the created instrumented type's enclosing method.
169
     * @return A new instrumented type with the supplied method as its enclosing method.
170
     */
171
    InstrumentedType withEnclosingMethod(MethodDescription.InDefinedShape enclosingMethod);
172

173
    /**
174
     * Creates a new instrumented type that is declared by the supplied type.
175
     *
176
     * @param declaringType The type that declares the instrumented type or {@code null} if no such type exists.
177
     * @return A new instrumented type that is declared by the instrumented type.
178
     */
179
    InstrumentedType withDeclaringType(@MaybeNull TypeDescription declaringType);
180

181
    /**
182
     * Creates a new instrumented type that indicates that it declared the supplied types.
183
     *
184
     * @param declaredTypes The types to add to the created instrumented type as declared types.
185
     * @return A new instrumented type that indicates that it has declared the supplied types.
186
     */
187
    InstrumentedType withDeclaredTypes(TypeList declaredTypes);
188

189
    /**
190
     * Creates a new instrumented type that includes the supplied permitted subclasses or unseals the type.
191
     *
192
     * @param permittedSubclasses A list of permitted subclasses to include or {@code null} to unseal the type.
193
     * @return A new instrumented type that includes the supplied permitted subclasses or unseals the type.
194
     */
195
    InstrumentedType withPermittedSubclasses(@MaybeNull TypeList permittedSubclasses);
196

197
    /**
198
     * Creates a new instrumented type that indicates that is defined as a local class. Setting this property
199
     * resets the anonymous class property.
200
     *
201
     * @param localClass {@code true} if the instrumented type is supposed to be treated as a local class.
202
     * @return A new instrumented type that is treated as a local class.
203
     */
204
    InstrumentedType withLocalClass(boolean localClass);
205

206
    /**
207
     * Creates a new instrumented type that indicates that it is defined as an anonymous class. Setting this property
208
     * resets the local class property.
209
     *
210
     * @param anonymousClass {@code true} if the instrumented type is supposed to be treated as an anonymous class.
211
     * @return A new instrumented type that is treated as an anonymous class.
212
     */
213
    InstrumentedType withAnonymousClass(boolean anonymousClass);
214

215
    /**
216
     * Creates a new instrumented type that indicates that it defined as a record type. Setting this property to false
217
     * removes all record components.
218
     *
219
     * @param record {@code true} if the instrumented type is supposed to be a record.
220
     * @return A new instrumented type that is defined as a record.
221
     */
222
    InstrumentedType withRecord(boolean record);
223

224
    /**
225
     * Creates a new instrumented type that includes the given {@link net.bytebuddy.implementation.LoadedTypeInitializer}.
226
     *
227
     * @param loadedTypeInitializer The type initializer to include.
228
     * @return A new instrumented type that is equal to this instrumented type but with the additional type initializer.
229
     */
230
    InstrumentedType withInitializer(LoadedTypeInitializer loadedTypeInitializer);
231

232
    /**
233
     * Creates a new instrumented type that executes the given initializer in the instrumented type's
234
     * type initializer.
235
     *
236
     * @param byteCodeAppender The byte code to add to the type initializer.
237
     * @return A new instrumented type that is equal to this instrumented type but with the given stack manipulation
238
     * attached to its type initializer.
239
     */
240
    InstrumentedType withInitializer(ByteCodeAppender byteCodeAppender);
241

242
    /**
243
     * Returns the {@link net.bytebuddy.implementation.LoadedTypeInitializer}s that were registered
244
     * for this instrumented type.
245
     *
246
     * @return The registered loaded type initializers for this instrumented type.
247
     */
248
    LoadedTypeInitializer getLoadedTypeInitializer();
249

250
    /**
251
     * Returns this instrumented type's type initializer.
252
     *
253
     * @return This instrumented type's type initializer.
254
     */
255
    TypeInitializer getTypeInitializer();
256

257
    /**
258
     * Validates the instrumented type to define a legal Java type.
259
     *
260
     * @return This instrumented type as a non-modifiable type description.
261
     */
262
    TypeDescription validated();
263

264
    /**
265
     * Implementations represent an {@link InstrumentedType} with a flexible name.
266
     */
267
    interface WithFlexibleName extends InstrumentedType {
268

269
        /**
270
         * {@inheritDoc}
271
         */
272
        WithFlexibleName withModuleDescription(@MaybeNull ModuleDescription moduleDescription);
273

274
        /**
275
         * {@inheritDoc}
276
         */
277
        WithFlexibleName withField(FieldDescription.Token token);
278

279
        /**
280
         * {@inheritDoc}
281
         */
282
        WithFlexibleName withAuxiliaryField(FieldDescription.Token token, Object value);
283

284
        /**
285
         * {@inheritDoc}
286
         */
287
        WithFlexibleName withMethod(MethodDescription.Token token);
288

289
        /**
290
         * {@inheritDoc}
291
         */
292
        WithFlexibleName withRecordComponent(RecordComponentDescription.Token token);
293

294
        /**
295
         * {@inheritDoc}
296
         */
297
        WithFlexibleName withModifiers(int modifiers);
298

299
        /**
300
         * {@inheritDoc}
301
         */
302
        WithFlexibleName withInterfaces(TypeList.Generic interfaceTypes);
303

304
        /**
305
         * {@inheritDoc}
306
         */
307
        WithFlexibleName withNestHost(TypeDescription nestHost);
308

309
        /**
310
         * {@inheritDoc}
311
         */
312
        WithFlexibleName withNestMembers(TypeList nestMembers);
313

314
        /**
315
         * {@inheritDoc}
316
         */
317
        WithFlexibleName withEnclosingType(@MaybeNull TypeDescription enclosingType);
318

319
        /**
320
         * {@inheritDoc}
321
         */
322
        WithFlexibleName withEnclosingMethod(MethodDescription.InDefinedShape enclosingMethod);
323

324
        /**
325
         * {@inheritDoc}
326
         */
327
        WithFlexibleName withDeclaringType(@MaybeNull TypeDescription declaringType);
328

329
        /**
330
         * {@inheritDoc}
331
         */
332
        WithFlexibleName withDeclaredTypes(TypeList declaredTypes);
333

334
        /**
335
         * {@inheritDoc}
336
         */
337
        WithFlexibleName withPermittedSubclasses(@MaybeNull TypeList permittedSubclasses);
338

339
        /**
340
         * {@inheritDoc}
341
         */
342
        WithFlexibleName withLocalClass(boolean localClass);
343

344
        /**
345
         * {@inheritDoc}
346
         */
347
        WithFlexibleName withAnonymousClass(boolean anonymousClass);
348

349
        /**
350
         * {@inheritDoc}
351
         */
352
        WithFlexibleName withRecord(boolean record);
353

354
        /**
355
         * {@inheritDoc}
356
         */
357
        WithFlexibleName withTypeVariable(TypeVariableToken typeVariable);
358

359
        /**
360
         * {@inheritDoc}
361
         */
362
        WithFlexibleName withAnnotations(List<? extends AnnotationDescription> annotationDescriptions);
363

364
        /**
365
         * {@inheritDoc}
366
         */
367
        WithFlexibleName withInitializer(LoadedTypeInitializer loadedTypeInitializer);
368

369
        /**
370
         * {@inheritDoc}
371
         */
372
        WithFlexibleName withInitializer(ByteCodeAppender byteCodeAppender);
373

374
        /**
375
         * Creates a new instrumented type with a changed name.
376
         *
377
         * @param name The name of the instrumented type.
378
         * @return A new instrumented type that has the given name.
379
         */
380
        WithFlexibleName withName(String name);
381

382
        /**
383
         * Applies a transformation onto all existing type variables of this instrumented type. A transformation is potentially unsafe
384
         * and it is the responsibility of the supplier to return a valid type variable token from the transformer.
385
         *
386
         * @param matcher     The matcher to decide what type variables to transform.
387
         * @param transformer The transformer to apply on all matched type variables.
388
         * @return A new instrumented type with all matched type variables transformed.
389
         */
390
        WithFlexibleName withTypeVariables(ElementMatcher<? super Generic> matcher, Transformer<TypeVariableToken> transformer);
391
    }
392

393
    /**
394
     * Implementations are able to prepare an {@link InstrumentedType}.
395
     */
396
    interface Prepareable {
397

398
        /**
399
         * Prepares a given instrumented type.
400
         *
401
         * @param instrumentedType The instrumented type in its current form.
402
         * @return The prepared instrumented type.
403
         */
404
        InstrumentedType prepare(InstrumentedType instrumentedType);
405

406
        /**
407
         * A prepareable that does not alter the instrumented type.
408
         */
409
        enum NoOp implements Prepareable {
1✔
410

411
            /**
412
             * The singleton instance.
413
             */
414
            INSTANCE;
1✔
415

416
            /**
417
             * {@inheritDoc}
418
             */
419
            public InstrumentedType prepare(InstrumentedType instrumentedType) {
420
                return instrumentedType;
1✔
421
            }
422
        }
423
    }
424

425
    /**
426
     * A factory for creating an {@link InstrumentedType}.
427
     */
428
    interface Factory {
429

430
        /**
431
         * Creates an instrumented type that represents the provided type.
432
         *
433
         * @param typeDescription The type to represent.
434
         * @return An appropriate instrumented type.
435
         */
436
        InstrumentedType.WithFlexibleName represent(TypeDescription typeDescription);
437

438
        /**
439
         * Creates a new instrumented type as a subclass.
440
         *
441
         * @param name       The type's name.
442
         * @param modifiers  The type's modifiers.
443
         * @param superClass The type's super class or {@code null} if no super class.
444
         * @return A new instrumented type representing a subclass of the given parameters.
445
         */
446
        InstrumentedType.WithFlexibleName subclass(String name, int modifiers, @MaybeNull TypeDescription.Generic superClass);
447

448
        /**
449
         * Default implementations of instrumented type factories.
450
         */
451
        enum Default implements Factory {
1✔
452

453
            /**
454
             * A factory for an instrumented type that allows to modify represented types.
455
             */
456
            MODIFIABLE {
1✔
457
                /** {@inheritDoc} */
458
                public InstrumentedType.WithFlexibleName represent(TypeDescription typeDescription) {
459
                    return new InstrumentedType.Default(typeDescription.getName(),
1✔
460
                            typeDescription.getModifiers(),
1✔
461
                            typeDescription.toModuleDescription(),
1✔
462
                            typeDescription.getTypeVariables().asTokenList(is(typeDescription)),
1✔
463
                            typeDescription.getSuperClass(),
1✔
464
                            typeDescription.getInterfaces().accept(Generic.Visitor.Substitutor.ForDetachment.of(typeDescription)),
1✔
465
                            typeDescription.getDeclaredFields().asTokenList(is(typeDescription)),
1✔
466
                            Collections.<String, Object>emptyMap(),
1✔
467
                            typeDescription.getDeclaredMethods().asTokenList(is(typeDescription)),
1✔
468
                            typeDescription.getRecordComponents().asTokenList(is(typeDescription)),
1✔
469
                            typeDescription.getDeclaredAnnotations(),
1✔
470
                            TypeInitializer.None.INSTANCE,
471
                            LoadedTypeInitializer.NoOp.INSTANCE,
472
                            typeDescription.getDeclaringType(),
1✔
473
                            typeDescription.getEnclosingMethod(),
1✔
474
                            typeDescription.getEnclosingType(),
1✔
475
                            typeDescription.getDeclaredTypes(),
1✔
476
                            typeDescription.isSealed()
1✔
477
                                    ? typeDescription.getPermittedSubtypes()
1✔
478
                                    : TypeList.UNDEFINED,
479
                            typeDescription.isAnonymousType(),
1✔
480
                            typeDescription.isLocalType(),
1✔
481
                            typeDescription.isRecord(),
1✔
482
                            typeDescription.isNestHost()
1✔
483
                                    ? TargetType.DESCRIPTION
484
                                    : typeDescription.getNestHost(),
1✔
485
                            typeDescription.isNestHost()
1✔
486
                                    ? typeDescription.getNestMembers().filter(not(is(typeDescription)))
1✔
487
                                    : Collections.<TypeDescription>emptyList());
1✔
488
                }
489
            },
490

491
            /**
492
             * A factory for an instrumented type that does not allow to modify represented types.
493
             */
494
            FROZEN {
1✔
495
                /** {@inheritDoc} */
496
                public InstrumentedType.WithFlexibleName represent(TypeDescription typeDescription) {
497
                    return new Frozen(typeDescription, LoadedTypeInitializer.NoOp.INSTANCE);
1✔
498
                }
499
            };
500

501
            /**
502
             * {@inheritDoc}
503
             */
504
            public InstrumentedType.WithFlexibleName subclass(String name, int modifiers, @MaybeNull TypeDescription.Generic superClass) {
505
                return new InstrumentedType.Default(name,
1✔
506
                        modifiers,
507
                        ModuleDescription.UNDEFINED,
508
                        Collections.<TypeVariableToken>emptyList(),
1✔
509
                        superClass,
510
                        Collections.<Generic>emptyList(),
1✔
511
                        Collections.<FieldDescription.Token>emptyList(),
1✔
512
                        Collections.<String, Object>emptyMap(),
1✔
513
                        Collections.<MethodDescription.Token>emptyList(),
1✔
514
                        Collections.<RecordComponentDescription.Token>emptyList(),
1✔
515
                        Collections.<AnnotationDescription>emptyList(),
1✔
516
                        TypeInitializer.None.INSTANCE,
517
                        LoadedTypeInitializer.NoOp.INSTANCE,
518
                        TypeDescription.UNDEFINED,
519
                        MethodDescription.UNDEFINED,
520
                        TypeDescription.UNDEFINED,
521
                        Collections.<TypeDescription>emptyList(),
1✔
522
                        TypeList.UNDEFINED,
523
                        false,
524
                        false,
525
                        false,
526
                        TargetType.DESCRIPTION,
527
                        Collections.<TypeDescription>emptyList());
1✔
528
            }
529
        }
530
    }
531

532
    /**
533
     * A default implementation of an instrumented type.
534
     */
535
    class Default extends AbstractBase.OfSimpleType implements InstrumentedType.WithFlexibleName {
536

537
        /**
538
         * A set containing all keywords of the Java programming language.
539
         */
540
        private static final Set<String> KEYWORDS = new HashSet<String>(Arrays.asList(
1✔
541
                "abstract", "continue", "for", "new", "switch", "assert", "default", "goto", "package", "synchronized", "boolean",
542
                "do", "if", "private", "this", "break", "double", "implements", "protected", "throw", "byte", "else", "import",
543
                "public", "throws", "case", "enum", "instanceof", "return", "transient", "catch", "extends", "int", "short",
544
                "try", "char", "final", "interface", "static", "void", "class", "finally", "long", "strictfp", "volatile",
545
                "const", "float", "native", "super", "while"
546
        ));
547

548
        /**
549
         * The binary name of the instrumented type.
550
         */
551
        private final String name;
552

553
        /**
554
         * The modifiers of the instrumented type.
555
         */
556
        private final int modifiers;
557

558
        /**
559
         * The generic super type of the instrumented type.
560
         */
561
        @MaybeNull
562
        private final Generic superClass;
563

564
        /**
565
         * The module metadata that this type implies or {@code null}.
566
         */
567
        @MaybeNull
568
        private final ModuleDescription moduleDescription;
569

570
        /**
571
         * The instrumented type's type variables in their tokenized form.
572
         */
573
        private final List<? extends TypeVariableToken> typeVariables;
574

575
        /**
576
         * A list of interfaces of the instrumented type.
577
         */
578
        private final List<? extends Generic> interfaceTypes;
579

580
        /**
581
         * A list of field tokens describing the fields of the instrumented type.
582
         */
583
        private final List<? extends FieldDescription.Token> fieldTokens;
584

585
        /**
586
         * A mapping of auxiliary field names to their mapped values.
587
         */
588
        private final Map<String, Object> auxiliaryFields;
589

590
        /**
591
         * A list of method tokens describing the methods of the instrumented type.
592
         */
593
        private final List<? extends MethodDescription.Token> methodTokens;
594

595
        /**
596
         * A list of record component tokens describing the record components of the instrumented type.
597
         */
598
        private final List<? extends RecordComponentDescription.Token> recordComponentTokens;
599

600
        /**
601
         * A list of annotations of the annotated type.
602
         */
603
        private final List<? extends AnnotationDescription> annotationDescriptions;
604

605
        /**
606
         * The type initializer of the instrumented type.
607
         */
608
        private final TypeInitializer typeInitializer;
609

610
        /**
611
         * The loaded type initializer of the instrumented type.
612
         */
613
        private final LoadedTypeInitializer loadedTypeInitializer;
614

615
        /**
616
         * The declaring type of the instrumented type or {@code null} if no such type exists.
617
         */
618
        @MaybeNull
619
        private final TypeDescription declaringType;
620

621
        /**
622
         * The enclosing method of the instrumented type or {@code null} if no such type exists.
623
         */
624
        @MaybeNull
625
        private final MethodDescription.InDefinedShape enclosingMethod;
626

627
        /**
628
         * The enclosing type of the instrumented type or {@code null} if no such type exists.
629
         */
630
        @MaybeNull
631
        private final TypeDescription enclosingType;
632

633
        /**
634
         * A list of types that are declared by this type.
635
         */
636
        private final List<? extends TypeDescription> declaredTypes;
637

638
        /**
639
         * A list of permitted subclasses or {@code null} if this type is not sealed.
640
         */
641
        @MaybeNull
642
        private final List<? extends TypeDescription> permittedSubclasses;
643

644
        /**
645
         * {@code true} if this type is an anonymous class.
646
         */
647
        private final boolean anonymousClass;
648

649
        /**
650
         * {@code true} if this type is a local class.
651
         */
652
        private final boolean localClass;
653

654
        /**
655
         * {@code true} if this class is a record class.
656
         */
657
        private final boolean record;
658

659
        /**
660
         * The nest host of this instrumented type or a description of {@link TargetType} if this type is its own nest host.
661
         */
662
        private final TypeDescription nestHost;
663

664
        /**
665
         * A list of all members of this types nest group excluding this type.
666
         */
667
        private final List<? extends TypeDescription> nestMembers;
668

669
        /**
670
         * Creates a new instrumented type.
671
         *
672
         * @param name                   The binary name of the instrumented type.
673
         * @param modifiers              The modifiers of the instrumented type.
674
         * @param moduleDescription      The module metadata that this type implies or {@code null}.
675
         * @param typeVariables          The instrumented type's type variables in their tokenized form.
676
         * @param superClass             The generic super type of the instrumented type.
677
         * @param interfaceTypes         A list of interfaces of the instrumented type.
678
         * @param fieldTokens            A list of field tokens describing the fields of the instrumented type.
679
         * @param auxiliaryFieldValues   A mapping of auxiliary field names to their mapped values.
680
         * @param methodTokens           A list of method tokens describing the methods of the instrumented type.
681
         * @param recordComponentTokens  A list of record component tokens describing the record components of the instrumented type.
682
         * @param annotationDescriptions A list of annotations of the annotated type.
683
         * @param typeInitializer        The type initializer of the instrumented type.
684
         * @param loadedTypeInitializer  The loaded type initializer of the instrumented type.
685
         * @param declaringType          The declaring type of the instrumented type or {@code null} if no such type exists.
686
         * @param enclosingMethod        The enclosing method of the instrumented type or {@code null} if no such type exists.
687
         * @param enclosingType          The enclosing type of the instrumented type or {@code null} if no such type exists.
688
         * @param declaredTypes          A list of types that are declared by this type.
689
         * @param permittedSubclasses    A list of permitted subclasses or {@code null} if this type is not sealed.
690
         * @param anonymousClass         {@code true} if this type is an anonymous class.
691
         * @param localClass             {@code true} if this type is a local class.
692
         * @param record                 {@code true} if this type is a record class.
693
         * @param nestHost               The nest host of this instrumented type or a description of {@link TargetType} if this type is its own nest host.
694
         * @param nestMembers            A list of all members of this types nest group excluding this type.
695
         */
696
        protected Default(String name,
697
                          int modifiers,
698
                          @MaybeNull ModuleDescription moduleDescription,
699
                          List<? extends TypeVariableToken> typeVariables,
700
                          @MaybeNull Generic superClass,
701
                          List<? extends Generic> interfaceTypes,
702
                          List<? extends FieldDescription.Token> fieldTokens,
703
                          Map<String, Object> auxiliaryFieldValues,
704
                          List<? extends MethodDescription.Token> methodTokens,
705
                          List<? extends RecordComponentDescription.Token> recordComponentTokens,
706
                          List<? extends AnnotationDescription> annotationDescriptions,
707
                          TypeInitializer typeInitializer,
708
                          LoadedTypeInitializer loadedTypeInitializer,
709
                          @MaybeNull TypeDescription declaringType,
710
                          @MaybeNull MethodDescription.InDefinedShape enclosingMethod,
711
                          @MaybeNull TypeDescription enclosingType,
712
                          List<? extends TypeDescription> declaredTypes,
713
                          @MaybeNull List<? extends TypeDescription> permittedSubclasses,
714
                          boolean anonymousClass,
715
                          boolean localClass,
716
                          boolean record,
717
                          TypeDescription nestHost,
718
                          List<? extends TypeDescription> nestMembers) {
1✔
719
            this.name = name;
1✔
720
            this.modifiers = modifiers;
1✔
721
            this.moduleDescription = moduleDescription;
1✔
722
            this.typeVariables = typeVariables;
1✔
723
            this.superClass = superClass;
1✔
724
            this.interfaceTypes = interfaceTypes;
1✔
725
            this.fieldTokens = fieldTokens;
1✔
726
            this.auxiliaryFields = auxiliaryFieldValues;
1✔
727
            this.methodTokens = methodTokens;
1✔
728
            this.recordComponentTokens = recordComponentTokens;
1✔
729
            this.annotationDescriptions = annotationDescriptions;
1✔
730
            this.typeInitializer = typeInitializer;
1✔
731
            this.loadedTypeInitializer = loadedTypeInitializer;
1✔
732
            this.declaringType = declaringType;
1✔
733
            this.enclosingMethod = enclosingMethod;
1✔
734
            this.enclosingType = enclosingType;
1✔
735
            this.declaredTypes = declaredTypes;
1✔
736
            this.permittedSubclasses = permittedSubclasses;
1✔
737
            this.anonymousClass = anonymousClass;
1✔
738
            this.localClass = localClass;
1✔
739
            this.record = record;
1✔
740
            this.nestHost = nestHost;
1✔
741
            this.nestMembers = nestMembers;
1✔
742
        }
1✔
743

744
        /**
745
         * Creates a new instrumented type.
746
         *
747
         * @param name                The type's name.
748
         * @param superClass          The type's super class.
749
         * @param modifierContributor The type's modifiers.
750
         * @return An appropriate instrumented type.
751
         */
752
        public static InstrumentedType of(String name, TypeDescription.Generic superClass, ModifierContributor.ForType... modifierContributor) {
753
            return of(name, superClass, ModifierContributor.Resolver.of(modifierContributor).resolve());
1✔
754
        }
755

756
        /**
757
         * Creates a new instrumented type.
758
         *
759
         * @param name       The type's name.
760
         * @param superClass The type's super class.
761
         * @param modifiers  The type's modifiers.
762
         * @return An appropriate instrumented type.
763
         */
764
        public static InstrumentedType of(String name, TypeDescription.Generic superClass, int modifiers) {
765
            return Factory.Default.MODIFIABLE.subclass(name, modifiers, superClass);
1✔
766
        }
767

768
        /**
769
         * {@inheritDoc}
770
         */
771
        public WithFlexibleName withModifiers(int modifiers) {
772
            return new Default(name,
1✔
773
                    modifiers,
774
                    moduleDescription,
775
                    typeVariables,
776
                    superClass,
777
                    interfaceTypes,
778
                    fieldTokens,
779
                    auxiliaryFields,
780
                    methodTokens,
781
                    recordComponentTokens,
782
                    annotationDescriptions,
783
                    typeInitializer,
784
                    loadedTypeInitializer,
785
                    declaringType,
786
                    enclosingMethod,
787
                    enclosingType,
788
                    declaredTypes,
789
                    permittedSubclasses,
790
                    anonymousClass,
791
                    localClass,
792
                    record,
793
                    nestHost,
794
                    nestMembers);
795
        }
796

797
        /**
798
         * {@inheritDoc}
799
         */
800
        public WithFlexibleName withField(FieldDescription.Token token) {
801
            return new Default(name,
1✔
802
                    modifiers,
803
                    moduleDescription,
804
                    typeVariables,
805
                    superClass,
806
                    interfaceTypes,
807
                    CompoundList.of(fieldTokens, token.accept(Generic.Visitor.Substitutor.ForDetachment.of(this))),
1✔
808
                    auxiliaryFields,
809
                    methodTokens,
810
                    recordComponentTokens,
811
                    annotationDescriptions,
812
                    typeInitializer,
813
                    loadedTypeInitializer,
814
                    declaringType,
815
                    enclosingMethod,
816
                    enclosingType,
817
                    declaredTypes,
818
                    permittedSubclasses,
819
                    anonymousClass,
820
                    localClass,
821
                    record,
822
                    nestHost,
823
                    nestMembers);
824
        }
825

826
        /**
827
         * {@inheritDoc}
828
         */
829
        public WithFlexibleName withAuxiliaryField(FieldDescription.Token token, Object value) {
830
            Map<String, Object> auxiliaryFields = new HashMap<String, Object>(this.auxiliaryFields);
1✔
831
            Object previous = auxiliaryFields.put(token.getName(), value);
1✔
832
            if (previous != null) {
1✔
833
                if (previous == value) {
1✔
834
                    return this;
1✔
835
                } else {
836
                    throw new IllegalStateException("Field " + token.getName()
1✔
837
                            + " for " + this
838
                            + " already mapped to " + previous
839
                            + " and not " + value);
840
                }
841
            }
842
            return new Default(name,
1✔
843
                    modifiers,
844
                    moduleDescription,
845
                    typeVariables,
846
                    superClass,
847
                    interfaceTypes,
848
                    CompoundList.of(fieldTokens, token.accept(Generic.Visitor.Substitutor.ForDetachment.of(this))),
1✔
849
                    auxiliaryFields,
850
                    methodTokens,
851
                    recordComponentTokens,
852
                    annotationDescriptions,
853
                    typeInitializer,
854
                    new LoadedTypeInitializer.Compound(loadedTypeInitializer, new LoadedTypeInitializer.ForStaticField(token.getName(), value)),
1✔
855
                    declaringType,
856
                    enclosingMethod,
857
                    enclosingType,
858
                    declaredTypes,
859
                    permittedSubclasses,
860
                    anonymousClass,
861
                    localClass,
862
                    record,
863
                    nestHost,
864
                    nestMembers);
865
        }
866

867
        /**
868
         * {@inheritDoc}
869
         */
870
        public WithFlexibleName withMethod(MethodDescription.Token token) {
871
            return new Default(name,
1✔
872
                    modifiers,
873
                    moduleDescription,
874
                    typeVariables,
875
                    superClass,
876
                    interfaceTypes,
877
                    fieldTokens,
878
                    auxiliaryFields,
879
                    CompoundList.of(methodTokens, token.accept(Generic.Visitor.Substitutor.ForDetachment.of(this))),
1✔
880
                    recordComponentTokens,
881
                    annotationDescriptions,
882
                    typeInitializer,
883
                    loadedTypeInitializer,
884
                    declaringType,
885
                    enclosingMethod,
886
                    enclosingType,
887
                    declaredTypes,
888
                    permittedSubclasses,
889
                    anonymousClass,
890
                    localClass,
891
                    record,
892
                    nestHost,
893
                    nestMembers);
894
        }
895

896
        /**
897
         * {@inheritDoc}
898
         */
899
        public WithFlexibleName withRecordComponent(RecordComponentDescription.Token token) {
900
            return new Default(name,
1✔
901
                    modifiers,
902
                    moduleDescription,
903
                    typeVariables,
904
                    superClass,
905
                    interfaceTypes,
906
                    fieldTokens,
907
                    auxiliaryFields,
908
                    methodTokens,
909
                    CompoundList.of(recordComponentTokens, token.accept(Generic.Visitor.Substitutor.ForDetachment.of(this))),
1✔
910
                    annotationDescriptions,
911
                    typeInitializer,
912
                    loadedTypeInitializer,
913
                    declaringType,
914
                    enclosingMethod,
915
                    enclosingType,
916
                    declaredTypes,
917
                    permittedSubclasses,
918
                    anonymousClass,
919
                    localClass,
920
                    true,
921
                    nestHost,
922
                    nestMembers);
923
        }
924

925
        /**
926
         * {@inheritDoc}
927
         */
928
        public WithFlexibleName withInterfaces(TypeList.Generic interfaceTypes) {
929
            return new Default(name,
1✔
930
                    modifiers,
931
                    moduleDescription,
932
                    typeVariables,
933
                    superClass,
934
                    CompoundList.of(this.interfaceTypes, interfaceTypes.accept(Generic.Visitor.Substitutor.ForDetachment.of(this))),
1✔
935
                    fieldTokens,
936
                    auxiliaryFields,
937
                    methodTokens,
938
                    recordComponentTokens,
939
                    annotationDescriptions,
940
                    typeInitializer,
941
                    loadedTypeInitializer,
942
                    declaringType,
943
                    enclosingMethod,
944
                    enclosingType,
945
                    declaredTypes,
946
                    permittedSubclasses,
947
                    anonymousClass,
948
                    localClass,
949
                    record,
950
                    nestHost,
951
                    nestMembers);
952
        }
953

954
        /**
955
         * {@inheritDoc}
956
         */
957
        public WithFlexibleName withAnnotations(List<? extends AnnotationDescription> annotationDescriptions) {
958
            return new Default(name,
1✔
959
                    modifiers,
960
                    moduleDescription,
961
                    typeVariables,
962
                    superClass,
963
                    interfaceTypes,
964
                    fieldTokens,
965
                    auxiliaryFields,
966
                    methodTokens,
967
                    recordComponentTokens,
968
                    CompoundList.of(this.annotationDescriptions, annotationDescriptions),
1✔
969
                    typeInitializer,
970
                    loadedTypeInitializer,
971
                    declaringType,
972
                    enclosingMethod,
973
                    enclosingType,
974
                    declaredTypes,
975
                    permittedSubclasses,
976
                    anonymousClass,
977
                    localClass,
978
                    record,
979
                    nestHost,
980
                    nestMembers);
981
        }
982

983
        /**
984
         * {@inheritDoc}
985
         */
986
        public WithFlexibleName withNestHost(TypeDescription nestHost) {
987
            return new Default(name,
1✔
988
                    modifiers,
989
                    moduleDescription,
990
                    typeVariables,
991
                    superClass,
992
                    interfaceTypes,
993
                    fieldTokens,
994
                    auxiliaryFields,
995
                    methodTokens,
996
                    recordComponentTokens,
997
                    annotationDescriptions,
998
                    typeInitializer,
999
                    loadedTypeInitializer,
1000
                    declaringType,
1001
                    enclosingMethod,
1002
                    enclosingType,
1003
                    declaredTypes,
1004
                    permittedSubclasses,
1005
                    anonymousClass,
1006
                    localClass,
1007
                    record,
1008
                    nestHost.equals(this)
1✔
1009
                            ? TargetType.DESCRIPTION
1010
                            : nestHost,
1011
                    Collections.<TypeDescription>emptyList());
1✔
1012
        }
1013

1014
        /**
1015
         * {@inheritDoc}
1016
         */
1017
        public WithFlexibleName withNestMembers(TypeList nestMembers) {
1018
            return new Default(name,
1✔
1019
                    modifiers,
1020
                    moduleDescription,
1021
                    typeVariables,
1022
                    superClass,
1023
                    interfaceTypes,
1024
                    fieldTokens,
1025
                    auxiliaryFields,
1026
                    methodTokens,
1027
                    recordComponentTokens,
1028
                    annotationDescriptions,
1029
                    typeInitializer,
1030
                    loadedTypeInitializer,
1031
                    declaringType,
1032
                    enclosingMethod,
1033
                    enclosingType,
1034
                    declaredTypes,
1035
                    permittedSubclasses,
1036
                    anonymousClass,
1037
                    localClass,
1038
                    record,
1039
                    TargetType.DESCRIPTION,
1040
                    CompoundList.of(this.nestMembers, nestMembers));
1✔
1041
        }
1042

1043
        /**
1044
         * {@inheritDoc}
1045
         */
1046
        public WithFlexibleName withEnclosingType(@MaybeNull TypeDescription enclosingType) {
1047
            return new Default(name,
1✔
1048
                    modifiers,
1049
                    moduleDescription,
1050
                    typeVariables,
1051
                    superClass,
1052
                    interfaceTypes,
1053
                    fieldTokens,
1054
                    auxiliaryFields,
1055
                    methodTokens,
1056
                    recordComponentTokens,
1057
                    annotationDescriptions,
1058
                    typeInitializer,
1059
                    loadedTypeInitializer,
1060
                    declaringType,
1061
                    MethodDescription.UNDEFINED,
1062
                    enclosingType,
1063
                    declaredTypes,
1064
                    permittedSubclasses,
1065
                    anonymousClass,
1066
                    localClass,
1067
                    record,
1068
                    nestHost,
1069
                    nestMembers);
1070
        }
1071

1072
        /**
1073
         * {@inheritDoc}
1074
         */
1075
        public WithFlexibleName withEnclosingMethod(MethodDescription.InDefinedShape enclosingMethod) {
1076
            return new Default(name,
1✔
1077
                    modifiers,
1078
                    moduleDescription,
1079
                    typeVariables,
1080
                    superClass,
1081
                    interfaceTypes,
1082
                    fieldTokens,
1083
                    auxiliaryFields,
1084
                    methodTokens,
1085
                    recordComponentTokens,
1086
                    annotationDescriptions,
1087
                    typeInitializer,
1088
                    loadedTypeInitializer,
1089
                    declaringType,
1090
                    enclosingMethod,
1091
                    enclosingMethod.getDeclaringType(),
1✔
1092
                    declaredTypes,
1093
                    permittedSubclasses,
1094
                    anonymousClass,
1095
                    localClass,
1096
                    record,
1097
                    nestHost,
1098
                    nestMembers);
1099
        }
1100

1101
        /**
1102
         * {@inheritDoc}
1103
         */
1104
        public WithFlexibleName withDeclaringType(@MaybeNull TypeDescription declaringType) {
1105
            return new Default(name,
1✔
1106
                    modifiers,
1107
                    moduleDescription,
1108
                    typeVariables,
1109
                    superClass,
1110
                    interfaceTypes,
1111
                    fieldTokens,
1112
                    auxiliaryFields,
1113
                    methodTokens,
1114
                    recordComponentTokens,
1115
                    annotationDescriptions,
1116
                    typeInitializer,
1117
                    loadedTypeInitializer,
1118
                    declaringType,
1119
                    enclosingMethod,
1120
                    enclosingType,
1121
                    declaredTypes,
1122
                    permittedSubclasses,
1123
                    anonymousClass,
1124
                    localClass,
1125
                    record,
1126
                    nestHost,
1127
                    nestMembers);
1128
        }
1129

1130
        /**
1131
         * {@inheritDoc}
1132
         */
1133
        public WithFlexibleName withDeclaredTypes(TypeList declaredTypes) {
1134
            return new Default(name,
1✔
1135
                    modifiers,
1136
                    moduleDescription,
1137
                    typeVariables,
1138
                    superClass,
1139
                    interfaceTypes,
1140
                    fieldTokens,
1141
                    auxiliaryFields,
1142
                    methodTokens,
1143
                    recordComponentTokens,
1144
                    annotationDescriptions,
1145
                    typeInitializer,
1146
                    loadedTypeInitializer,
1147
                    declaringType,
1148
                    enclosingMethod,
1149
                    enclosingType,
1150
                    CompoundList.of(this.declaredTypes, declaredTypes),
1✔
1151
                    permittedSubclasses,
1152
                    anonymousClass,
1153
                    localClass,
1154
                    record,
1155
                    nestHost,
1156
                    nestMembers);
1157
        }
1158

1159
        /**
1160
         * {@inheritDoc}
1161
         */
1162
        public WithFlexibleName withPermittedSubclasses(@MaybeNull TypeList permittedSubclasses) {
1163
            return new Default(name,
1✔
1164
                    modifiers,
1165
                    moduleDescription,
1166
                    typeVariables,
1167
                    superClass,
1168
                    interfaceTypes,
1169
                    fieldTokens,
1170
                    auxiliaryFields,
1171
                    methodTokens,
1172
                    recordComponentTokens,
1173
                    annotationDescriptions,
1174
                    typeInitializer,
1175
                    loadedTypeInitializer,
1176
                    declaringType,
1177
                    enclosingMethod,
1178
                    enclosingType,
1179
                    declaredTypes,
1180
                    permittedSubclasses == null || this.permittedSubclasses == null
1181
                            ? permittedSubclasses
1182
                            : CompoundList.of(this.permittedSubclasses, permittedSubclasses),
1✔
1183
                    anonymousClass,
1184
                    localClass,
1185
                    record,
1186
                    nestHost,
1187
                    nestMembers);
1188
        }
1189

1190
        @Override
1191
        public WithFlexibleName withModuleDescription(@MaybeNull ModuleDescription moduleDescription) {
1192
            return new Default(name,
1✔
1193
                    modifiers,
1194
                    moduleDescription,
1195
                    typeVariables,
1196
                    superClass,
1197
                    interfaceTypes,
1198
                    fieldTokens,
1199
                    auxiliaryFields,
1200
                    methodTokens,
1201
                    recordComponentTokens,
1202
                    annotationDescriptions,
1203
                    typeInitializer,
1204
                    loadedTypeInitializer,
1205
                    declaringType,
1206
                    enclosingMethod,
1207
                    enclosingType,
1208
                    declaredTypes,
1209
                    permittedSubclasses,
1210
                    anonymousClass,
1211
                    localClass,
1212
                    record,
1213
                    nestHost,
1214
                    nestMembers);
1215
        }
1216

1217
        /**
1218
         * {@inheritDoc}
1219
         */
1220
        public WithFlexibleName withTypeVariable(TypeVariableToken typeVariable) {
1221
            return new Default(name,
1✔
1222
                    modifiers,
1223
                    moduleDescription,
1224
                    CompoundList.of(typeVariables, typeVariable.accept(Generic.Visitor.Substitutor.ForDetachment.of(this))),
1✔
1225
                    superClass,
1226
                    interfaceTypes,
1227
                    fieldTokens,
1228
                    auxiliaryFields,
1229
                    methodTokens,
1230
                    recordComponentTokens,
1231
                    annotationDescriptions,
1232
                    typeInitializer,
1233
                    loadedTypeInitializer,
1234
                    declaringType,
1235
                    enclosingMethod,
1236
                    enclosingType,
1237
                    declaredTypes,
1238
                    permittedSubclasses,
1239
                    anonymousClass,
1240
                    localClass,
1241
                    record,
1242
                    nestHost,
1243
                    nestMembers);
1244
        }
1245

1246
        /**
1247
         * {@inheritDoc}
1248
         */
1249
        public WithFlexibleName withName(String name) {
1250
            return new Default(name,
1✔
1251
                    modifiers,
1252
                    moduleDescription,
1253
                    typeVariables,
1254
                    superClass,
1255
                    interfaceTypes,
1256
                    fieldTokens,
1257
                    auxiliaryFields,
1258
                    methodTokens,
1259
                    recordComponentTokens,
1260
                    annotationDescriptions,
1261
                    typeInitializer,
1262
                    loadedTypeInitializer,
1263
                    declaringType,
1264
                    enclosingMethod,
1265
                    enclosingType,
1266
                    declaredTypes,
1267
                    permittedSubclasses,
1268
                    anonymousClass,
1269
                    localClass,
1270
                    record,
1271
                    nestHost,
1272
                    nestMembers);
1273
        }
1274

1275
        /**
1276
         * {@inheritDoc}
1277
         */
1278
        public WithFlexibleName withTypeVariables(ElementMatcher<? super Generic> matcher, Transformer<TypeVariableToken> transformer) {
1279
            List<TypeVariableToken> typeVariables = new ArrayList<TypeVariableToken>(this.typeVariables.size());
1✔
1280
            int index = 0;
1✔
1281
            for (TypeVariableToken typeVariableToken : this.typeVariables) {
1✔
1282
                typeVariables.add(matcher.matches(getTypeVariables().get(index++))
1✔
1283
                        ? transformer.transform(this, typeVariableToken)
1✔
1284
                        : typeVariableToken);
1285
            }
1✔
1286
            return new Default(name,
1✔
1287
                    modifiers,
1288
                    moduleDescription,
1289
                    typeVariables,
1290
                    superClass,
1291
                    interfaceTypes,
1292
                    fieldTokens,
1293
                    auxiliaryFields,
1294
                    methodTokens,
1295
                    recordComponentTokens,
1296
                    annotationDescriptions,
1297
                    typeInitializer,
1298
                    loadedTypeInitializer,
1299
                    declaringType,
1300
                    enclosingMethod,
1301
                    enclosingType,
1302
                    declaredTypes,
1303
                    permittedSubclasses,
1304
                    anonymousClass,
1305
                    localClass,
1306
                    record,
1307
                    nestHost,
1308
                    nestMembers);
1309
        }
1310

1311
        /**
1312
         * {@inheritDoc}
1313
         */
1314
        public WithFlexibleName withLocalClass(boolean localClass) {
1315
            return new Default(name,
1✔
1316
                    modifiers,
1317
                    moduleDescription,
1318
                    typeVariables,
1319
                    superClass,
1320
                    interfaceTypes,
1321
                    fieldTokens,
1322
                    auxiliaryFields,
1323
                    methodTokens,
1324
                    recordComponentTokens,
1325
                    annotationDescriptions,
1326
                    typeInitializer,
1327
                    loadedTypeInitializer,
1328
                    declaringType,
1329
                    enclosingMethod,
1330
                    enclosingType,
1331
                    declaredTypes,
1332
                    permittedSubclasses,
1333
                    false,
1334
                    localClass,
1335
                    record,
1336
                    nestHost,
1337
                    nestMembers);
1338
        }
1339

1340
        /**
1341
         * {@inheritDoc}
1342
         */
1343
        public WithFlexibleName withAnonymousClass(boolean anonymousClass) {
1344
            return new Default(name,
1✔
1345
                    modifiers,
1346
                    moduleDescription,
1347
                    typeVariables,
1348
                    superClass,
1349
                    interfaceTypes,
1350
                    fieldTokens,
1351
                    auxiliaryFields,
1352
                    methodTokens,
1353
                    recordComponentTokens,
1354
                    annotationDescriptions,
1355
                    typeInitializer,
1356
                    loadedTypeInitializer,
1357
                    declaringType,
1358
                    enclosingMethod,
1359
                    enclosingType,
1360
                    declaredTypes,
1361
                    permittedSubclasses,
1362
                    anonymousClass,
1363
                    false,
1364
                    record,
1365
                    nestHost,
1366
                    nestMembers);
1367
        }
1368

1369
        /**
1370
         * {@inheritDoc}
1371
         */
1372
        public WithFlexibleName withRecord(boolean record) {
1373
            return new Default(name,
1✔
1374
                    modifiers,
1375
                    moduleDescription,
1376
                    typeVariables,
1377
                    superClass,
1378
                    interfaceTypes,
1379
                    fieldTokens,
1380
                    auxiliaryFields,
1381
                    methodTokens,
1382
                    record
1383
                            ? recordComponentTokens
1384
                            : Collections.<RecordComponentDescription.Token>emptyList(),
1✔
1385
                    annotationDescriptions,
1386
                    typeInitializer,
1387
                    loadedTypeInitializer,
1388
                    declaringType,
1389
                    enclosingMethod,
1390
                    enclosingType,
1391
                    declaredTypes,
1392
                    permittedSubclasses,
1393
                    anonymousClass,
1394
                    localClass,
1395
                    record,
1396
                    nestHost,
1397
                    nestMembers);
1398
        }
1399

1400
        /**
1401
         * {@inheritDoc}
1402
         */
1403
        public WithFlexibleName withInitializer(LoadedTypeInitializer loadedTypeInitializer) {
1404
            return new Default(name,
1✔
1405
                    modifiers,
1406
                    moduleDescription,
1407
                    typeVariables,
1408
                    superClass,
1409
                    interfaceTypes,
1410
                    fieldTokens,
1411
                    auxiliaryFields,
1412
                    methodTokens,
1413
                    recordComponentTokens,
1414
                    annotationDescriptions,
1415
                    typeInitializer,
1416
                    new LoadedTypeInitializer.Compound(this.loadedTypeInitializer, loadedTypeInitializer),
1417
                    declaringType,
1418
                    enclosingMethod,
1419
                    enclosingType,
1420
                    declaredTypes,
1421
                    permittedSubclasses,
1422
                    anonymousClass,
1423
                    localClass,
1424
                    record,
1425
                    nestHost,
1426
                    nestMembers);
1427
        }
1428

1429
        /**
1430
         * {@inheritDoc}
1431
         */
1432
        public WithFlexibleName withInitializer(ByteCodeAppender byteCodeAppender) {
1433
            return new Default(name,
1✔
1434
                    modifiers,
1435
                    moduleDescription,
1436
                    typeVariables,
1437
                    superClass,
1438
                    interfaceTypes,
1439
                    fieldTokens,
1440
                    auxiliaryFields,
1441
                    methodTokens,
1442
                    recordComponentTokens,
1443
                    annotationDescriptions,
1444
                    typeInitializer.expandWith(byteCodeAppender),
1✔
1445
                    loadedTypeInitializer,
1446
                    declaringType,
1447
                    enclosingMethod,
1448
                    enclosingType,
1449
                    declaredTypes,
1450
                    permittedSubclasses,
1451
                    anonymousClass,
1452
                    localClass,
1453
                    record,
1454
                    nestHost,
1455
                    nestMembers);
1456
        }
1457

1458
        /**
1459
         * {@inheritDoc}
1460
         */
1461
        public LoadedTypeInitializer getLoadedTypeInitializer() {
1462
            return loadedTypeInitializer;
1✔
1463
        }
1464

1465
        /**
1466
         * {@inheritDoc}
1467
         */
1468
        public TypeInitializer getTypeInitializer() {
1469
            return typeInitializer;
1✔
1470
        }
1471

1472
        /**
1473
         * {@inheritDoc}
1474
         */
1475
        @MaybeNull
1476
        public MethodDescription.InDefinedShape getEnclosingMethod() {
1477
            return enclosingMethod;
1✔
1478
        }
1479

1480
        /**
1481
         * {@inheritDoc}
1482
         */
1483
        @MaybeNull
1484
        public TypeDescription getEnclosingType() {
1485
            return enclosingType;
1✔
1486
        }
1487

1488
        /**
1489
         * {@inheritDoc}
1490
         */
1491
        public TypeList getDeclaredTypes() {
1492
            return new TypeList.Explicit(declaredTypes);
1✔
1493
        }
1494

1495
        /**
1496
         * {@inheritDoc}
1497
         */
1498
        public boolean isAnonymousType() {
1499
            return anonymousClass;
1✔
1500
        }
1501

1502
        /**
1503
         * {@inheritDoc}
1504
         */
1505
        public boolean isLocalType() {
1506
            return localClass;
1✔
1507
        }
1508

1509
        /**
1510
         * {@inheritDoc}
1511
         */
1512
        @MaybeNull
1513
        public PackageDescription getPackage() {
1514
            int packageIndex = name.lastIndexOf('.');
1✔
1515
            return packageIndex == -1
1✔
1516
                    ? PackageDescription.DEFAULT
1517
                    : new PackageDescription.Simple(name.substring(0, packageIndex));
1✔
1518
        }
1519

1520
        /**
1521
         * {@inheritDoc}
1522
         */
1523
        @MaybeNull
1524
        public ModuleDescription toModuleDescription() {
1525
            return moduleDescription;
1✔
1526
        }
1527

1528
        /**
1529
         * {@inheritDoc}
1530
         */
1531
        public AnnotationList getDeclaredAnnotations() {
1532
            return new AnnotationList.Explicit(annotationDescriptions);
1✔
1533
        }
1534

1535
        /**
1536
         * {@inheritDoc}
1537
         */
1538
        @MaybeNull
1539
        public TypeDescription getDeclaringType() {
1540
            return declaringType;
1✔
1541
        }
1542

1543
        /**
1544
         * {@inheritDoc}
1545
         */
1546
        @MaybeNull
1547
        public Generic getSuperClass() {
1548
            return superClass == null
1✔
1549
                    ? Generic.UNDEFINED
1550
                    : new Generic.LazyProjection.WithResolvedErasure(superClass, Generic.Visitor.Substitutor.ForAttachment.of(this));
1✔
1551
        }
1552

1553
        /**
1554
         * {@inheritDoc}
1555
         */
1556
        public TypeList.Generic getInterfaces() {
1557
            return new TypeList.Generic.ForDetachedTypes.WithResolvedErasure(interfaceTypes, TypeDescription.Generic.Visitor.Substitutor.ForAttachment.of(this));
1✔
1558
        }
1559

1560
        /**
1561
         * {@inheritDoc}
1562
         */
1563
        public FieldList<FieldDescription.InDefinedShape> getDeclaredFields() {
1564
            return new FieldList.ForTokens(this, fieldTokens);
1✔
1565
        }
1566

1567
        /**
1568
         * {@inheritDoc}
1569
         */
1570
        public MethodList<MethodDescription.InDefinedShape> getDeclaredMethods() {
1571
            return new MethodList.ForTokens(this, methodTokens);
1✔
1572
        }
1573

1574
        /**
1575
         * {@inheritDoc}
1576
         */
1577
        public TypeList.Generic getTypeVariables() {
1578
            return TypeList.Generic.ForDetachedTypes.attachVariables(this, typeVariables);
1✔
1579
        }
1580

1581
        /**
1582
         * {@inheritDoc}
1583
         */
1584
        public int getModifiers() {
1585
            return modifiers;
1✔
1586
        }
1587

1588
        /**
1589
         * {@inheritDoc}
1590
         */
1591
        public String getName() {
1592
            return name;
1✔
1593
        }
1594

1595
        /**
1596
         * {@inheritDoc}
1597
         */
1598
        public TypeDescription getNestHost() {
1599
            return nestHost.represents(TargetType.class)
1✔
1600
                    ? this
1601
                    : nestHost;
1602
        }
1603

1604
        /**
1605
         * {@inheritDoc}
1606
         */
1607
        public TypeList getNestMembers() {
1608
            return nestHost.represents(TargetType.class)
1✔
1609
                    ? new TypeList.Explicit(CompoundList.of(this, nestMembers))
1✔
1610
                    : nestHost.getNestMembers();
×
1611
        }
1612

1613
        /**
1614
         * {@inheritDoc}
1615
         */
1616
        public RecordComponentList<RecordComponentDescription.InDefinedShape> getRecordComponents() {
1617
            return new RecordComponentList.ForTokens(this, recordComponentTokens);
1✔
1618
        }
1619

1620
        /**
1621
         * {@inheritDoc}
1622
         */
1623
        @SuppressFBWarnings(value = "NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE", justification = "Assuming super class for given instance.")
1624
        public boolean isRecord() {
1625
            return record
1✔
1626
                    && superClass != null
1627
                    && getSuperClass().asErasure().equals(JavaType.RECORD.getTypeStub());
1✔
1628
        }
1629

1630
        @Override
1631
        public boolean isSealed() {
1632
            return permittedSubclasses != null;
1✔
1633
        }
1634

1635
        /**
1636
         * {@inheritDoc}
1637
         */
1638
        public TypeList getPermittedSubtypes() {
1639
            return permittedSubclasses == null
1✔
1640
                    ? new TypeList.Empty()
1641
                    : new TypeList.Explicit(permittedSubclasses);
1642
        }
1643

1644
        /**
1645
         * {@inheritDoc}
1646
         */
1647
        public TypeDescription validated() {
1648
            if (!isValidIdentifier(getName().split("\\."))) {
1✔
1649
                throw new IllegalStateException("Illegal type name: " + getName() + " for " + this);
1✔
1650
            } else if ((getModifiers() & ~ModifierContributor.ForType.MASK) != EMPTY_MASK) {
1✔
1651
                throw new IllegalStateException("Illegal modifiers " + getModifiers() + " for " + this);
1✔
1652
            } else if (isPackageType() && getModifiers() != PackageDescription.PACKAGE_MODIFIERS) {
1✔
1653
                throw new IllegalStateException("Illegal modifiers " + getModifiers() + " for package " + this);
1✔
1654
            } else if (isModuleType() && getModifiers() != ModifierContributor.EMPTY_MASK) {
1✔
1655
                throw new IllegalStateException("Illegal modifiers " + getModifiers() + " for module " + this);
×
1656
            }
1657
            TypeDescription.Generic superClass = getSuperClass();
1✔
1658
            if (superClass != null) {
1✔
1659
                if (!superClass.accept(Generic.Visitor.Validator.SUPER_CLASS)) {
1✔
1660
                    throw new IllegalStateException("Illegal super class " + superClass + " for " + this);
1✔
1661
                } else if (!superClass.accept(Generic.Visitor.Validator.ForTypeAnnotations.INSTANCE)) {
1✔
1662
                    throw new IllegalStateException("Illegal type annotations on super class " + superClass + " for " + this);
1✔
1663
                } else if (!superClass.asErasure().isVisibleTo(this)) {
1✔
1664
                    throw new IllegalStateException("Invisible super type " + superClass + " for " + this);
1✔
1665
                }
1666
            }
1667
            Set<TypeDescription> interfaceErasures = new HashSet<TypeDescription>();
1✔
1668
            for (TypeDescription.Generic interfaceType : getInterfaces()) {
1✔
1669
                if (!interfaceType.accept(Generic.Visitor.Validator.INTERFACE)) {
1✔
1670
                    throw new IllegalStateException("Illegal interface " + interfaceType + " for " + this);
1✔
1671
                } else if (!interfaceType.accept(Generic.Visitor.Validator.ForTypeAnnotations.INSTANCE)) {
1✔
1672
                    throw new IllegalStateException("Illegal type annotations on interface " + interfaceType + " for " + this);
1✔
1673
                } else if (!interfaceErasures.add(interfaceType.asErasure())) {
1✔
1674
                    throw new IllegalStateException("Already implemented interface " + interfaceType + " for " + this);
1✔
1675
                } else if (!interfaceType.asErasure().isVisibleTo(this)) {
1✔
1676
                    throw new IllegalStateException("Invisible interface type " + interfaceType + " for " + this);
1✔
1677
                }
1678
            }
1✔
1679
            TypeList.Generic typeVariables = getTypeVariables();
1✔
1680
            if (!typeVariables.isEmpty() && isAssignableTo(Throwable.class)) {
1✔
1681
                throw new IllegalStateException("Cannot define throwable " + this + " to be generic");
1✔
1682
            }
1683
            Set<String> typeVariableNames = new HashSet<String>();
1✔
1684
            for (TypeDescription.Generic typeVariable : typeVariables) {
1✔
1685
                String variableSymbol = typeVariable.getSymbol();
1✔
1686
                if (!typeVariableNames.add(variableSymbol)) {
1✔
1687
                    throw new IllegalStateException("Duplicate type variable symbol '" + typeVariable + "' for " + this);
1✔
1688
                } else if (!isValidIdentifier(variableSymbol)) {
1✔
1689
                    throw new IllegalStateException("Illegal type variable name '" + typeVariable + "' for " + this);
1✔
1690
                } else if (!Generic.Visitor.Validator.ForTypeAnnotations.ofFormalTypeVariable(typeVariable)) {
1✔
1691
                    throw new IllegalStateException("Illegal type annotation on '" + typeVariable + "' for " + this);
1✔
1692
                }
1693
                boolean interfaceBound = false;
1✔
1694
                Set<TypeDescription.Generic> bounds = new HashSet<Generic>();
1✔
1695
                for (TypeDescription.Generic bound : typeVariable.getUpperBounds()) {
1✔
1696
                    if (!bound.accept(Generic.Visitor.Validator.TYPE_VARIABLE)) {
1✔
1697
                        throw new IllegalStateException("Illegal type variable bound " + bound + " of " + typeVariable + " for " + this);
1✔
1698
                    } else if (!bound.accept(Generic.Visitor.Validator.ForTypeAnnotations.INSTANCE)) {
1✔
1699
                        throw new IllegalStateException("Illegal type annotations on type variable " + bound + " for " + this);
1✔
1700
                    } else if (!bounds.add(bound)) {
1✔
1701
                        throw new IllegalStateException("Duplicate bound " + bound + " of " + typeVariable + " for " + this);
1✔
1702
                    } else if (interfaceBound && (bound.getSort().isTypeVariable() || !bound.isInterface())) {
1✔
1703
                        throw new IllegalStateException("Illegal interface bound " + bound + " of " + typeVariable + " for " + this);
1✔
1704
                    }
1705
                    interfaceBound = true;
1✔
1706
                }
1✔
1707
                if (!interfaceBound) {
1✔
1708
                    throw new IllegalStateException("Type variable " + typeVariable + " for " + this + " does not define at least one bound");
1✔
1709
                }
1710
            }
1✔
1711
            TypeDescription enclosingType = getEnclosingType();
1✔
1712
            if (enclosingType != null && (enclosingType.isArray() || enclosingType.isPrimitive())) {
1✔
1713
                throw new IllegalStateException("Cannot define array type or primitive type " + enclosingType + " + as enclosing type for " + this);
1✔
1714
            }
1715
            MethodDescription.InDefinedShape enclosingMethod = getEnclosingMethod();
1✔
1716
            if (enclosingMethod != null && enclosingMethod.isTypeInitializer()) {
1✔
1717
                throw new IllegalStateException("Cannot enclose type declaration in class initializer " + enclosingMethod);
×
1718
            }
1719
            TypeDescription declaringType = getDeclaringType();
1✔
1720
            if (declaringType != null) {
1✔
1721
                if (declaringType.isPrimitive() || declaringType.isArray()) {
1✔
1722
                    throw new IllegalStateException("Cannot define array type or primitive type " + declaringType + " as declaring type for " + this);
1✔
1723
                }
1724
            } else if (enclosingType == null && enclosingMethod == null && (isLocalType() || isAnonymousType())) {
1✔
1725
                throw new IllegalStateException("Cannot define an anonymous or local class without a declaring type for " + this);
1✔
1726
            }
1727
            Set<TypeDescription> declaredTypes = new HashSet<TypeDescription>();
1✔
1728
            for (TypeDescription declaredType : getDeclaredTypes()) {
1✔
1729
                if (declaredType.isArray() || declaredType.isPrimitive()) {
1✔
1730
                    throw new IllegalStateException("Cannot define array type or primitive type " + declaredType + " + as declared type for " + this);
1✔
1731
                } else if (!declaredTypes.add(declaredType)) {
1✔
1732
                    throw new IllegalStateException("Duplicate definition of declared type " + declaredType);
1✔
1733
                }
1734
            }
1✔
1735
            TypeDescription nestHost = getNestHost();
1✔
1736
            if (nestHost.equals(this)) {
1✔
1737
                Set<TypeDescription> nestMembers = new HashSet<TypeDescription>();
1✔
1738
                for (TypeDescription nestMember : getNestMembers()) {
1✔
1739
                    if (nestMember.isArray() || nestMember.isPrimitive()) {
1✔
1740
                        throw new IllegalStateException("Cannot define array type or primitive type " + nestMember + " + as nest member of " + this);
1✔
1741
                    } else if (!nestMember.isSamePackage(this)) {
1✔
1742
                        throw new IllegalStateException("Cannot define nest member " + nestMember + " + within different package then " + this);
1✔
1743
                    } else if (!nestMembers.add(nestMember)) {
1✔
1744
                        throw new IllegalStateException("Duplicate definition of nest member " + nestMember);
1✔
1745
                    }
1746
                }
1✔
1747
            } else if (nestHost.isArray() || nestHost.isPrimitive()) {
1✔
1748
                throw new IllegalStateException("Cannot define array type or primitive type " + nestHost + " + as nest host for " + this);
1✔
1749
            } else if (!nestHost.isSamePackage(this)) {
1✔
1750
                throw new IllegalStateException("Cannot define nest host " + nestHost + " within different package then " + this);
1✔
1751
            }
1752
            for (TypeDescription permittedSubclass : getPermittedSubtypes()) {
1✔
1753
                if (!permittedSubclass.isAssignableTo(this) || permittedSubclass.equals(this)) {
1✔
1754
                    throw new IllegalStateException("Cannot assign permitted subclass " + permittedSubclass + " to " + this);
1✔
1755
                }
1756
            }
×
1757
            Set<TypeDescription> typeAnnotationTypes = new HashSet<TypeDescription>();
1✔
1758
            for (AnnotationDescription annotationDescription : getDeclaredAnnotations()) {
1✔
1759
                if (!annotationDescription.isSupportedOn(ElementType.TYPE)
1✔
1760
                        && !(isAnnotation() && annotationDescription.isSupportedOn(ElementType.ANNOTATION_TYPE))
1✔
1761
                        && !(isPackageType() && annotationDescription.isSupportedOn(ElementType.PACKAGE))
1✔
1762
                        && !(isModuleType() && annotationDescription.isSupportedOn("MODULE"))) {
1✔
1763
                    throw new IllegalStateException("Cannot add " + annotationDescription + " on " + this);
1✔
1764
                } else if (!typeAnnotationTypes.add(annotationDescription.getAnnotationType())) {
1✔
1765
                    throw new IllegalStateException("Duplicate annotation " + annotationDescription + " for " + this);
1✔
1766
                }
1767
            }
1✔
1768
            Set<FieldDescription.SignatureToken> fieldSignatureTokens = new HashSet<FieldDescription.SignatureToken>();
1✔
1769
            for (FieldDescription.InDefinedShape fieldDescription : getDeclaredFields()) {
1✔
1770
                String fieldName = fieldDescription.getName();
1✔
1771
                if (!fieldSignatureTokens.add(fieldDescription.asSignatureToken())) {
1✔
1772
                    throw new IllegalStateException("Duplicate field definition for " + fieldDescription);
1✔
1773
                } else if (!isValidUnqualifiedNameIdentifier(fieldName)) {
1✔
1774
                    throw new IllegalStateException("Illegal field name for " + fieldDescription);
1✔
1775
                } else if ((fieldDescription.getModifiers() & ~ModifierContributor.ForField.MASK) != EMPTY_MASK) {
1✔
1776
                    throw new IllegalStateException("Illegal field modifiers " + fieldDescription.getModifiers() + " for " + fieldDescription);
1✔
1777
                }
1778
                Generic fieldType = fieldDescription.getType();
1✔
1779
                if (!fieldType.accept(Generic.Visitor.Validator.FIELD)) {
1✔
1780
                    throw new IllegalStateException("Illegal field type " + fieldType + " for " + fieldDescription);
×
1781
                } else if (!fieldType.accept(Generic.Visitor.Validator.ForTypeAnnotations.INSTANCE)) {
1✔
1782
                    throw new IllegalStateException("Illegal type annotations on " + fieldType + " for " + this);
1✔
1783
                } else if (!fieldDescription.isSynthetic() && !fieldType.asErasure().isVisibleTo(this)) {
1✔
1784
                    throw new IllegalStateException("Invisible field type " + fieldDescription.getType() + " for " + fieldDescription);
1✔
1785
                }
1786
                Set<TypeDescription> fieldAnnotationTypes = new HashSet<TypeDescription>();
1✔
1787
                for (AnnotationDescription annotationDescription : fieldDescription.getDeclaredAnnotations()) {
1✔
1788
                    if (!annotationDescription.isSupportedOn(ElementType.FIELD)) {
1✔
1789
                        throw new IllegalStateException("Cannot add " + annotationDescription + " on " + fieldDescription);
1✔
1790
                    } else if (!fieldAnnotationTypes.add(annotationDescription.getAnnotationType())) {
1✔
1791
                        throw new IllegalStateException("Duplicate annotation " + annotationDescription + " for " + fieldDescription);
1✔
1792
                    }
1793
                }
1✔
1794
            }
1✔
1795
            Set<MethodDescription.SignatureToken> methodSignatureTokens = new HashSet<MethodDescription.SignatureToken>();
1✔
1796
            for (MethodDescription.InDefinedShape methodDescription : getDeclaredMethods()) {
1✔
1797
                if (!methodSignatureTokens.add(methodDescription.asSignatureToken())) {
1✔
1798
                    throw new IllegalStateException("Duplicate method signature for " + methodDescription);
1✔
1799
                } else if ((methodDescription.getModifiers() & ~ModifierContributor.ForMethod.MASK) != 0) {
1✔
1800
                    throw new IllegalStateException("Illegal modifiers " + methodDescription.getModifiers() + " for " + methodDescription);
1✔
1801
                } else if (methodDescription.isAbstract() && (methodDescription.getModifiers() & Opcodes.ACC_STRICT) != 0) {
1✔
1802
                    throw new IllegalStateException("Cannot declare strict computations for " + methodDescription);
×
1803
                } else if (isInterface() && !methodDescription.isPublic() && !methodDescription.isPrivate()) {
1✔
1804
                    throw new IllegalStateException("Methods declared by an interface must be public or private " + methodDescription);
1✔
1805
                }
1806
                Set<String> methodTypeVariableNames = new HashSet<String>();
1✔
1807
                for (TypeDescription.Generic typeVariable : methodDescription.getTypeVariables()) {
1✔
1808
                    String variableSymbol = typeVariable.getSymbol();
1✔
1809
                    if (!methodTypeVariableNames.add(variableSymbol)) {
1✔
1810
                        throw new IllegalStateException("Duplicate type variable symbol '" + typeVariable + "' for " + methodDescription);
1✔
1811
                    } else if (!isValidIdentifier(variableSymbol)) {
1✔
1812
                        throw new IllegalStateException("Illegal type variable name '" + typeVariable + "' for " + methodDescription);
1✔
1813
                    } else if (!Generic.Visitor.Validator.ForTypeAnnotations.ofFormalTypeVariable(typeVariable)) {
1✔
1814
                        throw new IllegalStateException("Illegal type annotation on '" + typeVariable + "' for " + methodDescription);
1✔
1815
                    }
1816
                    boolean interfaceBound = false;
1✔
1817
                    Set<TypeDescription.Generic> bounds = new HashSet<Generic>();
1✔
1818
                    for (TypeDescription.Generic bound : typeVariable.getUpperBounds()) {
1✔
1819
                        if (!bound.accept(Generic.Visitor.Validator.TYPE_VARIABLE)) {
1✔
1820
                            throw new IllegalStateException("Illegal type variable bound " + bound + " of " + typeVariable + " for " + methodDescription);
1✔
1821
                        } else if (!bound.accept(Generic.Visitor.Validator.ForTypeAnnotations.INSTANCE)) {
1✔
1822
                            throw new IllegalStateException("Illegal type annotations on bound " + bound + " of " + typeVariable + " for " + this);
1✔
1823
                        } else if (!bounds.add(bound)) {
1✔
1824
                            throw new IllegalStateException("Duplicate bound " + bound + " of " + typeVariable + " for " + methodDescription);
1✔
1825
                        } else if (interfaceBound && (bound.getSort().isTypeVariable() || !bound.isInterface())) {
1✔
1826
                            throw new IllegalStateException("Illegal interface bound " + bound + " of " + typeVariable + " for " + methodDescription);
1✔
1827
                        }
1828
                        interfaceBound = true;
1✔
1829
                    }
1✔
1830
                    if (!interfaceBound) {
1✔
1831
                        throw new IllegalStateException("Type variable " + typeVariable + " for " + methodDescription + " does not define at least one bound");
1✔
1832
                    }
1833
                }
1✔
1834
                Generic returnType = methodDescription.getReturnType();
1✔
1835
                if (methodDescription.isTypeInitializer()) {
1✔
1836
                    throw new IllegalStateException("Illegal explicit declaration of a type initializer by " + this);
1✔
1837
                } else if (methodDescription.isConstructor()) {
1✔
1838
                    if (!returnType.represents(void.class)) {
1✔
1839
                        throw new IllegalStateException("A constructor must return void " + methodDescription);
1✔
1840
                    } else if (!returnType.getDeclaredAnnotations().isEmpty()) {
1✔
1841
                        throw new IllegalStateException("The void non-type must not be annotated for " + methodDescription);
×
1842
                    }
1843
                } else if (!isValidMethodIdentifier(methodDescription.getInternalName())) {
1✔
1844
                    throw new IllegalStateException("Illegal method name " + returnType + " for " + methodDescription);
1✔
1845
                } else if (!returnType.accept(Generic.Visitor.Validator.METHOD_RETURN)) {
1✔
1846
                    throw new IllegalStateException("Illegal return type " + returnType + " for " + methodDescription);
×
1847
                } else if (!returnType.accept(Generic.Visitor.Validator.ForTypeAnnotations.INSTANCE)) {
1✔
1848
                    throw new IllegalStateException("Illegal type annotations on return type " + returnType + " for " + methodDescription);
1✔
1849
                } else if (!methodDescription.isSynthetic() && !methodDescription.getReturnType().asErasure().isVisibleTo(this)) {
1✔
1850
                    throw new IllegalStateException("Invisible return type " + methodDescription.getReturnType() + " for " + methodDescription);
1✔
1851
                }
1852
                Set<String> parameterNames = new HashSet<String>();
1✔
1853
                for (ParameterDescription.InDefinedShape parameterDescription : methodDescription.getParameters()) {
1✔
1854
                    Generic parameterType = parameterDescription.getType();
1✔
1855
                    if (!parameterType.accept(Generic.Visitor.Validator.METHOD_PARAMETER)) {
1✔
1856
                        throw new IllegalStateException("Illegal parameter type of " + parameterDescription + " for " + methodDescription);
1✔
1857
                    } else if (!parameterType.accept(Generic.Visitor.Validator.ForTypeAnnotations.INSTANCE)) {
1✔
1858
                        throw new IllegalStateException("Illegal type annotations on parameter " + parameterDescription + " for " + methodDescription);
×
1859
                    } else if (!methodDescription.isSynthetic() && !parameterType.asErasure().isVisibleTo(this)) {
1✔
1860
                        throw new IllegalStateException("Invisible parameter type of " + parameterDescription + " for " + methodDescription);
1✔
1861
                    }
1862
                    if (parameterDescription.isNamed()) {
1✔
1863
                        String parameterName = parameterDescription.getName();
1✔
1864
                        if (!parameterNames.add(parameterName)) {
1✔
1865
                            throw new IllegalStateException("Duplicate parameter name of " + parameterDescription + " for " + methodDescription);
1✔
1866
                        } else if (!isValidUnqualifiedNameIdentifier(parameterName)) {
1✔
1867
                            throw new IllegalStateException("Illegal parameter name of " + parameterDescription + " for " + methodDescription);
1✔
1868
                        }
1869
                    }
1870
                    if (parameterDescription.hasModifiers() && (parameterDescription.getModifiers() & ~ModifierContributor.ForParameter.MASK) != EMPTY_MASK) {
1✔
1871
                        throw new IllegalStateException("Illegal modifiers of " + parameterDescription + " for " + methodDescription);
1✔
1872
                    }
1873
                    Set<TypeDescription> parameterAnnotationTypes = new HashSet<TypeDescription>();
1✔
1874
                    for (AnnotationDescription annotationDescription : parameterDescription.getDeclaredAnnotations()) {
1✔
1875
                        if (!annotationDescription.isSupportedOn(ElementType.PARAMETER)) {
1✔
1876
                            throw new IllegalStateException("Cannot add " + annotationDescription + " on " + parameterDescription);
1✔
1877
                        } else if (!parameterAnnotationTypes.add(annotationDescription.getAnnotationType())) {
1✔
1878
                            throw new IllegalStateException("Duplicate annotation " + annotationDescription + " of " + parameterDescription + " for " + methodDescription);
1✔
1879
                        }
1880
                    }
1✔
1881
                }
1✔
1882
                for (TypeDescription.Generic exceptionType : methodDescription.getExceptionTypes()) {
1✔
1883
                    if (!exceptionType.accept(Generic.Visitor.Validator.EXCEPTION)) {
1✔
1884
                        throw new IllegalStateException("Illegal exception type " + exceptionType + " for " + methodDescription);
1✔
1885
                    } else if (!exceptionType.accept(Generic.Visitor.Validator.ForTypeAnnotations.INSTANCE)) {
1✔
1886
                        throw new IllegalStateException("Illegal type annotations on " + exceptionType + " for " + methodDescription);
1✔
1887
                    } else if (!methodDescription.isSynthetic() && !exceptionType.asErasure().isVisibleTo(this)) {
1✔
1888
                        throw new IllegalStateException("Invisible exception type " + exceptionType + " for " + methodDescription);
1✔
1889
                    }
1890
                }
1✔
1891
                Set<TypeDescription> methodAnnotationTypes = new HashSet<TypeDescription>();
1✔
1892
                for (AnnotationDescription annotationDescription : methodDescription.getDeclaredAnnotations()) {
1✔
1893
                    if (!annotationDescription.isSupportedOn(methodDescription.isMethod() ? ElementType.METHOD : ElementType.CONSTRUCTOR)) {
1✔
1894
                        throw new IllegalStateException("Cannot add " + annotationDescription + " on " + methodDescription);
1✔
1895
                    } else if (!methodAnnotationTypes.add(annotationDescription.getAnnotationType())) {
1✔
1896
                        throw new IllegalStateException("Duplicate annotation " + annotationDescription + " for " + methodDescription);
1✔
1897
                    }
1898
                }
1✔
1899
                AnnotationValue<?, ?> defaultValue = methodDescription.getDefaultValue();
1✔
1900
                if (defaultValue != null && !methodDescription.isDefaultValue(defaultValue)) {
1✔
1901
                    throw new IllegalStateException("Illegal default value " + defaultValue + "for " + methodDescription);
1✔
1902
                }
1903
                Generic receiverType = methodDescription.getReceiverType();
1✔
1904
                if (receiverType != null && !receiverType.accept(Generic.Visitor.Validator.RECEIVER)) {
1✔
1905
                    throw new IllegalStateException("Illegal receiver type " + receiverType + " for " + methodDescription);
×
1906
                } else if (methodDescription.isStatic()) {
1✔
1907
                    if (receiverType != null) {
1✔
1908
                        throw new IllegalStateException("Static method " + methodDescription + " defines a non-null receiver " + receiverType);
1✔
1909
                    }
1910
                } else if (methodDescription.isConstructor()) {
1✔
1911
                    if (receiverType == null || !receiverType.asErasure().equals(enclosingType == null ? this : enclosingType)) {
1✔
1912
                        throw new IllegalStateException("Constructor " + methodDescription + " defines an illegal receiver " + receiverType);
×
1913
                    }
1914
                } else if (/* methodDescription.isMethod() */ receiverType == null || !equals(receiverType.asErasure())) {
1✔
1915
                    throw new IllegalStateException("Method " + methodDescription + " defines an illegal receiver " + receiverType);
1✔
1916
                }
1917
            }
1✔
1918
            return this;
1✔
1919
        }
1920

1921
        /**
1922
         * Checks if an array of identifiers is a valid compound Java identifier.
1923
         *
1924
         * @param identifier an array of potentially invalid Java identifiers.
1925
         * @return {@code true} if all identifiers are valid and the array is not empty.
1926
         */
1927
        private static boolean isValidIdentifier(String[] identifier) {
1928
            if (identifier.length == 0) {
1✔
1929
                return false;
×
1930
            }
1931
            for (String part : identifier) {
1✔
1932
                if (!isValidIdentifier(part)) {
1✔
1933
                    return false;
1✔
1934
                }
1935
            }
1936
            return true;
1✔
1937
        }
1938

1939
        /**
1940
         * Checks if a Java identifier is valid.
1941
         *
1942
         * @param identifier The identifier to check for validity.
1943
         * @return {@code true} if the given identifier is valid.
1944
         */
1945
        private static boolean isValidIdentifier(String identifier) {
1946
            if (KEYWORDS.contains(identifier)
1✔
1947
                    || identifier.length() == 0
1✔
1948
                    || !(Character.isJavaIdentifierStart(identifier.charAt(0))
1✔
1949
                    || Character.isUnicodeIdentifierStart(identifier.charAt(0)))) {
×
1950
                return false;
1✔
1951
            } else if (identifier.equals(PackageDescription.PACKAGE_CLASS_NAME) || identifier.equals(ModuleDescription.MODULE_CLASS_NAME)) {
1✔
1952
                return true;
1✔
1953
            }
1954
            for (int index = 1; index < identifier.length(); index++) {
1✔
1955
                if (!(Character.isJavaIdentifierPart(identifier.charAt(index)) || Character.isUnicodeIdentifierPart(identifier.charAt(index)))) {
1✔
1956
                    return false;
1✔
1957
                }
1958
            }
1959
            return true;
1✔
1960
        }
1961

1962
        /**
1963
         * Checks if an identifier is a valid "Unqualified Name" for a field, a local variable or a formal parameter,
1964
         * per JVMS 4.2.2.
1965
         *
1966
         * @param identifier The identifier to check for validity.
1967
         * @return {@code true} if the given identifier is valid.
1968
         */
1969
        private static boolean isValidUnqualifiedNameIdentifier(String identifier) {
1970
            if (identifier.length() == 0) {
1✔
1971
                return false;
×
1972
            }
1973
            for (int index = 0; index < identifier.length(); index++) {
1✔
1974
                switch (identifier.charAt(index)) {
1✔
1975
                    case '.':
1976
                    case ';':
1977
                    case '[':
1978
                    case '/':
1979
                        return false;
1✔
1980
                }
1981
            }
1982
            return true;
1✔
1983
        }
1984

1985
        /**
1986
         * Checks if an identifier is a valid "Unqualified Name" for a method, per JVMS 4.2.2.
1987
         *
1988
         * @param identifier The identifier to check for validity.
1989
         * @return {@code true} if the given identifier is valid.
1990
         */
1991
        private static boolean isValidMethodIdentifier(String identifier) {
1992
            if (identifier.length() == 0) {
1✔
1993
                return false;
×
1994
            }
1995
            if (identifier.equals(MethodDescription.TYPE_INITIALIZER_INTERNAL_NAME)
1✔
1996
                    || identifier.equals(MethodDescription.CONSTRUCTOR_INTERNAL_NAME)) {
1✔
1997
                return true;
×
1998
            }
1999
            for (int index = 0; index < identifier.length(); index++) {
1✔
2000
                switch (identifier.charAt(index)) {
1✔
2001
                    case '.':
2002
                    case ';':
2003
                    case '[':
2004
                    case '/':
2005
                    case '<':
2006
                    case '>':
2007
                        return false;
1✔
2008
                }
2009
            }
2010
            return true;
1✔
2011
        }
2012
    }
2013

2014
    /**
2015
     * A frozen representation of an instrumented type of which the structure must not be modified.
2016
     */
2017
    class Frozen extends AbstractBase.OfSimpleType implements InstrumentedType.WithFlexibleName {
2018

2019
        /**
2020
         * The represented type description.
2021
         */
2022
        private final TypeDescription typeDescription;
2023

2024
        /**
2025
         * The type's loaded type initializer.
2026
         */
2027
        private final LoadedTypeInitializer loadedTypeInitializer;
2028

2029
        /**
2030
         * Creates a new frozen representation of an instrumented type.
2031
         *
2032
         * @param typeDescription       The represented type description.
2033
         * @param loadedTypeInitializer The type's loaded type initializer.
2034
         */
2035
        protected Frozen(TypeDescription typeDescription, LoadedTypeInitializer loadedTypeInitializer) {
1✔
2036
            this.typeDescription = typeDescription;
1✔
2037
            this.loadedTypeInitializer = loadedTypeInitializer;
1✔
2038
        }
1✔
2039

2040
        /**
2041
         * {@inheritDoc}
2042
         */
2043
        public AnnotationList getDeclaredAnnotations() {
2044
            return typeDescription.getDeclaredAnnotations();
1✔
2045
        }
2046

2047
        /**
2048
         * {@inheritDoc}
2049
         */
2050
        public int getModifiers() {
2051
            return typeDescription.getModifiers();
1✔
2052
        }
2053

2054
        /**
2055
         * {@inheritDoc}
2056
         */
2057
        public TypeList.Generic getTypeVariables() {
2058
            return typeDescription.getTypeVariables();
1✔
2059
        }
2060

2061
        /**
2062
         * {@inheritDoc}
2063
         */
2064
        public String getName() {
2065
            return typeDescription.getName();
1✔
2066
        }
2067

2068
        /**
2069
         * {@inheritDoc}
2070
         */
2071
        @MaybeNull
2072
        public Generic getSuperClass() {
2073
            return typeDescription.getSuperClass();
1✔
2074
        }
2075

2076
        /**
2077
         * {@inheritDoc}
2078
         */
2079
        public TypeList.Generic getInterfaces() {
2080
            return typeDescription.getInterfaces();
1✔
2081
        }
2082

2083
        /**
2084
         * {@inheritDoc}
2085
         */
2086
        public FieldList<FieldDescription.InDefinedShape> getDeclaredFields() {
2087
            return typeDescription.getDeclaredFields();
1✔
2088
        }
2089

2090
        /**
2091
         * {@inheritDoc}
2092
         */
2093
        public MethodList<MethodDescription.InDefinedShape> getDeclaredMethods() {
2094
            return typeDescription.getDeclaredMethods();
1✔
2095
        }
2096

2097
        /**
2098
         * {@inheritDoc}
2099
         */
2100
        public boolean isAnonymousType() {
2101
            return typeDescription.isAnonymousType();
1✔
2102
        }
2103

2104
        /**
2105
         * {@inheritDoc}
2106
         */
2107
        public boolean isLocalType() {
2108
            return typeDescription.isLocalType();
1✔
2109
        }
2110

2111
        /**
2112
         * {@inheritDoc}
2113
         */
2114
        @MaybeNull
2115
        public PackageDescription getPackage() {
2116
            return typeDescription.getPackage();
1✔
2117
        }
2118

2119
        /**
2120
         * {@inheritDoc}
2121
         */
2122
        @MaybeNull
2123
        public ModuleDescription toModuleDescription() {
2124
            return typeDescription.toModuleDescription();
1✔
2125
        }
2126

2127
        /**
2128
         * {@inheritDoc}
2129
         */
2130
        @MaybeNull
2131
        public TypeDescription getEnclosingType() {
2132
            return typeDescription.getEnclosingType();
1✔
2133
        }
2134

2135
        /**
2136
         * {@inheritDoc}
2137
         */
2138
        @MaybeNull
2139
        public TypeDescription getDeclaringType() {
2140
            return typeDescription.getDeclaringType();
1✔
2141
        }
2142

2143
        /**
2144
         * {@inheritDoc}
2145
         */
2146
        public TypeList getDeclaredTypes() {
2147
            return typeDescription.getDeclaredTypes();
1✔
2148
        }
2149

2150
        /**
2151
         * {@inheritDoc}
2152
         */
2153
        @MaybeNull
2154
        public MethodDescription.InDefinedShape getEnclosingMethod() {
2155
            return typeDescription.getEnclosingMethod();
1✔
2156
        }
2157

2158
        /**
2159
         * {@inheritDoc}
2160
         */
2161
        @MaybeNull
2162
        public String getGenericSignature() {
2163
            // Embrace use of native generic signature by direct delegation.
2164
            return typeDescription.getGenericSignature();
1✔
2165
        }
2166

2167
        /**
2168
         * {@inheritDoc}
2169
         */
2170
        public int getActualModifiers(boolean superFlag) {
2171
            // Embrace use of native actual modifiers by direct delegation.
2172
            return typeDescription.getActualModifiers(superFlag);
1✔
2173
        }
2174

2175
        /**
2176
         * {@inheritDoc}
2177
         */
2178
        public TypeDescription getNestHost() {
2179
            return typeDescription.getNestHost();
1✔
2180
        }
2181

2182
        /**
2183
         * {@inheritDoc}
2184
         */
2185
        public TypeList getNestMembers() {
2186
            return typeDescription.getNestMembers();
1✔
2187
        }
2188

2189
        /**
2190
         * {@inheritDoc}
2191
         */
2192
        public RecordComponentList<RecordComponentDescription.InDefinedShape> getRecordComponents() {
2193
            return typeDescription.getRecordComponents();
1✔
2194
        }
2195

2196
        /**
2197
         * {@inheritDoc}
2198
         */
2199
        public boolean isRecord() {
2200
            return typeDescription.isRecord();
×
2201
        }
2202

2203
        @Override
2204
        public boolean isSealed() {
2205
            return typeDescription.isSealed();
1✔
2206
        }
2207

2208
        /**
2209
         * {@inheritDoc}
2210
         */
2211
        public TypeList getPermittedSubtypes() {
2212
            return typeDescription.getPermittedSubtypes();
1✔
2213
        }
2214

2215
        /**
2216
         * {@inheritDoc}
2217
         */
2218
        public WithFlexibleName withModuleDescription(@MaybeNull ModuleDescription moduleDescription) {
2219
            throw new IllegalStateException("Cannot define module meta data for frozen type: " + typeDescription);
1✔
2220
        }
2221

2222
        /**
2223
         * {@inheritDoc}
2224
         */
2225
        public WithFlexibleName withField(FieldDescription.Token token) {
2226
            throw new IllegalStateException("Cannot define field for frozen type: " + typeDescription);
1✔
2227
        }
2228

2229
        /**
2230
         * {@inheritDoc}
2231
         */
2232
        public WithFlexibleName withAuxiliaryField(FieldDescription.Token token, Object value) {
2233
            throw new IllegalStateException("Cannot define auxiliary field for frozen type: " + typeDescription);
1✔
2234
        }
2235

2236
        /**
2237
         * {@inheritDoc}
2238
         */
2239
        public WithFlexibleName withMethod(MethodDescription.Token token) {
2240
            throw new IllegalStateException("Cannot define method for frozen type: " + typeDescription);
1✔
2241
        }
2242

2243
        /**
2244
         * {@inheritDoc}
2245
         */
2246
        public WithFlexibleName withRecordComponent(RecordComponentDescription.Token token) {
2247
            throw new IllegalStateException("Cannot define record component for frozen type: " + typeDescription);
1✔
2248
        }
2249

2250
        /**
2251
         * {@inheritDoc}
2252
         */
2253
        public WithFlexibleName withModifiers(int modifiers) {
2254
            throw new IllegalStateException("Cannot change modifiers for frozen type: " + typeDescription);
×
2255
        }
2256

2257
        /**
2258
         * {@inheritDoc}
2259
         */
2260
        public WithFlexibleName withInterfaces(TypeList.Generic interfaceTypes) {
2261
            throw new IllegalStateException("Cannot add interfaces for frozen type: " + typeDescription);
×
2262
        }
2263

2264
        /**
2265
         * {@inheritDoc}
2266
         */
2267
        public WithFlexibleName withTypeVariable(TypeVariableToken typeVariable) {
2268
            throw new IllegalStateException("Cannot define type variable for frozen type: " + typeDescription);
1✔
2269
        }
2270

2271
        /**
2272
         * {@inheritDoc}
2273
         */
2274
        public WithFlexibleName withAnnotations(List<? extends AnnotationDescription> annotationDescriptions) {
2275
            throw new IllegalStateException("Cannot add annotation to frozen type: " + typeDescription);
1✔
2276
        }
2277

2278
        /**
2279
         * {@inheritDoc}
2280
         */
2281
        public WithFlexibleName withNestHost(TypeDescription nestHost) {
2282
            throw new IllegalStateException("Cannot set nest host of frozen type: " + typeDescription);
1✔
2283
        }
2284

2285
        /**
2286
         * {@inheritDoc}
2287
         */
2288
        public WithFlexibleName withNestMembers(TypeList nestMembers) {
2289
            throw new IllegalStateException("Cannot add nest members to frozen type: " + typeDescription);
1✔
2290
        }
2291

2292
        /**
2293
         * {@inheritDoc}
2294
         */
2295
        public WithFlexibleName withEnclosingType(@MaybeNull TypeDescription enclosingType) {
2296
            throw new IllegalStateException("Cannot set enclosing type of frozen type: " + typeDescription);
1✔
2297
        }
2298

2299
        /**
2300
         * {@inheritDoc}
2301
         */
2302
        public WithFlexibleName withEnclosingMethod(MethodDescription.InDefinedShape enclosingMethod) {
2303
            throw new IllegalStateException("Cannot set enclosing method of frozen type: " + typeDescription);
1✔
2304
        }
2305

2306
        /**
2307
         * {@inheritDoc}
2308
         */
2309
        public WithFlexibleName withDeclaringType(@MaybeNull TypeDescription declaringType) {
2310
            throw new IllegalStateException("Cannot add declaring type to frozen type: " + typeDescription);
1✔
2311
        }
2312

2313
        /**
2314
         * {@inheritDoc}
2315
         */
2316
        public WithFlexibleName withDeclaredTypes(TypeList declaredTypes) {
2317
            throw new IllegalStateException("Cannot add declared types to frozen type: " + typeDescription);
1✔
2318
        }
2319

2320
        /**
2321
         * {@inheritDoc}
2322
         */
2323
        public WithFlexibleName withPermittedSubclasses(@MaybeNull TypeList permittedSubclasses) {
2324
            throw new IllegalStateException("Cannot add permitted subclasses to frozen type: " + typeDescription);
1✔
2325
        }
2326

2327
        /**
2328
         * {@inheritDoc}
2329
         */
2330
        public WithFlexibleName withLocalClass(boolean localClass) {
2331
            throw new IllegalStateException("Cannot define local class state for frozen type: " + typeDescription);
1✔
2332
        }
2333

2334
        /**
2335
         * {@inheritDoc}
2336
         */
2337
        public WithFlexibleName withAnonymousClass(boolean anonymousClass) {
2338
            throw new IllegalStateException("Cannot define anonymous class state for frozen type: " + typeDescription);
1✔
2339
        }
2340

2341
        /**
2342
         * {@inheritDoc}
2343
         */
2344
        public WithFlexibleName withRecord(boolean record) {
2345
            throw new IllegalStateException("Cannot define record state for frozen type: " + typeDescription);
1✔
2346
        }
2347

2348
        /**
2349
         * {@inheritDoc}
2350
         */
2351
        public WithFlexibleName withInitializer(LoadedTypeInitializer loadedTypeInitializer) {
2352
            return new Frozen(typeDescription, new LoadedTypeInitializer.Compound(this.loadedTypeInitializer, loadedTypeInitializer));
×
2353
        }
2354

2355
        /**
2356
         * {@inheritDoc}
2357
         */
2358
        public WithFlexibleName withInitializer(ByteCodeAppender byteCodeAppender) {
2359
            throw new IllegalStateException("Cannot add initializer to frozen type: " + typeDescription);
1✔
2360
        }
2361

2362
        /**
2363
         * {@inheritDoc}
2364
         */
2365
        public WithFlexibleName withName(String name) {
2366
            throw new IllegalStateException("Cannot change name of frozen type: " + typeDescription);
1✔
2367
        }
2368

2369
        /**
2370
         * {@inheritDoc}
2371
         */
2372
        public WithFlexibleName withTypeVariables(ElementMatcher<? super Generic> matcher, Transformer<TypeVariableToken> transformer) {
2373
            throw new IllegalStateException("Cannot add type variables of frozen type: " + typeDescription);
1✔
2374
        }
2375

2376
        /**
2377
         * {@inheritDoc}
2378
         */
2379
        public LoadedTypeInitializer getLoadedTypeInitializer() {
2380
            return loadedTypeInitializer;
1✔
2381
        }
2382

2383
        /**
2384
         * {@inheritDoc}
2385
         */
2386
        public TypeInitializer getTypeInitializer() {
2387
            return TypeInitializer.None.INSTANCE;
1✔
2388
        }
2389

2390
        @MaybeNull
2391
        @Override
2392
        public ClassFileVersion getClassFileVersion() {
2393
            return typeDescription.getClassFileVersion();
1✔
2394
        }
2395

2396
        /**
2397
         * {@inheritDoc}
2398
         */
2399
        public TypeDescription validated() {
2400
            return typeDescription;
1✔
2401
        }
2402
    }
2403
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc