Skip to content

dev 0.1.8#233

Open
mercyblitz wants to merge 144 commits intomicrosphere-projects:devfrom
mercyblitz:dev
Open

dev 0.1.8#233
mercyblitz wants to merge 144 commits intomicrosphere-projects:devfrom
mercyblitz:dev

Conversation

@mercyblitz
Copy link
Contributor

@mercyblitz mercyblitz commented Feb 4, 2026

This pull request introduces several improvements and refactors to the annotation processor module, focusing on dependency updates, code structure simplification, and modernization of build and test workflows. The most important changes are grouped below by theme.

Dependency and Build Workflow Updates:

  • Updated GitHub Actions workflows (.github/workflows/maven-build.yml, .github/workflows/maven-publish.yml) to use newer versions of actions/checkout and actions/setup-java, switched Maven build to use the wrapper (./mvnw), and added -Dsurefire.useSystemClassLoader=false for improved test reliability. [1] [2]
  • Changed Maven wrapper configuration in .mvn/wrapper/maven-wrapper.properties to use Maven 3.9.9 from an Aliyun mirror, and simplified wrapper settings.

Dependency Management in microsphere-annotation-processor:

  • Removed unused properties for javax.ws.rs.version and jaxws-api.version from pom.xml, and replaced property-based versioning with direct dependency versions. [1] [2]
  • Added new dependencies: microsphere-lang-model, microsphere-jdk-tools, and microsphere-java-test for enhanced annotation processing and testing capabilities. [1] [2]

Code Refactoring and Simplification:

  • Moved and renamed ConfigurationPropertyJSONElementVisitor to the main package, made it package-private, and updated its usage throughout the codebase. Also refactored its logic to handle attribute processing more generically. [1] [2] [3] [4] [5] [6]
  • Updated static imports and utility usage to reference new locations in microsphere.lang.model.util for annotation and messaging utilities. [1] [2] [3]

Testing Improvements:

  • Refactored ConfigurationPropertyAnnotationProcessorTest to use AbstractAnnotationProcessingTest and modernized imports, improving test clarity and maintainability.

Documentation and API Changes:

  • Updated Javadoc references and method visibility for improved clarity and encapsulation in ConfigurationPropertyAnnotationProcessor. [1] [2] [3] [4]

These changes collectively modernize the build and test setup, simplify annotation processor code, and enhance maintainability and extensibility for future development.

Updated the <revision> property in pom.xml to prepare for the next development iteration.
Introduce a new microsphere-jdk-tools Maven module. Adds pom.xml with dependencies (microsphere-java-core, JUnit, Mockito, Logback), maven-compiler config and maven-shade setup. Implements io.microsphere.jdk.tools.compiler.Compiler — a utility to programmatically compile Java sources, manage source/target paths, detect class/root/source locations, and configure processors/options/diagnostics. Includes unit tests (CompilerTest) covering constructors, default path detection, options, processors and compile flow, and a logback-test.xml for test logging.
Introduce Mockito to the parent POM: add a mockito.version property and a mockito-core dependency so tests can use Mockito. Also update JUnit versions: bump the root junit.version 6.0.1 → 6.0.2 and the profile's junit.version 5.13.4 → 5.14.2. The profile also sets mockito.version (4.11.0) to override the parent value.
Introduce a new microsphere-java-test Maven module providing testing utilities and fixtures. Adds pom.xml (compiler/shade configuration and test dependencies), a TestAnnotation and annotation-processing test infrastructure (AbstractAnnotationProcessingTest, AnnotationProcessingTestProcessor, CompilerInvocationInterceptor) that compiles test sources and runs processors during JUnit5 tests. Also adds a set of model classes, service interfaces/implementations, unit tests, logback-test.xml, and a service provider entry for annotation processors to support annotation-processing test cases.
Refactor annotation-processing test harness to use JUnit 5 reflective invocation API. AbstractAnnotationProcessingTest: remove ThreadLocal holder and @BeforeEach/@AfterEach, change beforeTest/afterTest signatures to accept ReflectiveInvocationContext and ExtensionContext (afterTest also receives result and failure), add necessary imports and reflection types. AnnotationProcessingTestProcessor: make package-private, use Invocation type directly, call beforeTest/afterTest with contexts and pass result/failure, and populate processingEnv, Elements/Types and test type information during prepare. CompilerInvocationInterceptor: make package-private, obtain test instance from invocationContext target, use the test class loader, and load SPI Processor implementations via ServiceLoader (merging them with the test processor). Also cleanup imports/usages in test class (remove assertion referencing removed holder). Overall adjusts lifecycle integration so the annotation processor drives the test invocation and reporting.
Add a new JUnit test class TestServiceImplTest (Mockito-based) to validate TestServiceImpl behavior (echo, close, constructors and DI). Make small API/encapsulation adjustments to the annotation-processing test infra: add Javadoc/comments for addCompiledClasses, beforeTest and afterTest in AbstractAnnotationProcessingTest; reduce visibility of AnnotationProcessingTestProcessor constructor and prepare method to package-private; and rename local variables in CompilerInvocationInterceptor to improve clarity and pass the test instance into the processor. These changes improve test coverage and tighten processor APIs.
Introduce io.microsphere.util.ThrowableUtils: a new utility class (with ASF license header and author info) providing getRootCause(Throwable) to traverse and return the deepest cause in a throwable chain. The class implements Utils and has a private constructor to prevent instantiation.
Add JUnit 5 tests for ThrowableUtils#getRootCause. The new test file verifies retrieving the root cause from a nested Throwable, checks behavior when using ThrowableAction.execute to handle thrown exceptions, and ensures rethrowing the root cause yields the expected NullPointerException.
Introduce a failing test and verify test lifecycle failure handling. Adds testOnFailure() which throws a RuntimeException("For testing") and overrides afterTest(ReflectiveInvocationContext<Method>, ExtensionContext, Object, Throwable) to assert the failure message when a failure is present. Also adds the required imports and an assertEquals assertion.
Add Microsphere test libraries to the module POM (microsphere-lang-model, microsphere-jdk-tools (test scope), and microsphere-java-test (test scope)). Update unit tests to extend AbstractAnnotationProcessingTest and adjust lifecycle hooks: beforeTest/afterTest signatures now accept ReflectiveInvocationContext<Method> and ExtensionContext (and afterTest includes result/failure). Import necessary classes (ReflectiveInvocationContext, ExtensionContext, Method) and update test setup/teardown to use the new testing extension API.
Delete the entire microsphere-annotation-processor module: remove source files under src/main/java (annotation model elements, visitors and various utility classes such as AnnotationUtils, ClassUtils, ConstructorUtils, ElementUtils, ExecutableElementComparator, FieldUtils, LoggerUtils, MemberUtils, MessagerUtils, MethodUtils, TypeUtils, etc.) and corresponding unit tests under src/test/java. This change removes the annotation processing implementation and its tests from the repository.
Introduce a new microsphere-lang-model Maven module. Adds pom.xml with dependencies and build configuration, core language-model classes (e.g. StringAnnotationValue) and a comprehensive set of utility classes for annotation/element processing (AnnotationUtils, ClassUtils, ConstructorUtils, ElementUtils, ExecutableElementComparator, FieldUtils, MethodUtils, TypeUtils, Resolvable/JSON visitors, LoggerUtils, MessagerUtils, MemberUtils, etc.). Includes unit tests for the added utilities and elements to validate behavior. This module provides reusable helpers for working with javax.lang.model types and annotation processing within the Microsphere project.
Replace references to io.microsphere.annotation.processor.util.* with the new io.microsphere.lang.model.util.* equivalents across the annotation processor (MessagerUtils, AnnotationUtils, ElementUtils, TypeUtils, ClassUtils, JSONElementVisitor). Update Javadoc and fully-qualified references where needed. Simplify ConfigurationPropertyAnnotationProcessorTest by using AbstractAnnotationProcessingTest and removing an unused lifecycle override. Update pom dependency management and dependencies to add microsphere-java-core and microsphere-lang-model, replace microsphere-java-core dependency usage with microsphere-jdk-tools, and add microsphere-java-test to reflect module relocations.
Add new modules to the parent POM and reorder existing entries. This commit introduces microsphere-jdk-tools, microsphere-java-test, and microsphere-lang-model to the <modules> section and moves microsphere-annotation-processor to the end of the list so the module ordering reflects the updated project structure.
Remove the <build> sections from microsphere-java-test, microsphere-jdk-tools, and microsphere-lang-model POMs. This deletes the maven-compiler-plugin configuration (compilerArgument -proc:none) and the maven-shade-plugin execution that shaded io.github.microsphere-projects:microsphere-java-core, consolidating/cleaning up module-level build configuration.
Move javax.ws.rs and jaxws-api version properties into the parent pom and add dependencyManagement entries for javax.ws.rs-api and jaxws-api. Remove duplicate properties and explicit version elements from module poms (annotation-processor, lang-model, java-test) so they inherit the parent-managed versions. Adjust microsphere-java-dependencies to reorder artifactIds (swap mappings between microsphere-lang-model, microsphere-jdk-tools, microsphere-annotation-processor, and microsphere-java-test). Delete the TestProcessor test class and its service registration (META-INF/services) from the java-test module.
Reorder and group static imports in FieldUtils for consistency and readability. Remove an unused import (AbstractAnnotationProcessingTest) from JSONElementVisitorTest to eliminate a compiler/IDE warning. No behavior changes.
Normalize and tidy imports across multiple modules: reorder static imports for consistency, remove unused imports (including AbstractAnnotationProcessingTest in tests), and fix minor formatting. Replace Mockito wildcard import with explicit mock import in TestServiceImplTest. These are code-cleanup changes to reduce warnings and improve import organization.
Create a new microsphere-java-annotations module and move annotation sources and tests from microsphere-java-core into it. Added a module POM (including jsr305 and JUnit test deps), new NonnullTest and NullableTest classes, and updated test Javadocs. Updated microsphere-java-core POM to depend on the new annotations artifact (replacing the previous direct jsr305 dependency), added the annotations artifact to dependencyManagement, and registered the new module in the root POM. Also removed an unused import in Since.java.
Update the project's parent POM from io.github.microsphere-projects:microsphere-build:0.2.2 to 0.2.3 to incorporate upstream build configuration changes and fixes.
Add JSR-305 (com.google.code.findbugs:jsr305) as a test-scoped dependency in microsphere-java-core/pom.xml. This brings in standard nullability annotations for use in tests and static analysis during the test phase.
Replace checked-in maven-wrapper binary with the newer wrapper scripts and properties. Removes .mvn/wrapper/maven-wrapper.jar, updates .mvn/wrapper/maven-wrapper.properties to wrapperVersion=3.3.4 and points distributionUrl to an aliyun mirror (apache-maven-3.9.9) using distributionType=only-script. Replaces mvnw and mvnw.cmd with revamped wrapper implementations that download/install Maven on demand, add support for MVNW_REPOURL/MVNW_USERNAME/MVNW_PASSWORD/MVNW_VERBOSE, improve Java detection and error handling, support checksum validation, and add mvnd handling.
Bump GitHub Actions steps to v5 (actions/checkout and actions/setup-java) and switch the build command to use the project Maven wrapper (./mvnw) instead of system mvn. Removed the setup-java cache configuration; this ensures the workflow uses the updated action versions and a consistent, project-provided Maven runtime for builds.
Bump actions/checkout and actions/setup-java from v4 to v5 in .github/workflows/maven-publish.yml. Java 11 (Temurin) configuration remains unchanged. Update brings the workflow to the latest major action releases for improvements, fixes, and security updates.
@codecov
Copy link

codecov bot commented Feb 4, 2026

Codecov Report

❌ Patch coverage is 98.28125% with 11 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ore/src/main/java/io/microsphere/net/URLUtils.java 91.66% 0 Missing and 5 partials ⚠️
...java/io/microsphere/convert/AbstractConverter.java 33.33% 2 Missing and 2 partials ⚠️
...src/main/java/io/microsphere/json/JSONTokener.java 95.00% 0 Missing and 1 partial ⚠️
...n/java/io/microsphere/reflect/ReflectionUtils.java 95.45% 0 Missing and 1 partial ⚠️
Files with missing lines Coverage Δ Complexity Δ
...ssor/ConfigurationPropertyAnnotationProcessor.java 100.00% <100.00%> (+6.97%) 16.00 <5.00> (+4.00)
...essor/ConfigurationPropertyJSONElementVisitor.java 100.00% <100.00%> (ø) 24.00 <4.00> (?)
...crosphere/annotation/processor/FilerProcessor.java 100.00% <ø> (ø) 5.00 <0.00> (ø)
...sphere/annotation/processor/ResourceProcessor.java 100.00% <ø> (+7.40%) 36.00 <0.00> (ø)
...assloading/BannedArtifactClassLoadingExecutor.java 100.00% <100.00%> (+25.53%) 13.00 <1.00> (+4.00)
...classloading/ManifestArtifactResourceResolver.java 100.00% <100.00%> (+13.51%) 13.00 <2.00> (-1.00) ⬆️
...classloading/ServiceLoadingURLClassPathHandle.java 100.00% <100.00%> (+16.66%) 5.00 <1.00> (-1.00) ⬆️
...e/classloading/StreamArtifactResourceResolver.java 100.00% <100.00%> (+8.16%) 17.00 <2.00> (-1.00) ⬆️
.../io/microsphere/collection/DelegatingIterator.java 100.00% <100.00%> (ø) 9.00 <9.00> (?)
.../java/io/microsphere/collection/EmptyIterator.java 100.00% <100.00%> (+37.50%) 2.00 <1.00> (-1.00) ⬆️
... and 77 more

... and 11 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Provide a base beforeTest implementation in UtilTest that initializes testTypeElement from TestServiceImpl and add required imports (TestServiceImpl, ReflectiveInvocationContext, ExtensionContext, Method). Update several test classes (ElementUtilsTest, JSONAnnotationValueVisitorTest, MessagerUtilsTest, MethodUtilsTest, ResolvableAnnotationValueVisitorTest) to call super.beforeTest(invocationContext, extensionContext) at the start of their overridden beforeTest methods so the shared setup runs correctly.
Introduce initTestClass(Class<?>) to centralize initialization of test class metadata for annotation-processing tests. The new method sets testClass, testClassName, resolves testTypeElement via Elements, assigns testTypeMirror and casts it to testDeclaredType (DeclaredType). This consolidates repeated setup logic and prepares type information for subsequent processing.
StopWatchTest was updated to add a static import for getLogger and replace the explicit LoggerFactory.getLogger(...) call with getLogger(...). This simplifies the code style in the test and introduces no functional change.
Use static getLogger import and simplify logger field initialization; change error handling in convert() to log as warn and wrap exceptions as IllegalArgumentException instead of RuntimeException; remove redundant target null initialization; add identity short-circuit in equals() for faster equality checks and clearer semantics. These changes improve logging, exception semantics, and minor code cleanup.
Change AbstractConverterTest to use String generic types instead of Object and update related method signatures. Add import for assertThrows and a new test (testConvertOnFailed) that verifies convert(...) wraps conversion errors as IllegalArgumentException. Simplify testConvertIfPossible (now empty) and extend equality checks to assert the converter is not equal to StringToBooleanConverter.INSTANCE or ObjectToStringConverter.INSTANCE. These changes improve type-safety and add coverage for failure and equality behavior.
Change AbstractConverter to wrap caught Throwables in RuntimeException instead of IllegalArgumentException to better represent arbitrary conversion failures. Update AbstractConverterTest to expect RuntimeException accordingly.
Extend Filter<T> with java.util.function.Predicate<T> and provide a default test(T) implementation that delegates to accept(T) for compatibility with the Java functional API. Add FilterTest to verify both accept(...) and test(...) behavior using a simple String-based predicate.
Restrict test logging methods to protected, centralize temporary file/directory creation under TEST_TEMP_DIR, and ensure created files/directories are marked deleteOnExit. Replace UUID.randomUUID() calls with a static randomUUID import and remove the now-unneeded newTempFile helper. Adds convenience methods createRandomTempFile() and newRandomTempFile(), and consolidates random filename generation.
Simplify and harden JarUtils internals: - Replace verbose toJarFile implementation with a concise ternary return. - Convert anonymous JarEntryFilter to a lambda for readability. - Change doExtract signature from Iterable<JarEntry> to Collection<JarEntry>, add null/empty guard (uses CollectionUtils.isEmpty) and early return to avoid NPEs. - Move resource closing into finally block and keep extraction logic unchanged. These changes improve readability and null-safety; note the doExtract signature change may require updating callers.
Convert JarUtilsTest to extend AbstractTestCase and replace manual temp-dir handling with createRandomTempDirectory. Clean up imports and use ClassLoaderUtils helpers consistently. Add/adjust tests to improve coverage and robustness: filter behavior, toJarFile edge cases (null, invalid protocol, not-found), assertJarURLProtocol, resolveRelative/absolute paths, findJarEntry, extract variations (URL overload, doExtract with nulls/missing entries) and lambdas for JarEntryFilter. Overall this refactors setup and expands test cases to catch more error conditions and behaviors.
Remove unused Collections.emptyMap import and the early-return check for an empty handlers list. The loadHandlers method was made package-private (removed @Nonnull/@immutable and private modifier) and now directly builds the handlers map with toFixedMap, simplifying the logic and removing redundant code.
Simplify equals and hashCode implementations in TypeArgument: switch the class equality check to an instanceof check, add clearer brace formatting, and replace the manual hash computation with java.util.Objects.hash (via static import). These changes improve readability and delegate hash calculation to the standard library.
Introduce NameFileFilterTest covering NameFileFilter behavior for exact matches and case variations. Tests assert accept() returns true for an exact filename and verifies both case-sensitive and case-insensitive matching scenarios. Also includes a minor EOF newline normalization in NameFileFilter.java.
Replace direct null comparison with Objects.nonNull via a static import for readability, and remove the final modifier from isPresent to allow overriding in subclasses. Minor whitespace/formatting adjustments.
Clean up StreamArtifactResourceResolver by removing unnecessary logger.isTraceEnabled()/isErrorEnabled() guards and calling logger methods directly. Simplify readArtifactMetadataDataFromArchiveFile by returning early and preferring the directory branch, removing an intermediate variable. Minor tidy-up of input stream handling and trace messages; no API changes intended.
Remove the unused getCodeSourceLocation(Class<?>) method from ClassDataRepository and eliminate several now-unused imports (File, URL, MalformedURLException, CodeSource, ProtectionDomain, StringUtils). Move the private constructor to the end of the class. Update tests to use the ClassDataRepository.INSTANCE constant, remove the test for getCodeSourceLocation, add negative tests for not-found classpath/package, and tidy up test imports and assertions accordingly.
Remove the unused io.microsphere.logging.LoggerFactory import from MethodDefinitionTest.java to clean up the test file and avoid unused-import warnings.
Replace direct dependency on ClassDataRepository in Version.java by using ClassUtils.getCodeSourceLocation. Removed ClassDataRepository import and static INSTANCE usage, added static import for getCodeSourceLocation, and updated the classResource lookup before throwing the error when Implementation-Version is missing. This simplifies the utility usage and reduces coupling.
Add proper lifecycle control and logging to StandardFileWatchService: introduce a Logger, AtomicBoolean 'started', isStarted/stop/close methods, and make event loop Future volatile. Reorder and initialize executors consistently, log directory registrations and dispatched events, and use MILLISECONDS wait in stop. Also convert several helper methods to static (toWatchEventKinds, toWatchEventKind, toKind) and tighten thread-safety when accessing shared state.
Add unit tests for StandardFileWatchService covering watch-event-kind conversions and service lifecycle. New tests validate toWatchEventKinds behavior (including null/empty inputs), mapping from StandardWatchEventKinds to FileChangedEvent.Kind via toKind, and that OVERFLOW is rejected. Existing file-watching tests updated to assert isStarted after start and isStopped after stop, and to explicitly stop the service. Added necessary static imports and assertions.
Refactor resolvePathFromFile to delegate to a new overload that accepts an isOsWindows flag (resolvePathFromFile(URL, boolean)), improving testability. Replace the previous manual index/substring logic with substringAfter(path, SLASH) to strip the leading slash on Windows. Add the required substringAfter import and minor cleanup.
Refactor test constants for query/matrix strings and add coverage for combined matrix+query case. Introduces tests for resolvePathFromFile (file:// path handling with/without leading slash) and buildPath to validate path extraction for file URLs. Also adds required static imports and minor test adjustments.
Add a new JarUtils.isDirectoryEntry(URL) method to detect whether a given 'jar:' URL refers to a directory entry (treating an empty relative path as the JAR root). The method only supports the 'jar' protocol, resolves the relative path, and uses findJarEntry to verify directory entries. Also add a null-check in findJarEntry to handle cases where toJarFile(url) returns null, and import StringUtils.EMPTY for the empty-path comparison.
Add a new test method testIsDirectoryEntry to cover JarUtils.isDirectoryEntry behavior across various URL types: a temp file URL (expected false), a package directory resource (expected true), a trimmed package URL (expected true), a class resource URL (expected false), and an explicit jar URL with trailing slash (expected false). Also add required static imports (substringBeforeLast, isDirectoryEntry, assertTrue). This improves coverage for directory-detection edge cases.
Add a Logger and URLUtils import to JarUtils and make JAR resolution more robust: toJarFile now returns null on IO errors (catching IOException and logging at trace) instead of propagating IOExceptions, and its signature was changed to throw IllegalArgumentException for invalid protocols. Removed declared IOExceptions from findJarEntry and isDirectoryEntry. Minor import and static logger initialization added to support these changes.
Simplify URL directory detection by adding an early null check, delegating JAR-entry checks to JarUtils.isDirectoryEntry, and using buildPath(...) for file URLs. The previous implementation that opened JarFile and resolved JarEntry has been removed (including the toJarFile helper and its Javadoc) to avoid exception-heavy logic and improve readability; related unused imports were also cleaned up.
Update URLUtilsTest.testIsDirectoryURL to assert that isDirectoryURL(null) returns false and remove the unnecessary 'throws Exception' from the test signature. This strengthens the test by covering a null input and cleans up the method declaration.
Introduce isArchiveProtocol(String) to centralize archive-protocol checks (jar/zip/war/ear) and update isArchiveURL to use it. Add ZIP_PROTOCOL import and non-null check via Objects.nonNull for JarFile. Reorganize and reintroduce URL path helper methods (resolvePath, resolvePathFromFile, resolvePathFromJar, buildPath) and adjust resolveArchiveDirectory to use buildPath(resourceURL). Replace manual list-first logic with ListUtils.first in getFirst and clean up related imports and javadoc for the new API.
Add and refactor tests in URLUtilsTest to improve coverage for archive-related behavior. Introduces new tests for unresolved archive files, various isJarURL edge cases (HTTP and null), and isArchiveProtocol checks for JAR/ZIP/WAR/EAR. Adjusts isDirectoryURL test to verify directory entries and uses JarUtils.isDirectoryEntry. Removes unnecessary throws declarations from many tests and simplifies helper usage (resolvePath, ofURL). Adds a test helper for testing archive protocols and leaves some additional archive tests commented for future use.
Relax visibility of unfinishedProcessesCache from private to package-private so tests can access it. Add a @beforeeach setUp in ProcessManagerTest (and import BeforeEach) to clear the cache before each test, ensuring test isolation and preventing state leakage between tests.
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant