private JavacListener createRecordingListener(@Nullable JavacListener listener,
	                                              @Nonnull List<CompilerDiagnostic> diagnostics) {
		return new ForwardingListener(listener) {
			@Override
			public void report(@Nonnull Diagnostic<? extends JavaFileObject> diagnostic) {
				// Pass to user defined listener
				super.report(diagnostic);

				// Record the diagnostic to our output
				if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
					diagnostics.add(new CompilerDiagnostic(
							(int) diagnostic.getLineNumber(),
							(int) diagnostic.getColumnNumber(),
							(int) diagnostic.getEndPosition() - (int) diagnostic.getPosition(),
							diagnostic.getMessage(Locale.getDefault()),
							mapKind(diagnostic.getKind())
					));
				}
			}

			private CompilerDiagnostic.Level mapKind(Diagnostic.Kind kind) {
				switch (kind) {
					case ERROR:
						return CompilerDiagnostic.Level.ERROR;
					case WARNING:
					case MANDATORY_WARNING:
						return CompilerDiagnostic.Level.WARNING;
					case NOTE:
					case OTHER:
					default:
						return CompilerDiagnostic.Level.INFO;
				}
			}
		};
	}
@param listener
		Optional listener to wrap.
@param diagnostics
		List to add diagnostics to.

@return Listener to encompass recording behavior and the user defined listener.
recaf-core/src/main/java/software/coley/recaf/services/compile/JavacCompiler.java