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

raphw / byte-buddy / #803

27 Oct 2025 11:52AM UTC coverage: 84.961% (+0.3%) from 84.697%
#803

push

raphw
Add missing annotation.

29755 of 35022 relevant lines covered (84.96%)

0.85 hits per line

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

41.54
/byte-buddy-dep/src/main/java/net/bytebuddy/description/module/ModuleDescription.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.description.module;
17

18
import net.bytebuddy.build.AccessControllerPlugin;
19
import net.bytebuddy.description.ModifierReviewable;
20
import net.bytebuddy.description.NamedElement;
21
import net.bytebuddy.description.annotation.AnnotationList;
22
import net.bytebuddy.description.annotation.AnnotationSource;
23
import net.bytebuddy.utility.dispatcher.JavaDispatcher;
24
import net.bytebuddy.utility.nullability.AlwaysNull;
25
import net.bytebuddy.utility.nullability.MaybeNull;
26

27
import java.lang.reflect.AnnotatedElement;
28
import java.security.PrivilegedAction;
29
import java.util.LinkedHashMap;
30
import java.util.Map;
31
import java.util.Set;
32

33
/**
34
 * Description of a named Java {@code java.lang.Module}.
35
 */
36
public interface ModuleDescription extends NamedElement,
37
        ModifierReviewable.ForModuleDescription,
38
        AnnotationSource {
39

40
    /**
41
     * Defines a module that is not resolved.
42
     */
43
    @AlwaysNull
44
    ModuleDescription UNDEFINED = null;
1✔
45

46
    /**
47
     * Returns the version of this module.
48
     *
49
     * @return The module's version or {@code null} if no version is specified.
50
     */
51
    @MaybeNull
52
    String getVersion();
53

54
    /**
55
     * Returns the main class of this module.
56
     *
57
     * @return The module's main class or {@code null} if no main class is specified.
58
     */
59
    @MaybeNull
60
    String getMainClass();
61

62
    /**
63
     * Returns all packages contained in this module.
64
     *
65
     * @return A set of all package names within this module.
66
     */
67
    Set<String> getPackages();
68

69
    /**
70
     * Returns all package exports of this module.
71
     *
72
     * @return A mapping of package names to their export declarations.
73
     */
74
    Map<String, Exports> getExports();
75

76
    /**
77
     * Returns all package opens of this module.
78
     *
79
     * @return A mapping of package names to their opens declarations.
80
     */
81
    Map<String, Opens> getOpens();
82

83
    /**
84
     * Returns all module dependencies of this module.
85
     *
86
     * @return A mapping of module names to their require declarations.
87
     */
88
    Map<String, Requires> getRequires();
89

90
    /**
91
     * Returns all service types that this module uses.
92
     *
93
     * @return A set of service class names that this module uses.
94
     */
95
    Set<String> getUses();
96

97
    /**
98
     * Returns all service implementations provided by this module.
99
     *
100
     * @return A mapping of service names to their provider declarations.
101
     */
102
    Map<String, Provides> getProvides();
103

104
    /**
105
     * Represents an exported package declaration in a module. Exports control which packages
106
     * are accessible to other modules.
107
     */
108
    interface Exports extends ModifierReviewable.OfMandatable {
109

110
        /**
111
         * Returns the target modules that this package is exported to.
112
         *
113
         * @return A set of module names that can access this exported package, or an empty set if exported to all modules.
114
         */
115
        Set<String> getTargets();
116

117
        /**
118
         * Determines if this export is qualified (exported to specific modules only).
119
         *
120
         * @return {@code true} if this export has specific target modules, {@code false} if exported to all modules.
121
         */
122
        boolean isQualified();
123

124
        /**
125
         * An abstract base implementation of {@link Exports} that provides a default implementation
126
         * for {@link #isQualified()}.
127
         */
128
        abstract class AbstractBase extends ModifierReviewable.AbstractBase implements Exports {
1✔
129

130
            /**
131
             * {@inheritDoc}
132
             */
133
            public boolean isQualified() {
134
                return !getTargets().isEmpty();
×
135
            }
136

137
            @Override
138
            public int hashCode() {
139
                int hashCode = getModifiers();
1✔
140
                return hashCode + 17 * getTargets().hashCode();
1✔
141
            }
142

143
            @Override
144
            public boolean equals(Object other) {
145
                if (!(other instanceof Exports)) return false;
1✔
146
                Exports exports = (Exports) other;
1✔
147
                return getModifiers() == exports.getModifiers() && getTargets().equals(exports.getTargets());
1✔
148
            }
149

150
            @Override
151
            public String toString() {
152
                return "Opens{"
×
153
                        + "targets=" + getTargets()
×
154
                        + ",modifiers=" + getModifiers()
×
155
                        + '}';
156
            }
157
        }
158

159
        /**
160
         * A simple implementation of {@link Exports} that stores the target modules and modifiers.
161
         */
162
        class Simple extends AbstractBase {
163

164
            /**
165
             * The target modules for this export.
166
             */
167
            private final Set<String> targets;
168

169
            /**
170
             * The modifiers for this export.
171
             */
172
            protected final int modifiers;
173

174
            /**
175
             * Creates a new simple export declaration.
176
             *
177
             * @param targets   The target modules for this export.
178
             * @param modifiers The modifiers for this export.
179
             */
180
            public Simple(Set<String> targets, int modifiers) {
1✔
181
                this.targets = targets;
1✔
182
                this.modifiers = modifiers;
1✔
183
            }
1✔
184

185
            /**
186
             * {@inheritDoc}
187
             */
188
            public Set<String> getTargets() {
189
                return targets;
1✔
190
            }
191

192
            /**
193
             * {@inheritDoc}
194
             */
195
            public int getModifiers() {
196
                return modifiers;
1✔
197
            }
198
        }
199
    }
200

201
    /**
202
     * Represents an opened package declaration in a module. Opens allow deep reflective access
203
     * to packages for other modules.
204
     */
205
    interface Opens extends ModifierReviewable.OfMandatable {
206

207
        /**
208
         * Returns the target modules that this package is opened to.
209
         *
210
         * @return A set of module names that can reflectively access this opened package, or an empty set if opened to all modules.
211
         */
212
        Set<String> getTargets();
213

214
        /**
215
         * Determines if this opens declaration is qualified (opened to specific modules only).
216
         *
217
         * @return {@code true} if this opens has specific target modules, {@code false} if opened to all modules.
218
         */
219
        boolean isQualified();
220

221
        /**
222
         * An abstract base implementation of {@link Opens}.
223
         */
224
        abstract class AbstractBase extends ModifierReviewable.AbstractBase implements Opens {
1✔
225

226
            /**
227
             * {@inheritDoc}
228
             */
229
            public boolean isQualified() {
230
                return !getTargets().isEmpty();
×
231
            }
232

233
            @Override
234
            public int hashCode() {
235
                int hashCode = getModifiers();
1✔
236
                return hashCode + 17 * getTargets().hashCode();
1✔
237
            }
238

239
            @Override
240
            public boolean equals(Object other) {
241
                if (!(other instanceof Opens)) return false;
1✔
242
                Opens opens = (Opens) other;
1✔
243
                return getModifiers() == opens.getModifiers() && getTargets().equals(opens.getTargets());
1✔
244
            }
245

246
            @Override
247
            public String toString() {
248
                return "Opens{"
×
249
                        + "targets=" + getTargets()
×
250
                        + ",modifiers=" + getModifiers()
×
251
                        + '}';
252
            }
253
        }
254

255
        /**
256
         * A simple implementation of {@link Opens}.
257
         */
258
        class Simple extends AbstractBase {
259

260
            /**
261
             * The target modules for this opens declaration.
262
             */
263
            private final Set<String> targets;
264

265
            /**
266
             * The modifiers for this opens declaration.
267
             */
268
            protected final int modifiers;
269

270
            /**
271
             * Creates a new simple opens declaration.
272
             *
273
             * @param targets   The target modules for this opens declaration.
274
             * @param modifiers The modifiers for this opens declaration.
275
             */
276
            public Simple(Set<String> targets, int modifiers) {
1✔
277
                this.targets = targets;
1✔
278
                this.modifiers = modifiers;
1✔
279
            }
1✔
280

281
            /**
282
             * {@inheritDoc}
283
             */
284
            public Set<String> getTargets() {
285
                return targets;
1✔
286
            }
287

288
            /**
289
             * {@inheritDoc}
290
             */
291
            public int getModifiers() {
292
                return modifiers;
1✔
293
            }
294
        }
295
    }
296

297
    /**
298
     * Represents a module dependency declaration. Requires specify which modules this module
299
     * depends on for compilation and runtime.
300
     */
301
    interface Requires extends ModifierReviewable.ForModuleRequirement {
302

303
        /**
304
         * Returns the version of the required module.
305
         *
306
         * @return The required module's version or {@code null} if no specific version is required.
307
         */
308
        @MaybeNull
309
        String getVersion();
310

311
        /**
312
         * An abstract base implementation of {@link Requires}.
313
         */
314
        abstract class AbstractBase extends ModifierReviewable.AbstractBase implements Requires {
1✔
315

316
            @Override
317
            public int hashCode() {
318
                int hashCode = getModifiers();
1✔
319
                String version = getVersion();
1✔
320
                return version == null ? hashCode : (hashCode + 17 * version.hashCode());
1✔
321
            }
322

323
            @Override
324
            public boolean equals(Object other) {
325
                if (!(other instanceof Requires)) return false;
1✔
326
                Requires requires = (Requires) other;
1✔
327
                String version = getVersion();
1✔
328
                return getModifiers() == requires.getModifiers() && version == null ? requires.getVersion() == null : version.equals(requires.getVersion());
1✔
329
            }
330

331
            @Override
332
            public String toString() {
333
                String version = getVersion();
×
334
                return "Requires{"
×
335
                        + "version=" + (version == null ? "" : '"' + version + '\'')
336
                        + ",modifiers=" + getModifiers()
×
337
                        + '}';
338
            }
339
        }
340

341
        /**
342
         * A simple implementation of {@link Requires}.
343
         */
344
        class Simple extends AbstractBase {
345

346
            /**
347
             * The version of the required module.
348
             */
349
            @MaybeNull
350
            private final String version;
351

352
            /**
353
             * The modifiers for this requires declaration.
354
             */
355
            private final int modifiers;
356

357
            /**
358
             * Creates a new simple requires declaration.
359
             *
360
             * @param version   The version of the required module or {@code null} if no specific version is required.
361
             * @param modifiers The modifiers for this requires declaration.
362
             */
363
            public Simple(@MaybeNull String version, int modifiers) {
1✔
364
                this.version = version;
1✔
365
                this.modifiers = modifiers;
1✔
366
            }
1✔
367

368
            /**
369
             * {@inheritDoc}
370
             */
371
            @MaybeNull
372
            public String getVersion() {
373
                return version;
1✔
374
            }
375

376
            /**
377
             * {@inheritDoc}
378
             */
379
            public int getModifiers() {
380
                return modifiers;
1✔
381
            }
382
        }
383
    }
384

385
    /**
386
     * Represents a service provider declaration in a module. Provides specify which service
387
     * implementations this module offers to other modules.
388
     */
389
    interface Provides {
390

391
        /**
392
         * Returns the implementation classes that provide the service.
393
         *
394
         * @return A set of class names that implement the service.
395
         */
396
        Set<String> getProviders();
397

398
        /**
399
         * An abstract base implementation of {@link Provides}.
400
         */
401
        abstract class AbstractBase implements Provides {
1✔
402

403
            @Override
404
            public int hashCode() {
405
                return getProviders().hashCode();
1✔
406
            }
407

408
            @Override
409
            public boolean equals(Object other) {
410
                if (!(other instanceof Provides)) return false;
1✔
411
                Provides provides = (Provides) other;
1✔
412
                return getProviders().equals(provides.getProviders());
1✔
413
            }
414

415
            @Override
416
            public String toString() {
417
                return "Provides{providers=" + getProviders() + '}';
×
418
            }
419
        }
420

421
        /**
422
         * A simple implementation of {@link Provides}.
423
         */
424
        class Simple extends AbstractBase {
425

426
            /**
427
             * The implementation classes that provide the service.
428
             */
429
            private final Set<String> providers;
430

431
            /**
432
             * Creates a new simple provides declaration.
433
             *
434
             * @param providers The implementation classes that provide the service.
435
             */
436
            public Simple(Set<String> providers) {
1✔
437
                this.providers = providers;
1✔
438
            }
1✔
439

440
            /**
441
             * {@inheritDoc}
442
             */
443
            public Set<String> getProviders() {
444
                return providers;
1✔
445
            }
446
        }
447
    }
448

449
    /**
450
     * An abstract base implementation of a {@link ModuleDescription}.
451
     */
452
    abstract class AbstractBase extends ModifierReviewable.AbstractBase implements ModuleDescription {
1✔
453

454
        @Override
455
        public int hashCode() {
456
            return 17 * getActualName().hashCode();
1✔
457
        }
458

459
        @Override
460
        public boolean equals(Object other) {
461
            if (!(other instanceof ModuleDescription)) return false;
1✔
462
            ModuleDescription module = (ModuleDescription) other;
1✔
463
            return getActualName().equals(module.getActualName());
1✔
464
        }
465

466
        @Override
467
        public String toString() {
468
            return "module " + getActualName();
1✔
469
        }
470
    }
471

472
    /**
473
     * A {@link ModuleDescription} implementation that represents a loaded Java module.
474
     * This implementation uses reflection and Java dispatchers to access module information
475
     * from the runtime module system.
476
     */
477
    class ForLoadedModule extends AbstractBase {
478

479
        /**
480
         * A dispatcher for accessing {@code java.lang.Module} methods.
481
         */
482
        protected static final Module MODULE = doPrivileged(JavaDispatcher.of(Module.class));
×
483

484
        /**
485
         * A dispatcher for accessing {@code java.lang.ModuleDescriptor} methods.
486
         */
487
        protected static final ModuleDescriptor MODULE_DESCRIPTOR = doPrivileged(JavaDispatcher.of(ModuleDescriptor.class));
×
488

489
        /**
490
         * A dispatcher for accessing {@code java.lang.ModuleDescriptor.Exports} methods.
491
         */
492
        protected static final ModuleDescriptor.Exports MODULE_DESCRIPTOR_EXPORTS = doPrivileged(JavaDispatcher.of(ModuleDescriptor.Exports.class));
×
493

494
        /**
495
         * A dispatcher for accessing {@code java.lang.ModuleDescriptor.Exports.Modifier} methods.
496
         */
497
        protected static final ModuleDescriptor.Exports.Modifier MODULE_DESCRIPTOR_EXPORTS_MODIFIER = doPrivileged(JavaDispatcher.of(ModuleDescriptor.Exports.Modifier.class));
×
498

499
        /**
500
         * A dispatcher for accessing {@code java.lang.ModuleDescriptor.Opens} methods.
501
         */
502
        protected static final ModuleDescriptor.Opens MODULE_DESCRIPTOR_OPENS = doPrivileged(JavaDispatcher.of(ModuleDescriptor.Opens.class));
×
503

504
        /**
505
         * A dispatcher for accessing {@code java.lang.ModuleDescriptor.Opens.Modifier} methods.
506
         */
507
        protected static final ModuleDescriptor.Opens.Modifier MODULE_DESCRIPTOR_OPENS_MODIFIER = doPrivileged(JavaDispatcher.of(ModuleDescriptor.Opens.Modifier.class));
×
508

509
        /**
510
         * A dispatcher for accessing {@code java.lang.ModuleDescriptor.Requires} methods.
511
         */
512
        protected static final ModuleDescriptor.Requires MODULE_DESCRIPTOR_REQUIRES = doPrivileged(JavaDispatcher.of(ModuleDescriptor.Requires.class));
×
513

514
        /**
515
         * A dispatcher for accessing {@code java.lang.ModuleDescriptor.Requires.Modifier} methods.
516
         */
517
        protected static final ModuleDescriptor.Requires.Modifier MODULE_DESCRIPTOR_REQUIRES_MODIFIER = doPrivileged(JavaDispatcher.of(ModuleDescriptor.Requires.Modifier.class));
×
518

519
        /**
520
         * A dispatcher for accessing {@code java.lang.ModuleDescriptor.Provides} methods.
521
         */
522
        protected static final ModuleDescriptor.Provides MODULE_DESCRIPTOR_PROVIDES = doPrivileged(JavaDispatcher.of(ModuleDescriptor.Provides.class));
×
523

524
        /**
525
         * A dispatcher for accessing {@code java.util.Optional} methods.
526
         */
527
        protected static final Optional OPTIONAL = doPrivileged(JavaDispatcher.of(Optional.class));
×
528

529
        /**
530
         * The module represented by this description.
531
         */
532
        private final AnnotatedElement module;
533

534
        /**
535
         * Creates a module description for the supplied module.
536
         *
537
         * @param module The module to represent.
538
         * @return A module description for the supplied module.
539
         * @throws IllegalArgumentException If the supplied instance is not a module or if the module is unnamed.
540
         */
541
        public static ForLoadedModule of(Object module) {
542
            if (!MODULE.isInstance(module)) {
×
543
                throw new IllegalArgumentException("Not a Java module: " + module);
×
544
            } else if (!MODULE.isNamed(module)) {
×
545
                throw new IllegalArgumentException("Not a named module: " + module);
×
546
            }
547
            return new ForLoadedModule((AnnotatedElement) module);
×
548
        }
549

550
        /**
551
         * A proxy for {@code java.security.AccessController#doPrivileged} that is activated if available.
552
         *
553
         * @param action The action to execute from a privileged context.
554
         * @param <T>    The type of the action's resolved value.
555
         * @return The action's resolved value.
556
         */
557
        @AccessControllerPlugin.Enhance
558
        private static <T> T doPrivileged(PrivilegedAction<T> action) {
559
            return action.run();
×
560
        }
561

562
        /**
563
         * Creates a new module description for the supplied module.
564
         *
565
         * @param module The module to represent.
566
         */
567
        protected ForLoadedModule(AnnotatedElement module) {
×
568
            this.module = module;
×
569
        }
×
570

571
        /**
572
         * {@inheritDoc}
573
         */
574
        @MaybeNull
575
        public String getVersion() {
576
            return (String) OPTIONAL.orElse(MODULE_DESCRIPTOR.rawVersion(MODULE.getDescriptor(module)), null);
×
577
        }
578

579
        /**
580
         * {@inheritDoc}
581
         */
582
        @MaybeNull
583
        public String getMainClass() {
584
            return (String) OPTIONAL.orElse(MODULE_DESCRIPTOR.mainClass(MODULE.getDescriptor(module)), null);
×
585
        }
586

587
        /**
588
         * {@inheritDoc}
589
         */
590
        public boolean isOpen() {
591
            return MODULE_DESCRIPTOR.isOpen(MODULE.getDescriptor(module));
×
592
        }
593

594
        /**
595
         * {@inheritDoc}
596
         */
597
        public Set<String> getPackages() {
598
            return MODULE_DESCRIPTOR.packages(MODULE.getDescriptor(module));
×
599
        }
600

601
        /**
602
         * {@inheritDoc}
603
         */
604
        public Set<String> getUses() {
605
            return MODULE_DESCRIPTOR.uses(MODULE.getDescriptor(module));
×
606
        }
607

608
        /**
609
         * {@inheritDoc}
610
         */
611
        public Map<String, Exports> getExports() {
612
            Map<String, Exports> exports = new LinkedHashMap<String, Exports>();
×
613
            for (Object export : MODULE_DESCRIPTOR.exports(MODULE.getDescriptor(module))) {
×
614
                int modifiers = 0;
×
615
                for (Object modifier : MODULE_DESCRIPTOR_EXPORTS.modifiers(export)) {
×
616
                    modifiers |= MODULE_DESCRIPTOR_EXPORTS_MODIFIER.getMask(modifier);
×
617
                }
×
618
                exports.put(MODULE_DESCRIPTOR_EXPORTS.source(export), new Exports.Simple(MODULE_DESCRIPTOR_EXPORTS.targets(export), modifiers));
×
619
            }
×
620
            return exports;
×
621
        }
622

623
        /**
624
         * {@inheritDoc}
625
         */
626
        public Map<String, Opens> getOpens() {
627
            Map<String, Opens> opens = new LinkedHashMap<String, Opens>();
×
628
            for (Object open : MODULE_DESCRIPTOR.opens(MODULE.getDescriptor(module))) {
×
629
                int modifiers = 0;
×
630
                for (Object modifier : MODULE_DESCRIPTOR_OPENS.modifiers(open)) {
×
631
                    modifiers |= MODULE_DESCRIPTOR_OPENS_MODIFIER.getMask(modifier);
×
632
                }
×
633
                opens.put(MODULE_DESCRIPTOR_OPENS.source(open), new Opens.Simple(MODULE_DESCRIPTOR_OPENS.targets(open), modifiers));
×
634
            }
×
635
            return opens;
×
636
        }
637

638
        /**
639
         * {@inheritDoc}
640
         */
641
        public Map<String, Requires> getRequires() {
642
            Map<String, Requires> requires = new LinkedHashMap<String, Requires>();
×
643
            for (Object require : MODULE_DESCRIPTOR.requires(MODULE.getDescriptor(module))) {
×
644
                int modifiers = 0;
×
645
                for (Object modifier : MODULE_DESCRIPTOR_REQUIRES.modifiers(require)) {
×
646
                    modifiers |= MODULE_DESCRIPTOR_REQUIRES_MODIFIER.getMask(modifier);
×
647
                }
×
648
                requires.put(MODULE_DESCRIPTOR_REQUIRES.name(require), new Requires.Simple(
×
649
                        (String) OPTIONAL.orElse(MODULE_DESCRIPTOR_REQUIRES.rawCompiledVersion(require), null),
×
650
                        modifiers));
651
            }
×
652
            return requires;
×
653
        }
654

655
        /**
656
         * {@inheritDoc}
657
         */
658
        public Map<String, Provides> getProvides() {
659
            Map<String, Provides> provides = new LinkedHashMap<String, Provides>();
×
660
            for (Object require : MODULE_DESCRIPTOR.provides(MODULE.getDescriptor(module))) {
×
661
                provides.put(MODULE_DESCRIPTOR_PROVIDES.service(require), new Provides.Simple(MODULE_DESCRIPTOR_PROVIDES.provides(require)));
×
662
            }
×
663
            return provides;
×
664
        }
665

666
        /**
667
         * {@inheritDoc}
668
         */
669
        public int getModifiers() {
670
            int modifiers = 0;
×
671
            for (Object modifier : MODULE_DESCRIPTOR.modifiers(module)) {
×
672
                modifiers |= MODULE_DESCRIPTOR_REQUIRES_MODIFIER.getMask(modifier);
×
673
            }
×
674
            return modifiers;
×
675
        }
676

677
        /**
678
         * {@inheritDoc}
679
         */
680
        public String getActualName() {
681
            return MODULE_DESCRIPTOR.name(MODULE.getDescriptor(module));
×
682
        }
683

684
        /**
685
         * {@inheritDoc}
686
         */
687
        public AnnotationList getDeclaredAnnotations() {
688
            return new AnnotationList.ForLoadedAnnotations(module.getDeclaredAnnotations());
×
689
        }
690

691
        /**
692
         * A proxy for interacting with {@code java.lang.Module}.
693
         */
694
        @JavaDispatcher.Proxied("java.lang.Module")
695
        protected interface Module {
696

697
            /**
698
             * Returns {@code true} if the supplied instance is of type {@code java.lang.Module}.
699
             *
700
             * @param value The instance to investigate.
701
             * @return {@code true} if the supplied value is a {@code java.lang.Module}.
702
             */
703
            @JavaDispatcher.Instance
704
            boolean isInstance(Object value);
705

706
            /**
707
             * Returns {@code true} if the supplied module is named.
708
             *
709
             * @param value The {@code java.lang.Module} to check for the existence of a name.
710
             * @return {@code true} if the supplied module is named.
711
             */
712
            boolean isNamed(Object value);
713

714
            /**
715
             * Returns the module's name.
716
             *
717
             * @param value The {@code java.lang.Module} to check for its name.
718
             * @return The module's (implicit or explicit) name.
719
             */
720
            String getName(Object value);
721

722
            /**
723
             * Returns the module's exported packages.
724
             *
725
             * @param value The {@code java.lang.Module} to check for its packages.
726
             * @return The module's packages.
727
             */
728
            Set<String> getPackages(Object value);
729

730
            /**
731
             * Returns the module descriptor.
732
             * @param value The {@code java.lang.Module} to check for its descriptor.
733
             * @return The module's descriptor.
734
             */
735
            Object getDescriptor(Object value);
736
        }
737

738
        /**
739
         * A proxy for interacting with {@code java.lang.ModuleDescriptor}.
740
         */
741
        @JavaDispatcher.Proxied("java.lang.ModuleDescriptor")
742
        protected interface ModuleDescriptor {
743

744
            /**
745
             * Returns the module's name.
746
             *
747
             * @param value The {@code java.lang.ModuleDescriptor} instance.
748
             * @return The module's name.
749
             */
750
            String name(Object value);
751

752
            /**
753
             * Returns the module's modifiers.
754
             *
755
             * @param value The {@code java.lang.ModuleDescriptor} instance.
756
             * @return The module's modifiers.
757
             */
758
            Set<?> modifiers(Object value);
759

760
            /**
761
             * Returns {@code true} if this is an open module.
762
             *
763
             * @param value The {@code java.lang.ModuleDescriptor} instance.
764
             * @return {@code true} if this is an open module.
765
             */
766
            boolean isOpen(Object value);
767

768
            /**
769
             * Returns the module's requires declarations.
770
             *
771
             * @param value The {@code java.lang.ModuleDescriptor} instance.
772
             * @return The module's requires declarations.
773
             */
774
            Set<?> requires(Object value);
775

776
            /**
777
             * Returns the module's exports declarations.
778
             *
779
             * @param value The {@code java.lang.ModuleDescriptor} instance.
780
             * @return The module's exports declarations.
781
             */
782
            Set<?> exports(Object value);
783

784
            /**
785
             * Returns the module's opens declarations.
786
             *
787
             * @param value The {@code java.lang.ModuleDescriptor} instance.
788
             * @return The module's opens declarations.
789
             */
790
            Set<?> opens(Object value);
791

792
            /**
793
             * Returns the module's uses declarations.
794
             *
795
             * @param value The {@code java.lang.ModuleDescriptor} instance.
796
             * @return The module's uses declarations.
797
             */
798
            Set<String> uses(Object value);
799

800
            /**
801
             * Returns the module's provides declarations.
802
             *
803
             * @param value The {@code java.lang.ModuleDescriptor} instance.
804
             * @return The module's provides declarations.
805
             */
806
            Set<?> provides(Object value);
807

808
            /**
809
             * Returns the module's raw version.
810
             *
811
             * @param value The {@code java.lang.ModuleDescriptor} instance.
812
             * @return The module's raw version as an {@code Optional}.
813
             */
814
            Object rawVersion(Object value);
815

816
            /**
817
             * Returns the module's main class.
818
             *
819
             * @param value The {@code java.lang.ModuleDescriptor} instance.
820
             * @return The module's main class as an {@code Optional}.
821
             */
822
            Object mainClass(Object value);
823

824
            /**
825
             * Returns the module's packages.
826
             *
827
             * @param value The {@code java.lang.ModuleDescriptor} instance.
828
             * @return The module's packages.
829
             */
830
            Set<String> packages(Object value);
831

832
            /**
833
             * A proxy for interacting with {@code java.lang.ModuleDescriptor.Requires}.
834
             */
835
            @JavaDispatcher.Proxied("java.lang.ModuleDescriptor$Requires")
836
            interface Requires {
837

838
                /**
839
                 * Returns the name of the required module.
840
                 *
841
                 * @param value The {@code java.lang.ModuleDescriptor.Requires} instance.
842
                 * @return The name of the required module.
843
                 */
844
                String name(Object value);
845

846
                /**
847
                 * Returns the modifiers of the requires declaration.
848
                 *
849
                 * @param value The {@code java.lang.ModuleDescriptor.Requires} instance.
850
                 * @return The modifiers of the requires declaration.
851
                 */
852
                Set<?> modifiers(Object value);
853

854
                /**
855
                 * Returns the raw compiled version of the required module.
856
                 *
857
                 * @param value The {@code java.lang.ModuleDescriptor.Requires} instance.
858
                 * @return The raw compiled version as an {@code Optional}.
859
                 */
860
                Object rawCompiledVersion(Object value);
861

862
                /**
863
                 * A proxy for interacting with {@code java.lang.ModuleDescriptor.Requires.Modifier}.
864
                 */
865
                @JavaDispatcher.Proxied("java.lang.ModuleDescriptor$Requires$Modifier")
866
                interface Modifier {
867

868
                    /**
869
                     * Returns the mask value for this modifier.
870
                     *
871
                     * @param value The {@code java.lang.ModuleDescriptor.Requires.Modifier} instance.
872
                     * @return The mask value for this modifier.
873
                     */
874
                    int getMask(Object value);
875
                }
876
            }
877

878
            /**
879
             * A proxy for interacting with {@code java.lang.ModuleDescriptor.Exports}.
880
             */
881
            @JavaDispatcher.Proxied("java.lang.ModuleDescriptor$Exports")
882
            interface Exports {
883

884
                /**
885
                 * Returns the source package name for this export.
886
                 *
887
                 * @param value The {@code java.lang.ModuleDescriptor.Exports} instance.
888
                 * @return The source package name.
889
                 */
890
                String source(Object value);
891

892
                /**
893
                 * Returns the modifiers of the exports declaration.
894
                 *
895
                 * @param value The {@code java.lang.ModuleDescriptor.Exports} instance.
896
                 * @return The modifiers of the exports declaration.
897
                 */
898
                Set<?> modifiers(Object value);
899

900
                /**
901
                 * Returns the target modules for this export.
902
                 *
903
                 * @param value The {@code java.lang.ModuleDescriptor.Exports} instance.
904
                 * @return The target modules for this export.
905
                 */
906
                Set<String> targets(Object value);
907

908
                /**
909
                 * A proxy for interacting with {@code java.lang.ModuleDescriptor.Exports.Modifier}.
910
                 */
911
                @JavaDispatcher.Proxied("java.lang.ModuleDescriptor$Exports$Modifier")
912
                interface Modifier {
913

914
                    /**
915
                     * Returns the mask value for this modifier.
916
                     *
917
                     * @param value The {@code java.lang.ModuleDescriptor.Exports.Modifier} instance.
918
                     * @return The mask value for this modifier.
919
                     */
920
                    int getMask(Object value);
921
                }
922
            }
923

924
            /**
925
             * A proxy for interacting with {@code java.lang.ModuleDescriptor.Opens}.
926
             */
927
            @JavaDispatcher.Proxied("java.lang.ModuleDescriptor$Opens")
928
            interface Opens {
929

930
                /**
931
                 * Returns the source package name for this opens declaration.
932
                 *
933
                 * @param value The {@code java.lang.ModuleDescriptor.Opens} instance.
934
                 * @return The source package name.
935
                 */
936
                String source(Object value);
937

938
                /**
939
                 * Returns the modifiers of the opens declaration.
940
                 *
941
                 * @param value The {@code java.lang.ModuleDescriptor.Opens} instance.
942
                 * @return The modifiers of the opens declaration.
943
                 */
944
                Set<?> modifiers(Object value);
945

946
                /**
947
                 * Returns the target modules for this opens declaration.
948
                 *
949
                 * @param value The {@code java.lang.ModuleDescriptor.Opens} instance.
950
                 * @return The target modules for this opens declaration.
951
                 */
952
                Set<String> targets(Object value);
953

954
                /**
955
                 * A proxy for interacting with {@code java.lang.ModuleDescriptor.Opens.Modifier}.
956
                 */
957
                @JavaDispatcher.Proxied("java.lang.ModuleDescriptor$Opens$Modifier")
958
                interface Modifier {
959

960
                    /**
961
                     * Returns the mask value for this modifier.
962
                     *
963
                     * @param value The {@code java.lang.ModuleDescriptor.Opens.Modifier} instance.
964
                     * @return The mask value for this modifier.
965
                     */
966
                    int getMask(Object value);
967
                }
968
            }
969

970
            /**
971
             * A proxy for interacting with {@code java.lang.ModuleDescriptor.Provides}.
972
             */
973
            @JavaDispatcher.Proxied("java.lang.ModuleDescriptor$Provides")
974
            interface Provides {
975

976
                /**
977
                 * Returns the service interface name for this provides declaration.
978
                 *
979
                 * @param value The {@code java.lang.ModuleDescriptor.Provides} instance.
980
                 * @return The service interface name.
981
                 */
982
                String service(Object value);
983

984
                /**
985
                 * Returns the provider implementation class names for this provides declaration.
986
                 *
987
                 * @param value The {@code java.lang.ModuleDescriptor.Provides} instance.
988
                 * @return The provider implementation class names.
989
                 */
990
                Set<String> provides(Object value);
991
            }
992
        }
993

994
        /**
995
         * A proxy for interacting with {@code java.util.Optional}.
996
         */
997
        @JavaDispatcher.Proxied("java.lang.Optional")
998
        protected interface Optional {
999

1000
            /**
1001
             * Returns the value if present, otherwise returns the fallback value.
1002
             *
1003
             * @param value    The {@code java.util.Optional} instance.
1004
             * @param fallback The fallback value to return if the optional is empty.
1005
             * @return The value if present, otherwise the fallback value.
1006
             */
1007
            @MaybeNull
1008
            Object orElse(Object value, @MaybeNull Object fallback);
1009
        }
1010
    }
1011
}
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