├── .devcontainer └── devcontainer.json ├── .editorconfig ├── .gitattributes ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── PULL_REQUEST_TEMPLATE.md ├── dependabot.yml └── workflows │ ├── build.yml │ ├── deploy.yml │ ├── pages.yml │ └── security.yml ├── .gitignore ├── .mvn ├── checkstyle │ ├── checkstyle.xml │ └── suppressions.xml ├── jvm.config ├── license │ └── license-header.txt ├── maven.config └── wrapper │ └── maven-wrapper.properties ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE.txt ├── README.md ├── SECURITY.md ├── codecov.yml ├── java-compiler-testing ├── pom.xml └── src │ ├── it │ ├── avaje-http │ │ ├── pom.xml │ │ └── src │ │ │ └── test │ │ │ ├── java │ │ │ └── io │ │ │ │ └── github │ │ │ │ └── ascopes │ │ │ │ └── jct │ │ │ │ └── acceptancetests │ │ │ │ └── avajehttp │ │ │ │ └── AvajeHttpTest.java │ │ │ └── resources │ │ │ ├── code │ │ │ ├── module-info.java │ │ │ └── org │ │ │ │ └── example │ │ │ │ ├── PatchedUser.java │ │ │ │ ├── User.java │ │ │ │ └── UserApi.java │ │ │ └── junit-platform.properties │ ├── avaje-inject │ │ ├── pom.xml │ │ └── src │ │ │ └── test │ │ │ ├── java │ │ │ └── io │ │ │ │ └── github │ │ │ │ └── ascopes │ │ │ │ └── jct │ │ │ │ └── acceptancetests │ │ │ │ └── avajeinject │ │ │ │ └── AvajeInjectTest.java │ │ │ └── resources │ │ │ ├── code │ │ │ ├── module-info.java │ │ │ └── org │ │ │ │ └── example │ │ │ │ ├── CoffeeMaker.java │ │ │ │ ├── Grinder.java │ │ │ │ └── Pump.java │ │ │ └── junit-platform.properties │ ├── avaje-jsonb │ │ ├── pom.xml │ │ └── src │ │ │ └── test │ │ │ ├── java │ │ │ └── io │ │ │ │ └── github │ │ │ │ └── ascopes │ │ │ │ └── jct │ │ │ │ └── acceptancetests │ │ │ │ └── avajejsonb │ │ │ │ └── AvajeJsonbTest.java │ │ │ └── resources │ │ │ ├── code │ │ │ └── User.java │ │ │ └── junit-platform.properties │ ├── checkerframework │ │ ├── pom.xml │ │ └── src │ │ │ └── test │ │ │ ├── java │ │ │ └── io │ │ │ │ └── github │ │ │ │ └── ascopes │ │ │ │ └── jct │ │ │ │ └── acceptancetests │ │ │ │ └── checkerframework │ │ │ │ └── CheckerNullTest.java │ │ │ └── resources │ │ │ ├── code │ │ │ └── nullness │ │ │ │ ├── happy │ │ │ │ └── HappyCase.java │ │ │ │ └── sad │ │ │ │ └── SadCase.java │ │ │ └── junit-platform.properties │ ├── dagger │ │ ├── pom.xml │ │ └── src │ │ │ └── test │ │ │ ├── java │ │ │ └── io │ │ │ │ └── github │ │ │ │ └── ascopes │ │ │ │ └── jct │ │ │ │ └── acceptancetests │ │ │ │ └── dagger │ │ │ │ └── DaggerTest.java │ │ │ └── resources │ │ │ ├── code │ │ │ ├── WebServer.java │ │ │ └── WebServerConfiguration.java │ │ │ └── junit-platform.properties │ ├── dogfood │ │ ├── pom.xml │ │ └── src │ │ │ └── test │ │ │ ├── java │ │ │ ├── io │ │ │ │ └── github │ │ │ │ │ └── ascopes │ │ │ │ │ └── jct │ │ │ │ │ └── acceptancetests │ │ │ │ │ └── dogfood │ │ │ │ │ ├── JctCompilationConfigurer.java │ │ │ │ │ └── JctDogfoodTest.java │ │ │ └── module-info.java │ │ │ └── resources │ │ │ └── junit-platform.properties │ ├── google-auto-factory │ │ ├── pom.xml │ │ └── src │ │ │ └── test │ │ │ ├── java │ │ │ └── io │ │ │ │ └── github │ │ │ │ └── ascopes │ │ │ │ └── jct │ │ │ │ └── acceptancetests │ │ │ │ └── autofactory │ │ │ │ └── AutoFactoryTest.java │ │ │ └── resources │ │ │ ├── code │ │ │ └── User.java │ │ │ └── junit-platform.properties │ ├── google-auto-service │ │ ├── pom.xml │ │ └── src │ │ │ └── test │ │ │ ├── java │ │ │ └── io │ │ │ │ └── github │ │ │ │ └── ascopes │ │ │ │ └── jct │ │ │ │ └── acceptancetests │ │ │ │ └── autoservice │ │ │ │ └── AutoServiceTest.java │ │ │ └── resources │ │ │ ├── code │ │ │ ├── SomeImpl.java │ │ │ └── SomeInterface.java │ │ │ └── junit-platform.properties │ ├── google-auto-value │ │ ├── pom.xml │ │ └── src │ │ │ └── test │ │ │ ├── java │ │ │ └── io │ │ │ │ └── github │ │ │ │ └── ascopes │ │ │ │ └── jct │ │ │ │ └── acceptancetests │ │ │ │ └── autovalue │ │ │ │ └── AutoValueTest.java │ │ │ └── resources │ │ │ ├── code │ │ │ ├── User.java │ │ │ └── UserBuilder.java │ │ │ └── junit-platform.properties │ ├── google-error-prone │ │ ├── pom.xml │ │ ├── selector.bsh │ │ └── src │ │ │ └── test │ │ │ ├── java │ │ │ └── io │ │ │ │ └── github │ │ │ │ └── ascopes │ │ │ │ └── jct │ │ │ │ └── acceptancetests │ │ │ │ └── errorprone │ │ │ │ └── ErrorProneTest.java │ │ │ └── resources │ │ │ ├── code │ │ │ └── nullness │ │ │ │ ├── happy │ │ │ │ └── HappyCase.java │ │ │ │ └── sad │ │ │ │ └── SadCase.java │ │ │ └── junit-platform.properties │ ├── immutables │ │ ├── pom.xml │ │ └── src │ │ │ └── test │ │ │ ├── java │ │ │ └── io │ │ │ │ └── github │ │ │ │ └── ascopes │ │ │ │ └── jct │ │ │ │ └── acceptancetests │ │ │ │ └── immutables │ │ │ │ └── ImmutablesTest.java │ │ │ └── resources │ │ │ ├── code │ │ │ ├── flat │ │ │ │ └── org │ │ │ │ │ └── example │ │ │ │ │ └── Animal.java │ │ │ └── jpms │ │ │ │ ├── module-info.java │ │ │ │ └── org │ │ │ │ └── example │ │ │ │ └── Animal.java │ │ │ └── junit-platform.properties │ ├── invoker-debug.properties │ ├── invoker.properties │ ├── lombok │ │ ├── pom.xml │ │ ├── selector.bsh │ │ └── src │ │ │ └── test │ │ │ ├── java │ │ │ └── io │ │ │ │ └── github │ │ │ │ └── ascopes │ │ │ │ └── jct │ │ │ │ └── acceptancetests │ │ │ │ └── lombok │ │ │ │ └── LombokTest.java │ │ │ └── resources │ │ │ ├── code │ │ │ ├── flat │ │ │ │ └── org │ │ │ │ │ └── example │ │ │ │ │ └── Animal.java │ │ │ └── jpms │ │ │ │ ├── module-info.java │ │ │ │ └── org │ │ │ │ └── example │ │ │ │ └── Animal.java │ │ │ └── junit-platform.properties │ ├── mapstruct │ │ ├── pom.xml │ │ └── src │ │ │ └── test │ │ │ ├── java │ │ │ └── io │ │ │ │ └── github │ │ │ │ └── ascopes │ │ │ │ └── jct │ │ │ │ └── acceptancetests │ │ │ │ └── mapstruct │ │ │ │ └── MapStructTest.java │ │ │ └── resources │ │ │ ├── code │ │ │ ├── flat │ │ │ │ └── org │ │ │ │ │ └── example │ │ │ │ │ ├── Car.java │ │ │ │ │ ├── CarDto.java │ │ │ │ │ ├── CarMapper.java │ │ │ │ │ └── CarType.java │ │ │ └── jpms │ │ │ │ ├── module-info.java │ │ │ │ └── org │ │ │ │ └── example │ │ │ │ ├── Car.java │ │ │ │ ├── CarDto.java │ │ │ │ ├── CarMapper.java │ │ │ │ └── CarType.java │ │ │ └── junit-platform.properties │ ├── micronaut │ │ ├── pom.xml │ │ ├── selector.bsh │ │ └── src │ │ │ └── test │ │ │ ├── java │ │ │ └── io │ │ │ │ └── github │ │ │ │ └── ascopes │ │ │ │ └── jct │ │ │ │ └── acceptancetests │ │ │ │ └── micronaut │ │ │ │ ├── MicronautConfigurer.java │ │ │ │ └── MicronautIntegrationTest.java │ │ │ └── resources │ │ │ ├── code │ │ │ ├── Application.java │ │ │ └── HelloController.java │ │ │ └── junit-platform.properties │ ├── serviceloader-jpms │ │ ├── pom.xml │ │ └── src │ │ │ ├── main │ │ │ └── java │ │ │ │ ├── io │ │ │ │ └── github │ │ │ │ │ └── ascopes │ │ │ │ │ └── jct │ │ │ │ │ └── acceptancetests │ │ │ │ │ └── serviceloaderjpms │ │ │ │ │ ├── AnnotatedService.java │ │ │ │ │ ├── Service.java │ │ │ │ │ └── ServiceProcessor.java │ │ │ │ └── module-info.java │ │ │ └── test │ │ │ ├── java │ │ │ └── io │ │ │ │ └── github │ │ │ │ └── ascopes │ │ │ │ └── jct │ │ │ │ └── acceptancetests │ │ │ │ └── serviceloaderjpms │ │ │ │ └── testing │ │ │ │ └── ServiceProcessorJpmsTest.java │ │ │ └── resources │ │ │ ├── code │ │ │ ├── module-info.java │ │ │ └── org │ │ │ │ └── example │ │ │ │ ├── InsultProvider.java │ │ │ │ └── MeanInsultProviderImpl.java │ │ │ └── junit-platform.properties │ ├── serviceloader │ │ ├── pom.xml │ │ └── src │ │ │ ├── main │ │ │ └── java │ │ │ │ └── io │ │ │ │ └── github │ │ │ │ └── ascopes │ │ │ │ └── jct │ │ │ │ └── acceptancetests │ │ │ │ └── serviceloader │ │ │ │ ├── AnnotatedService.java │ │ │ │ ├── Service.java │ │ │ │ └── ServiceProcessor.java │ │ │ └── test │ │ │ ├── java │ │ │ └── io │ │ │ │ └── github │ │ │ │ └── ascopes │ │ │ │ └── jct │ │ │ │ └── acceptancetests │ │ │ │ └── serviceloader │ │ │ │ └── testing │ │ │ │ └── ServiceProcessorTest.java │ │ │ └── resources │ │ │ ├── code │ │ │ ├── InsultProvider.java │ │ │ └── MeanInsultProviderImpl.java │ │ │ └── junit-platform.properties │ ├── settings.xml │ └── spring │ │ ├── pom.xml │ │ └── src │ │ └── test │ │ ├── java │ │ └── io │ │ │ └── github │ │ │ └── ascopes │ │ │ └── jct │ │ │ └── acceptancetests │ │ │ └── spring │ │ │ ├── SpringBootAutoconfigureProcessorTest.java │ │ │ └── SpringBootConfigurationProcessorTest.java │ │ └── resources │ │ ├── code │ │ ├── autoconfigure │ │ │ ├── module-info.java │ │ │ └── org │ │ │ │ └── example │ │ │ │ ├── Application.java │ │ │ │ ├── config │ │ │ │ └── RouteConfig.java │ │ │ │ └── handlers │ │ │ │ └── HelloWorldHandler.java │ │ └── configuration │ │ │ ├── module-info.java │ │ │ └── org │ │ │ └── example │ │ │ ├── Application.java │ │ │ ├── config │ │ │ └── RouteConfig.java │ │ │ ├── handlers │ │ │ └── HelloWorldHandler.java │ │ │ └── properties │ │ │ └── HelloWorldProperties.java │ │ └── junit-platform.properties │ ├── main │ ├── java │ │ ├── io │ │ │ └── github │ │ │ │ └── ascopes │ │ │ │ └── jct │ │ │ │ ├── assertions │ │ │ │ ├── AbstractContainerGroupAssert.java │ │ │ │ ├── AbstractEnumAssert.java │ │ │ │ ├── AbstractJavaFileObjectAssert.java │ │ │ │ ├── ClassLoaderAssert.java │ │ │ │ ├── DiagnosticKindAssert.java │ │ │ │ ├── JavaFileObjectAssert.java │ │ │ │ ├── JavaFileObjectKindAssert.java │ │ │ │ ├── JctAssertions.java │ │ │ │ ├── JctCompilationAssert.java │ │ │ │ ├── LocationAssert.java │ │ │ │ ├── ModuleContainerGroupAssert.java │ │ │ │ ├── OutputContainerGroupAssert.java │ │ │ │ ├── PackageContainerGroupAssert.java │ │ │ │ ├── PathFileObjectAssert.java │ │ │ │ ├── StackTraceAssert.java │ │ │ │ ├── StackTraceElementAssert.java │ │ │ │ ├── TraceDiagnosticAssert.java │ │ │ │ ├── TraceDiagnosticListAssert.java │ │ │ │ ├── TypeAwareListAssert.java │ │ │ │ └── package-info.java │ │ │ │ ├── compilers │ │ │ │ ├── AbstractJctCompiler.java │ │ │ │ ├── CompilationMode.java │ │ │ │ ├── DebuggingInfo.java │ │ │ │ ├── JctCompilation.java │ │ │ │ ├── JctCompilationFactory.java │ │ │ │ ├── JctCompiler.java │ │ │ │ ├── JctCompilerConfigurer.java │ │ │ │ ├── JctCompilers.java │ │ │ │ ├── JctFlagBuilder.java │ │ │ │ ├── JctFlagBuilderFactory.java │ │ │ │ ├── Jsr199CompilerFactory.java │ │ │ │ ├── impl │ │ │ │ │ ├── JavacJctCompilerImpl.java │ │ │ │ │ ├── JavacJctFlagBuilderImpl.java │ │ │ │ │ ├── JctCompilationFactoryImpl.java │ │ │ │ │ ├── JctCompilationImpl.java │ │ │ │ │ └── package-info.java │ │ │ │ └── package-info.java │ │ │ │ ├── containers │ │ │ │ ├── Container.java │ │ │ │ ├── ContainerGroup.java │ │ │ │ ├── ModuleContainerGroup.java │ │ │ │ ├── OutputContainerGroup.java │ │ │ │ ├── PackageContainerGroup.java │ │ │ │ ├── impl │ │ │ │ │ ├── AbstractPackageContainerGroup.java │ │ │ │ │ ├── ContainerGroupRepositoryImpl.java │ │ │ │ │ ├── JarContainerImpl.java │ │ │ │ │ ├── ModuleContainerGroupImpl.java │ │ │ │ │ ├── OutputContainerGroupImpl.java │ │ │ │ │ ├── PackageContainerGroupImpl.java │ │ │ │ │ ├── PackageContainerGroupUrlClassLoader.java │ │ │ │ │ ├── PathWrappingContainerImpl.java │ │ │ │ │ └── package-info.java │ │ │ │ └── package-info.java │ │ │ │ ├── diagnostics │ │ │ │ ├── TeeWriter.java │ │ │ │ ├── TraceDiagnostic.java │ │ │ │ ├── TracingDiagnosticListener.java │ │ │ │ └── package-info.java │ │ │ │ ├── ex │ │ │ │ ├── JctCompilerException.java │ │ │ │ ├── JctException.java │ │ │ │ ├── JctIllegalInputException.java │ │ │ │ ├── JctJunitConfigurerException.java │ │ │ │ ├── JctNotFoundException.java │ │ │ │ ├── JctNotImplementedException.java │ │ │ │ └── package-info.java │ │ │ │ ├── filemanagers │ │ │ │ ├── AnnotationProcessorDiscovery.java │ │ │ │ ├── JctFileManager.java │ │ │ │ ├── JctFileManagerFactory.java │ │ │ │ ├── JctFileManagers.java │ │ │ │ ├── LoggingMode.java │ │ │ │ ├── ModuleLocation.java │ │ │ │ ├── PathFileObject.java │ │ │ │ ├── config │ │ │ │ │ ├── JctFileManagerAnnotationProcessorClassPathConfigurer.java │ │ │ │ │ ├── JctFileManagerConfigurer.java │ │ │ │ │ ├── JctFileManagerConfigurerChain.java │ │ │ │ │ ├── JctFileManagerJvmClassPathConfigurer.java │ │ │ │ │ ├── JctFileManagerJvmClassPathModuleConfigurer.java │ │ │ │ │ ├── JctFileManagerJvmModulePathConfigurer.java │ │ │ │ │ ├── JctFileManagerJvmSystemModulesConfigurer.java │ │ │ │ │ ├── JctFileManagerLoggingProxyConfigurer.java │ │ │ │ │ ├── JctFileManagerRequiredLocationsConfigurer.java │ │ │ │ │ ├── JctFileManagerWorkspaceConfigurer.java │ │ │ │ │ └── package-info.java │ │ │ │ ├── impl │ │ │ │ │ ├── JctFileManagerFactoryImpl.java │ │ │ │ │ ├── JctFileManagerImpl.java │ │ │ │ │ ├── LoggingFileManagerProxy.java │ │ │ │ │ ├── PathFileObjectImpl.java │ │ │ │ │ └── package-info.java │ │ │ │ └── package-info.java │ │ │ │ ├── junit │ │ │ │ ├── AbstractCompilersProvider.java │ │ │ │ ├── JavacCompilerTest.java │ │ │ │ ├── JavacCompilersProvider.java │ │ │ │ ├── JctExtension.java │ │ │ │ ├── Managed.java │ │ │ │ ├── VersionStrategy.java │ │ │ │ └── package-info.java │ │ │ │ ├── repr │ │ │ │ ├── LocationRepresentation.java │ │ │ │ ├── StackTraceRepresentation.java │ │ │ │ ├── TraceDiagnosticListRepresentation.java │ │ │ │ ├── TraceDiagnosticRepresentation.java │ │ │ │ └── package-info.java │ │ │ │ ├── utils │ │ │ │ ├── FileUtils.java │ │ │ │ ├── IoExceptionUtils.java │ │ │ │ ├── IterableUtils.java │ │ │ │ ├── Lazy.java │ │ │ │ ├── LoomPolyfill.java │ │ │ │ ├── ModuleDiscoverer.java │ │ │ │ ├── SpecialLocationUtils.java │ │ │ │ ├── StringSlicer.java │ │ │ │ ├── StringUtils.java │ │ │ │ ├── ToStringBuilder.java │ │ │ │ ├── UtilityClass.java │ │ │ │ ├── VisibleForTestingOnly.java │ │ │ │ └── package-info.java │ │ │ │ └── workspaces │ │ │ │ ├── DirectoryBuilder.java │ │ │ │ ├── FileBuilder.java │ │ │ │ ├── ManagedDirectory.java │ │ │ │ ├── PathRoot.java │ │ │ │ ├── PathStrategy.java │ │ │ │ ├── Workspace.java │ │ │ │ ├── Workspaces.java │ │ │ │ ├── impl │ │ │ │ ├── AbstractManagedDirectory.java │ │ │ │ ├── DirectoryBuilderImpl.java │ │ │ │ ├── FileBuilderImpl.java │ │ │ │ ├── JarFactoryImpl.java │ │ │ │ ├── MemoryFileSystemProvider.java │ │ │ │ ├── RamDirectoryImpl.java │ │ │ │ ├── TempDirectoryImpl.java │ │ │ │ ├── WorkspaceDumper.java │ │ │ │ ├── WorkspaceImpl.java │ │ │ │ ├── WrappingDirectoryImpl.java │ │ │ │ └── package-info.java │ │ │ │ └── package-info.java │ │ └── module-info.java │ └── resources │ │ └── META-INF │ │ └── services │ │ └── java.net.spi.URLStreamHandlerProvider │ └── test │ ├── java │ └── io │ │ └── github │ │ └── ascopes │ │ └── jct │ │ ├── assertions │ │ ├── AbstractContainerGroupAssertTest.java │ │ ├── AbstractEnumAssertTest.java │ │ ├── AbstractJavaFileObjectAssertTest.java │ │ ├── ClassLoaderAssertTest.java │ │ ├── DiagnosticKindAssertTest.java │ │ ├── JavaFileObjectAssertTest.java │ │ ├── JavaFileObjectKindAssertTest.java │ │ ├── JctAssertionsTest.java │ │ ├── JctCompilationAssertTest.java │ │ ├── LocationAssertTest.java │ │ ├── ModuleContainerGroupAssertTest.java │ │ ├── OutputContainerGroupAssertTest.java │ │ ├── PackageContainerGroupAssertTest.java │ │ ├── PathFileObjectAssertTest.java │ │ ├── StackTraceAssertTest.java │ │ ├── StackTraceElementAssertTest.java │ │ ├── TraceDiagnosticAssertTest.java │ │ └── TraceDiagnosticListAssertTest.java │ │ ├── compilers │ │ ├── AbstractJctCompilerTest.java │ │ ├── DebuggingInfoTest.java │ │ ├── JctCompilationTest.java │ │ ├── JctCompilerTest.java │ │ ├── JctCompilersTest.java │ │ └── impl │ │ │ ├── JavacJctCompilerImplTest.java │ │ │ ├── JavacJctFlagBuilderImplTest.java │ │ │ ├── JctCompilationFactoryImplTest.java │ │ │ └── JctCompilationImplTest.java │ │ ├── containers │ │ └── impl │ │ │ ├── AbstractPackageContainerGroupTest.java │ │ │ ├── ContainerGroupRepositoryImplTest.java │ │ │ └── PackageContainerGroupUrlClassLoaderTest.java │ │ ├── diagnostics │ │ ├── TeeWriterTest.java │ │ ├── TraceDiagnosticTest.java │ │ └── TracingDiagnosticListenerTest.java │ │ ├── ex │ │ ├── JctCompilerExceptionTest.java │ │ ├── JctIllegalInputExceptionTest.java │ │ ├── JctJunitConfigurerExceptionTest.java │ │ ├── JctNotFoundExceptionTest.java │ │ └── JctNotImplementedTest.java │ │ ├── filemanagers │ │ ├── JctFileManagerTest.java │ │ ├── JctFileManagersTest.java │ │ ├── ModuleLocationTest.java │ │ ├── config │ │ │ ├── JctFileManagerAnnotationProcessorClassPathConfigurerTest.java │ │ │ ├── JctFileManagerConfigurerChainTest.java │ │ │ ├── JctFileManagerConfigurerTest.java │ │ │ ├── JctFileManagerJvmClassPathConfigurerTest.java │ │ │ ├── JctFileManagerJvmClassPathModuleConfigurerTest.java │ │ │ ├── JctFileManagerJvmModulePathConfigurerTest.java │ │ │ ├── JctFileManagerJvmSystemModulesConfigurerTest.java │ │ │ ├── JctFileManagerLoggingProxyConfigurerTest.java │ │ │ ├── JctFileManagerRequiredLocationsConfigurerTest.java │ │ │ └── JctFileManagerWorkspaceConfigurerTest.java │ │ └── impl │ │ │ ├── JctFileManagerFactoryImplTest.java │ │ │ ├── JctFileManagerImplTest.java │ │ │ ├── LoggingFileManagerProxyTest.java │ │ │ └── PathFileObjectImplTest.java │ │ ├── fixtures │ │ ├── ExtraArgumentMatchers.java │ │ ├── Fixtures.java │ │ ├── Slf4jLoggerFake.java │ │ └── UtilityClassTestTemplate.java │ │ ├── integration │ │ ├── AbstractIntegrationTest.java │ │ ├── compilation │ │ │ ├── BasicLegacyCompilationIntegrationTest.java │ │ │ ├── BasicModuleCompilationIntegrationTest.java │ │ │ ├── BasicMultiModuleCompilationIntegrationTest.java │ │ │ ├── CompilingSpecificClassesIntegrationTest.java │ │ │ └── MultiTieredCompilationIntegrationTest.java │ │ └── junit │ │ │ └── JctExtensionIntegrationTest.java │ │ ├── junit │ │ ├── AbstractCompilersProviderTest.java │ │ ├── JavacCompilersProviderTest.java │ │ ├── JctExtensionTest.java │ │ └── VersionStrategyTest.java │ │ ├── repr │ │ ├── LocationRepresentationTest.java │ │ ├── StackTraceRepresentationTest.java │ │ ├── TraceDiagnosticListRepresentationTest.java │ │ └── TraceDiagnosticRepresentationTest.java │ │ ├── utils │ │ ├── FileUtilsTest.java │ │ ├── IoExceptionUtilsTest.java │ │ ├── IterableUtilsTest.java │ │ ├── LazyTest.java │ │ ├── LoomPolyfillTest.java │ │ ├── ModuleDiscovererTest.java │ │ ├── SpecialLocationsUtilsTest.java │ │ ├── StringSlicerTest.java │ │ ├── StringUtilsTest.java │ │ └── ToStringBuilderTest.java │ │ └── workspaces │ │ ├── ManagedDirectoryTest.java │ │ ├── PathStrategyTest.java │ │ ├── WorkspaceTest.java │ │ ├── WorkspacesTest.java │ │ └── impl │ │ ├── JarFactoryImplTest.java │ │ ├── MemoryFileSystemProviderImplTest.java │ │ └── WrappingDirectoryImplTest.java │ └── resources │ ├── io │ └── github │ │ └── ascopes │ │ └── jct │ │ └── integration │ │ └── compilation │ │ ├── BasicLegacyCompilationIntegrationTest_resources │ │ └── HelloWorld.java │ │ ├── BasicModuleCompilationIntegrationTest_resources │ │ ├── com │ │ │ └── example │ │ │ │ └── HelloWorld.java │ │ └── module-info.java │ │ ├── BasicMultiModuleCompilationIntegrationTest_resources │ │ ├── greeter │ │ │ ├── com │ │ │ │ └── example │ │ │ │ │ └── greeter │ │ │ │ │ └── Greeter.java │ │ │ └── module-info.java │ │ ├── hello.world.crossmodule │ │ │ ├── com │ │ │ │ └── example │ │ │ │ │ └── HelloWorld.java │ │ │ └── module-info.java │ │ └── hello.world.singlemodule │ │ │ ├── com │ │ │ └── example │ │ │ │ └── HelloWorld.java │ │ │ └── module-info.java │ │ ├── CompilingSpecificClassesIntegrationTest_resources │ │ ├── Fibonacci.java │ │ ├── HelloWorld.java │ │ └── Sum.java │ │ └── MultiTieredCompilationIntegrationTest_resources │ │ ├── first │ │ └── Adder.java │ │ └── second │ │ └── Main.java │ └── junit-platform.properties ├── mvnw ├── mvnw.cmd └── pom.xml /.devcontainer/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "image": "mcr.microsoft.com/devcontainers/universal:2", 3 | "features": { 4 | "ghcr.io/devcontainers/features/java:1": { 5 | "version": "22", 6 | "jdkDistro": "tem", 7 | "installMaven": true 8 | }, 9 | "ghcr.io/devcontainers/features/common-utils:2": {} 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Needed to stop Git Bash in CI accidentally injecting \r into jvm.config and breaking builds. 2 | * text=auto eol=lf 3 | *.cmd text=auto eol=crlf 4 | *.jar -text 5 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: "[BUG] " 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behaviour: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behaviour** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Test case or reproduction** 24 | Please attach a reproduction or code snippet to help us understand what is being performed. 25 | 26 | **Logs** 27 | If applicable, add screenshots to help explain your problem. 28 | 29 | **Additional context** 30 | 31 | - JCT library version: _Please enter the library version you are using here (e.g. v3.4.5)_ 32 | - JDK version: _Please enter the JDK you are using here (e.g. 17.0.1)_ 33 | - JDK vendor: _Please enter the JDK vendor being used (e.g. Amazon Corretto, Adoptium)_ 34 | - Platform: _Please enter details about your platform (e.g. Fedora Linux ARM64, Windows 11 AMD64). 35 | 36 | Add any other context about the problem here. 37 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: new feature 6 | assignees: ascopes 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ### Summary 2 | 3 | Describe briefly what this change is about. 4 | 5 | ### Additional details 6 | 7 | Add any additional details here, or delete this section. 8 | 9 | ### Checklist 10 | 11 | - [ ] I have reviewed the `CONTRIBUTING.md` and agree to 12 | the licensing terms of this project. 13 | - [ ] I have added new tests for any new features. 14 | - [ ] I have made sure the project builds correctly on my local 15 | machine (`./mvnw clean verify`). 16 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: github-actions 4 | directory: / 5 | open-pull-requests-limit: 99 6 | rebase-strategy: auto 7 | schedule: 8 | interval: weekly 9 | day: monday 10 | time: "06:00" 11 | timezone: Europe/London 12 | target-branch: main 13 | assignees: 14 | - ascopes 15 | labels: 16 | - ci 17 | - package-ecosystem: maven 18 | directory: / 19 | open-pull-requests-limit: 99 20 | rebase-strategy: auto 21 | schedule: 22 | interval: weekly 23 | day: monday 24 | time: "06:00" 25 | timezone: Europe/London 26 | target-branch: main 27 | assignees: 28 | - ascopes 29 | labels: 30 | - maven 31 | -------------------------------------------------------------------------------- /.github/workflows/pages.yml: -------------------------------------------------------------------------------- 1 | name: Snapshot Pages 2 | 3 | on: 4 | push: 5 | branches: [main] 6 | 7 | jobs: 8 | pages: 9 | name: Deploy Pages 10 | runs-on: ubuntu-latest 11 | 12 | permissions: 13 | id-token: write 14 | pages: write 15 | 16 | steps: 17 | - name: Checkout 18 | uses: actions/checkout@v4 19 | 20 | - name: Set up JDK 21 | uses: actions/setup-java@v4 22 | with: 23 | java-version: 23 24 | distribution: 'temurin' 25 | 26 | - name: Generate JavaDocs 27 | shell: bash 28 | run: >- 29 | ./mvnw -B -U -am -pl java-compiler-testing 30 | -Dmaven.test.skip=true 31 | -Dcheckstyle.skip=true 32 | -Dlicense.skip=true 33 | clean compile javadoc:jar 34 | 35 | - name: Upload JavaDocs as a build artifact 36 | uses: actions/upload-pages-artifact@v3 37 | with: 38 | path: java-compiler-testing/target/reports/apidocs 39 | 40 | - name: Deploy JavaDocs build artifact to GitHub Pages 41 | id: snapshot-javadocs 42 | uses: actions/deploy-pages@v4 43 | -------------------------------------------------------------------------------- /.github/workflows/security.yml: -------------------------------------------------------------------------------- 1 | name: Security Analysis 2 | on: 3 | push: 4 | branches: 5 | - main 6 | - v5 7 | 8 | jobs: 9 | submit-dependency-snapshot: 10 | name: Submit Dependency Snapshot 11 | runs-on: ubuntu-latest 12 | permissions: 13 | contents: write 14 | steps: 15 | - name: Checkout repository 16 | uses: actions/checkout@v4 17 | with: 18 | fetch-depth: 1 19 | 20 | - name: Initialize Java environment 21 | uses: actions/setup-java@v4 22 | with: 23 | distribution: zulu 24 | java-version: 23 25 | 26 | - name: Submit Dependency Snapshot 27 | uses: advanced-security/maven-dependency-submission-action@v5 28 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Build output 2 | build/ 3 | out/ 4 | target/ 5 | *.javaimport 6 | 7 | # Maven invoker plugin 8 | **/interpolated-pom.xml 9 | 10 | # IntelliJ junk 11 | *.iml 12 | .idea 13 | 14 | # VSCode 15 | .vscode/ 16 | .vs/ 17 | 18 | # Eclipse 19 | .settings/ 20 | .classpath 21 | 22 | # Maven 23 | pom.xml.next 24 | pom.xml.releaseBackup 25 | pom.xml.tag 26 | pom.xml.versionsBackup 27 | release.properties 28 | -------------------------------------------------------------------------------- /.mvn/checkstyle/suppressions.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /.mvn/jvm.config: -------------------------------------------------------------------------------- 1 | -XX:+TieredCompilation -XX:TieredStopAtLevel=1 2 | -------------------------------------------------------------------------------- /.mvn/license/license-header.txt: -------------------------------------------------------------------------------- 1 | Copyright (C) ${inceptionYear} - ${currentYear}, the original author or authors. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /.mvn/maven.config: -------------------------------------------------------------------------------- 1 | -e 2 | -T2C 3 | -Dstyle.color=always 4 | -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 5 | --no-transfer-progress 6 | -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | wrapperVersion=3.3.2 18 | distributionType=only-script 19 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip 20 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | This software is designed to be used as part of testing flows 4 | rather than as a production-facing system. Therefore, most 5 | exploitable security issues that could occur will not have 6 | significant impact. However, should an issue be identified, I 7 | will strive to fix these issues as soon as possible. 8 | 9 | Fixes will be released as a new version, built from the most 10 | recent `main` branch for Java 17, and from the `v4` branch for 11 | Java 11 backwards compatibility. Unless expressly requested, 12 | no attempt to backport changes will be made. 13 | 14 | Given this library is designed for use in test packs, the main 15 | design assumption is that the software is being used by a 16 | trusted user in a semi-trusted environment. 17 | -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2022 - 2025, the original author or authors. 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 | 17 | # General behaviour. 18 | coverage: 19 | round: up 20 | precision: 2 21 | 22 | codecov: 23 | notify: 24 | # Notify via a separate pipeline step in CI once all builds have completed. This way, we don't 25 | # report coverage after each parallel build completes, which results in spammy and incorrect 26 | # email notifications and prematurely marking the build as having failed. 27 | # https://github.com/codecov/codecov-action/issues/1436#issuecomment-2614065472 28 | manual_trigger: true 29 | require_ci_to_pass: true 30 | strict_yaml_branch: main 31 | 32 | comment: 33 | layout: "reach, diff, flags, files" 34 | behavior: default 35 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/avaje-http/src/test/java/io/github/ascopes/jct/acceptancetests/avajehttp/AvajeHttpTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 io.github.ascopes.jct.acceptancetests.avajehttp; 17 | 18 | import static io.github.ascopes.jct.assertions.JctAssertions.assertThatCompilation; 19 | 20 | import io.github.ascopes.jct.compilers.JctCompiler; 21 | import io.github.ascopes.jct.junit.JavacCompilerTest; 22 | import io.github.ascopes.jct.workspaces.Workspaces; 23 | import org.junit.jupiter.api.DisplayName; 24 | 25 | @DisplayName("Avaje HTTP acceptance tests") 26 | class AvajeHttpTest { 27 | 28 | @DisplayName("HTTP client code gets generated as expected") 29 | @JavacCompilerTest(minVersion = 11) 30 | void httpClientCodeGetsGeneratedAsExpected(JctCompiler compiler) { 31 | // Given 32 | try (var workspace = Workspaces.newWorkspace()) { 33 | workspace 34 | .createSourcePathPackage() 35 | .copyContentsFrom("src", "test", "resources", "code"); 36 | 37 | // When 38 | var compilation = compiler 39 | .compile(workspace); 40 | 41 | // Then 42 | assertThatCompilation(compilation) 43 | .isSuccessfulWithoutWarnings() 44 | .classOutputPackages() 45 | .allFilesExist( 46 | "org/example/httpclient/GeneratedHttpComponent.class", 47 | "org/example/httpclient/UserApiHttpClient.class" 48 | ); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/avaje-http/src/test/resources/code/module-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 | module org.example { 17 | exports org.example; 18 | 19 | requires io.avaje.http.client; 20 | requires io.avaje.http.api; 21 | 22 | provides io.avaje.http.client.HttpClient.GeneratedComponent with org.example.httpclient.GeneratedHttpComponent; 23 | } 24 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/avaje-http/src/test/resources/code/org/example/PatchedUser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 org.example; 17 | 18 | /** 19 | * A patched user. 20 | */ 21 | public final class PatchedUser { 22 | 23 | private final String name; 24 | private final String nickName; 25 | 26 | /** 27 | * Initalise the user. 28 | * 29 | * @param name the user's name. 30 | * @param nickName the user's nickname. 31 | */ 32 | public PatchedUser(String name, String nickName) { 33 | this.name = name; 34 | this.nickName = nickName; 35 | } 36 | 37 | /** 38 | * Get the user's name. 39 | * 40 | * @return the user's name. 41 | */ 42 | public String getName() { 43 | return name; 44 | } 45 | 46 | /** 47 | * Get the user's nickname. 48 | * 49 | * @return the user's nickname. 50 | */ 51 | public String getNickName() { 52 | return nickName; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/avaje-http/src/test/resources/code/org/example/User.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 org.example; 17 | 18 | /** 19 | * A user. 20 | */ 21 | public final class User { 22 | private final String id; 23 | private final String name; 24 | private final String nickName; 25 | 26 | /** 27 | * Initialise the user. 28 | * 29 | * @param id the user's ID. 30 | * @param name the user's name. 31 | * @param nickName the user's nickname. 32 | */ 33 | public User(String id, String name, String nickName) { 34 | this.id = id; 35 | this.name = name; 36 | this.nickName = nickName; 37 | } 38 | 39 | /** 40 | * Get the user's ID. 41 | * 42 | * @return the user's ID. 43 | */ 44 | public String getId() { 45 | return id; 46 | } 47 | 48 | /** 49 | * Get the user's name. 50 | * 51 | * @return the user's name. 52 | */ 53 | public String getName() { 54 | return name; 55 | } 56 | 57 | /** 58 | * Get the user's nickname. 59 | * 60 | * @return the user's nickname. 61 | */ 62 | public String getNickName() { 63 | return nickName; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/avaje-http/src/test/resources/code/org/example/UserApi.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 org.example; 17 | 18 | import io.avaje.http.api.Client; 19 | import io.avaje.http.api.Consumes; 20 | import io.avaje.http.api.Delete; 21 | import io.avaje.http.api.Get; 22 | import io.avaje.http.api.Path; 23 | import io.avaje.http.api.Produces; 24 | import io.avaje.http.api.Put; 25 | 26 | /** 27 | * API stub for a user repository REST API. 28 | */ 29 | @Client 30 | @Path("/users") 31 | public interface UserApi { 32 | 33 | /** 34 | * Get a user. 35 | * 36 | * @param id the ID of the user to get. 37 | * @return the user. 38 | */ 39 | @Get("/{id}") 40 | @Produces("application/xml") 41 | User getUser(String id); 42 | 43 | /** 44 | * Store or update a user. 45 | * 46 | * @param id the ID of the user to store. 47 | * @param patchedUser the user details to store. 48 | * @return the user. 49 | */ 50 | @Consumes("application/xml") 51 | @Produces("application/xml") 52 | @Put("/{id}") 53 | User putUser(String id, PatchedUser patchedUser); 54 | 55 | /** 56 | * Delete a user. 57 | * 58 | * @param id the ID of the user to delete. 59 | */ 60 | @Delete("/{id}") 61 | void deleteUser(String id); 62 | } 63 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/avaje-http/src/test/resources/junit-platform.properties: -------------------------------------------------------------------------------- 1 | junit.jupiter.execution.parallel.enabled=true 2 | junit.jupiter.execution.parallel.mode.classes.default=SAME_THREAD 3 | junit.jupiter.execution.parallel.mode.default=CONCURRENT 4 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/avaje-inject/src/test/resources/code/module-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 | module org.example { 17 | exports org.example; 18 | 19 | requires io.avaje.inject; 20 | 21 | provides io.avaje.inject.spi.AvajeModule with org.example.ExampleModule; 22 | } 23 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/avaje-inject/src/test/resources/code/org/example/CoffeeMaker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 org.example; 17 | 18 | import jakarta.inject.Inject; 19 | import jakarta.inject.Singleton; 20 | 21 | /** 22 | * Makes coffee. 23 | */ 24 | @Singleton 25 | public class CoffeeMaker { 26 | 27 | private final Grinder grinder; 28 | private final Pump pump; 29 | 30 | @Inject 31 | public CoffeeMaker(Grinder grinder, Pump pump) { 32 | this.grinder = grinder; 33 | this.pump = pump; 34 | } 35 | 36 | public void makeCoffee() { 37 | // ... 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/avaje-inject/src/test/resources/code/org/example/Grinder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 org.example; 17 | 18 | import jakarta.inject.Singleton; 19 | 20 | /** 21 | * Grinds coffee. 22 | */ 23 | @Singleton 24 | public class Grinder { 25 | // ... 26 | } 27 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/avaje-inject/src/test/resources/code/org/example/Pump.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 org.example; 17 | 18 | import jakarta.inject.Singleton; 19 | 20 | /** 21 | * Pumps coffee. 22 | */ 23 | @Singleton 24 | public class Pump { 25 | // ... 26 | } 27 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/avaje-inject/src/test/resources/junit-platform.properties: -------------------------------------------------------------------------------- 1 | junit.jupiter.execution.parallel.enabled=true 2 | junit.jupiter.execution.parallel.mode.classes.default=SAME_THREAD 3 | junit.jupiter.execution.parallel.mode.default=CONCURRENT 4 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/avaje-jsonb/src/test/resources/code/User.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 org.example; 17 | 18 | import io.avaje.jsonb.Json; 19 | import java.time.Instant; 20 | 21 | /** 22 | * A user object. 23 | */ 24 | @Json 25 | public class User { 26 | 27 | private final String id; 28 | private final String userName; 29 | private final Instant createdAt; 30 | 31 | /** 32 | * Init the user. 33 | * 34 | * @param id the user ID. 35 | * @param userName the username. 36 | * @param createdAt the date and time the user was created at. 37 | */ 38 | public User(String id, String userName, Instant createdAt) { 39 | this.id = id; 40 | this.userName = userName; 41 | this.createdAt = createdAt; 42 | } 43 | 44 | public String getId() { 45 | return id; 46 | } 47 | 48 | public String getUserName() { 49 | return userName; 50 | } 51 | 52 | public Instant getCreatedAt() { 53 | return createdAt; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/avaje-jsonb/src/test/resources/junit-platform.properties: -------------------------------------------------------------------------------- 1 | junit.jupiter.execution.parallel.enabled=true 2 | junit.jupiter.execution.parallel.mode.classes.default=SAME_THREAD 3 | junit.jupiter.execution.parallel.mode.default=CONCURRENT 4 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/checkerframework/src/test/resources/code/nullness/happy/HappyCase.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 org.example; 17 | 18 | import org.checkerframework.checker.nullness.qual.Nullable; 19 | 20 | /** 21 | * This should pass checkerframework. 22 | */ 23 | public class HappyCase { 24 | 25 | public static void main(String[] args) { 26 | @Nullable String foo = null; 27 | System.out.println(foo); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/checkerframework/src/test/resources/code/nullness/sad/SadCase.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 org.example; 17 | 18 | import org.checkerframework.checker.nullness.qual.NonNull; 19 | 20 | /** 21 | * This should fail checkerframework because it assigns a null value to a non-null holder. 22 | */ 23 | public class SadCase { 24 | 25 | public static void main(String[] args) { 26 | @NonNull String foo = null; 27 | System.out.println(foo); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/checkerframework/src/test/resources/junit-platform.properties: -------------------------------------------------------------------------------- 1 | junit.jupiter.execution.parallel.enabled=true 2 | junit.jupiter.execution.parallel.mode.classes.default=SAME_THREAD 3 | junit.jupiter.execution.parallel.mode.default=CONCURRENT 4 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/dagger/src/test/resources/code/WebServer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 org.example; 17 | 18 | import javax.inject.Inject; 19 | 20 | /** 21 | * Dummy web server stub. 22 | */ 23 | public class WebServer { 24 | 25 | private final WebServerConfiguration config; 26 | 27 | /** 28 | * Initialise the web server. 29 | */ 30 | @Inject 31 | public WebServer(WebServerConfiguration config) { 32 | this.config = config; 33 | } 34 | 35 | public void serve() { 36 | // do something. 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/dagger/src/test/resources/code/WebServerConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 org.example; 17 | 18 | import java.util.Locale; 19 | import java.util.function.Function; 20 | 21 | /** 22 | * Configuration properties for a web server. 23 | */ 24 | public class WebServerConfiguration { 25 | 26 | final String basePath; 27 | final Integer port; 28 | final Boolean https; 29 | 30 | /** 31 | * Initialise the web server configuration. 32 | */ 33 | public WebServerConfiguration() { 34 | basePath = propertyOrEnv("web.server.base.path", Function.identity()); 35 | port = propertyOrEnv("web.server.port", Integer::parseInt); 36 | https = propertyOrEnv("web.server.https", Boolean::parseBoolean); 37 | } 38 | 39 | static T propertyOrEnv(String name, Function converter) { 40 | String raw = System.getProperty(name); 41 | 42 | if (raw == null) { 43 | System.getenv(name.replace('.', '_').toUpperCase(Locale.ROOT)); 44 | } 45 | 46 | if (raw == null) { 47 | return null; 48 | } 49 | 50 | return converter.apply(raw); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/dagger/src/test/resources/junit-platform.properties: -------------------------------------------------------------------------------- 1 | junit.jupiter.execution.parallel.enabled=true 2 | junit.jupiter.execution.parallel.mode.classes.default=SAME_THREAD 3 | junit.jupiter.execution.parallel.mode.default=CONCURRENT 4 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/dogfood/src/test/java/io/github/ascopes/jct/acceptancetests/dogfood/JctCompilationConfigurer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 io.github.ascopes.jct.acceptancetests.dogfood; 17 | 18 | import io.github.ascopes.jct.compilers.JctCompiler; 19 | import io.github.ascopes.jct.compilers.JctCompilerConfigurer; 20 | import java.util.Locale; 21 | 22 | /** 23 | * Configure the compiler to mimic the Maven settings for compiling JCT 24 | * that we use normally. 25 | * 26 | * @author Ashley Scopes 27 | */ 28 | public class JctCompilationConfigurer implements JctCompilerConfigurer { 29 | 30 | @Override 31 | public void configure(JctCompiler compiler) { 32 | compiler 33 | .failOnWarnings(false) 34 | .showWarnings(false) // ignore spam about the testing module being hidden 35 | .locale(Locale.ENGLISH); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/dogfood/src/test/java/module-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 | open module io.github.ascopes.jct.acceptancetests.dogfood { 17 | requires io.github.ascopes.jct; 18 | requires java.compiler; 19 | requires org.assertj.core; 20 | requires transitive org.junit.jupiter.api; 21 | requires transitive org.junit.jupiter.engine; 22 | requires transitive org.junit.jupiter.params; 23 | requires transitive org.junit.platform.commons; // required to make IntelliJ happy. 24 | requires transitive org.junit.platform.engine; // required to make IntelliJ happy. 25 | requires transitive org.junit.platform.launcher; // required to make IntelliJ happy. 26 | } 27 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/dogfood/src/test/resources/junit-platform.properties: -------------------------------------------------------------------------------- 1 | junit.jupiter.execution.parallel.enabled=true 2 | junit.jupiter.execution.parallel.mode.classes.default=SAME_THREAD 3 | junit.jupiter.execution.parallel.mode.default=CONCURRENT 4 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/google-auto-factory/src/test/resources/code/User.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 org.example; 17 | 18 | import com.google.auto.factory.AutoFactory; 19 | import java.time.Instant; 20 | 21 | /** 22 | * A user type. 23 | */ 24 | @AutoFactory 25 | public final class User { 26 | 27 | private final String id; 28 | private final String name; 29 | private final Instant createdAt; 30 | 31 | User(String id, String name, Instant createdAt) { 32 | this.id = id; 33 | this.name = name; 34 | this.createdAt = createdAt; 35 | } 36 | 37 | public String getId() { 38 | return id; 39 | } 40 | 41 | public String getName() { 42 | return name; 43 | } 44 | 45 | public Instant getCreatedAt() { 46 | return createdAt; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/google-auto-factory/src/test/resources/junit-platform.properties: -------------------------------------------------------------------------------- 1 | junit.jupiter.execution.parallel.enabled=true 2 | junit.jupiter.execution.parallel.mode.classes.default=SAME_THREAD 3 | junit.jupiter.execution.parallel.mode.default=CONCURRENT 4 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/google-auto-service/src/test/java/io/github/ascopes/jct/acceptancetests/autoservice/AutoServiceTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 io.github.ascopes.jct.acceptancetests.autoservice; 17 | 18 | import static io.github.ascopes.jct.assertions.JctAssertions.assertThatCompilation; 19 | 20 | import io.github.ascopes.jct.compilers.JctCompiler; 21 | import io.github.ascopes.jct.junit.JavacCompilerTest; 22 | import io.github.ascopes.jct.workspaces.Workspaces; 23 | import org.junit.jupiter.api.DisplayName; 24 | 25 | @DisplayName("AutoService integration tests") 26 | class AutoServiceTest { 27 | 28 | @DisplayName("The AutoService descriptor is created as expected") 29 | @JavacCompilerTest 30 | void autoServiceDescriptorIsCreatedAsExpected(JctCompiler compiler) { 31 | try (var workspace = Workspaces.newWorkspace()) { 32 | // Given 33 | workspace 34 | .createSourcePathPackage() 35 | .createDirectory("org", "example") 36 | .copyContentsFrom("src", "test", "resources", "code"); 37 | 38 | // When 39 | var compilation = compiler.compile(workspace); 40 | 41 | // Then 42 | assertThatCompilation(compilation) 43 | .isSuccessfulWithoutWarnings() 44 | .classOutputPackages() 45 | .fileExists("META-INF", "services", "org.example.SomeInterface") 46 | .hasContent("org.example.SomeImpl"); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/google-auto-service/src/test/resources/code/SomeImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 org.example; 17 | 18 | import com.google.auto.service.AutoService; 19 | 20 | /** 21 | * An implementation of an interface. 22 | */ 23 | @AutoService(SomeInterface.class) 24 | public class SomeImpl implements SomeInterface { 25 | 26 | @Override 27 | public void doSomething() { 28 | System.out.println("Bang"); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/google-auto-service/src/test/resources/code/SomeInterface.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 org.example; 17 | 18 | /** 19 | * An interface. 20 | */ 21 | public interface SomeInterface { 22 | 23 | /** 24 | * Do something. 25 | */ 26 | void doSomething(); 27 | } 28 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/google-auto-service/src/test/resources/junit-platform.properties: -------------------------------------------------------------------------------- 1 | junit.jupiter.execution.parallel.enabled=true 2 | junit.jupiter.execution.parallel.mode.classes.default=SAME_THREAD 3 | junit.jupiter.execution.parallel.mode.default=CONCURRENT 4 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/google-auto-value/src/test/resources/code/User.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 org.example; 17 | 18 | import com.google.auto.value.AutoValue; 19 | import java.time.Instant; 20 | 21 | /** 22 | * An abstract representation of a user. 23 | */ 24 | @AutoValue 25 | public abstract class User { 26 | 27 | /** 28 | * Get the user ID. 29 | * 30 | * @return the user ID. 31 | */ 32 | public abstract String getId(); 33 | 34 | /** 35 | * Get the user name. 36 | * 37 | * @return the user name. 38 | */ 39 | public abstract String getName(); 40 | 41 | /** 42 | * Get the time the user was created at. 43 | * 44 | * @return the time the user was created at. 45 | */ 46 | public abstract Instant getCreatedAt(); 47 | } 48 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/google-auto-value/src/test/resources/code/UserBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 org.example; 17 | 18 | import com.google.auto.value.AutoBuilder; 19 | import java.time.Instant; 20 | 21 | /** 22 | * Abstract representation of a builder for a user. 23 | */ 24 | @AutoBuilder(ofClass = AutoValue_User.class) 25 | public abstract class UserBuilder { 26 | 27 | /** 28 | * Create a new builder for a user. 29 | * 30 | * @return the builder. 31 | */ 32 | public static UserBuilder builder() { 33 | return new AutoBuilder_UserBuilder(); 34 | } 35 | 36 | /** 37 | * Set the user ID. 38 | * 39 | * @param id the ID to set. 40 | * @return this builder. 41 | */ 42 | public abstract UserBuilder setId(String id); 43 | 44 | /** 45 | * Set the user name. 46 | * 47 | * @param name the name to set. 48 | * @return this builder. 49 | */ 50 | public abstract UserBuilder setName(String name); 51 | 52 | /** 53 | * Set the user's creation date. 54 | * 55 | * @param createdAt the creation date to set. 56 | * @return this builder. 57 | */ 58 | public abstract UserBuilder setCreatedAt(Instant createdAt); 59 | 60 | /** 61 | * Build the user object. 62 | * 63 | * @return the new user object.. 64 | */ 65 | public abstract AutoValue_User build(); 66 | } 67 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/google-auto-value/src/test/resources/junit-platform.properties: -------------------------------------------------------------------------------- 1 | junit.jupiter.execution.parallel.enabled=true 2 | junit.jupiter.execution.parallel.mode.classes.default=SAME_THREAD 3 | junit.jupiter.execution.parallel.mode.default=CONCURRENT 4 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/google-error-prone/selector.bsh: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 | // Use bsh rather than groovy since groovy does not support arbitrary JVM bytecode versions. 17 | if (Runtime.version().toString().toLowerCase().contains("ea")) { 18 | System.out.println("Error Prone does not support EA releases of the JDK."); 19 | return false; 20 | } else { 21 | System.out.println("Detected a GA release, proceeding"); 22 | return true; 23 | } 24 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/google-error-prone/src/test/resources/code/nullness/happy/HappyCase.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 org.example; 17 | 18 | import com.google.errorprone.annotations.MustBeClosed; 19 | import java.io.IOException; 20 | import java.io.InputStream; 21 | import java.nio.file.Files; 22 | import java.nio.file.Path; 23 | 24 | /** 25 | * This should pass error-prone because it always closes an auto-closeable resource. 26 | */ 27 | public class HappyCase { 28 | 29 | /** 30 | * Do something. 31 | * 32 | * @param args arguments. 33 | * @throws IOException any exception. 34 | */ 35 | public static void main(String[] args) throws IOException { 36 | try (InputStream inputStream = inputStream()) { 37 | inputStream.read(); 38 | } 39 | } 40 | 41 | @MustBeClosed 42 | private static InputStream inputStream() throws IOException { 43 | Path tempFile = Files.createTempFile("foo", "bar"); 44 | return Files.newInputStream(tempFile); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/google-error-prone/src/test/resources/code/nullness/sad/SadCase.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 org.example; 17 | 18 | import com.google.errorprone.annotations.MustBeClosed; 19 | import java.io.IOException; 20 | import java.io.InputStream; 21 | import java.nio.file.Files; 22 | import java.nio.file.Path; 23 | 24 | /** 25 | * This should fail error-prone because it never closes an auto-closeable resource. 26 | */ 27 | public class SadCase { 28 | 29 | /** 30 | * Do something. 31 | * 32 | * @param args arguments. 33 | * @throws IOException any exception. 34 | */ 35 | public static void main(String[] args) throws IOException { 36 | InputStream inputStream = inputStream(); 37 | inputStream.read(); 38 | } 39 | 40 | @MustBeClosed 41 | private static InputStream inputStream() throws IOException { 42 | Path tempFile = Files.createTempFile("foo", "bar"); 43 | return Files.newInputStream(tempFile); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/google-error-prone/src/test/resources/junit-platform.properties: -------------------------------------------------------------------------------- 1 | junit.jupiter.execution.parallel.enabled=true 2 | junit.jupiter.execution.parallel.mode.classes.default=SAME_THREAD 3 | junit.jupiter.execution.parallel.mode.default=CONCURRENT 4 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/immutables/src/test/resources/code/flat/org/example/Animal.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 org.example; 17 | 18 | import java.lang.annotation.Inherited; 19 | import org.immutables.value.Value; 20 | 21 | /** 22 | * Interface that immutables will generate an implementation for. 23 | * 24 | *

We have to set the inherited annotation here to force immutables to not try and use 25 | * javax.annotation.Generated which is only available in JDK-8 and older. Not sure why it is doing 26 | * this, but it looks like a bug in Immutables rather than JCT itself, since it appears to be 27 | * resolving the class somewhere. Guessing there is an issue with the usage of the --release javac 28 | * flag somewhere? 29 | */ 30 | @Value.Immutable 31 | @Value.Style(allowedClasspathAnnotations = Inherited.class) 32 | public interface Animal { 33 | 34 | String name(); 35 | 36 | int legCount(); 37 | 38 | int age(); 39 | } 40 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/immutables/src/test/resources/code/jpms/module-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 | module org.example { 17 | requires static org.immutables.value; 18 | requires java.base; 19 | } 20 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/immutables/src/test/resources/code/jpms/org/example/Animal.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 org.example; 17 | 18 | import java.lang.annotation.Inherited; 19 | import org.immutables.value.Value; 20 | 21 | /** 22 | * Interface that immutables will generate an implementation for. 23 | * 24 | *

We have to set the inherited annotation here to force immutables to not try and use 25 | * javax.annotation.Generated which is only available in JDK-8 and older. Not sure why it is doing 26 | * this, but it looks like a bug in Immutables rather than JCT itself, since it appears to be 27 | * resolving the class somewhere. Guessing there is an issue with the usage of the --release javac 28 | * flag somewhere? 29 | */ 30 | @Value.Immutable 31 | @Value.Style(allowedClasspathAnnotations = Inherited.class) 32 | public interface Animal { 33 | 34 | String name(); 35 | 36 | int legCount(); 37 | 38 | int age(); 39 | } 40 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/immutables/src/test/resources/junit-platform.properties: -------------------------------------------------------------------------------- 1 | junit.jupiter.execution.parallel.enabled=true 2 | junit.jupiter.execution.parallel.mode.classes.default=SAME_THREAD 3 | junit.jupiter.execution.parallel.mode.default=CONCURRENT 4 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/invoker-debug.properties: -------------------------------------------------------------------------------- 1 | invoker.mavenOpts = -Dmaven.surefire.debug="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=localhost:5005" -Dmaven.failsafe.debug="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=localhost:5005" 2 | invoker.quiet = false 3 | invoker.timeoutInSeconds = 0 4 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.mavenOpts = ${invoker.mavenOpts} 2 | invoker.profiles = its 3 | invoker.quiet = false 4 | invoker.timeoutInSeconds = 300 5 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/lombok/selector.bsh: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 | // Use bsh rather than groovy since groovy does not support arbitrary JVM bytecode versions. 17 | if (Runtime.version().toString().toLowerCase().contains("ea")) { 18 | System.out.println("Lombok does not support EA releases of the JDK."); 19 | return false; 20 | } else { 21 | System.out.println("Detected a GA release, proceeding"); 22 | return true; 23 | } 24 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/lombok/src/test/resources/code/flat/org/example/Animal.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 org.example; 17 | 18 | import lombok.Data; 19 | 20 | /** 21 | * Animal data class. 22 | */ 23 | @Data 24 | public class Animal { 25 | 26 | private final String name; 27 | private final int legCount; 28 | private final int age; 29 | } 30 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/lombok/src/test/resources/code/jpms/module-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 | module org.example { 17 | requires java.base; 18 | requires static lombok; 19 | } 20 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/lombok/src/test/resources/code/jpms/org/example/Animal.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 org.example; 17 | 18 | import lombok.Data; 19 | 20 | /** 21 | * Animal data class. 22 | */ 23 | @Data 24 | public class Animal { 25 | 26 | private final String name; 27 | private final int legCount; 28 | private final int age; 29 | } 30 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/lombok/src/test/resources/junit-platform.properties: -------------------------------------------------------------------------------- 1 | junit.jupiter.execution.parallel.enabled=true 2 | junit.jupiter.execution.parallel.mode.classes.default=SAME_THREAD 3 | junit.jupiter.execution.parallel.mode.default=CONCURRENT 4 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/mapstruct/src/test/resources/code/flat/org/example/Car.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 org.example; 17 | 18 | /** 19 | * Basic POJO representing a car. 20 | */ 21 | public class Car { 22 | 23 | private String make; 24 | private int numberOfSeats; 25 | private CarType type; 26 | 27 | public String getMake() { 28 | return make; 29 | } 30 | 31 | public int getNumberOfSeats() { 32 | return numberOfSeats; 33 | } 34 | 35 | public CarType getType() { 36 | return type; 37 | } 38 | 39 | public void setMake(String make) { 40 | this.make = make; 41 | } 42 | 43 | public void setNumberOfSeats(int numberOfSeats) { 44 | this.numberOfSeats = numberOfSeats; 45 | } 46 | 47 | public void setType(CarType type) { 48 | this.type = type; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/mapstruct/src/test/resources/code/flat/org/example/CarDto.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 org.example; 17 | 18 | /** 19 | * Basic POJO representing a car DTO. 20 | */ 21 | public class CarDto { 22 | 23 | private String make; 24 | private int seatCount; 25 | private String type; 26 | 27 | public String getMake() { 28 | return make; 29 | } 30 | 31 | public int getSeatCount() { 32 | return seatCount; 33 | } 34 | 35 | public String getType() { 36 | return type; 37 | } 38 | 39 | public void setMake(String make) { 40 | this.make = make; 41 | } 42 | 43 | public void setSeatCount(int seatCount) { 44 | this.seatCount = seatCount; 45 | } 46 | 47 | public void setType(String type) { 48 | this.type = type; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/mapstruct/src/test/resources/code/flat/org/example/CarMapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 org.example; 17 | 18 | import org.mapstruct.Mapper; 19 | import org.mapstruct.Mapping; 20 | import org.mapstruct.factory.Mappers; 21 | 22 | /** 23 | * Mapper for a Car to a Car DTO object. 24 | */ 25 | @Mapper 26 | public interface CarMapper { 27 | 28 | CarMapper INSTANCE = Mappers.getMapper(CarMapper.class); 29 | 30 | @Mapping(source = "numberOfSeats", target = "seatCount") 31 | CarDto carToCarDto(Car car); 32 | } 33 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/mapstruct/src/test/resources/code/flat/org/example/CarType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 org.example; 17 | 18 | /** 19 | * Basic enum representing types of cars. 20 | */ 21 | public enum CarType { 22 | SEDAN, 23 | HATCHBACK, 24 | SUV, 25 | CONVERTABLE, 26 | COUPE, 27 | MINIVAN, 28 | SPORTS, 29 | ATV, 30 | CLOWN, 31 | } 32 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/mapstruct/src/test/resources/code/jpms/module-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 | module org.example { 17 | requires static org.mapstruct; 18 | requires java.base; 19 | } 20 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/mapstruct/src/test/resources/code/jpms/org/example/Car.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 org.example; 17 | 18 | /** 19 | * Basic POJO representing a car. 20 | */ 21 | public class Car { 22 | 23 | private String make; 24 | private int numberOfSeats; 25 | private CarType type; 26 | 27 | public String getMake() { 28 | return make; 29 | } 30 | 31 | public int getNumberOfSeats() { 32 | return numberOfSeats; 33 | } 34 | 35 | public CarType getType() { 36 | return type; 37 | } 38 | 39 | public void setMake(String make) { 40 | this.make = make; 41 | } 42 | 43 | public void setNumberOfSeats(int numberOfSeats) { 44 | this.numberOfSeats = numberOfSeats; 45 | } 46 | 47 | public void setType(CarType type) { 48 | this.type = type; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/mapstruct/src/test/resources/code/jpms/org/example/CarDto.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 org.example; 17 | 18 | /** 19 | * Basic POJO representing a car DTO. 20 | */ 21 | public class CarDto { 22 | 23 | private String make; 24 | private int seatCount; 25 | private String type; 26 | 27 | public String getMake() { 28 | return make; 29 | } 30 | 31 | public int getSeatCount() { 32 | return seatCount; 33 | } 34 | 35 | public String getType() { 36 | return type; 37 | } 38 | 39 | public void setMake(String make) { 40 | this.make = make; 41 | } 42 | 43 | public void setSeatCount(int seatCount) { 44 | this.seatCount = seatCount; 45 | } 46 | 47 | public void setType(String type) { 48 | this.type = type; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/mapstruct/src/test/resources/code/jpms/org/example/CarMapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 org.example; 17 | 18 | import org.mapstruct.Mapper; 19 | import org.mapstruct.Mapping; 20 | import org.mapstruct.factory.Mappers; 21 | 22 | /** 23 | * Mapper for a Car to a Car DTO object. 24 | */ 25 | @Mapper 26 | public interface CarMapper { 27 | 28 | CarMapper INSTANCE = Mappers.getMapper(CarMapper.class); 29 | 30 | @Mapping(source = "numberOfSeats", target = "seatCount") 31 | CarDto carToCarDto(Car car); 32 | } 33 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/mapstruct/src/test/resources/code/jpms/org/example/CarType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 org.example; 17 | 18 | /** 19 | * Basic enum representing types of cars. 20 | */ 21 | public enum CarType { 22 | SEDAN, 23 | HATCHBACK, 24 | SUV, 25 | CONVERTABLE, 26 | COUPE, 27 | MINIVAN, 28 | SPORTS, 29 | ATV, 30 | CLOWN, 31 | } 32 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/mapstruct/src/test/resources/junit-platform.properties: -------------------------------------------------------------------------------- 1 | junit.jupiter.execution.parallel.enabled=true 2 | junit.jupiter.execution.parallel.mode.classes.default=SAME_THREAD 3 | junit.jupiter.execution.parallel.mode.default=CONCURRENT 4 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/micronaut/selector.bsh: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 | // Use bsh rather than groovy since groovy does not support arbitrary JVM bytecode versions. 17 | if (Runtime.version().major() < 17) { 18 | System.out.println("Micronaut does not support JVMs before Java 17"); 19 | return false; 20 | } else { 21 | return true; 22 | } 23 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/micronaut/src/test/java/io/github/ascopes/jct/acceptancetests/micronaut/MicronautConfigurer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 io.github.ascopes.jct.acceptancetests.micronaut; 17 | 18 | import io.github.ascopes.jct.compilers.JctCompiler; 19 | import io.github.ascopes.jct.compilers.JctCompilerConfigurer; 20 | import io.micronaut.annotation.processing.AggregatingTypeElementVisitorProcessor; 21 | import io.micronaut.annotation.processing.BeanDefinitionInjectProcessor; 22 | import io.micronaut.annotation.processing.ConfigurationMetadataProcessor; 23 | import io.micronaut.annotation.processing.PackageConfigurationInjectProcessor; 24 | import io.micronaut.annotation.processing.TypeElementVisitorProcessor; 25 | 26 | 27 | /** 28 | * Micronaut annotation processor configurer. 29 | * 30 | * @author Ashley Scopes 31 | */ 32 | public class MicronautConfigurer implements JctCompilerConfigurer { 33 | 34 | @Override 35 | public void configure(JctCompiler compiler) { 36 | compiler.addAnnotationProcessors( 37 | new AggregatingTypeElementVisitorProcessor(), 38 | new BeanDefinitionInjectProcessor(), 39 | new ConfigurationMetadataProcessor(), 40 | new PackageConfigurationInjectProcessor(), 41 | new TypeElementVisitorProcessor() 42 | ); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/micronaut/src/test/java/io/github/ascopes/jct/acceptancetests/micronaut/MicronautIntegrationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 io.github.ascopes.jct.acceptancetests.micronaut; 17 | 18 | import static io.github.ascopes.jct.assertions.JctAssertions.assertThatCompilation; 19 | 20 | import io.github.ascopes.jct.compilers.JctCompiler; 21 | import io.github.ascopes.jct.junit.JavacCompilerTest; 22 | import io.github.ascopes.jct.workspaces.Workspaces; 23 | import org.junit.jupiter.api.DisplayName; 24 | 25 | @DisplayName("Micronaut integration tests") 26 | class MicronautIntegrationTest { 27 | 28 | @DisplayName("Micronaut generates the expected code") 29 | @JavacCompilerTest(configurers = MicronautConfigurer.class) 30 | void micronautGeneratesTheExpectedCode(JctCompiler compiler) { 31 | try (var workspace = Workspaces.newWorkspace()) { 32 | // Given 33 | workspace 34 | .createSourcePathPackage() 35 | .createDirectory("org", "example") 36 | .copyContentsFrom("src", "test", "resources", "code"); 37 | 38 | // When 39 | var compilation = compiler.compile(workspace); 40 | 41 | // Then 42 | assertThatCompilation(compilation) 43 | .isSuccessful() 44 | .classOutputPackages() 45 | .allFilesExist( 46 | // Micronaut will generate these files. 47 | "org/example/$HelloController$Definition.class", 48 | "org/example/$HelloController$Definition$Exec.class", 49 | "org/example/$HelloController$Definition$Reference.class" 50 | ); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/micronaut/src/test/resources/code/Application.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 org.example; 17 | 18 | import io.micronaut.runtime.Micronaut; 19 | 20 | /** 21 | * Example Micronaut entrypoint. 22 | */ 23 | public class Application { 24 | 25 | public static void main(String[] args) { 26 | Micronaut.run(Application.class, args); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/micronaut/src/test/resources/code/HelloController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 org.example; 17 | 18 | import io.micronaut.http.MediaType; 19 | import io.micronaut.http.annotation.Controller; 20 | import io.micronaut.http.annotation.Get; 21 | import io.micronaut.http.annotation.Produces; 22 | 23 | /** 24 | * Example controller in Micronaut. 25 | */ 26 | @Controller("/hello") 27 | public class HelloController { 28 | 29 | @Get 30 | @Produces(MediaType.TEXT_PLAIN) 31 | public String index() { 32 | return "Hello World"; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/micronaut/src/test/resources/junit-platform.properties: -------------------------------------------------------------------------------- 1 | junit.jupiter.execution.parallel.enabled=true 2 | junit.jupiter.execution.parallel.mode.classes.default=SAME_THREAD 3 | junit.jupiter.execution.parallel.mode.default=CONCURRENT 4 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/serviceloader-jpms/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 4.0.0 21 | 22 | 23 | @project.groupId@ 24 | java-compiler-testing-parent 25 | @project.version@ 26 | ../../../../pom.xml 27 | 28 | 29 | acceptance-tests-serviceloader-jpms 30 | JCT acceptance tests for a service loader API (JPMS) 31 | Acceptance tests for a handwritten service-loader API using JPMS. 32 | 33 | 34 | 35 | @project.groupId@ 36 | @project.artifactId@ 37 | @project.version@ 38 | test 39 | 40 | 41 | 42 | org.junit.jupiter 43 | junit-jupiter 44 | test 45 | 46 | 47 | 48 | org.slf4j 49 | slf4j-simple 50 | test 51 | 52 | 53 | 54 | 55 | 56 | 57 | org.apache.maven.plugins 58 | maven-failsafe-plugin 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/serviceloader-jpms/src/main/java/io/github/ascopes/jct/acceptancetests/serviceloaderjpms/AnnotatedService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 io.github.ascopes.jct.acceptancetests.serviceloaderjpms; 17 | 18 | /** 19 | * Descriptor of an annotated service type. 20 | * 21 | * @author Ashley Scopes 22 | */ 23 | class AnnotatedService { 24 | 25 | private final String interfaceType; 26 | private final String implementationType; 27 | 28 | AnnotatedService(String interfaceType, String implementationType) { 29 | this.interfaceType = interfaceType; 30 | this.implementationType = implementationType; 31 | } 32 | 33 | String getInterfaceType() { 34 | return interfaceType; 35 | } 36 | 37 | String getImplementationType() { 38 | return implementationType; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/serviceloader-jpms/src/main/java/io/github/ascopes/jct/acceptancetests/serviceloaderjpms/Service.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 io.github.ascopes.jct.acceptancetests.serviceloaderjpms; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * Annotation that marks a class to be injected as part of a service loader. 26 | * 27 | * @author Ashley Scopes 28 | */ 29 | @Documented 30 | @Retention(RetentionPolicy.SOURCE) 31 | @Target(ElementType.TYPE) 32 | public @interface Service { 33 | 34 | /** 35 | * The interface type to register the annotated class as an implementation of. 36 | * 37 | * @return the interface class to bind to. 38 | */ 39 | Class value(); 40 | } 41 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/serviceloader-jpms/src/main/java/module-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 | import io.github.ascopes.jct.acceptancetests.serviceloaderjpms.ServiceProcessor; 17 | import javax.annotation.processing.Processor; 18 | 19 | module io.github.ascopes.jct.acceptancetests.serviceloaderjpms { 20 | requires java.compiler; 21 | exports io.github.ascopes.jct.acceptancetests.serviceloaderjpms; 22 | provides Processor with ServiceProcessor; 23 | } 24 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/serviceloader-jpms/src/test/resources/code/module-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 | module org.example { 17 | requires static io.github.ascopes.jct.acceptancetests.serviceloaderjpms; 18 | } 19 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/serviceloader-jpms/src/test/resources/code/org/example/InsultProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 org.example; 17 | 18 | /** 19 | * Interface to a provider of insults. 20 | */ 21 | public interface InsultProvider { 22 | 23 | String getInsult(); 24 | } 25 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/serviceloader-jpms/src/test/resources/code/org/example/MeanInsultProviderImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 org.example; 17 | 18 | import io.github.ascopes.jct.acceptancetests.serviceloaderjpms.Service; 19 | 20 | /** 21 | * Provider of overly mean insults. 22 | */ 23 | @Service(InsultProvider.class) 24 | public class MeanInsultProviderImpl implements InsultProvider { 25 | 26 | @Override 27 | public String getInsult() { 28 | return "Silence is the best answer for a fool"; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/serviceloader-jpms/src/test/resources/junit-platform.properties: -------------------------------------------------------------------------------- 1 | junit.jupiter.execution.parallel.enabled=true 2 | junit.jupiter.execution.parallel.mode.classes.default=SAME_THREAD 3 | junit.jupiter.execution.parallel.mode.default=CONCURRENT 4 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/serviceloader/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 4.0.0 21 | 22 | 23 | @project.groupId@ 24 | java-compiler-testing-parent 25 | @project.version@ 26 | ../../../../pom.xml 27 | 28 | 29 | acceptance-tests-serviceloader 30 | JCT acceptance tests for a service loader API 31 | Acceptance tests for a handwritten service-loader API. 32 | 33 | 34 | 35 | @project.groupId@ 36 | @project.artifactId@ 37 | @project.version@ 38 | test 39 | 40 | 41 | 42 | org.junit.jupiter 43 | junit-jupiter 44 | test 45 | 46 | 47 | 48 | org.slf4j 49 | slf4j-simple 50 | test 51 | 52 | 53 | 54 | 55 | 56 | 57 | org.apache.maven.plugins 58 | maven-failsafe-plugin 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/serviceloader/src/main/java/io/github/ascopes/jct/acceptancetests/serviceloader/AnnotatedService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 io.github.ascopes.jct.acceptancetests.serviceloader; 17 | 18 | /** 19 | * Descriptor of an annotated service type. 20 | * 21 | * @author Ashley Scopes 22 | */ 23 | class AnnotatedService { 24 | 25 | private final String interfaceType; 26 | private final String implementationType; 27 | 28 | AnnotatedService(String interfaceType, String implementationType) { 29 | this.interfaceType = interfaceType; 30 | this.implementationType = implementationType; 31 | } 32 | 33 | String getInterfaceType() { 34 | return interfaceType; 35 | } 36 | 37 | String getImplementationType() { 38 | return implementationType; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/serviceloader/src/main/java/io/github/ascopes/jct/acceptancetests/serviceloader/Service.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 io.github.ascopes.jct.acceptancetests.serviceloader; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * Annotation that marks a class to be injected as part of a service loader. 26 | * 27 | * @author Ashley Scopes 28 | */ 29 | @Documented 30 | @Retention(RetentionPolicy.SOURCE) 31 | @Target(ElementType.TYPE) 32 | public @interface Service { 33 | 34 | /** 35 | * The interface type to register the annotated class as an implementation of. 36 | * 37 | * @return the interface class to bind to. 38 | */ 39 | Class value(); 40 | } 41 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/serviceloader/src/test/java/io/github/ascopes/jct/acceptancetests/serviceloader/testing/ServiceProcessorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 io.github.ascopes.jct.acceptancetests.serviceloader.testing; 17 | 18 | import static io.github.ascopes.jct.assertions.JctAssertions.assertThatCompilation; 19 | 20 | import io.github.ascopes.jct.acceptancetests.serviceloader.ServiceProcessor; 21 | import io.github.ascopes.jct.compilers.JctCompiler; 22 | import io.github.ascopes.jct.junit.JavacCompilerTest; 23 | import io.github.ascopes.jct.workspaces.Workspaces; 24 | import org.junit.jupiter.api.DisplayName; 25 | 26 | @DisplayName("ServiceProcessor tests (no JPMS)") 27 | class ServiceProcessorTest { 28 | 29 | @DisplayName("Expected files get created when the processor is run") 30 | @JavacCompilerTest 31 | void expectedFilesGetCreated(JctCompiler compiler) { 32 | try (var workspace = Workspaces.newWorkspace()) { 33 | // Given 34 | workspace 35 | .createSourcePathPackage() 36 | .createDirectory("org", "example") 37 | .copyContentsFrom("src", "test", "resources", "code"); 38 | 39 | var compilation = compiler 40 | .addAnnotationProcessors(new ServiceProcessor()) 41 | .compile(workspace); 42 | 43 | assertThatCompilation(compilation) 44 | .isSuccessfulWithoutWarnings() 45 | .classOutputPackages() 46 | .fileExists("META-INF", "services", "org.example.InsultProvider") 47 | .hasContent("org.example.MeanInsultProviderImpl"); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/serviceloader/src/test/resources/code/InsultProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 org.example; 17 | 18 | /** 19 | * Interface to a provider of insults. 20 | */ 21 | public interface InsultProvider { 22 | 23 | String getInsult(); 24 | } 25 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/serviceloader/src/test/resources/code/MeanInsultProviderImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 org.example; 17 | 18 | import io.github.ascopes.jct.acceptancetests.serviceloader.Service; 19 | 20 | /** 21 | * Provider of overly mean insults. 22 | */ 23 | @Service(InsultProvider.class) 24 | public class MeanInsultProviderImpl implements InsultProvider { 25 | 26 | @Override 27 | public String getInsult() { 28 | return "Silence is the best answer for a fool"; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/serviceloader/src/test/resources/junit-platform.properties: -------------------------------------------------------------------------------- 1 | junit.jupiter.execution.parallel.enabled=true 2 | junit.jupiter.execution.parallel.mode.classes.default=SAME_THREAD 3 | junit.jupiter.execution.parallel.mode.default=CONCURRENT 4 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 21 | 22 | its 23 | 24 | 25 | 26 | local.central 27 | @localRepositoryUrl@ 28 | 29 | true 30 | 31 | 32 | true 33 | 34 | 35 | 36 | 37 | 38 | 39 | local.central 40 | @localRepositoryUrl@ 41 | 42 | true 43 | 44 | 45 | true 46 | 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/spring/src/test/resources/code/autoconfigure/module-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 | module org.example { 17 | requires java.base; 18 | requires spring.beans; 19 | requires spring.boot; 20 | requires spring.boot.autoconfigure; 21 | requires spring.context; 22 | requires spring.core; 23 | requires spring.web; 24 | requires spring.webflux; 25 | } 26 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/spring/src/test/resources/code/autoconfigure/org/example/Application.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 org.example; 17 | 18 | import org.springframework.boot.SpringApplication; 19 | import org.springframework.boot.autoconfigure.SpringBootApplication; 20 | import org.springframework.boot.context.properties.ConfigurationPropertiesScan; 21 | 22 | /** 23 | * Spring Boot application entrypoint. 24 | */ 25 | @ConfigurationPropertiesScan 26 | @SpringBootApplication 27 | public class Application { 28 | 29 | public static void main(String[] args) { 30 | SpringApplication.run(Application.class, args); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/spring/src/test/resources/code/autoconfigure/org/example/config/RouteConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 org.example.config; 17 | 18 | import org.example.handlers.HelloWorldHandler; 19 | import org.springframework.boot.autoconfigure.AutoConfiguration; 20 | import org.springframework.context.annotation.Bean; 21 | import org.springframework.web.reactive.function.server.RouterFunction; 22 | import org.springframework.web.reactive.function.server.RouterFunctions; 23 | import org.springframework.web.reactive.function.server.ServerResponse; 24 | 25 | /** 26 | * Routing configuration. 27 | */ 28 | @AutoConfiguration 29 | public class RouteConfig { 30 | 31 | /** 32 | * Application web router bean. 33 | * 34 | * @param handler the handler for "Hello, World!" responses. 35 | * @return the router. 36 | */ 37 | @Bean 38 | public RouterFunction router(HelloWorldHandler handler) { 39 | return RouterFunctions 40 | .route() 41 | .GET("/api/v1/hello-world", handler::getHelloWorld) 42 | .build(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/spring/src/test/resources/code/autoconfigure/org/example/handlers/HelloWorldHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 org.example.handlers; 17 | 18 | import org.springframework.stereotype.Component; 19 | import org.springframework.web.reactive.function.server.ServerRequest; 20 | import org.springframework.web.reactive.function.server.ServerResponse; 21 | import reactor.core.publisher.Mono; 22 | 23 | /** 24 | * Handler that just says hello and then finishes. Very enterprise-oriented logic. 25 | */ 26 | @Component 27 | public class HelloWorldHandler { 28 | 29 | /** 30 | * Just say the message and then go away. 31 | * 32 | * @param request the GET request. 33 | * @return a 200 OK response that very politely greets me and makes me feel like I have an AI as a 34 | * friend. 35 | */ 36 | public Mono getHelloWorld(ServerRequest request) { 37 | return ServerResponse 38 | .ok() 39 | .bodyValue("Hello, World!"); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/spring/src/test/resources/code/configuration/module-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 | module org.example { 17 | requires java.base; 18 | requires spring.beans; 19 | requires spring.boot; 20 | requires spring.context; 21 | requires spring.core; 22 | requires spring.web; 23 | requires spring.webflux; 24 | } 25 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/spring/src/test/resources/code/configuration/org/example/Application.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 org.example; 17 | 18 | import org.springframework.boot.SpringApplication; 19 | import org.springframework.boot.autoconfigure.SpringBootApplication; 20 | import org.springframework.boot.context.properties.ConfigurationPropertiesScan; 21 | 22 | /** 23 | * Spring Boot application entrypoint. 24 | */ 25 | @ConfigurationPropertiesScan 26 | @SpringBootApplication 27 | public class Application { 28 | 29 | public static void main(String[] args) { 30 | SpringApplication.run(Application.class, args); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/spring/src/test/resources/code/configuration/org/example/config/RouteConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 org.example.config; 17 | 18 | import org.example.handlers.HelloWorldHandler; 19 | import org.springframework.context.annotation.Bean; 20 | import org.springframework.context.annotation.Configuration; 21 | import org.springframework.web.reactive.function.server.RouterFunction; 22 | import org.springframework.web.reactive.function.server.RouterFunctions; 23 | import org.springframework.web.reactive.function.server.ServerResponse; 24 | 25 | /** 26 | * Routing configuration. 27 | */ 28 | @Configuration 29 | public class RouteConfig { 30 | 31 | /** 32 | * Application web router bean. 33 | * 34 | * @param handler the handler for "Hello, World!" responses. 35 | * @return the router. 36 | */ 37 | @Bean 38 | public RouterFunction router(HelloWorldHandler handler) { 39 | return RouterFunctions 40 | .route() 41 | .GET("/api/v1/hello-world", handler::getHelloWorld) 42 | .build(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/spring/src/test/resources/code/configuration/org/example/handlers/HelloWorldHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 org.example.handlers; 17 | 18 | import org.example.properties.HelloWorldProperties; 19 | import org.springframework.stereotype.Component; 20 | import org.springframework.web.reactive.function.server.ServerRequest; 21 | import org.springframework.web.reactive.function.server.ServerResponse; 22 | import reactor.core.publisher.Mono; 23 | 24 | /** 25 | * Handler that just says hello and then finishes. Very enterprise-oriented logic. 26 | */ 27 | @Component 28 | public class HelloWorldHandler { 29 | 30 | private final HelloWorldProperties properties; 31 | 32 | public HelloWorldHandler(HelloWorldProperties properties) { 33 | this.properties = properties; 34 | } 35 | 36 | /** 37 | * Just say the message and then go away. 38 | * 39 | * @param request the GET request. 40 | * @return a 200 OK response that very politely greets me and makes me feel like I have an AI as a 41 | * friend. 42 | */ 43 | public Mono getHelloWorld(ServerRequest request) { 44 | return ServerResponse 45 | .ok() 46 | .bodyValue(properties.getMessage()); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/spring/src/test/resources/code/configuration/org/example/properties/HelloWorldProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 org.example.properties; 17 | 18 | import org.springframework.boot.context.properties.ConfigurationProperties; 19 | 20 | /** 21 | * A configuration properties class implementation. 22 | */ 23 | @ConfigurationProperties("hello.world") 24 | public class HelloWorldProperties { 25 | 26 | private String message; 27 | 28 | public String getMessage() { 29 | return message; 30 | } 31 | 32 | public void setMessage(String message) { 33 | this.message = message; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/spring/src/test/resources/junit-platform.properties: -------------------------------------------------------------------------------- 1 | junit.jupiter.execution.parallel.enabled=true 2 | junit.jupiter.execution.parallel.mode.classes.default=SAME_THREAD 3 | junit.jupiter.execution.parallel.mode.default=CONCURRENT 4 | -------------------------------------------------------------------------------- /java-compiler-testing/src/main/java/io/github/ascopes/jct/assertions/ClassLoaderAssert.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 io.github.ascopes.jct.assertions; 17 | 18 | import org.assertj.core.api.AbstractAssert; 19 | import org.jspecify.annotations.Nullable; 20 | 21 | /** 22 | * Assertions to perform on a classloader. 23 | * 24 | *

This type is a placeholder and will be replaced when AssertJ releases changes to 25 | * support assertions on classloaders. 26 | * 27 | * @author Ashley Scopes 28 | * @since 0.0.1 29 | */ 30 | public final class ClassLoaderAssert extends AbstractAssert { 31 | 32 | /** 33 | * Initialize a new assertions object. 34 | * 35 | * @param actual the class loader to assert upon. 36 | */ 37 | @SuppressWarnings("DataFlowIssue") 38 | public ClassLoaderAssert(@Nullable ClassLoader actual) { 39 | super(actual, ClassLoaderAssert.class); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /java-compiler-testing/src/main/java/io/github/ascopes/jct/assertions/JavaFileObjectAssert.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 io.github.ascopes.jct.assertions; 17 | 18 | import javax.tools.JavaFileObject; 19 | import org.jspecify.annotations.Nullable; 20 | 21 | /** 22 | * Assertions for {@link JavaFileObject Java file objects}. 23 | * 24 | * @author Ashley Scopes 25 | * @since 0.0.1 26 | */ 27 | public final class JavaFileObjectAssert 28 | extends AbstractJavaFileObjectAssert { 29 | 30 | /** 31 | * Create a new instance of this assertion object. 32 | * 33 | * @param actual the Java file object to assert upon. 34 | */ 35 | public JavaFileObjectAssert(@Nullable JavaFileObject actual) { 36 | super(actual, JavaFileObjectAssert.class); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /java-compiler-testing/src/main/java/io/github/ascopes/jct/assertions/OutputContainerGroupAssert.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 io.github.ascopes.jct.assertions; 17 | 18 | import io.github.ascopes.jct.containers.OutputContainerGroup; 19 | import org.jspecify.annotations.Nullable; 20 | 21 | /** 22 | * Assertions for output container groups. 23 | * 24 | * @author Ashley Scopes 25 | * @since 0.0.1 26 | */ 27 | public final class OutputContainerGroupAssert 28 | extends AbstractContainerGroupAssert { 29 | 30 | /** 31 | * Initialize the container group assertions. 32 | * 33 | * @param containerGroup the container group to assert upon. 34 | * @throws AssertionError if the container group is null. 35 | */ 36 | public OutputContainerGroupAssert(@Nullable OutputContainerGroup containerGroup) { 37 | super(containerGroup, OutputContainerGroupAssert.class); 38 | } 39 | 40 | /** 41 | * Get assertions to perform on package-oriented paths within this location. 42 | * 43 | * @return the package-oriented assertions. 44 | * @throws AssertionError if the container group is null. 45 | */ 46 | public PackageContainerGroupAssert packages() { 47 | isNotNull(); 48 | 49 | return new PackageContainerGroupAssert(actual); 50 | } 51 | 52 | /** 53 | * Get assertions to perform on module-oriented paths within this location. 54 | * 55 | * @return the module-oriented assertions. 56 | * @throws AssertionError if the container group is null. 57 | */ 58 | public ModuleContainerGroupAssert modules() { 59 | isNotNull(); 60 | 61 | return new ModuleContainerGroupAssert(actual); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /java-compiler-testing/src/main/java/io/github/ascopes/jct/assertions/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 | /** 17 | * AssertJ extensions for testing the results of compilations. 18 | */ 19 | package io.github.ascopes.jct.assertions; 20 | -------------------------------------------------------------------------------- /java-compiler-testing/src/main/java/io/github/ascopes/jct/compilers/CompilationMode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 io.github.ascopes.jct.compilers; 17 | 18 | /** 19 | * An enum representing the various types of compilation mode that a compiler can run under. 20 | * 21 | *

This corresponds to the {@code -proc} flag in the OpenJDK Javac implementation. 22 | * 23 | * @author Ashley Scopes 24 | * @since 0.0.1 25 | */ 26 | public enum CompilationMode { 27 | 28 | /** 29 | * Run compilation and run the annotation processors, if configured. 30 | * 31 | *

Prior to Java 21, this is the default if no {@code -proc} flag is provided to the compiler. 32 | * 33 | *

From Java 21 and onwards, this is equivalent to passing {@code -proc:full} to the compiler. 34 | */ 35 | COMPILATION_AND_ANNOTATION_PROCESSING, 36 | 37 | /** 38 | * Run compilation, but skip any annotation processing that may run. 39 | * 40 | *

This corresponds to providing {@code -proc:none} in the OpenJDK Javac implementation. 41 | */ 42 | COMPILATION_ONLY, 43 | 44 | /** 45 | * Skip compilation, but run any annotation processing that may be enabled. 46 | * 47 | *

This corresponds to providing {@code -proc:only} in the OpenJDK Javac implementation. 48 | */ 49 | ANNOTATION_PROCESSING_ONLY, 50 | } 51 | -------------------------------------------------------------------------------- /java-compiler-testing/src/main/java/io/github/ascopes/jct/compilers/DebuggingInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 io.github.ascopes.jct.compilers; 17 | 18 | import java.util.Collections; 19 | import java.util.EnumSet; 20 | import java.util.Set; 21 | 22 | /** 23 | * An enum representing the various types of debugger info that can be included in compilations. 24 | * 25 | *

This corresponds to the {@code -g} flag in the OpenJDK Javac implementation. 26 | * 27 | *

Debugging info flags are designed to be combined using the helper methods on this class. 28 | * 29 | * @author Ashley Scopes 30 | * @since 3.0.0 31 | */ 32 | public enum DebuggingInfo { 33 | 34 | /** 35 | * Include line numbers. 36 | */ 37 | LINES, 38 | 39 | /** 40 | * Include local variable names. 41 | */ 42 | VARS, 43 | 44 | /** 45 | * Include source code. 46 | */ 47 | SOURCE; 48 | 49 | /** 50 | * Return a set of none of the debugger info flags. 51 | * 52 | * @return a set containing no debugger flags. 53 | */ 54 | public static Set none() { 55 | return EnumSet.noneOf(DebuggingInfo.class); 56 | } 57 | 58 | /** 59 | * Return a set of the given debugger info flags. 60 | * 61 | * @param flags flags. 62 | * @return the set of the debugger info flags. 63 | */ 64 | public static Set just(DebuggingInfo... flags) { 65 | var set = none(); 66 | Collections.addAll(set, flags); 67 | return set; 68 | } 69 | 70 | /** 71 | * Return a set of all the debugger info flags. 72 | * 73 | * @return a set containing all the debugger flags. 74 | */ 75 | public static Set all() { 76 | return EnumSet.allOf(DebuggingInfo.class); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /java-compiler-testing/src/main/java/io/github/ascopes/jct/compilers/JctCompilers.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 io.github.ascopes.jct.compilers; 17 | 18 | import io.github.ascopes.jct.compilers.impl.JavacJctCompilerImpl; 19 | import io.github.ascopes.jct.utils.UtilityClass; 20 | 21 | /** 22 | * Helpers to create new compiler instances. 23 | * 24 | * @author Ashley Scopes 25 | * @since 0.0.1 26 | */ 27 | public final class JctCompilers extends UtilityClass { 28 | 29 | private JctCompilers() { 30 | // Static-only class. 31 | } 32 | 33 | /** 34 | * Create a new instance of the default platform compiler that is part of the JDK ({@code javac} 35 | * on OpenJDK-derived implementations). 36 | * 37 | * @return the compiler instance. 38 | * @since 0.2.0 39 | */ 40 | public static JctCompiler newPlatformCompiler() { 41 | return new JavacJctCompilerImpl(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /java-compiler-testing/src/main/java/io/github/ascopes/jct/compilers/JctFlagBuilderFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 io.github.ascopes.jct.compilers; 17 | 18 | /** 19 | * Factory that creates a flag builder. 20 | * 21 | * @author Ashley Scopes 22 | * @since 0.0.1 23 | */ 24 | @FunctionalInterface 25 | public interface JctFlagBuilderFactory { 26 | 27 | /** 28 | * Create a new flag builder. 29 | * 30 | * @return the flag builder. 31 | */ 32 | JctFlagBuilder createFlagBuilder(); 33 | } 34 | -------------------------------------------------------------------------------- /java-compiler-testing/src/main/java/io/github/ascopes/jct/compilers/Jsr199CompilerFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 io.github.ascopes.jct.compilers; 17 | 18 | import javax.tools.JavaCompiler; 19 | 20 | /** 21 | * Factory that creates an instance of a JSR-199 compiler. 22 | * 23 | * @author Ashley Scopes 24 | * @since 0.0.1 25 | */ 26 | @FunctionalInterface 27 | public interface Jsr199CompilerFactory { 28 | 29 | /** 30 | * Create a new instance of a JSR-199 {@link JavaCompiler}. 31 | * 32 | * @return the JSR-199 Java compiler. 33 | */ 34 | JavaCompiler createCompiler(); 35 | } 36 | -------------------------------------------------------------------------------- /java-compiler-testing/src/main/java/io/github/ascopes/jct/compilers/impl/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 | /** 17 | * Compiler backend integrations. 18 | */ 19 | package io.github.ascopes.jct.compilers.impl; 20 | -------------------------------------------------------------------------------- /java-compiler-testing/src/main/java/io/github/ascopes/jct/compilers/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 | /** 17 | * APIs for performing compiler passes across user-defined workspaces. 18 | */ 19 | package io.github.ascopes.jct.compilers; 20 | -------------------------------------------------------------------------------- /java-compiler-testing/src/main/java/io/github/ascopes/jct/containers/impl/PackageContainerGroupUrlClassLoader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 io.github.ascopes.jct.containers.impl; 17 | 18 | import io.github.ascopes.jct.containers.Container; 19 | import io.github.ascopes.jct.containers.PackageContainerGroup; 20 | import io.github.ascopes.jct.workspaces.PathRoot; 21 | import java.net.URL; 22 | import java.net.URLClassLoader; 23 | 24 | /** 25 | * An extension of the Java {@link URLClassLoader} that wraps around container groups. 26 | * 27 | * @author Ashley Scopes 28 | * @since 0.0.1 29 | */ 30 | public final class PackageContainerGroupUrlClassLoader extends URLClassLoader { 31 | 32 | /** 33 | * Initialise this class loader. 34 | * 35 | * @param group the container group to use. 36 | */ 37 | public PackageContainerGroupUrlClassLoader(PackageContainerGroup group) { 38 | super( 39 | "Packages within " + group.getLocation().getName(), 40 | extractUrls(group), 41 | ClassLoader.getSystemClassLoader() 42 | ); 43 | } 44 | 45 | private static URL[] extractUrls(PackageContainerGroup group) { 46 | return group.getPackages() 47 | .stream() 48 | .map(Container::getPathRoot) 49 | .map(PathRoot::getUrl) 50 | .toArray(URL[]::new); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /java-compiler-testing/src/main/java/io/github/ascopes/jct/containers/impl/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 | /** 17 | * Implementations of compiler container hierarchies. 18 | */ 19 | package io.github.ascopes.jct.containers.impl; 20 | -------------------------------------------------------------------------------- /java-compiler-testing/src/main/java/io/github/ascopes/jct/containers/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 | /** 17 | * APIs for representing the various file management locations across multiple file system 18 | * implementations. 19 | */ 20 | package io.github.ascopes.jct.containers; 21 | -------------------------------------------------------------------------------- /java-compiler-testing/src/main/java/io/github/ascopes/jct/diagnostics/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 | /** 17 | * Support for collecting and representing diagnostics from compiler implementations. 18 | */ 19 | package io.github.ascopes.jct.diagnostics; 20 | -------------------------------------------------------------------------------- /java-compiler-testing/src/main/java/io/github/ascopes/jct/ex/JctCompilerException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 io.github.ascopes.jct.ex; 17 | 18 | import org.jspecify.annotations.Nullable; 19 | 20 | /** 21 | * Exception that is thrown if the compiler fails to run and throws an unhandled exception. 22 | * 23 | * @author Ashley Scopes 24 | * @since 0.0.1 25 | */ 26 | public final class JctCompilerException extends JctException { 27 | 28 | /** 29 | * Initialize the error. 30 | * 31 | * @param message the error message. 32 | */ 33 | public JctCompilerException(String message) { 34 | super(message); 35 | } 36 | 37 | /** 38 | * Initialize the error. 39 | * 40 | * @param message the error message. 41 | * @param cause the cause of the error (or {@code null} if no cause exists). 42 | */ 43 | public JctCompilerException(String message, @Nullable Throwable cause) { 44 | super(message, cause); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /java-compiler-testing/src/main/java/io/github/ascopes/jct/ex/JctException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 io.github.ascopes.jct.ex; 17 | 18 | import org.jspecify.annotations.Nullable; 19 | 20 | /** 21 | * Base for any exceptions thrown by JCT. 22 | * 23 | * @author Ashley Scopes 24 | * @since 0.0.1 25 | */ 26 | public abstract class JctException extends RuntimeException { 27 | 28 | /** 29 | * Initialise the exception with a message. 30 | * 31 | * @param message the message to initialise the exception with. 32 | */ 33 | JctException(String message) { 34 | super(message); 35 | } 36 | 37 | /** 38 | * Initialise the exception with a message and a cause. 39 | * 40 | * @param message the message to initialise the exception with. 41 | * @param cause the cause of the exception (or {@code null} if no cause exists). 42 | */ 43 | JctException(String message, @Nullable Throwable cause) { 44 | super(message, cause); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /java-compiler-testing/src/main/java/io/github/ascopes/jct/ex/JctIllegalInputException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 io.github.ascopes.jct.ex; 17 | 18 | import org.jspecify.annotations.Nullable; 19 | 20 | /** 21 | * Exception raised if an illegal input is provided to a method. 22 | * 23 | * @author Ashley Scopes 24 | * @since 1.1.0 25 | */ 26 | public final class JctIllegalInputException extends JctException { 27 | 28 | /** 29 | * Initialise the exception. 30 | * 31 | * @param message the message to report. 32 | */ 33 | public JctIllegalInputException(String message) { 34 | super(message); 35 | } 36 | 37 | /** 38 | * Initialise the exception with a cause. 39 | * 40 | * @param message the message to report. 41 | * @param cause the cause of the exception (or {@code null} if no cause exists). 42 | */ 43 | public JctIllegalInputException(String message, @Nullable Throwable cause) { 44 | super(message, cause); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /java-compiler-testing/src/main/java/io/github/ascopes/jct/ex/JctJunitConfigurerException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 io.github.ascopes.jct.ex; 17 | 18 | import org.jspecify.annotations.Nullable; 19 | 20 | /** 21 | * An exception that is thrown when a compiler configurer cannot be initialised successfully using 22 | * the JCT JUnit parameterised test API. 23 | * 24 | * @author Ashley Scopes 25 | * @since 0.0.1 26 | */ 27 | public final class JctJunitConfigurerException extends JctException { 28 | 29 | /** 30 | * Initialise the exception. 31 | * 32 | * @param message the error message to show. 33 | */ 34 | public JctJunitConfigurerException(String message) { 35 | super(message); 36 | } 37 | 38 | /** 39 | * Initialise the exception. 40 | * 41 | * @param message the error message to show. 42 | * @param cause the cause of the exception (or {@code null} if no cause exists). 43 | */ 44 | public JctJunitConfigurerException(String message, @Nullable Throwable cause) { 45 | super(message, cause); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /java-compiler-testing/src/main/java/io/github/ascopes/jct/ex/JctNotFoundException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 io.github.ascopes.jct.ex; 17 | 18 | /** 19 | * Exception raised if an element is not found. 20 | * 21 | * @author Ashley Scopes 22 | * @since 1.1.0 23 | */ 24 | public final class JctNotFoundException extends JctException { 25 | 26 | /** 27 | * Initialise the exception. 28 | * 29 | * @param message the message to report. 30 | */ 31 | public JctNotFoundException(String message) { 32 | super(message); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /java-compiler-testing/src/main/java/io/github/ascopes/jct/ex/JctNotImplementedException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 io.github.ascopes.jct.ex; 17 | 18 | /** 19 | * Exception that is raised if an internal feature is not implemented. 20 | * 21 | * @author Ashley Scopes 22 | * @since 1.1.0 23 | */ 24 | public final class JctNotImplementedException extends JctException { 25 | 26 | /** 27 | * Initialise the exception. 28 | * 29 | * @param message the message to report. 30 | */ 31 | public JctNotImplementedException(String message) { 32 | super(message); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /java-compiler-testing/src/main/java/io/github/ascopes/jct/ex/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 | /** 17 | * Common exceptions used within this API. 18 | */ 19 | package io.github.ascopes.jct.ex; 20 | 21 | -------------------------------------------------------------------------------- /java-compiler-testing/src/main/java/io/github/ascopes/jct/filemanagers/AnnotationProcessorDiscovery.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 io.github.ascopes.jct.filemanagers; 17 | 18 | /** 19 | * Mode for annotation processor discovery when no explicit processors are provided. 20 | * 21 | * @author Ashley Scopes 22 | * @since 0.0.1 23 | */ 24 | public enum AnnotationProcessorDiscovery { 25 | /** 26 | * Discovery is enabled, and will also scan any dependencies in the classpath or module path. 27 | */ 28 | INCLUDE_DEPENDENCIES, 29 | 30 | /** 31 | * Discovery is enabled using the provided processor paths. 32 | */ 33 | ENABLED, 34 | 35 | /** 36 | * Discovery is disabled. 37 | */ 38 | DISABLED, 39 | } 40 | -------------------------------------------------------------------------------- /java-compiler-testing/src/main/java/io/github/ascopes/jct/filemanagers/JctFileManagerFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 io.github.ascopes.jct.filemanagers; 17 | 18 | import io.github.ascopes.jct.workspaces.Workspace; 19 | 20 | /** 21 | * Factory interface for building a file manager object. 22 | * 23 | * @author Ashley Scopes 24 | * @since 0.0.1 25 | */ 26 | @FunctionalInterface 27 | public interface JctFileManagerFactory { 28 | 29 | /** 30 | * Create and configure a file manager for a workspace. 31 | * 32 | * @param workspace the workspace to access files in. 33 | * @return the file manager. 34 | */ 35 | JctFileManager createFileManager(Workspace workspace); 36 | } 37 | -------------------------------------------------------------------------------- /java-compiler-testing/src/main/java/io/github/ascopes/jct/filemanagers/JctFileManagers.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 io.github.ascopes.jct.filemanagers; 17 | 18 | import io.github.ascopes.jct.compilers.JctCompiler; 19 | import io.github.ascopes.jct.filemanagers.impl.JctFileManagerFactoryImpl; 20 | import io.github.ascopes.jct.utils.UtilityClass; 21 | 22 | /** 23 | * Helpers to create instances of default implementations for file managers. 24 | * 25 | * @author Ashley Scopes 26 | * @since 1.1.0 27 | */ 28 | public final class JctFileManagers extends UtilityClass { 29 | 30 | private JctFileManagers() { 31 | // Static-only class. 32 | } 33 | 34 | /** 35 | * Create a new default implementation of a file manager factory. 36 | * 37 | * @param compiler the JctCompiler to bind any file managers to. 38 | * @return the file manager factory instance. 39 | */ 40 | public static JctFileManagerFactory newJctFileManagerFactory(JctCompiler compiler) { 41 | return new JctFileManagerFactoryImpl(compiler); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /java-compiler-testing/src/main/java/io/github/ascopes/jct/filemanagers/LoggingMode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 io.github.ascopes.jct.filemanagers; 17 | 18 | /** 19 | * Options for how to handle logging on special internal components. 20 | * 21 | *

This primarily exists to support debugging the JCT library itself. 22 | * 23 | * @author Ashley Scopes 24 | * @since 0.0.1 25 | */ 26 | public enum LoggingMode { 27 | 28 | /** 29 | * Enable basic logging. 30 | */ 31 | ENABLED, 32 | 33 | /** 34 | * Enable logging and include stacktraces in the logs for each entry. 35 | */ 36 | STACKTRACES, 37 | 38 | /** 39 | * Do not log anything. 40 | */ 41 | DISABLED, 42 | } 43 | -------------------------------------------------------------------------------- /java-compiler-testing/src/main/java/io/github/ascopes/jct/filemanagers/config/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 | /** 17 | * Reusable components for setting up JSR-199 file managers. 18 | */ 19 | package io.github.ascopes.jct.filemanagers.config; 20 | 21 | -------------------------------------------------------------------------------- /java-compiler-testing/src/main/java/io/github/ascopes/jct/filemanagers/impl/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 | /** 17 | * File manager implementation details. 18 | */ 19 | package io.github.ascopes.jct.filemanagers.impl; 20 | 21 | -------------------------------------------------------------------------------- /java-compiler-testing/src/main/java/io/github/ascopes/jct/filemanagers/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 | /** 17 | * APIs that integrate with the JSR-199 FileManager APIs. 18 | */ 19 | package io.github.ascopes.jct.filemanagers; 20 | -------------------------------------------------------------------------------- /java-compiler-testing/src/main/java/io/github/ascopes/jct/junit/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 | /** 17 | * Integrations with Junit Jupiter APIs. 18 | */ 19 | package io.github.ascopes.jct.junit; 20 | -------------------------------------------------------------------------------- /java-compiler-testing/src/main/java/io/github/ascopes/jct/repr/LocationRepresentation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 io.github.ascopes.jct.repr; 17 | 18 | import javax.tools.JavaFileManager.Location; 19 | import org.assertj.core.presentation.Representation; 20 | import org.jspecify.annotations.Nullable; 21 | 22 | /** 23 | * Representation for a {@link Location location}. 24 | * 25 | * @author Ashley Scopes 26 | * @since 0.0.1 27 | */ 28 | public final class LocationRepresentation implements Representation { 29 | 30 | private static final LocationRepresentation INSTANCE 31 | = new LocationRepresentation(); 32 | 33 | /** 34 | * Get an instance of this location representation. 35 | * 36 | * @return the instance. 37 | */ 38 | public static LocationRepresentation getInstance() { 39 | return INSTANCE; 40 | } 41 | 42 | private LocationRepresentation() { 43 | // Nothing to see here, move along now. 44 | } 45 | 46 | @Override 47 | public String toStringOf(@Nullable Object object) { 48 | return object == null ? "null" : ((Location) object).getName(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /java-compiler-testing/src/main/java/io/github/ascopes/jct/repr/StackTraceRepresentation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 io.github.ascopes.jct.repr; 17 | 18 | import java.util.List; 19 | import org.assertj.core.presentation.Representation; 20 | import org.jspecify.annotations.Nullable; 21 | 22 | /** 23 | * Representation of a {@link List list} of {@link StackTraceElement stack trace frames}. 24 | * 25 | * @author Ashley Scopes 26 | * @since 0.0.1 27 | */ 28 | public final class StackTraceRepresentation implements Representation { 29 | 30 | private static final StackTraceRepresentation INSTANCE = new StackTraceRepresentation(); 31 | 32 | /** 33 | * Get an instance of this stack trace representation. 34 | * 35 | * @return the instance. 36 | */ 37 | public static StackTraceRepresentation getInstance() { 38 | return INSTANCE; 39 | } 40 | 41 | private StackTraceRepresentation() { 42 | // Nothing to see here, move along now! 43 | } 44 | 45 | @Override 46 | @SuppressWarnings("unchecked") 47 | public String toStringOf(@Nullable Object object) { 48 | if (object == null) { 49 | return "null"; 50 | } 51 | 52 | var trace = (List) object; 53 | var builder = new StringBuilder("Stacktrace:"); 54 | for (var frame : trace) { 55 | builder.append("\n\tat ").append(frame); 56 | } 57 | return builder.toString(); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /java-compiler-testing/src/main/java/io/github/ascopes/jct/repr/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 | /** 17 | * Representation facilities for AssertJ integration. 18 | */ 19 | package io.github.ascopes.jct.repr; 20 | -------------------------------------------------------------------------------- /java-compiler-testing/src/main/java/io/github/ascopes/jct/utils/LoomPolyfill.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 io.github.ascopes.jct.utils; 17 | 18 | /** 19 | * Polyfill to enable supporting using the newer Thread APIs on newer platforms. 20 | * 21 | *

This specifically targets the new APIs introduced as part of Project Loom 22 | * in Java 19. 23 | * 24 | * @author Ashley Scopes 25 | * @since 0.0.1 26 | */ 27 | public final class LoomPolyfill extends UtilityClass { 28 | 29 | private LoomPolyfill() { 30 | // Static-only class. 31 | } 32 | 33 | /** 34 | * Get the thread ID. 35 | * 36 | *

This ensures that the underlying system does not spoof the thread ID on JDK 19 and newer. 37 | * 38 | * @param thread the thread to use. 39 | * @return the thread ID. 40 | */ 41 | public static long getThreadId(Thread thread) { 42 | // Note: this test will never get 100% coverage on one JDK, because it totally depends on the 43 | // JDK in use as to which code path runs. 44 | try { 45 | // Where possible, use the newer Loom API to fetch the thread ID. 46 | var method = Thread.class.getDeclaredMethod("threadId"); 47 | return (long) method.invoke(thread); 48 | } catch (Exception ex) { 49 | // Fall back to the old API (which is the only method prior to Java 19). 50 | return thread.getId(); 51 | } 52 | } 53 | 54 | /** 55 | * Get the current thread. 56 | * 57 | * @return the current thread. 58 | */ 59 | public static Thread getCurrentThread() { 60 | return Thread.currentThread(); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /java-compiler-testing/src/main/java/io/github/ascopes/jct/utils/UtilityClass.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 io.github.ascopes.jct.utils; 17 | 18 | /** 19 | * Abstract base for a static-only class. This base cannot be initialised. 20 | * 21 | * @author Ashley Scopes 22 | * @since 0.0.1 23 | */ 24 | public abstract class UtilityClass { 25 | 26 | protected UtilityClass() { 27 | throw new UnsupportedOperationException( 28 | "this is a utility class that cannot be initialised or extended" 29 | ); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /java-compiler-testing/src/main/java/io/github/ascopes/jct/utils/VisibleForTestingOnly.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 io.github.ascopes.jct.utils; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * Annotation that marks the annotated method or constructor as only being visible for testing 26 | * purposes. 27 | * 28 | *

This means any API should not be using this element directly. 29 | * 30 | * @author Ashley Scopes 31 | * @since 0.0.1 32 | */ 33 | @Documented 34 | @Retention(RetentionPolicy.CLASS) 35 | @Target({ElementType.CONSTRUCTOR, ElementType.METHOD}) 36 | public @interface VisibleForTestingOnly { 37 | } 38 | -------------------------------------------------------------------------------- /java-compiler-testing/src/main/java/io/github/ascopes/jct/utils/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 | /** 17 | * Internal shared utilities. 18 | * 19 | *

These components are part of the internal API and should not be used by external 20 | * modules. As such, they are not covered by the semantic versioning policy and may change without 21 | * notice. 22 | */ 23 | package io.github.ascopes.jct.utils; 24 | -------------------------------------------------------------------------------- /java-compiler-testing/src/main/java/io/github/ascopes/jct/workspaces/impl/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 | /** 17 | * Internal workspace implementation details. 18 | */ 19 | package io.github.ascopes.jct.workspaces.impl; 20 | -------------------------------------------------------------------------------- /java-compiler-testing/src/main/java/io/github/ascopes/jct/workspaces/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 | /** 17 | * Workspace components to hold complex source code structures within memory. 18 | */ 19 | package io.github.ascopes.jct.workspaces; 20 | -------------------------------------------------------------------------------- /java-compiler-testing/src/main/resources/META-INF/services/java.net.spi.URLStreamHandlerProvider: -------------------------------------------------------------------------------- 1 | # For some reason this is not detected correctly if we use the JPMS mechanism to deal with this 2 | # file. We fall back to the old mechanism instead to avoid this problem. 3 | io.github.ascopes.jct.workspaces.impl.MemoryFileSystemProvider$MemoryFileSystemUrlHandlerProvider 4 | -------------------------------------------------------------------------------- /java-compiler-testing/src/test/java/io/github/ascopes/jct/assertions/ClassLoaderAssertTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 io.github.ascopes.jct.assertions; 17 | 18 | import static org.mockito.Mockito.mock; 19 | 20 | import org.junit.jupiter.api.DisplayName; 21 | import org.junit.jupiter.api.Test; 22 | 23 | /** 24 | * {@link ClassLoaderAssert} tests. 25 | * 26 | * @author Ashley Scopes 27 | */ 28 | @DisplayName("ClassLoaderAssert tests") 29 | class ClassLoaderAssertTest { 30 | 31 | @DisplayName("Assertions are performed on the classloader") 32 | @Test 33 | void assertionsArePerformedOnTheClassLoader() { 34 | // Given 35 | var classLoader = mock(ClassLoader.class); 36 | 37 | // When 38 | var assertions = new ClassLoaderAssert(classLoader); 39 | 40 | // Then 41 | assertions.isSameAs(classLoader); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /java-compiler-testing/src/test/java/io/github/ascopes/jct/assertions/JavaFileObjectAssertTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 io.github.ascopes.jct.assertions; 17 | 18 | import static io.github.ascopes.jct.fixtures.Fixtures.someJavaFileObject; 19 | import static org.assertj.core.api.Assertions.assertThat; 20 | 21 | import org.junit.jupiter.api.DisplayName; 22 | import org.junit.jupiter.api.Test; 23 | 24 | /** 25 | * {@link JavaFileObjectAssert} tests. 26 | * 27 | * @author Ashley Scopes 28 | */ 29 | @DisplayName("JavaFileObjectAssert tests") 30 | class JavaFileObjectAssertTest { 31 | 32 | @DisplayName("Assertions are performed on the JavaFileObject") 33 | @Test 34 | void assertionsArePerformedOnTheJavaFileObject() { 35 | // Given 36 | var javaFileObject = someJavaFileObject(); 37 | 38 | // When 39 | var assertions = new JavaFileObjectAssert(javaFileObject); 40 | 41 | // Then 42 | assertions 43 | .isSameAs(javaFileObject); 44 | assertThat(assertions) 45 | .isInstanceOf(AbstractJavaFileObjectAssert.class); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /java-compiler-testing/src/test/java/io/github/ascopes/jct/compilers/DebuggingInfoTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 io.github.ascopes.jct.compilers; 17 | 18 | import static org.assertj.core.api.Assertions.assertThat; 19 | 20 | import org.junit.jupiter.api.DisplayName; 21 | import org.junit.jupiter.api.Test; 22 | 23 | 24 | /** 25 | * {@link DebuggingInfo} tests. 26 | * 27 | * @author Ashley Scopes 28 | */ 29 | class DebuggingInfoTest { 30 | 31 | @DisplayName(".none() returns an empty set") 32 | @Test 33 | void noneReturnsEmptySet() { 34 | // When 35 | var set = DebuggingInfo.none(); 36 | 37 | // Then 38 | assertThat(set).isEmpty(); 39 | } 40 | 41 | 42 | @DisplayName(".just(DebuggingInfo, DebuggingInfo...) returns a combined set") 43 | @Test 44 | void justReturnsCombinedSet() { 45 | // When 46 | var set = DebuggingInfo.just(DebuggingInfo.LINES, DebuggingInfo.VARS); 47 | 48 | // Then 49 | assertThat(set).containsExactlyInAnyOrder( 50 | DebuggingInfo.LINES, 51 | DebuggingInfo.VARS 52 | ); 53 | } 54 | 55 | @DisplayName(".all() returns a set of all members") 56 | @Test 57 | void allReturnsSetOfAllMembers() { 58 | // When 59 | var set = DebuggingInfo.all(); 60 | 61 | // Then 62 | assertThat(set).containsExactlyInAnyOrder(DebuggingInfo.values()); 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /java-compiler-testing/src/test/java/io/github/ascopes/jct/compilers/JctCompilersTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 io.github.ascopes.jct.compilers; 17 | 18 | import static org.assertj.core.api.Assertions.assertThat; 19 | 20 | import io.github.ascopes.jct.compilers.impl.JavacJctCompilerImpl; 21 | import io.github.ascopes.jct.fixtures.UtilityClassTestTemplate; 22 | import org.junit.jupiter.api.DisplayName; 23 | import org.junit.jupiter.api.Test; 24 | import org.mockito.Mockito; 25 | 26 | /** 27 | * {@link JctCompilers} tests. 28 | * 29 | * @author Ashley Scopes 30 | */ 31 | @DisplayName("JctCompilers tests") 32 | class JctCompilersTest implements UtilityClassTestTemplate { 33 | 34 | @Override 35 | public Class getTypeBeingTested() { 36 | return JctCompilers.class; 37 | } 38 | 39 | @DisplayName(".newPlatformCompiler() creates a JavacJctCompilerImpl instance") 40 | @Test 41 | void newPlatformCompilerReturnsTheExpectedInstance() { 42 | try (var javacJctCompilerImplMock = Mockito.mockConstruction(JavacJctCompilerImpl.class)) { 43 | // When 44 | var compiler = JctCompilers.newPlatformCompiler(); 45 | 46 | // Then 47 | assertThat(compiler) 48 | .isInstanceOf(JavacJctCompilerImpl.class); 49 | 50 | assertThat(javacJctCompilerImplMock.constructed()) 51 | .singleElement() 52 | // Nested assertion to swap expected/actual args. 53 | .satisfies(constructed -> assertThat(compiler).isSameAs(constructed)); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /java-compiler-testing/src/test/java/io/github/ascopes/jct/ex/JctCompilerExceptionTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 io.github.ascopes.jct.ex; 17 | 18 | import static org.assertj.core.api.Assertions.assertThat; 19 | import static org.mockito.Mockito.mock; 20 | 21 | import org.junit.jupiter.api.DisplayName; 22 | import org.junit.jupiter.api.Test; 23 | 24 | /** 25 | * Tests for {@link JctCompilerException}. 26 | * 27 | * @author Ashley Scopes 28 | */ 29 | @DisplayName("JctCompilerException tests") 30 | class JctCompilerExceptionTest { 31 | 32 | @DisplayName("The message is set when no cause is given") 33 | @Test 34 | void messageIsSetWhenNoCauseGiven() { 35 | // Given 36 | var message = "foo bar baz"; 37 | 38 | // When 39 | var ex = new JctCompilerException(message); 40 | 41 | // Then 42 | assertThat(ex) 43 | .hasMessage("foo bar baz"); 44 | } 45 | 46 | @DisplayName("The message is set when a cause is given") 47 | @Test 48 | void messageIsSetWhenCauseGiven() { 49 | // Given 50 | var message = "qux quxx quxxx"; 51 | var cause = mock(Throwable.class); 52 | 53 | // When 54 | var ex = new JctCompilerException(message, cause); 55 | 56 | // Then 57 | assertThat(ex) 58 | .hasMessage("qux quxx quxxx"); 59 | } 60 | 61 | @DisplayName("The cause is set when a cause is given") 62 | @Test 63 | void causeIsSetWhenCauseGiven() { 64 | // Given 65 | var message = "do ray me"; 66 | var cause = mock(Throwable.class); 67 | 68 | // When 69 | var ex = new JctCompilerException(message, cause); 70 | 71 | // Then 72 | assertThat(ex) 73 | .hasCause(cause); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /java-compiler-testing/src/test/java/io/github/ascopes/jct/ex/JctIllegalInputExceptionTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 io.github.ascopes.jct.ex; 17 | 18 | import static org.assertj.core.api.Assertions.assertThat; 19 | import static org.mockito.Mockito.mock; 20 | 21 | import org.junit.jupiter.api.DisplayName; 22 | import org.junit.jupiter.api.Test; 23 | 24 | /** 25 | * Tests for {@link JctIllegalInputException}. 26 | * 27 | * @author Ashley Scopes 28 | */ 29 | @DisplayName("JctIllegalInputException tests") 30 | class JctIllegalInputExceptionTest { 31 | 32 | @DisplayName("The message is set when no cause is given") 33 | @Test 34 | void messageIsSetWhenNoCauseGiven() { 35 | // Given 36 | var message = "foo bar baz"; 37 | 38 | // When 39 | var ex = new JctIllegalInputException(message); 40 | 41 | // Then 42 | assertThat(ex) 43 | .hasMessage("foo bar baz"); 44 | } 45 | 46 | @DisplayName("The message is set when a cause is given") 47 | @Test 48 | void messageIsSetWhenCauseGiven() { 49 | // Given 50 | var message = "qux quxx quxxx"; 51 | var cause = mock(Throwable.class); 52 | 53 | // When 54 | var ex = new JctIllegalInputException(message, cause); 55 | 56 | // Then 57 | assertThat(ex) 58 | .hasMessage("qux quxx quxxx"); 59 | } 60 | 61 | @DisplayName("The cause is set when a cause is given") 62 | @Test 63 | void causeIsSetWhenCauseGiven() { 64 | // Given 65 | var message = "do ray me"; 66 | var cause = mock(Throwable.class); 67 | 68 | // When 69 | var ex = new JctIllegalInputException(message, cause); 70 | 71 | // Then 72 | assertThat(ex) 73 | .hasCause(cause); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /java-compiler-testing/src/test/java/io/github/ascopes/jct/ex/JctJunitConfigurerExceptionTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 io.github.ascopes.jct.ex; 17 | 18 | import static org.assertj.core.api.Assertions.assertThat; 19 | import static org.mockito.Mockito.mock; 20 | 21 | import org.junit.jupiter.api.DisplayName; 22 | import org.junit.jupiter.api.Test; 23 | 24 | /** 25 | * {@link JctJunitConfigurerException} tests. 26 | * 27 | * @author Ashley Scopes 28 | */ 29 | @DisplayName("JctJunitConfigurerException tests") 30 | class JctJunitConfigurerExceptionTest { 31 | 32 | @DisplayName("The message is set when no cause is given") 33 | @Test 34 | void messageIsSetWhenNoCauseGiven() { 35 | // Given 36 | var message = "foo bar baz"; 37 | 38 | // When 39 | var ex = new JctJunitConfigurerException(message); 40 | 41 | // Then 42 | assertThat(ex) 43 | .hasMessage("foo bar baz"); 44 | } 45 | 46 | @DisplayName("The message is set when a cause is given") 47 | @Test 48 | void messageIsSetWhenCauseGiven() { 49 | // Given 50 | var message = "qux quxx quxxx"; 51 | var cause = mock(Throwable.class); 52 | 53 | // When 54 | var ex = new JctJunitConfigurerException(message, cause); 55 | 56 | // Then 57 | assertThat(ex) 58 | .hasMessage("qux quxx quxxx"); 59 | } 60 | 61 | @DisplayName("The cause is set when a cause is given") 62 | @Test 63 | void causeIsSetWhenCauseGiven() { 64 | // Given 65 | var message = "do ray me"; 66 | var cause = mock(Throwable.class); 67 | 68 | // When 69 | var ex = new JctJunitConfigurerException(message, cause); 70 | 71 | // Then 72 | assertThat(ex) 73 | .hasCause(cause); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /java-compiler-testing/src/test/java/io/github/ascopes/jct/ex/JctNotFoundExceptionTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 io.github.ascopes.jct.ex; 17 | 18 | import static org.assertj.core.api.Assertions.assertThat; 19 | 20 | import org.junit.jupiter.api.DisplayName; 21 | import org.junit.jupiter.api.Test; 22 | 23 | /** 24 | * Tests for {@link JctNotFoundException}. 25 | * 26 | * @author Ashley Scopes 27 | */ 28 | @DisplayName("JctNotFoundException tests") 29 | class JctNotFoundExceptionTest { 30 | 31 | @DisplayName("The message is set when no cause is given") 32 | @Test 33 | void messageIsSetWhenNoCauseGiven() { 34 | // Given 35 | var message = "foo bar baz"; 36 | 37 | // When 38 | var ex = new JctNotFoundException(message); 39 | 40 | // Then 41 | assertThat(ex) 42 | .hasMessage("foo bar baz"); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /java-compiler-testing/src/test/java/io/github/ascopes/jct/ex/JctNotImplementedTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 io.github.ascopes.jct.ex; 17 | 18 | import static org.assertj.core.api.Assertions.assertThat; 19 | 20 | import org.junit.jupiter.api.DisplayName; 21 | import org.junit.jupiter.api.Test; 22 | 23 | /** 24 | * Tests for {@link JctNotImplementedException}. 25 | * 26 | * @author Ashley Scopes 27 | */ 28 | @DisplayName("JctNotImplementedException tests") 29 | class JctNotImplementedTest { 30 | 31 | @DisplayName("The message is set when no cause is given") 32 | @Test 33 | void messageIsSetWhenNoCauseGiven() { 34 | // Given 35 | var message = "foo bar baz"; 36 | 37 | // When 38 | var ex = new JctNotImplementedException(message); 39 | 40 | // Then 41 | assertThat(ex) 42 | .hasMessage("foo bar baz"); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /java-compiler-testing/src/test/java/io/github/ascopes/jct/filemanagers/JctFileManagersTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 io.github.ascopes.jct.filemanagers; 17 | 18 | import static org.assertj.core.api.Assertions.assertThat; 19 | import static org.mockito.Mockito.mock; 20 | 21 | import io.github.ascopes.jct.compilers.JctCompiler; 22 | import io.github.ascopes.jct.filemanagers.impl.JctFileManagerFactoryImpl; 23 | import io.github.ascopes.jct.fixtures.UtilityClassTestTemplate; 24 | import org.junit.jupiter.api.DisplayName; 25 | import org.junit.jupiter.api.Test; 26 | 27 | /** 28 | * {@link JctFileManagers} tests. 29 | * 30 | * @author Ashley Scopes 31 | */ 32 | @DisplayName("JctFileManagers tests") 33 | class JctFileManagersTest implements UtilityClassTestTemplate { 34 | 35 | @Override 36 | public Class getTypeBeingTested() { 37 | return JctFileManagers.class; 38 | } 39 | 40 | @DisplayName( 41 | ".newJctFileManagerFactory(JctCompiler) returns a new JctFileManagerFactoryImpl instance" 42 | ) 43 | @Test 44 | void newJctFileManagerFactoryReturnsNewJctFileManagerFactoryImplInstance() { 45 | // Given 46 | var compiler = mock(JctCompiler.class); 47 | 48 | // When 49 | var fileManagerFactory = JctFileManagers.newJctFileManagerFactory(compiler); 50 | 51 | // Then 52 | assertThat(fileManagerFactory).isInstanceOf(JctFileManagerFactoryImpl.class); 53 | assertThat(((JctFileManagerFactoryImpl) fileManagerFactory).getCompiler()).isSameAs(compiler); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /java-compiler-testing/src/test/java/io/github/ascopes/jct/filemanagers/config/JctFileManagerConfigurerTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 io.github.ascopes.jct.filemanagers.config; 17 | 18 | import static org.assertj.core.api.Assertions.assertThat; 19 | 20 | import org.junit.jupiter.api.DisplayName; 21 | import org.junit.jupiter.api.Test; 22 | import org.junit.jupiter.api.extension.ExtendWith; 23 | import org.mockito.Answers; 24 | import org.mockito.Mock; 25 | import org.mockito.junit.jupiter.MockitoExtension; 26 | 27 | /** 28 | * {@link JctFileManagerConfigurer} tests. 29 | * 30 | * @author Ashley Scopes 31 | */ 32 | @DisplayName("JctFileManagerConfigurer tests") 33 | @ExtendWith(MockitoExtension.class) 34 | class JctFileManagerConfigurerTest { 35 | 36 | @Mock(answer = Answers.CALLS_REAL_METHODS) 37 | JctFileManagerConfigurer configurer; 38 | 39 | @DisplayName(".isEnabled() defaults to returning true") 40 | @Test 41 | void isEnabledReturnsTrue() { 42 | // Then 43 | assertThat(configurer.isEnabled()).isTrue(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /java-compiler-testing/src/test/java/io/github/ascopes/jct/integration/AbstractIntegrationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 io.github.ascopes.jct.integration; 17 | 18 | import java.nio.file.Files; 19 | import java.nio.file.Path; 20 | 21 | /** 22 | * Abstract base class for integration tests to use. 23 | * 24 | * @author Ashley Scopes 25 | */ 26 | public abstract class AbstractIntegrationTest { 27 | 28 | /** 29 | * Get the resources directory for this test. This will be a directory named the full canonical 30 | * class name. 31 | * 32 | * @return the resource directory path. 33 | */ 34 | protected Path resourcesDirectory() { 35 | var path = Path.of("src", "test", "resources"); 36 | 37 | // Add a suffix, as older Java versions complain if packages exist with the same name as 38 | // classes. 39 | var dirName = getClass().getCanonicalName() + "_resources"; 40 | 41 | for (var part : dirName.split("[./]")) { 42 | path = path.resolve(part); 43 | } 44 | 45 | if (!Files.isDirectory(path)) { 46 | throw new IllegalStateException( 47 | "Please ensure the directory " + path + " exists, and try again" 48 | ); 49 | } 50 | 51 | return path; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /java-compiler-testing/src/test/java/io/github/ascopes/jct/integration/compilation/CompilingSpecificClassesIntegrationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 io.github.ascopes.jct.integration.compilation; 17 | 18 | import static io.github.ascopes.jct.assertions.JctAssertions.assertThat; 19 | 20 | import io.github.ascopes.jct.compilers.JctCompiler; 21 | import io.github.ascopes.jct.integration.AbstractIntegrationTest; 22 | import io.github.ascopes.jct.junit.JavacCompilerTest; 23 | import io.github.ascopes.jct.workspaces.Workspaces; 24 | import org.junit.jupiter.api.DisplayName; 25 | 26 | /** 27 | * Integration tests that test the compilation of specific classes only. 28 | * 29 | * @author Ashley Scopes 30 | */ 31 | @DisplayName("Compiling specific classes integration tests") 32 | class CompilingSpecificClassesIntegrationTest extends AbstractIntegrationTest { 33 | 34 | @DisplayName("Only the classes that I specify get compiled") 35 | @JavacCompilerTest 36 | void onlyTheClassesSpecifiedGetCompiled(JctCompiler compiler) { 37 | try (var workspace = Workspaces.newWorkspace()) { 38 | workspace 39 | .createSourcePathPackage() 40 | .copyContentsFrom(resourcesDirectory()); 41 | 42 | var compilation = compiler.compile(workspace, "Fibonacci", "HelloWorld"); 43 | 44 | assertThat(compilation) 45 | .isSuccessfulWithoutWarnings() 46 | .classOutputPackages() 47 | .allFilesExist("Fibonacci.class", "HelloWorld.class") 48 | .fileDoesNotExist("Sum.class"); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /java-compiler-testing/src/test/java/io/github/ascopes/jct/repr/LocationRepresentationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 io.github.ascopes.jct.repr; 17 | 18 | import static io.github.ascopes.jct.fixtures.Fixtures.oneOf; 19 | import static org.assertj.core.api.Assertions.assertThat; 20 | 21 | import javax.tools.StandardLocation; 22 | import org.junit.jupiter.api.DisplayName; 23 | import org.junit.jupiter.api.Test; 24 | 25 | /** 26 | * {@link LocationRepresentation} tests. 27 | * 28 | * @author Ashley Scopes 29 | */ 30 | @DisplayName("LocationRepresentation tests") 31 | class LocationRepresentationTest { 32 | 33 | @DisplayName("toStringOf(null) returns \"null\"") 34 | @Test 35 | void toStringOfNullReturnsNull() { 36 | // Given 37 | var repr = LocationRepresentation.getInstance(); 38 | 39 | // When 40 | var result = repr.toStringOf(null); 41 | 42 | // Then 43 | assertThat(result).isEqualTo("null"); 44 | } 45 | 46 | @DisplayName("toStringOf(Location) returns the location name") 47 | @Test 48 | void toStringOfLocationReturnsName() { 49 | // Given 50 | var repr = LocationRepresentation.getInstance(); 51 | var location = oneOf(StandardLocation.values()); 52 | 53 | // When 54 | var result = repr.toStringOf(location); 55 | 56 | // Then 57 | assertThat(result).isEqualTo(location.getName()); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /java-compiler-testing/src/test/java/io/github/ascopes/jct/workspaces/ManagedDirectoryTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 io.github.ascopes.jct.workspaces; 17 | 18 | import static org.assertj.core.api.Assertions.assertThat; 19 | 20 | import org.junit.jupiter.api.DisplayName; 21 | import org.junit.jupiter.api.Test; 22 | import org.junit.jupiter.api.extension.ExtendWith; 23 | import org.mockito.Answers; 24 | import org.mockito.Mock; 25 | import org.mockito.junit.jupiter.MockitoExtension; 26 | 27 | /** 28 | * {@link ManagedDirectory} tests. 29 | * 30 | * @author Ashley Scopes 31 | */ 32 | @DisplayName("ManagedDirectory tests") 33 | @ExtendWith(MockitoExtension.class) 34 | class ManagedDirectoryTest { 35 | 36 | @Mock(answer = Answers.CALLS_REAL_METHODS) 37 | ManagedDirectory managedDirectory; 38 | 39 | @DisplayName(".and() returns the object") 40 | @Test 41 | void andReturnsTheObject() { 42 | // Then 43 | assertThat(managedDirectory.and()).isSameAs(managedDirectory); 44 | } 45 | 46 | @DisplayName(".also() returns the object") 47 | @Test 48 | void alsoReturnsTheObject() { 49 | // Then 50 | assertThat(managedDirectory.also()).isSameAs(managedDirectory); 51 | } 52 | 53 | @DisplayName(".then() returns the object") 54 | @Test 55 | void thenReturnsTheObject() { 56 | // Then 57 | assertThat(managedDirectory.then()).isSameAs(managedDirectory); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /java-compiler-testing/src/test/resources/io/github/ascopes/jct/integration/compilation/BasicLegacyCompilationIntegrationTest_resources/HelloWorld.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 com.example; 17 | 18 | /** 19 | * A test case that just prints hello world. 20 | */ 21 | public class HelloWorld { 22 | 23 | /** 24 | * Main method. 25 | * 26 | * @param args command line arguments. 27 | */ 28 | public static void main(String[] args) { 29 | System.out.println("Hello, World"); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /java-compiler-testing/src/test/resources/io/github/ascopes/jct/integration/compilation/BasicModuleCompilationIntegrationTest_resources/com/example/HelloWorld.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 com.example; 17 | 18 | /** 19 | * A test case that just prints hello world. 20 | */ 21 | public class HelloWorld { 22 | 23 | /** 24 | * Main method. 25 | * 26 | * @param args command line arguments. 27 | */ 28 | public static void main(String[] args) { 29 | System.out.println("Hello, World"); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /java-compiler-testing/src/test/resources/io/github/ascopes/jct/integration/compilation/BasicModuleCompilationIntegrationTest_resources/module-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 | /** 17 | * A JPMS module. 18 | */ 19 | module hello.world { 20 | requires java.base; 21 | exports com.example; 22 | } 23 | -------------------------------------------------------------------------------- /java-compiler-testing/src/test/resources/io/github/ascopes/jct/integration/compilation/BasicMultiModuleCompilationIntegrationTest_resources/greeter/com/example/greeter/Greeter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 com.example.greeter; 17 | 18 | /** 19 | * A class that can greet me. 20 | */ 21 | public class Greeter { 22 | 23 | /** 24 | * Greet me. 25 | * 26 | * @param name my name. 27 | * @return the greeting. 28 | */ 29 | public static String greet(String name) { 30 | return "Hello, " + name + "!"; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /java-compiler-testing/src/test/resources/io/github/ascopes/jct/integration/compilation/BasicMultiModuleCompilationIntegrationTest_resources/greeter/module-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 | /** 17 | * A JPMS module. 18 | */ 19 | module greeter { 20 | exports com.example.greeter; 21 | } 22 | -------------------------------------------------------------------------------- /java-compiler-testing/src/test/resources/io/github/ascopes/jct/integration/compilation/BasicMultiModuleCompilationIntegrationTest_resources/hello.world.crossmodule/com/example/HelloWorld.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 com.example; 17 | 18 | /** 19 | * A class that says hello. 20 | */ 21 | public class HelloWorld { 22 | 23 | /** 24 | * Main method. 25 | * 26 | * @param args command line arguments. 27 | */ 28 | public static void main(String[] args) { 29 | System.out.println("Hello, World"); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /java-compiler-testing/src/test/resources/io/github/ascopes/jct/integration/compilation/BasicMultiModuleCompilationIntegrationTest_resources/hello.world.crossmodule/module-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 | /** 17 | * A JPMS module. 18 | */ 19 | module hello.world.crossmodule { 20 | requires java.base; 21 | exports com.example; 22 | } 23 | -------------------------------------------------------------------------------- /java-compiler-testing/src/test/resources/io/github/ascopes/jct/integration/compilation/BasicMultiModuleCompilationIntegrationTest_resources/hello.world.singlemodule/com/example/HelloWorld.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 com.example; 17 | 18 | /** 19 | * A class that says hello. 20 | */ 21 | public class HelloWorld { 22 | 23 | /** 24 | * Main method. 25 | * 26 | * @param args command line arguments. 27 | */ 28 | public static void main(String[] args) { 29 | System.out.println("Hello, World"); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /java-compiler-testing/src/test/resources/io/github/ascopes/jct/integration/compilation/BasicMultiModuleCompilationIntegrationTest_resources/hello.world.singlemodule/module-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 | /** 17 | * A JPMS module. 18 | */ 19 | module hello.world.singlemodule { 20 | requires java.base; 21 | exports com.example; 22 | } 23 | -------------------------------------------------------------------------------- /java-compiler-testing/src/test/resources/io/github/ascopes/jct/integration/compilation/CompilingSpecificClassesIntegrationTest_resources/Fibonacci.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 | import static java.math.BigInteger.ONE; 17 | import static java.math.BigInteger.ZERO; 18 | 19 | import java.math.BigInteger; 20 | 21 | /** 22 | * Command line app to calculate the nth number of the fibonacci sequence. 23 | */ 24 | public class Fibonacci { 25 | 26 | /** 27 | * Main method. 28 | * 29 | * @param args command line arguments. 30 | */ 31 | public static void main(String[] args) { 32 | if (args.length != 1) { 33 | System.out.println("USAGE: java Fibonacci "); 34 | System.out.println(" Fibonacci number to generate"); 35 | } 36 | 37 | BigInteger n = new BigInteger(args[0], 10); 38 | BigInteger a = ZERO; 39 | BigInteger b = ONE; 40 | 41 | for (BigInteger i = ZERO; i.compareTo(n) < 0; i = i.add(ONE)) { 42 | BigInteger oldB = b; 43 | b = a.add(b); 44 | a = oldB; 45 | } 46 | 47 | System.out.println(a); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /java-compiler-testing/src/test/resources/io/github/ascopes/jct/integration/compilation/CompilingSpecificClassesIntegrationTest_resources/HelloWorld.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 | /** 17 | * Command line app that says hello to me. 18 | */ 19 | public class HelloWorld { 20 | 21 | /** 22 | * Main method. 23 | * 24 | * @param args command line arguments. 25 | */ 26 | public static void main(String[] args) { 27 | System.out.println("Hello, World!"); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /java-compiler-testing/src/test/resources/io/github/ascopes/jct/integration/compilation/CompilingSpecificClassesIntegrationTest_resources/Sum.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 | /** 17 | * Command line app that sums together given integers. 18 | */ 19 | public class Sum { 20 | 21 | /** 22 | * Main method. 23 | * 24 | * @param args command line arguments. 25 | */ 26 | public static void main(String[] args) { 27 | long sum = 0; 28 | for (String arg : args) { 29 | sum += Integer.parseInt(arg); 30 | } 31 | System.out.println(sum); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /java-compiler-testing/src/test/resources/io/github/ascopes/jct/integration/compilation/MultiTieredCompilationIntegrationTest_resources/first/Adder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 org.example.first; 17 | 18 | /** 19 | * Class that adds things together. 20 | */ 21 | public class Adder { 22 | 23 | /** 24 | * Add things together. 25 | * 26 | * @param a the first thing. 27 | * @param b the second thing. 28 | * @return the things, added together. 29 | */ 30 | public int add(int a, int b) { 31 | return a + b; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /java-compiler-testing/src/test/resources/io/github/ascopes/jct/integration/compilation/MultiTieredCompilationIntegrationTest_resources/second/Main.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 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 org.example.second; 17 | 18 | import org.example.first.Adder; 19 | 20 | /** 21 | * A class that uses another class to add things together and is totally not an overkill or 22 | * anything whatsoever. 23 | */ 24 | public class Main { 25 | 26 | /** 27 | * Add the things together. 28 | * 29 | * @param a the first thing. 30 | * @param b the second thing. 31 | * @return the things, added together externally. 32 | */ 33 | public static int addTogether(int a, int b) { 34 | Adder adder = new Adder(); 35 | return adder.add(a, b); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /java-compiler-testing/src/test/resources/junit-platform.properties: -------------------------------------------------------------------------------- 1 | junit.jupiter.execution.parallel.enabled=true 2 | --------------------------------------------------------------------------------