Skip to content

Commit 35eace2

Browse files
authored
Road grading; cleans documentation; adds notion of well-defined annotation sameness (#38)
Signed-off-by: Laird Nelson <ljnelson@gmail.com>
1 parent 3523dde commit 35eace2

21 files changed

+676
-169
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ dependency:
3636
Always check https://search.maven.org/artifact/org.microbean/microbean-construct
3737
for up-to-date available versions.
3838
-->
39-
<version>0.0.22</version>
39+
<version>0.0.23</version>
4040
</dependency>
4141
```
4242

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@
253253
<dependency>
254254
<groupId>com.puppycrawl.tools</groupId>
255255
<artifactId>checkstyle</artifactId>
256-
<version>13.0.0</version>
256+
<version>13.2.0</version>
257257
</dependency>
258258
</dependencies>
259259
</plugin>
@@ -284,7 +284,7 @@
284284
</plugin>
285285
<plugin>
286286
<artifactId>maven-dependency-plugin</artifactId>
287-
<version>3.9.0</version>
287+
<version>3.10.0</version>
288288
</plugin>
289289
<plugin>
290290
<artifactId>maven-deploy-plugin</artifactId>

src/main/java/module-info.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* -*- mode: Java; c-basic-offset: 2; indent-tabs-mode: nil; coding: utf-8-unix -*-
22
*
3-
* Copyright © 2024 microBean™.
3+
* Copyright © 2024–2026 microBean™.
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
66
* the License. You may obtain a copy of the License at
@@ -13,7 +13,7 @@
1313
*/
1414

1515
/**
16-
* Provides packages related to Java constructs.
16+
* Provides packages related to valid Java language constructs.
1717
*
1818
* @author <a href="https://about.me/lairdnelson" target="_top">Laird Nelson</a>
1919
*

src/main/java/org/microbean/construct/BlockingCompilationTask.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* -*- mode: Java; c-basic-offset: 2; indent-tabs-mode: nil; coding: utf-8-unix -*-
22
*
3-
* Copyright © 2024–2025 microBean™.
3+
* Copyright © 2024–2026 microBean™.
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
66
* the License. You may obtain a copy of the License at
@@ -170,7 +170,7 @@ public final void run() {
170170
options.add("-verbose");
171171
}
172172

173-
// Use an appropriate compiler-supplied thread-safe name table.
173+
// Use an appropriate compiler-supplied name table. None are thread-safe, sadly.
174174
installNameTableOptions(options::add);
175175

176176
// Propagate the current classpath to the compiler environment.
@@ -193,7 +193,7 @@ public final void run() {
193193
moduleLocations),
194194
diagnosticLogger,
195195
options,
196-
List.of("java.lang.Deprecated"), // arbitrary, but is always read by the compiler no matter what so incurs no extra reads
196+
List.of("java.lang.Deprecated"), // arbitrary, but always read by the compiler no matter what so incurs no extra reads
197197
null); // no compilation units; we're -proc:only
198198
task.setLocale(locale);
199199
task.addModules(additionalRootModuleNames);
@@ -252,6 +252,7 @@ private final Set<String> additionalRootModuleNames(final Consumer<? super ReadO
252252
return Collections.unmodifiableSet(additionalRootModuleNames);
253253
}
254254

255+
// (Invoked only by method reference.)
255256
private final void obtrudeException() {
256257
// Ideally we'd use CancellationException but see
257258
// https://github.com/openjdk/jdk/blob/jdk-25%2B3/src/java.base/share/classes/java/util/concurrent/CompletableFuture.java#L2210.

src/main/java/org/microbean/construct/DefaultDomain.java

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* -*- mode: Java; c-basic-offset: 2; indent-tabs-mode: nil; coding: utf-8-unix -*-
22
*
3-
* Copyright © 2024–2025 microBean™.
3+
* Copyright © 2024–2026 microBean™.
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
66
* the License. You may obtain a copy of the License at
@@ -55,7 +55,7 @@
5555
import static java.lang.constant.ConstantDescs.BSM_INVOKE;
5656

5757
/**
58-
* A {@linkplain Domain domain of Java constructs} that can be used at annotation processing time or at runtime.
58+
* A {@linkplain Domain domain of valid Java constructs} that can be used at annotation processing time or at runtime.
5959
*
6060
* @author <a href="https://about.me/lairdnelson" target="_top">Laird Nelson</a>
6161
*
@@ -83,13 +83,15 @@ public DefaultDomain() {
8383
* Creates a new {@link DefaultDomain} <strong>normally for use at annotation processing time</strong>, whose usage
8484
* type is actually determined by the argument supplied to this constructor.
8585
*
86-
* @param pe a {@link ProcessingEnvironment}; may be {@code null} in which case the return value of an invocation of
87-
* {@link Supplier#get()} on the return value of an invocation of {@link RuntimeProcessingEnvironmentSupplier#of()}
88-
* will be used instead
86+
* @param pe a {@link ProcessingEnvironment}; may be {@code null} (<strong>the expected value for runtime
87+
* usage</strong>), in which case the return value of an invocation of {@link Supplier#get()} on the return value of
88+
* an invocation of {@link RuntimeProcessingEnvironmentSupplier#of()} will be used instead
8989
*
9090
* @see #DefaultDomain(ProcessingEnvironment, Lock)
9191
*
92-
* @see SymbolCompletionLock
92+
* @see RuntimeProcessingEnvironmentSupplier#get()
93+
*
94+
* @see SymbolCompletionLock#INSTANCE
9395
*/
9496
public DefaultDomain(final ProcessingEnvironment pe) {
9597
this(pe, null);
@@ -103,9 +105,9 @@ public DefaultDomain(final ProcessingEnvironment pe) {
103105
*
104106
* @see #DefaultDomain(ProcessingEnvironment, Lock)
105107
*
106-
* @see RuntimeProcessingEnvironmentSupplier
108+
* @see RuntimeProcessingEnvironmentSupplier#get()
107109
*
108-
* @see SymbolCompletionLock
110+
* @see SymbolCompletionLock#INSTANCE
109111
*/
110112
public DefaultDomain(final Lock lock) {
111113
this(null, lock);
@@ -115,18 +117,18 @@ public DefaultDomain(final Lock lock) {
115117
* Creates a new {@link DefaultDomain} <strong>normally for use at annotation processing time</strong>, whose usage
116118
* type is actually determined by the arguments supplied to this constructor.
117119
*
118-
* @param pe a {@link ProcessingEnvironment}; may be {@code null} in which case the return value of an invocation of
119-
* {@link Supplier#get()} on the return value of an invocation of {@link RuntimeProcessingEnvironmentSupplier#of()}
120-
* will be used instead
120+
* @param pe a {@link ProcessingEnvironment}; may be {@code null} (<strong>the expected value for runtime
121+
* usage</strong>), in which case the return value of an invocation of {@link Supplier#get()} on the return value of
122+
* an invocation of {@link RuntimeProcessingEnvironmentSupplier#of()} will be used instead
121123
*
122124
* @param lock a {@link Lock} to use to serialize symbol completion; if {@code null} and {@code pe} is {@code null},
123125
* then a global {@link ReentrantLock} will be used instead; if {@code null} and {@code pe} is non-{@code null}, then
124126
* no serialization of symbol completion will occur <strong>and this {@link DefaultDomain} therefore will not be safe
125127
* for concurrent use by multiple threads</strong>
126128
*
127-
* @see RuntimeProcessingEnvironmentSupplier
129+
* @see RuntimeProcessingEnvironmentSupplier#get()
128130
*
129-
* @see SymbolCompletionLock
131+
* @see SymbolCompletionLock#INSTANCE
130132
*/
131133
public DefaultDomain(final ProcessingEnvironment pe, final Lock lock) {
132134
super();
@@ -159,7 +161,7 @@ public List<? extends UniversalElement> allMembers(TypeElement e) {
159161
return UniversalElement.of(this.elements().getAllMembers(e), this);
160162
}
161163
}
162-
164+
163165
/**
164166
* Returns a {@link UniversalType} representing an {@link javax.lang.model.type.ArrayType} whose {@linkplain
165167
* javax.lang.model.type.ArrayType#getComponentType() component type} {@linkplain #sameType(TypeMirror, TypeMirror) is
@@ -611,8 +613,10 @@ public UniversalType wildcardType(TypeMirror extendsBound, TypeMirror superBound
611613
*/
612614

613615

616+
// (Invoked only by method reference.)
614617
private static final void doNothing() {}
615618

619+
// (Invoked only by method reference.)
616620
private static final Unlockable noopLock() {
617621
return DefaultDomain::doNothing;
618622
}
@@ -626,7 +630,7 @@ private static final <E extends Element> E unwrap(final E e) {
626630
}
627631

628632
private static final TypeMirror[] unwrap(final TypeMirror[] ts) {
629-
if (ts == null || ts.length <= 0) {
633+
if (ts == null || ts.length == 0) {
630634
return ts;
631635
}
632636
final TypeMirror[] rv = new TypeMirror[ts.length];

src/main/java/org/microbean/construct/Domain.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@
6666
import static javax.lang.model.type.TypeKind.DECLARED;
6767

6868
/**
69-
* A representation of a domain of valid Java constructs.
69+
* A {@link PrimordialDomain} that represents a domain of valid Java language constructs.
7070
*
71-
* <p>A <dfn id="domain">domain</dfn> is a set of valid Java <a href="#construct">constructs</a>. A {@link Domain}
72-
* provides access to a domain and its members.</p>
71+
* <p>A <dfn id="domain">domain</dfn> is a set of valid Java language <a href="#construct">constructs</a>. A {@link
72+
* Domain} provides access to a domain and its members.</p>
7373
*
7474
* <p>A Java <dfn id="construct">construct</dfn> is either a <a href="#type">type</a> or an <a
7575
* href="#element">element</a>.</p>
@@ -91,6 +91,8 @@
9191
*
9292
* @see PrimordialDomain
9393
*
94+
* @see DefaultDomain
95+
*
9496
* @see <a href="https://bugs.openjdk.org/browse/JDK-8055219">JDK-8055219</a>
9597
*/
9698
@SuppressWarnings("try")

src/main/java/org/microbean/construct/PrimordialDomain.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* -*- mode: Java; c-basic-offset: 2; indent-tabs-mode: nil; coding: utf-8-unix -*-
22
*
3-
* Copyright © 2025 microBean™.
3+
* Copyright © 2025–2026 microBean™.
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
66
* the License. You may obtain a copy of the License at
@@ -42,6 +42,8 @@
4242
* @see #noType(TypeKind)
4343
*
4444
* @see #nullType()
45+
*
46+
* @see Domain
4547
*/
4648
public interface PrimordialDomain {
4749

@@ -95,7 +97,7 @@ public interface PrimordialDomain {
9597
/**
9698
* Returns a (non-{@code null}, determinate) {@link NullType} representing the null type.
9799
*
98-
* <p>Implementations of thsi method must not return {@code null}.</p>
100+
* <p>Implementations of this method must not return {@code null}.</p>
99101
*
100102
* @return a {@link NullType} representing the null type; never {@code null}
101103
*
@@ -110,9 +112,9 @@ public interface PrimordialDomain {
110112
* <p>The default implementation of this method may return {@code null} if the supplied {@code name} is {@code
111113
* null}.</p>
112114
*
113-
* <p>In many implementations of domains, converting a {@link Name} to a {@link String} can cause problems if symbol
114-
* completion is taking place concurrently and the symbol completion lock is not held. This method helps avoid those
115-
* problems.</p>
115+
* <p>In many implementations of {@link PrimordialDomain}s, converting a {@link Name} to a {@link String} can cause
116+
* problems if symbol completion is taking place concurrently and the symbol completion lock is not held. This method
117+
* helps avoid those problems.</p>
116118
*
117119
* <p>Overriding this method is not normally needed.</p>
118120
*
@@ -139,5 +141,5 @@ public default String toString(final CharSequence name) {
139141
default -> name.toString();
140142
};
141143
}
142-
144+
143145
}

src/main/java/org/microbean/construct/Processor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* -*- mode: Java; c-basic-offset: 2; indent-tabs-mode: nil; coding: utf-8-unix -*-
22
*
3-
* Copyright © 2024–2025 microBean™.
3+
* Copyright © 2024–2026 microBean™.
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
66
* the License. You may obtain a copy of the License at
@@ -204,6 +204,7 @@ public final boolean process(final Set<? extends TypeElement> annotations, final
204204
return false;
205205
}
206206

207+
// (Invoked only by method reference.)
207208
private static final void sink() {}
208209

209210
}

src/main/java/org/microbean/construct/RuntimeProcessingEnvironmentSupplier.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* -*- mode: Java; c-basic-offset: 2; indent-tabs-mode: nil; coding: utf-8-unix -*-
22
*
3-
* Copyright © 2024–2025 microBean™.
3+
* Copyright © 2024–2026 microBean™.
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
66
* the License. You may obtain a copy of the License at
@@ -29,6 +29,9 @@
2929
/**
3030
* A utility class that can {@linkplain #of() supply} a {@link ProcessingEnvironment} suitable for use at runtime.
3131
*
32+
* <p>Most users should simply {@linkplain DefaultDomain#DefaultDomain() use an appropriate <code>DefaultDomain</code>}
33+
* instead of working directly with instances of this class.</p>
34+
*
3235
* @author <a href="https://about.me/lairdnelson" target="_top">Laird Nelson</a>
3336
*
3437
* @see #get()
@@ -39,7 +42,7 @@
3942
*
4043
* @see ProcessingEnvironment
4144
*
42-
* @see Domain
45+
* @see DefaultDomain#DefaultDomain()
4346
*/
4447
public final class RuntimeProcessingEnvironmentSupplier implements AutoCloseable, Supplier<ProcessingEnvironment> {
4548

@@ -103,9 +106,12 @@ public final void close() {
103106
* <p><strong>{@link ProcessingEnvironment} instances are not guaranteed to be safe for concurrent use by multiple
104107
* threads.</strong></p>
105108
*
109+
* <p>Most users should simply use an appropriate {@link DefaultDomain} instead of working directly with instances of
110+
* this class.</p>
111+
*
106112
* @return a non-{@code null} {@link ProcessingEnvironment}
107113
*
108-
* @see Domain
114+
* @see DefaultDomain#DefaultDomain()
109115
*/
110116
@Override // Supplier<ProcessingEnvironment>
111117
public final ProcessingEnvironment get() {
@@ -139,11 +145,14 @@ private static final BlockingCompilationTask install(final Consumer<? super Bloc
139145
/**
140146
* Returns a non-{@code null} {@link RuntimeProcessingEnvironmentSupplier}.
141147
*
148+
* <p>Most users should simply use an appropriate {@link DefaultDomain} instead of working directly with instances of
149+
* this class.</p>
150+
*
142151
* @return a non-{@code null} {@link RuntimeProcessingEnvironmentSupplier}
143152
*
144153
* @see ProcessingEnvironment
145154
*
146-
* @see Domain
155+
* @see DefaultDomain#DefaultDomain()
147156
*/
148157
public static final RuntimeProcessingEnvironmentSupplier of() {
149158
return INSTANCE;

src/main/java/org/microbean/construct/SymbolCompletionLock.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* -*- mode: Java; c-basic-offset: 2; indent-tabs-mode: nil; coding: utf-8-unix -*-
22
*
3-
* Copyright © 2024 microBean™.
3+
* Copyright © 2024–2026 microBean™.
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
66
* the License. You may obtain a copy of the License at
@@ -19,13 +19,18 @@
1919
* A class holding a {@link ReentrantLock} that should be used to serialize <dfn>symbol completion</dfn> and <dfn>name
2020
* expansion</dfn>.
2121
*
22+
* <p>Most users should simply {@linkplain DefaultDomain#DefaultDomain() use an appropriate <code>DefaultDomain</code>}
23+
* instead of working directly with instances of this class.</p>
24+
*
2225
* @author <a href="https://about.me/lairdnelson" target="_top">Laird Nelson</a>
2326
*
2427
* @see #INSTANCE
2528
*
2629
* @see Domain#lock()
2730
*
2831
* @see Domain#toString(CharSequence)
32+
*
33+
* @see DefaultDomain#DefaultDomain()
2934
*/
3035
public final class SymbolCompletionLock {
3136

0 commit comments

Comments
 (0)