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

raphw / byte-buddy / #802

27 Oct 2025 09:58AM UTC coverage: 84.697% (-0.02%) from 84.715%
#802

push

raphw
Add method to expose possible module information of a type.

3 of 11 new or added lines in 4 files covered. (27.27%)

51 existing lines in 2 files now uncovered.

29589 of 34935 relevant lines covered (84.7%)

0.85 hits per line

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

1.09
/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 service types that this module uses.
71
     *
72
     * @return A set of service class names that this module uses.
73
     */
74
    Set<String> getUses();
75

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

83
    /**
84
     * Returns all package opens of this module.
85
     *
86
     * @return A mapping of package names to their opens declarations.
87
     */
88
    Map<String, Opens> getOpens();
89

90
    /**
91
     * Returns all module dependencies of this module.
92
     *
93
     * @return A mapping of module names to their require declarations.
94
     */
95
    Map<String, Requires> getRequires();
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
         */
UNCOV
128
        abstract class AbstractBase extends ModifierReviewable.AbstractBase implements Exports {
×
129

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

138
        /**
139
         * A simple implementation of {@link Exports} that stores the target modules and modifiers.
140
         */
141
        class Simple extends AbstractBase {
142

143
            /**
144
             * The target modules for this export.
145
             */
146
            private final Set<String> targets;
147

148
            /**
149
             * The modifiers for this export.
150
             */
151
            protected final int modifiers;
152

153
            /**
154
             * Creates a new simple export declaration.
155
             *
156
             * @param targets   The target modules for this export.
157
             * @param modifiers The modifiers for this export.
158
             */
UNCOV
159
            public Simple(Set<String> targets, int modifiers) {
×
UNCOV
160
                this.targets = targets;
×
UNCOV
161
                this.modifiers = modifiers;
×
UNCOV
162
            }
×
163

164
            /**
165
             * {@inheritDoc}
166
             */
167
            public Set<String> getTargets() {
UNCOV
168
                return targets;
×
169
            }
170

171
            /**
172
             * {@inheritDoc}
173
             */
174
            public int getModifiers() {
175
                return modifiers;
×
176
            }
177
        }
178
    }
179

180
    /**
181
     * Represents an opened package declaration in a module. Opens allow deep reflective access
182
     * to packages for other modules.
183
     */
184
    interface Opens extends ModifierReviewable.OfMandatable {
185

186
        /**
187
         * Returns the target modules that this package is opened to.
188
         *
189
         * @return A set of module names that can reflectively access this opened package, or an empty set if opened to all modules.
190
         */
191
        Set<String> getTargets();
192

193
        /**
194
         * Determines if this opens declaration is qualified (opened to specific modules only).
195
         *
196
         * @return {@code true} if this opens has specific target modules, {@code false} if opened to all modules.
197
         */
198
        boolean isQualified();
199

200
        /**
201
         * An abstract base implementation of {@link Opens}.
202
         */
UNCOV
203
        abstract class AbstractBase extends ModifierReviewable.AbstractBase implements Opens {
×
204

205
            /**
206
             * {@inheritDoc}
207
             */
208
            public boolean isQualified() {
UNCOV
209
                return !getTargets().isEmpty();
×
210
            }
211
        }
212

213
        /**
214
         * A simple implementation of {@link Opens}.
215
         */
216
        class Simple extends AbstractBase {
217

218
            /**
219
             * The target modules for this opens declaration.
220
             */
221
            private final Set<String> targets;
222

223
            /**
224
             * The modifiers for this opens declaration.
225
             */
226
            protected final int modifiers;
227

228
            /**
229
             * Creates a new simple opens declaration.
230
             *
231
             * @param targets   The target modules for this opens declaration.
232
             * @param modifiers The modifiers for this opens declaration.
233
             */
UNCOV
234
            public Simple(Set<String> targets, int modifiers) {
×
UNCOV
235
                this.targets = targets;
×
UNCOV
236
                this.modifiers = modifiers;
×
UNCOV
237
            }
×
238

239
            /**
240
             * {@inheritDoc}
241
             */
242
            public Set<String> getTargets() {
UNCOV
243
                return targets;
×
244
            }
245

246
            /**
247
             * {@inheritDoc}
248
             */
249
            public boolean isQualified() {
250
                return !targets.isEmpty();
×
251
            }
252

253
            /**
254
             * {@inheritDoc}
255
             */
256
            public int getModifiers() {
UNCOV
257
                return modifiers;
×
258
            }
259
        }
260
    }
261

262
    /**
263
     * Represents a module dependency declaration. Requires specify which modules this module
264
     * depends on for compilation and runtime.
265
     */
266
    interface Requires extends ModifierReviewable.ForModuleRequirement {
267

268
        /**
269
         * Returns the version of the required module.
270
         *
271
         * @return The required module's version or {@code null} if no specific version is required.
272
         */
273
        @MaybeNull
274
        String getVersion();
275

276
        /**
277
         * A simple implementation of {@link Requires}.
278
         */
279
        class Simple extends ModifierReviewable.AbstractBase implements Requires {
280

281
            /**
282
             * The version of the required module.
283
             */
284
            @MaybeNull
285
            private final String version;
286

287
            /**
288
             * The modifiers for this requires declaration.
289
             */
290
            private final int modifiers;
291

292
            /**
293
             * Creates a new simple requires declaration.
294
             *
295
             * @param version   The version of the required module or {@code null} if no specific version is required.
296
             * @param modifiers The modifiers for this requires declaration.
297
             */
UNCOV
298
            public Simple(@MaybeNull String version, int modifiers) {
×
UNCOV
299
                this.version = version;
×
UNCOV
300
                this.modifiers = modifiers;
×
UNCOV
301
            }
×
302

303
            /**
304
             * {@inheritDoc}
305
             */
306
            @MaybeNull
307
            public String getVersion() {
UNCOV
308
                return version;
×
309
            }
310

311
            /**
312
             * {@inheritDoc}
313
             */
314
            public int getModifiers() {
315
                return modifiers;
×
316
            }
317
        }
318
    }
319

320
    /**
321
     * Represents a service provider declaration in a module. Provides specify which service
322
     * implementations this module offers to other modules.
323
     */
324
    interface Provides {
325

326
        /**
327
         * Returns the implementation classes that provide the service.
328
         *
329
         * @return A set of class names that implement the service.
330
         */
331
        Set<String> getProviders();
332

333
        /**
334
         * A simple implementation of {@link Provides}.
335
         */
336
        class Simple implements Provides {
337

338
            /**
339
             * The implementation classes that provide the service.
340
             */
341
            private final Set<String> providers;
342

343
            /**
344
             * Creates a new simple provides declaration.
345
             *
346
             * @param providers The implementation classes that provide the service.
347
             */
UNCOV
348
            public Simple(Set<String> providers) {
×
UNCOV
349
                this.providers = providers;
×
UNCOV
350
            }
×
351

352
            /**
353
             * {@inheritDoc}
354
             */
355
            public Set<String> getProviders() {
UNCOV
356
                return providers;
×
357
            }
358
        }
359
    }
360

361
    /**
362
     * A {@link ModuleDescription} implementation that represents a loaded Java module.
363
     * This implementation uses reflection and Java dispatchers to access module information
364
     * from the runtime module system.
365
     */
366
    class ForLoadedModule extends ModifierReviewable.AbstractBase implements ModuleDescription {
367

368
        /**
369
         * A dispatcher for accessing {@code java.lang.Module} methods.
370
         */
371
        protected static final Module MODULE = doPrivileged(JavaDispatcher.of(Module.class));
×
372

373
        /**
374
         * A dispatcher for accessing {@code java.lang.ModuleDescriptor} methods.
375
         */
UNCOV
376
        protected static final ModuleDescriptor MODULE_DESCRIPTOR = doPrivileged(JavaDispatcher.of(ModuleDescriptor.class));
×
377

378
        /**
379
         * A dispatcher for accessing {@code java.lang.ModuleDescriptor.Exports} methods.
380
         */
UNCOV
381
        protected static final ModuleDescriptor.Exports MODULE_DESCRIPTOR_EXPORTS = doPrivileged(JavaDispatcher.of(ModuleDescriptor.Exports.class));
×
382

383
        /**
384
         * A dispatcher for accessing {@code java.lang.ModuleDescriptor.Exports.Modifier} methods.
385
         */
386
        protected static final ModuleDescriptor.Exports.Modifier MODULE_DESCRIPTOR_EXPORTS_MODIFIER = doPrivileged(JavaDispatcher.of(ModuleDescriptor.Exports.Modifier.class));
×
387

388
        /**
389
         * A dispatcher for accessing {@code java.lang.ModuleDescriptor.Opens} methods.
390
         */
391
        protected static final ModuleDescriptor.Opens MODULE_DESCRIPTOR_OPENS = doPrivileged(JavaDispatcher.of(ModuleDescriptor.Opens.class));
×
392

393
        /**
394
         * A dispatcher for accessing {@code java.lang.ModuleDescriptor.Opens.Modifier} methods.
395
         */
396
        protected static final ModuleDescriptor.Opens.Modifier MODULE_DESCRIPTOR_OPENS_MODIFIER = doPrivileged(JavaDispatcher.of(ModuleDescriptor.Opens.Modifier.class));
×
397

398
        /**
399
         * A dispatcher for accessing {@code java.lang.ModuleDescriptor.Requires} methods.
400
         */
401
        protected static final ModuleDescriptor.Requires MODULE_DESCRIPTOR_REQUIRES = doPrivileged(JavaDispatcher.of(ModuleDescriptor.Requires.class));
×
402

403
        /**
404
         * A dispatcher for accessing {@code java.lang.ModuleDescriptor.Requires.Modifier} methods.
405
         */
406
        protected static final ModuleDescriptor.Requires.Modifier MODULE_DESCRIPTOR_REQUIRES_MODIFIER = doPrivileged(JavaDispatcher.of(ModuleDescriptor.Requires.Modifier.class));
×
407

408
        /**
409
         * A dispatcher for accessing {@code java.lang.ModuleDescriptor.Provides} methods.
410
         */
411
        protected static final ModuleDescriptor.Provides MODULE_DESCRIPTOR_PROVIDES = doPrivileged(JavaDispatcher.of(ModuleDescriptor.Provides.class));
×
412

413
        /**
414
         * A dispatcher for accessing {@code java.util.Optional} methods.
415
         */
416
        protected static final Optional OPTIONAL = doPrivileged(JavaDispatcher.of(Optional.class));
×
417

418
        /**
419
         * The module represented by this description.
420
         */
421
        private final AnnotatedElement module;
422

423
        /**
424
         * Creates a module description for the supplied module.
425
         *
426
         * @param module The module to represent.
427
         * @return A module description for the supplied module.
428
         * @throws IllegalArgumentException If the supplied instance is not a module or if the module is unnamed.
429
         */
430
        public static ForLoadedModule of(Object module) {
431
            if (!MODULE.isInstance(module)) {
×
UNCOV
432
                throw new IllegalArgumentException("Not a Java module: " + module);
×
UNCOV
433
            } else if (!MODULE.isNamed(module)) {
×
UNCOV
434
                throw new IllegalArgumentException("Not a named module: " + module);
×
435
            }
UNCOV
436
            return new ForLoadedModule((AnnotatedElement) module);
×
437
        }
438

439
        /**
440
         * A proxy for {@code java.security.AccessController#doPrivileged} that is activated if available.
441
         *
442
         * @param action The action to execute from a privileged context.
443
         * @param <T>    The type of the action's resolved value.
444
         * @return The action's resolved value.
445
         */
446
        @AccessControllerPlugin.Enhance
447
        private static <T> T doPrivileged(PrivilegedAction<T> action) {
448
            return action.run();
×
449
        }
450

451
        /**
452
         * Creates a new module description for the supplied module.
453
         *
454
         * @param module The module to represent.
455
         */
UNCOV
456
        protected ForLoadedModule(AnnotatedElement module) {
×
UNCOV
457
            this.module = module;
×
UNCOV
458
        }
×
459

460
        /**
461
         * {@inheritDoc}
462
         */
463
        @MaybeNull
464
        public String getVersion() {
UNCOV
465
            return (String) OPTIONAL.orElse(MODULE_DESCRIPTOR.rawVersion(MODULE.getDescriptor(module)), null);
×
466
        }
467

468
        /**
469
         * {@inheritDoc}
470
         */
471
        @MaybeNull
472
        public String getMainClass() {
473
            return (String) OPTIONAL.orElse(MODULE_DESCRIPTOR.mainClass(MODULE.getDescriptor(module)), null);
×
474
        }
475

476
        /**
477
         * {@inheritDoc}
478
         */
479
        public boolean isOpen() {
480
            return MODULE_DESCRIPTOR.isOpen(MODULE.getDescriptor(module));
×
481
        }
482

483
        /**
484
         * {@inheritDoc}
485
         */
486
        public Set<String> getPackages() {
UNCOV
487
            return MODULE_DESCRIPTOR.packages(MODULE.getDescriptor(module));
×
488
        }
489

490
        /**
491
         * {@inheritDoc}
492
         */
493
        public Set<String> getUses() {
UNCOV
494
            return MODULE_DESCRIPTOR.uses(MODULE.getDescriptor(module));
×
495
        }
496

497
        /**
498
         * {@inheritDoc}
499
         */
500
        public Map<String, Exports> getExports() {
UNCOV
501
            Map<String, Exports> exports = new LinkedHashMap<String, Exports>();
×
502
            for (Object export : MODULE_DESCRIPTOR.exports(MODULE.getDescriptor(module))) {
×
UNCOV
503
                int modifiers = 0;
×
UNCOV
504
                for (Object modifier : MODULE_DESCRIPTOR_EXPORTS.modifiers(export)) {
×
UNCOV
505
                    modifiers |= MODULE_DESCRIPTOR_EXPORTS_MODIFIER.getMask(modifier);
×
UNCOV
506
                }
×
UNCOV
507
                exports.put(MODULE_DESCRIPTOR_EXPORTS.source(export), new Exports.Simple(MODULE_DESCRIPTOR_EXPORTS.targets(export), modifiers));
×
UNCOV
508
            }
×
509
            return exports;
×
510
        }
511

512
        /**
513
         * {@inheritDoc}
514
         */
515
        public Map<String, Opens> getOpens() {
516
            Map<String, Opens> opens = new LinkedHashMap<String, Opens>();
×
517
            for (Object open : MODULE_DESCRIPTOR.opens(MODULE.getDescriptor(module))) {
×
518
                int modifiers = 0;
×
519
                for (Object modifier : MODULE_DESCRIPTOR_OPENS.modifiers(open)) {
×
520
                    modifiers |= MODULE_DESCRIPTOR_OPENS_MODIFIER.getMask(modifier);
×
521
                }
×
522
                opens.put(MODULE_DESCRIPTOR_OPENS.source(open), new Opens.Simple(MODULE_DESCRIPTOR_OPENS.targets(open), modifiers));
×
523
            }
×
524
            return opens;
×
525
        }
526

527
        /**
528
         * {@inheritDoc}
529
         */
530
        public Map<String, Requires> getRequires() {
531
            Map<String, Requires> requires = new LinkedHashMap<String, Requires>();
×
532
            for (Object require : MODULE_DESCRIPTOR.requires(MODULE.getDescriptor(module))) {
×
533
                int modifiers = 0;
×
534
                for (Object modifier : MODULE_DESCRIPTOR_REQUIRES.modifiers(require)) {
×
535
                    modifiers |= MODULE_DESCRIPTOR_REQUIRES_MODIFIER.getMask(modifier);
×
536
                }
×
537
                requires.put(MODULE_DESCRIPTOR_REQUIRES.name(require), new Requires.Simple(
×
538
                        (String) OPTIONAL.orElse(MODULE_DESCRIPTOR_REQUIRES.rawCompiledVersion(require), null),
×
539
                        modifiers));
UNCOV
540
            }
×
UNCOV
541
            return requires;
×
542
        }
543

544
        /**
545
         * {@inheritDoc}
546
         */
547
        public Map<String, Provides> getProvides() {
548
            Map<String, Provides> provides = new LinkedHashMap<String, Provides>();
×
549
            for (Object require : MODULE_DESCRIPTOR.provides(MODULE.getDescriptor(module))) {
×
550
                provides.put(MODULE_DESCRIPTOR_PROVIDES.service(require), new Provides.Simple(MODULE_DESCRIPTOR_PROVIDES.provides(require)));
×
551
            }
×
552
            return provides;
×
553
        }
554

555
        /**
556
         * {@inheritDoc}
557
         */
558
        public int getModifiers() {
UNCOV
559
            int modifiers = 0;
×
UNCOV
560
            for (Object modifier : MODULE_DESCRIPTOR.modifiers(module)) {
×
UNCOV
561
                modifiers |= MODULE_DESCRIPTOR_REQUIRES_MODIFIER.getMask(modifier);
×
UNCOV
562
            }
×
563
            return modifiers;
×
564
        }
565

566
        /**
567
         * {@inheritDoc}
568
         */
569
        public String getActualName() {
UNCOV
570
            return MODULE_DESCRIPTOR.name(MODULE.getDescriptor(module));
×
571
        }
572

573
        /**
574
         * {@inheritDoc}
575
         */
576
        public AnnotationList getDeclaredAnnotations() {
577
            return new AnnotationList.ForLoadedAnnotations(module.getDeclaredAnnotations());
×
578
        }
579

580
        /**
581
         * A proxy for interacting with {@code java.lang.Module}.
582
         */
583
        @JavaDispatcher.Proxied("java.lang.Module")
584
        protected interface Module {
585

586
            /**
587
             * Returns {@code true} if the supplied instance is of type {@code java.lang.Module}.
588
             *
589
             * @param value The instance to investigate.
590
             * @return {@code true} if the supplied value is a {@code java.lang.Module}.
591
             */
592
            @JavaDispatcher.Instance
593
            boolean isInstance(Object value);
594

595
            /**
596
             * Returns {@code true} if the supplied module is named.
597
             *
598
             * @param value The {@code java.lang.Module} to check for the existence of a name.
599
             * @return {@code true} if the supplied module is named.
600
             */
601
            boolean isNamed(Object value);
602

603
            /**
604
             * Returns the module's name.
605
             *
606
             * @param value The {@code java.lang.Module} to check for its name.
607
             * @return The module's (implicit or explicit) name.
608
             */
609
            String getName(Object value);
610

611
            /**
612
             * Returns the module's exported packages.
613
             *
614
             * @param value The {@code java.lang.Module} to check for its packages.
615
             * @return The module's packages.
616
             */
617
            Set<String> getPackages(Object value);
618

619
            /**
620
             * Returns the module descriptor.
621
             * @param value The {@code java.lang.Module} to check for its descriptor.
622
             * @return The module's descriptor.
623
             */
624
            Object getDescriptor(Object value);
625
        }
626

627
        /**
628
         * A proxy for interacting with {@code java.lang.ModuleDescriptor}.
629
         */
630
        @JavaDispatcher.Proxied("java.lang.ModuleDescriptor")
631
        protected interface ModuleDescriptor {
632

633
            /**
634
             * Returns the module's name.
635
             *
636
             * @param value The {@code java.lang.ModuleDescriptor} instance.
637
             * @return The module's name.
638
             */
639
            String name(Object value);
640

641
            /**
642
             * Returns the module's modifiers.
643
             *
644
             * @param value The {@code java.lang.ModuleDescriptor} instance.
645
             * @return The module's modifiers.
646
             */
647
            Set<?> modifiers(Object value);
648

649
            /**
650
             * Returns {@code true} if this is an open module.
651
             *
652
             * @param value The {@code java.lang.ModuleDescriptor} instance.
653
             * @return {@code true} if this is an open module.
654
             */
655
            boolean isOpen(Object value);
656

657
            /**
658
             * Returns the module's requires declarations.
659
             *
660
             * @param value The {@code java.lang.ModuleDescriptor} instance.
661
             * @return The module's requires declarations.
662
             */
663
            Set<?> requires(Object value);
664

665
            /**
666
             * Returns the module's exports declarations.
667
             *
668
             * @param value The {@code java.lang.ModuleDescriptor} instance.
669
             * @return The module's exports declarations.
670
             */
671
            Set<?> exports(Object value);
672

673
            /**
674
             * Returns the module's opens declarations.
675
             *
676
             * @param value The {@code java.lang.ModuleDescriptor} instance.
677
             * @return The module's opens declarations.
678
             */
679
            Set<?> opens(Object value);
680

681
            /**
682
             * Returns the module's uses declarations.
683
             *
684
             * @param value The {@code java.lang.ModuleDescriptor} instance.
685
             * @return The module's uses declarations.
686
             */
687
            Set<String> uses(Object value);
688

689
            /**
690
             * Returns the module's provides declarations.
691
             *
692
             * @param value The {@code java.lang.ModuleDescriptor} instance.
693
             * @return The module's provides declarations.
694
             */
695
            Set<?> provides(Object value);
696

697
            /**
698
             * Returns the module's raw version.
699
             *
700
             * @param value The {@code java.lang.ModuleDescriptor} instance.
701
             * @return The module's raw version as an {@code Optional}.
702
             */
703
            Object rawVersion(Object value);
704

705
            /**
706
             * Returns the module's main class.
707
             *
708
             * @param value The {@code java.lang.ModuleDescriptor} instance.
709
             * @return The module's main class as an {@code Optional}.
710
             */
711
            Object mainClass(Object value);
712

713
            /**
714
             * Returns the module's packages.
715
             *
716
             * @param value The {@code java.lang.ModuleDescriptor} instance.
717
             * @return The module's packages.
718
             */
719
            Set<String> packages(Object value);
720

721
            /**
722
             * A proxy for interacting with {@code java.lang.ModuleDescriptor.Requires}.
723
             */
724
            @JavaDispatcher.Proxied("java.lang.ModuleDescriptor$Requires")
725
            interface Requires {
726

727
                /**
728
                 * Returns the name of the required module.
729
                 *
730
                 * @param value The {@code java.lang.ModuleDescriptor.Requires} instance.
731
                 * @return The name of the required module.
732
                 */
733
                String name(Object value);
734

735
                /**
736
                 * Returns the modifiers of the requires declaration.
737
                 *
738
                 * @param value The {@code java.lang.ModuleDescriptor.Requires} instance.
739
                 * @return The modifiers of the requires declaration.
740
                 */
741
                Set<?> modifiers(Object value);
742

743
                /**
744
                 * Returns the raw compiled version of the required module.
745
                 *
746
                 * @param value The {@code java.lang.ModuleDescriptor.Requires} instance.
747
                 * @return The raw compiled version as an {@code Optional}.
748
                 */
749
                Object rawCompiledVersion(Object value);
750

751
                /**
752
                 * A proxy for interacting with {@code java.lang.ModuleDescriptor.Requires.Modifier}.
753
                 */
754
                @JavaDispatcher.Proxied("java.lang.ModuleDescriptor$Requires$Modifier")
755
                interface Modifier {
756

757
                    /**
758
                     * Returns the mask value for this modifier.
759
                     *
760
                     * @param value The {@code java.lang.ModuleDescriptor.Requires.Modifier} instance.
761
                     * @return The mask value for this modifier.
762
                     */
763
                    int getMask(Object value);
764
                }
765
            }
766

767
            /**
768
             * A proxy for interacting with {@code java.lang.ModuleDescriptor.Exports}.
769
             */
770
            @JavaDispatcher.Proxied("java.lang.ModuleDescriptor$Exports")
771
            interface Exports {
772

773
                /**
774
                 * Returns the source package name for this export.
775
                 *
776
                 * @param value The {@code java.lang.ModuleDescriptor.Exports} instance.
777
                 * @return The source package name.
778
                 */
779
                String source(Object value);
780

781
                /**
782
                 * Returns the modifiers of the exports declaration.
783
                 *
784
                 * @param value The {@code java.lang.ModuleDescriptor.Exports} instance.
785
                 * @return The modifiers of the exports declaration.
786
                 */
787
                Set<?> modifiers(Object value);
788

789
                /**
790
                 * Returns the target modules for this export.
791
                 *
792
                 * @param value The {@code java.lang.ModuleDescriptor.Exports} instance.
793
                 * @return The target modules for this export.
794
                 */
795
                Set<String> targets(Object value);
796

797
                /**
798
                 * A proxy for interacting with {@code java.lang.ModuleDescriptor.Exports.Modifier}.
799
                 */
800
                @JavaDispatcher.Proxied("java.lang.ModuleDescriptor$Exports$Modifier")
801
                interface Modifier {
802

803
                    /**
804
                     * Returns the mask value for this modifier.
805
                     *
806
                     * @param value The {@code java.lang.ModuleDescriptor.Exports.Modifier} instance.
807
                     * @return The mask value for this modifier.
808
                     */
809
                    int getMask(Object value);
810
                }
811
            }
812

813
            /**
814
             * A proxy for interacting with {@code java.lang.ModuleDescriptor.Opens}.
815
             */
816
            @JavaDispatcher.Proxied("java.lang.ModuleDescriptor$Opens")
817
            interface Opens {
818

819
                /**
820
                 * Returns the source package name for this opens declaration.
821
                 *
822
                 * @param value The {@code java.lang.ModuleDescriptor.Opens} instance.
823
                 * @return The source package name.
824
                 */
825
                String source(Object value);
826

827
                /**
828
                 * Returns the modifiers of the opens declaration.
829
                 *
830
                 * @param value The {@code java.lang.ModuleDescriptor.Opens} instance.
831
                 * @return The modifiers of the opens declaration.
832
                 */
833
                Set<?> modifiers(Object value);
834

835
                /**
836
                 * Returns the target modules for this opens declaration.
837
                 *
838
                 * @param value The {@code java.lang.ModuleDescriptor.Opens} instance.
839
                 * @return The target modules for this opens declaration.
840
                 */
841
                Set<String> targets(Object value);
842

843
                /**
844
                 * A proxy for interacting with {@code java.lang.ModuleDescriptor.Opens.Modifier}.
845
                 */
846
                @JavaDispatcher.Proxied("java.lang.ModuleDescriptor$Opens$Modifier")
847
                interface Modifier {
848

849
                    /**
850
                     * Returns the mask value for this modifier.
851
                     *
852
                     * @param value The {@code java.lang.ModuleDescriptor.Opens.Modifier} instance.
853
                     * @return The mask value for this modifier.
854
                     */
855
                    int getMask(Object value);
856
                }
857
            }
858

859
            /**
860
             * A proxy for interacting with {@code java.lang.ModuleDescriptor.Provides}.
861
             */
862
            @JavaDispatcher.Proxied("java.lang.ModuleDescriptor$Provides")
863
            interface Provides {
864

865
                /**
866
                 * Returns the service interface name for this provides declaration.
867
                 *
868
                 * @param value The {@code java.lang.ModuleDescriptor.Provides} instance.
869
                 * @return The service interface name.
870
                 */
871
                String service(Object value);
872

873
                /**
874
                 * Returns the provider implementation class names for this provides declaration.
875
                 *
876
                 * @param value The {@code java.lang.ModuleDescriptor.Provides} instance.
877
                 * @return The provider implementation class names.
878
                 */
879
                Set<String> provides(Object value);
880
            }
881
        }
882

883
        /**
884
         * A proxy for interacting with {@code java.util.Optional}.
885
         */
886
        @JavaDispatcher.Proxied("java.lang.Optional")
887
        protected interface Optional {
888

889
            /**
890
             * Returns the value if present, otherwise returns the fallback value.
891
             *
892
             * @param value    The {@code java.util.Optional} instance.
893
             * @param fallback The fallback value to return if the optional is empty.
894
             * @return The value if present, otherwise the fallback value.
895
             */
896
            @MaybeNull
897
            Object orElse(Object value, @MaybeNull Object fallback);
898
        }
899
    }
900
}
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