Skip to content

Commit 223268b

Browse files
committed
Rework internal exceptions to be tied to custom exception types where appropriate
1 parent f43ee0b commit 223268b

File tree

59 files changed

+710
-348
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+710
-348
lines changed

java-compiler-testing/pom.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
limitations under the License.
1717
1818
-->
19-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
19+
<project xmlns="http://maven.apache.org/POM/4.0.0"
20+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
21+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2022
<modelVersion>4.0.0</modelVersion>
2123

2224
<parent>

java-compiler-testing/src/main/java/io/github/ascopes/jct/assertions/JctCompilationAssert.java

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,11 @@ public TraceDiagnosticListAssert diagnostics() {
157157
*
158158
* @param location the location to configure.
159159
* @return the assertions to perform.
160-
* @throws AssertionError if the compilation was null, or no group for the location
161-
* was found.
160+
* @throws AssertionError if the compilation was null, or no group for the location was
161+
* found.
162162
* @throws IllegalArgumentException if the location was
163-
* {@link Location#isModuleOrientedLocation() module-oriented}
164-
* or {@link Location#isOutputLocation() an output location}.
163+
* {@link Location#isModuleOrientedLocation() module-oriented} or
164+
* {@link Location#isOutputLocation() an output location}.
165165
* @throws NullPointerException if the provided location object is null.
166166
*/
167167
public PackageContainerGroupAssert packageGroup(Location location) {
@@ -193,8 +193,8 @@ public PackageContainerGroupAssert packageGroup(Location location) {
193193
*
194194
* @param location the location to configure.
195195
* @return the assertions to perform.
196-
* @throws AssertionError if the compilation was null, or no group for the location
197-
* was found.
196+
* @throws AssertionError if the compilation was null, or no group for the location was
197+
* found.
198198
* @throws IllegalArgumentException if the location is not
199199
* {@link Location#isModuleOrientedLocation() module-oriented}.
200200
* @throws NullPointerException if the provided location object is null.
@@ -228,8 +228,8 @@ public ModuleContainerGroupAssert moduleGroup(Location location) {
228228
*
229229
* @param location the location to configure.
230230
* @return the assertions to perform.
231-
* @throws AssertionError if the compilation was null, or no group for the location
232-
* was found.
231+
* @throws AssertionError if the compilation was null, or no group for the location was
232+
* found.
233233
* @throws IllegalArgumentException if the location is not
234234
* {@link Location#isOutputLocation() an output location}.
235235
* @throws NullPointerException if the provided location object is null.
@@ -256,8 +256,7 @@ public OutputContainerGroupAssert outputGroup(Location location) {
256256
* <p>If not configured, the value being asserted on will be {@code null} in value.
257257
*
258258
* @return the assertions to perform on the class package outputs.
259-
* @throws AssertionError if the compilation was null, or no group for the location
260-
* was found.
259+
* @throws AssertionError if the compilation was null, or no group for the location was found.
261260
*/
262261
@API(since = "0.6.4", status = Status.STABLE)
263262
public PackageContainerGroupAssert classOutputPackages() {
@@ -270,8 +269,7 @@ public PackageContainerGroupAssert classOutputPackages() {
270269
* <p>If not configured, the value being asserted on will be {@code null} in value.
271270
*
272271
* @return the assertions to perform on the class module outputs.
273-
* @throws AssertionError if the compilation was null, or no group for the location
274-
* was found.
272+
* @throws AssertionError if the compilation was null, or no group for the location was found.
275273
*/
276274
@API(since = "0.6.4", status = Status.STABLE)
277275
public ModuleContainerGroupAssert classOutputModules() {
@@ -284,8 +282,7 @@ public ModuleContainerGroupAssert classOutputModules() {
284282
* <p>If not configured, the value being asserted on will be {@code null} in value.
285283
*
286284
* @return the assertions to perform on the source package outputs.
287-
* @throws AssertionError if the compilation was null, or no group for the location
288-
* was found.
285+
* @throws AssertionError if the compilation was null, or no group for the location was found.
289286
*/
290287
@API(since = "0.6.4", status = Status.STABLE)
291288
public PackageContainerGroupAssert sourceOutputPackages() {
@@ -298,8 +295,7 @@ public PackageContainerGroupAssert sourceOutputPackages() {
298295
* <p>If not configured, the value being asserted on will be {@code null} in value.
299296
*
300297
* @return the assertions to perform on the source module outputs.
301-
* @throws AssertionError if the compilation was null, or no group for the location
302-
* was found.
298+
* @throws AssertionError if the compilation was null, or no group for the location was found.
303299
*/
304300
@API(since = "0.6.4", status = Status.STABLE)
305301
public ModuleContainerGroupAssert sourceOutputModules() {
@@ -312,8 +308,7 @@ public ModuleContainerGroupAssert sourceOutputModules() {
312308
* <p>If not configured, the value being asserted on will be {@code null} in value.
313309
*
314310
* @return the assertions to perform on the class path.
315-
* @throws AssertionError if the compilation was null, or no group for the location
316-
* was found.
311+
* @throws AssertionError if the compilation was null, or no group for the location was found.
317312
*/
318313
@API(since = "0.6.4", status = Status.STABLE)
319314
public PackageContainerGroupAssert classPathPackages() {
@@ -326,8 +321,7 @@ public PackageContainerGroupAssert classPathPackages() {
326321
* <p>If not configured, the value being asserted on will be {@code null} in value.
327322
*
328323
* @return the assertions to perform on the source path.
329-
* @throws AssertionError if the compilation was null, or no group for the location
330-
* was found.
324+
* @throws AssertionError if the compilation was null, or no group for the location was found.
331325
*/
332326
@API(since = "0.6.4", status = Status.STABLE)
333327
public PackageContainerGroupAssert sourcePathPackages() {
@@ -340,8 +334,7 @@ public PackageContainerGroupAssert sourcePathPackages() {
340334
* <p>If not configured, the value being asserted on will be {@code null} in value.
341335
*
342336
* @return the assertions to perform on the source path.
343-
* @throws AssertionError if the compilation was null, or no group for the location
344-
* was found.
337+
* @throws AssertionError if the compilation was null, or no group for the location was found.
345338
*/
346339
@API(since = "0.6.4", status = Status.STABLE)
347340
public ModuleContainerGroupAssert moduleSourcePathModules() {
@@ -354,8 +347,7 @@ public ModuleContainerGroupAssert moduleSourcePathModules() {
354347
* <p>If not configured, the value being asserted on will be {@code null} in value.
355348
*
356349
* @return the assertions to perform on the module path.
357-
* @throws AssertionError if the compilation was null, or no group for the location
358-
* was found.
350+
* @throws AssertionError if the compilation was null, or no group for the location was found.
359351
*/
360352
@API(since = "0.6.4", status = Status.STABLE)
361353
public ModuleContainerGroupAssert modulePathModules() {

java-compiler-testing/src/main/java/io/github/ascopes/jct/assertions/StackTraceAssert.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
*/
3535
@API(since = "0.0.1", status = Status.STABLE)
3636
public final class StackTraceAssert
37-
extends AbstractListAssert<StackTraceAssert, List<? extends StackTraceElement>, StackTraceElement, StackTraceElementAssert> {
37+
extends
38+
AbstractListAssert<StackTraceAssert, List<? extends StackTraceElement>, StackTraceElement, StackTraceElementAssert> {
3839

3940
/**
4041
* Initialize a new assertions object.

java-compiler-testing/src/main/java/io/github/ascopes/jct/assertions/TraceDiagnosticListAssert.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@
4646
*/
4747
@API(since = "0.0.1", status = Status.STABLE)
4848
public final class TraceDiagnosticListAssert
49-
extends AbstractListAssert<TraceDiagnosticListAssert, List<? extends TraceDiagnostic<? extends JavaFileObject>>, TraceDiagnostic<? extends JavaFileObject>, TraceDiagnosticAssert> {
49+
extends
50+
AbstractListAssert<TraceDiagnosticListAssert, List<? extends TraceDiagnostic<? extends JavaFileObject>>, TraceDiagnostic<? extends JavaFileObject>, TraceDiagnosticAssert> {
5051

5152
/**
5253
* Initialize this assertion.

java-compiler-testing/src/main/java/io/github/ascopes/jct/compilers/AbstractJctCompiler.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ public JctCompilation compile(Workspace workspace, Collection<String> classNames
121121
}
122122

123123
@Override
124-
public final <E extends Exception> AbstractJctCompiler configure(JctCompilerConfigurer<E> configurer) throws E {
124+
public final <E extends Exception> AbstractJctCompiler configure(
125+
JctCompilerConfigurer<E> configurer) throws E {
125126
requireNonNull(configurer, "configurer");
126127
configurer.configure(this);
127128
return this;
@@ -210,7 +211,8 @@ public List<String> getAnnotationProcessorOptions() {
210211
}
211212

212213
@Override
213-
public AbstractJctCompiler addAnnotationProcessorOptions(Iterable<String> annotationProcessorOptions) {
214+
public AbstractJctCompiler addAnnotationProcessorOptions(
215+
Iterable<String> annotationProcessorOptions) {
214216
requireNonNullValues(annotationProcessorOptions, "annotationProcessorOptions");
215217
annotationProcessorOptions.forEach(this.annotationProcessorOptions::add);
216218
return this;
@@ -222,7 +224,8 @@ public List<Processor> getAnnotationProcessors() {
222224
}
223225

224226
@Override
225-
public AbstractJctCompiler addAnnotationProcessors(Iterable<? extends Processor> annotationProcessors) {
227+
public AbstractJctCompiler addAnnotationProcessors(
228+
Iterable<? extends Processor> annotationProcessors) {
226229
requireNonNullValues(annotationProcessors, "annotationProcessors");
227230
annotationProcessors.forEach(this.annotationProcessors::add);
228231

@@ -396,7 +399,8 @@ public AnnotationProcessorDiscovery getAnnotationProcessorDiscovery() {
396399
}
397400

398401
@Override
399-
public AbstractJctCompiler annotationProcessorDiscovery(AnnotationProcessorDiscovery annotationProcessorDiscovery) {
402+
public AbstractJctCompiler annotationProcessorDiscovery(
403+
AnnotationProcessorDiscovery annotationProcessorDiscovery) {
400404
this.annotationProcessorDiscovery = requireNonNull(
401405
annotationProcessorDiscovery,
402406
"annotationProcessorDiscovery"
@@ -431,7 +435,8 @@ public final String toString() {
431435
public abstract Jsr199CompilerFactory getCompilerFactory();
432436

433437
/**
434-
* Get the file manager factory to use for building AbstractJctCompiler file manager during compilation.
438+
* Get the file manager factory to use for building AbstractJctCompiler file manager during
439+
* compilation.
435440
*
436441
* <p>Since v1.1.0, this method has provided a default implementation. Before this, it was
437442
* abstract. The default implementation calls
@@ -451,8 +456,8 @@ public JctFileManagerFactory getFileManagerFactory() {
451456
*
452457
* <p>Some obscure compiler implementations with potentially satanic rituals for initialising
453458
* and configuring components correctly may need to provide a custom implementation here instead.
454-
* In this case, this method should be overridden. Base classes are not provided for you to
455-
* extend in this case as this is usually not something you want to be doing. Instead, you should
459+
* In this case, this method should be overridden. Base classes are not provided for you to extend
460+
* in this case as this is usually not something you want to be doing. Instead, you should
456461
* implement {@link JctCompilationFactory} directly.
457462
*
458463
* @return the compilation factory.

java-compiler-testing/src/main/java/io/github/ascopes/jct/compilers/JctCompilationFactory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ public interface JctCompilationFactory {
4444
* @return the compilation result that contains whether the compiler succeeded or failed, amongst
4545
* other information.
4646
* @throws JctCompilerException if any prerequisites fail, such as no compilation units being
47-
* found, or if the underlying JSR-199 compiler raises an unhandled exception and cannot
48-
* complete when invoked.
47+
* found, or if the underlying JSR-199 compiler raises an unhandled
48+
* exception and cannot complete when invoked.
4949
*/
5050
JctCompilation createCompilation(
5151
List<String> flags,

java-compiler-testing/src/main/java/io/github/ascopes/jct/compilers/JctCompiler.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ public interface JctCompiler {
157157
* @see #compile(Workspace)
158158
* @see #compile(Workspace, Collection)
159159
*/
160-
default JctCompilation compile(Workspace workspace, String firstClassName, String... additionalClassNames) {
160+
default JctCompilation compile(Workspace workspace, String firstClassName,
161+
String... additionalClassNames) {
161162
return compile(workspace, IterableUtils.combineOneOrMore(firstClassName, additionalClassNames));
162163
}
163164

@@ -842,5 +843,6 @@ default JctCompiler target(SourceVersion target) {
842843
* @param annotationProcessorDiscovery the processor discovery mode to use.
843844
* @return this compiler for further call chaining.
844845
*/
845-
JctCompiler annotationProcessorDiscovery(AnnotationProcessorDiscovery annotationProcessorDiscovery);
846+
JctCompiler annotationProcessorDiscovery(
847+
AnnotationProcessorDiscovery annotationProcessorDiscovery);
846848
}

java-compiler-testing/src/main/java/io/github/ascopes/jct/containers/Container.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ public interface Container extends Closeable {
9999
* in, rather than the location of the archive on the original file system.
100100
*
101101
* <p>It is worth noting that this operation may result in the archive being loaded into memory
102-
* eagerly if it uses lazy loading, due to the need to load the archive to be able to determine
103-
* an accurate handle to the inner root directory.
102+
* eagerly if it uses lazy loading, due to the need to load the archive to be able to determine an
103+
* accurate handle to the inner root directory.
104104
*
105105
* @return the path root.
106106
* @since 0.0.6

java-compiler-testing/src/main/java/io/github/ascopes/jct/containers/OutputContainerGroup.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
* group. Operations on non-module packages should operate on this container group directly.
3333
*
3434
* <p>Note that each container group will usually only support one package container group
35-
* in the outputs. This is due to the JSR-199 API not providing a method for specifying which
36-
* output location to write files to for legacy-style packages.
35+
* in the outputs. This is due to the JSR-199 API not providing a method for specifying which output
36+
* location to write files to for legacy-style packages.
3737
*
3838
* @author Ashley Scopes
3939
* @since 0.0.1
@@ -81,7 +81,7 @@ public interface OutputContainerGroup extends PackageContainerGroup, ModuleConta
8181
* JSR-199 limitations.
8282
*
8383
* @return the list containing the package container, if it exists. Otherwise, an empty list is
84-
* returned instead.
84+
* returned instead.
8585
*/
8686
@Override
8787
List<Container> getPackages();

0 commit comments

Comments
 (0)