Skip to content

Commit

Permalink
Rework internal exceptions to be tied to custom exception types where…
Browse files Browse the repository at this point in the history
… appropriate
  • Loading branch information
ascopes committed Jul 30, 2023
1 parent f43ee0b commit 223268b
Show file tree
Hide file tree
Showing 59 changed files with 710 additions and 348 deletions.
4 changes: 3 additions & 1 deletion java-compiler-testing/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
limitations under the License.
-->
<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">
<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">
<modelVersion>4.0.0</modelVersion>

<parent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,11 @@ public TraceDiagnosticListAssert diagnostics() {
*
* @param location the location to configure.
* @return the assertions to perform.
* @throws AssertionError if the compilation was null, or no group for the location
* was found.
* @throws AssertionError if the compilation was null, or no group for the location was
* found.
* @throws IllegalArgumentException if the location was
* {@link Location#isModuleOrientedLocation() module-oriented}
* or {@link Location#isOutputLocation() an output location}.
* {@link Location#isModuleOrientedLocation() module-oriented} or
* {@link Location#isOutputLocation() an output location}.
* @throws NullPointerException if the provided location object is null.
*/
public PackageContainerGroupAssert packageGroup(Location location) {
Expand Down Expand Up @@ -193,8 +193,8 @@ public PackageContainerGroupAssert packageGroup(Location location) {
*
* @param location the location to configure.
* @return the assertions to perform.
* @throws AssertionError if the compilation was null, or no group for the location
* was found.
* @throws AssertionError if the compilation was null, or no group for the location was
* found.
* @throws IllegalArgumentException if the location is not
* {@link Location#isModuleOrientedLocation() module-oriented}.
* @throws NullPointerException if the provided location object is null.
Expand Down Expand Up @@ -228,8 +228,8 @@ public ModuleContainerGroupAssert moduleGroup(Location location) {
*
* @param location the location to configure.
* @return the assertions to perform.
* @throws AssertionError if the compilation was null, or no group for the location
* was found.
* @throws AssertionError if the compilation was null, or no group for the location was
* found.
* @throws IllegalArgumentException if the location is not
* {@link Location#isOutputLocation() an output location}.
* @throws NullPointerException if the provided location object is null.
Expand All @@ -256,8 +256,7 @@ public OutputContainerGroupAssert outputGroup(Location location) {
* <p>If not configured, the value being asserted on will be {@code null} in value.
*
* @return the assertions to perform on the class package outputs.
* @throws AssertionError if the compilation was null, or no group for the location
* was found.
* @throws AssertionError if the compilation was null, or no group for the location was found.
*/
@API(since = "0.6.4", status = Status.STABLE)
public PackageContainerGroupAssert classOutputPackages() {
Expand All @@ -270,8 +269,7 @@ public PackageContainerGroupAssert classOutputPackages() {
* <p>If not configured, the value being asserted on will be {@code null} in value.
*
* @return the assertions to perform on the class module outputs.
* @throws AssertionError if the compilation was null, or no group for the location
* was found.
* @throws AssertionError if the compilation was null, or no group for the location was found.
*/
@API(since = "0.6.4", status = Status.STABLE)
public ModuleContainerGroupAssert classOutputModules() {
Expand All @@ -284,8 +282,7 @@ public ModuleContainerGroupAssert classOutputModules() {
* <p>If not configured, the value being asserted on will be {@code null} in value.
*
* @return the assertions to perform on the source package outputs.
* @throws AssertionError if the compilation was null, or no group for the location
* was found.
* @throws AssertionError if the compilation was null, or no group for the location was found.
*/
@API(since = "0.6.4", status = Status.STABLE)
public PackageContainerGroupAssert sourceOutputPackages() {
Expand All @@ -298,8 +295,7 @@ public PackageContainerGroupAssert sourceOutputPackages() {
* <p>If not configured, the value being asserted on will be {@code null} in value.
*
* @return the assertions to perform on the source module outputs.
* @throws AssertionError if the compilation was null, or no group for the location
* was found.
* @throws AssertionError if the compilation was null, or no group for the location was found.
*/
@API(since = "0.6.4", status = Status.STABLE)
public ModuleContainerGroupAssert sourceOutputModules() {
Expand All @@ -312,8 +308,7 @@ public ModuleContainerGroupAssert sourceOutputModules() {
* <p>If not configured, the value being asserted on will be {@code null} in value.
*
* @return the assertions to perform on the class path.
* @throws AssertionError if the compilation was null, or no group for the location
* was found.
* @throws AssertionError if the compilation was null, or no group for the location was found.
*/
@API(since = "0.6.4", status = Status.STABLE)
public PackageContainerGroupAssert classPathPackages() {
Expand All @@ -326,8 +321,7 @@ public PackageContainerGroupAssert classPathPackages() {
* <p>If not configured, the value being asserted on will be {@code null} in value.
*
* @return the assertions to perform on the source path.
* @throws AssertionError if the compilation was null, or no group for the location
* was found.
* @throws AssertionError if the compilation was null, or no group for the location was found.
*/
@API(since = "0.6.4", status = Status.STABLE)
public PackageContainerGroupAssert sourcePathPackages() {
Expand All @@ -340,8 +334,7 @@ public PackageContainerGroupAssert sourcePathPackages() {
* <p>If not configured, the value being asserted on will be {@code null} in value.
*
* @return the assertions to perform on the source path.
* @throws AssertionError if the compilation was null, or no group for the location
* was found.
* @throws AssertionError if the compilation was null, or no group for the location was found.
*/
@API(since = "0.6.4", status = Status.STABLE)
public ModuleContainerGroupAssert moduleSourcePathModules() {
Expand All @@ -354,8 +347,7 @@ public ModuleContainerGroupAssert moduleSourcePathModules() {
* <p>If not configured, the value being asserted on will be {@code null} in value.
*
* @return the assertions to perform on the module path.
* @throws AssertionError if the compilation was null, or no group for the location
* was found.
* @throws AssertionError if the compilation was null, or no group for the location was found.
*/
@API(since = "0.6.4", status = Status.STABLE)
public ModuleContainerGroupAssert modulePathModules() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
*/
@API(since = "0.0.1", status = Status.STABLE)
public final class StackTraceAssert
extends AbstractListAssert<StackTraceAssert, List<? extends StackTraceElement>, StackTraceElement, StackTraceElementAssert> {
extends
AbstractListAssert<StackTraceAssert, List<? extends StackTraceElement>, StackTraceElement, StackTraceElementAssert> {

/**
* Initialize a new assertions object.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
*/
@API(since = "0.0.1", status = Status.STABLE)
public final class TraceDiagnosticListAssert
extends AbstractListAssert<TraceDiagnosticListAssert, List<? extends TraceDiagnostic<? extends JavaFileObject>>, TraceDiagnostic<? extends JavaFileObject>, TraceDiagnosticAssert> {
extends
AbstractListAssert<TraceDiagnosticListAssert, List<? extends TraceDiagnostic<? extends JavaFileObject>>, TraceDiagnostic<? extends JavaFileObject>, TraceDiagnosticAssert> {

/**
* Initialize this assertion.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ public JctCompilation compile(Workspace workspace, Collection<String> classNames
}

@Override
public final <E extends Exception> AbstractJctCompiler configure(JctCompilerConfigurer<E> configurer) throws E {
public final <E extends Exception> AbstractJctCompiler configure(
JctCompilerConfigurer<E> configurer) throws E {
requireNonNull(configurer, "configurer");
configurer.configure(this);
return this;
Expand Down Expand Up @@ -210,7 +211,8 @@ public List<String> getAnnotationProcessorOptions() {
}

@Override
public AbstractJctCompiler addAnnotationProcessorOptions(Iterable<String> annotationProcessorOptions) {
public AbstractJctCompiler addAnnotationProcessorOptions(
Iterable<String> annotationProcessorOptions) {
requireNonNullValues(annotationProcessorOptions, "annotationProcessorOptions");
annotationProcessorOptions.forEach(this.annotationProcessorOptions::add);
return this;
Expand All @@ -222,7 +224,8 @@ public List<Processor> getAnnotationProcessors() {
}

@Override
public AbstractJctCompiler addAnnotationProcessors(Iterable<? extends Processor> annotationProcessors) {
public AbstractJctCompiler addAnnotationProcessors(
Iterable<? extends Processor> annotationProcessors) {
requireNonNullValues(annotationProcessors, "annotationProcessors");
annotationProcessors.forEach(this.annotationProcessors::add);

Expand Down Expand Up @@ -396,7 +399,8 @@ public AnnotationProcessorDiscovery getAnnotationProcessorDiscovery() {
}

@Override
public AbstractJctCompiler annotationProcessorDiscovery(AnnotationProcessorDiscovery annotationProcessorDiscovery) {
public AbstractJctCompiler annotationProcessorDiscovery(
AnnotationProcessorDiscovery annotationProcessorDiscovery) {
this.annotationProcessorDiscovery = requireNonNull(
annotationProcessorDiscovery,
"annotationProcessorDiscovery"
Expand Down Expand Up @@ -431,7 +435,8 @@ public final String toString() {
public abstract Jsr199CompilerFactory getCompilerFactory();

/**
* Get the file manager factory to use for building AbstractJctCompiler file manager during compilation.
* Get the file manager factory to use for building AbstractJctCompiler file manager during
* compilation.
*
* <p>Since v1.1.0, this method has provided a default implementation. Before this, it was
* abstract. The default implementation calls
Expand All @@ -451,8 +456,8 @@ public JctFileManagerFactory getFileManagerFactory() {
*
* <p>Some obscure compiler implementations with potentially satanic rituals for initialising
* and configuring components correctly may need to provide a custom implementation here instead.
* In this case, this method should be overridden. Base classes are not provided for you to
* extend in this case as this is usually not something you want to be doing. Instead, you should
* In this case, this method should be overridden. Base classes are not provided for you to extend
* in this case as this is usually not something you want to be doing. Instead, you should
* implement {@link JctCompilationFactory} directly.
*
* @return the compilation factory.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ public interface JctCompilationFactory {
* @return the compilation result that contains whether the compiler succeeded or failed, amongst
* other information.
* @throws JctCompilerException if any prerequisites fail, such as no compilation units being
* found, or if the underlying JSR-199 compiler raises an unhandled exception and cannot
* complete when invoked.
* found, or if the underlying JSR-199 compiler raises an unhandled
* exception and cannot complete when invoked.
*/
JctCompilation createCompilation(
List<String> flags,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ public interface JctCompiler {
* @see #compile(Workspace)
* @see #compile(Workspace, Collection)
*/
default JctCompilation compile(Workspace workspace, String firstClassName, String... additionalClassNames) {
default JctCompilation compile(Workspace workspace, String firstClassName,
String... additionalClassNames) {
return compile(workspace, IterableUtils.combineOneOrMore(firstClassName, additionalClassNames));
}

Expand Down Expand Up @@ -842,5 +843,6 @@ default JctCompiler target(SourceVersion target) {
* @param annotationProcessorDiscovery the processor discovery mode to use.
* @return this compiler for further call chaining.
*/
JctCompiler annotationProcessorDiscovery(AnnotationProcessorDiscovery annotationProcessorDiscovery);
JctCompiler annotationProcessorDiscovery(
AnnotationProcessorDiscovery annotationProcessorDiscovery);
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ public interface Container extends Closeable {
* in, rather than the location of the archive on the original file system.
*
* <p>It is worth noting that this operation may result in the archive being loaded into memory
* eagerly if it uses lazy loading, due to the need to load the archive to be able to determine
* an accurate handle to the inner root directory.
* eagerly if it uses lazy loading, due to the need to load the archive to be able to determine an
* accurate handle to the inner root directory.
*
* @return the path root.
* @since 0.0.6
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
* group. Operations on non-module packages should operate on this container group directly.
*
* <p>Note that each container group will usually only support one package container group
* in the outputs. This is due to the JSR-199 API not providing a method for specifying which
* output location to write files to for legacy-style packages.
* in the outputs. This is due to the JSR-199 API not providing a method for specifying which output
* location to write files to for legacy-style packages.
*
* @author Ashley Scopes
* @since 0.0.1
Expand Down Expand Up @@ -81,7 +81,7 @@ public interface OutputContainerGroup extends PackageContainerGroup, ModuleConta
* JSR-199 limitations.
*
* @return the list containing the package container, if it exists. Otherwise, an empty list is
* returned instead.
* returned instead.
*/
@Override
List<Container> getPackages();
Expand Down
Loading

0 comments on commit 223268b

Please sign in to comment.