Skip to content

Release 0.1.8#248

Merged
mercyblitz merged 467 commits intoreleasefrom
dev
Mar 4, 2026
Merged

Release 0.1.8#248
mercyblitz merged 467 commits intoreleasefrom
dev

Conversation

@mercyblitz
Copy link
Contributor

This pull request introduces significant improvements to the build system, annotation processor module, and documentation. The main changes update the Maven wrapper and CI workflows for better compatibility and reliability, enhance the annotation processor's modularity and code organization, and improve the project documentation to reflect new modules.

Build System and CI Improvements

  • Upgraded Maven wrapper to version 3.9.9 and switched the distribution source to Aliyun for improved reliability; changed wrapper configuration to use script-only distribution (.mvn/wrapper/maven-wrapper.properties).
  • Updated GitHub Actions workflows to use newer versions of actions/checkout and actions/setup-java, switched Maven build to use ./mvnw instead of mvn, and added a JVM system property for tests (.github/workflows/maven-build.yml, .github/workflows/maven-publish.yml). [1] [2]

Annotation Processor Module Enhancements

  • Added new test and utility dependencies (microsphere-lang-model, microsphere-jdk-tools, microsphere-java-test) to microsphere-annotation-processor/pom.xml, and removed unused properties. [1] [2] [3] [4]
  • Refactored ConfigurationPropertyAnnotationProcessor and ConfigurationPropertyJSONElementVisitor for better modularity: moved visitor to top-level package, updated imports to use shared utilities, improved metadata resolution logic, and made visitor/package-private and methods less exposed. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]

Documentation Updates

  • Updated README.md to list new modules, provide links to their JavaDocs, and clarify getting started instructions. [1] [2] [3]

Refactor test to extend AbstractMBeanFeatureInfoBuilderTest<MBeanAttributeInfoBuilder>, removing the local builder field and @beforeeach setup. Drop the now-unused static import and BeforeEach import. Add an assertion for attributeType("java.lang.Boolean") to verify fluent API chaining.
Remove the fluent attributeType(...) setter and assign attributeType directly in the static attribute(...) factory. The @nonnull annotation was reformatted to its own line. The factory still asserts non-null for attributeType, but the field is now set internally on builder creation, simplifying the builder API and preventing external mutation via the removed setter.
Add static import for MBeanAttributeInfoBuilder.attribute and override builder() to return attribute(Boolean.class) for test setup. Remove redundant assertion that previously set attributeType("java.lang.Boolean"). This simplifies initialization and centralizes builder creation in the test.
Introduce MBeanParameterInfoBuilder in io.microsphere.management.builder to construct javax.management.MBeanParameterInfo instances. The builder extends MBeanFeatureInfoBuilder, holds a 'type' field, provides build(), and static factory methods parameter(Class<?>) (uses getTypeName) and parameter(String) for convenient creation.
Add MBeanParameterInfoBuilderTest to verify that MBeanParameterInfoBuilder.parameter(String.class) constructs an MBeanParameterInfo with the correct type (java.lang.String). The test extends AbstractMBeanFeatureInfoBuilderTest and implements builder() and testBuild() methods.
Add org.junit.jupiter.api.Disabled import and annotate the test class with @disabled to prevent JUnit from running this base test. Also change the class from public to package-private and declare it abstract so it serves only as a superclass for concrete test implementations.
Add a test-only annotation `@Units` under io.microsphere.management. The annotation is targeted at methods, retained at runtime, and meta-annotated with `@DescriptorKey("units")` to attach a JMX descriptor key for units. This supports management-related tests that need unit metadata on MBean attributes/operations.
Introduce a new test interface CacheControlMBean in src/test/java/io/microsphere/management. The file includes an ASF license header and Javadoc, and defines a single method getCacheSize() annotated with @Units("bytes") as an example for the Units annotation.
Introduce descriptorForElement and descriptorForAnnotations to build ImmutableDescriptor from annotations (honoring @DescriptorKey) and return EMPTY_DESCRIPTOR when no entries. Refactor doGetAttribute to handle null/non-readable attributes early, wrap unexpected throwables with ExceptionUtils.wrap, and improve logging (include MBeanInfo in attribute-not-found logs and remove redundant isWarnEnabled checks). Also add related imports and small utility usage (newFixedHashMap, invokeMethod) to support the changes.
Introduce new unit tests in JmxUtilsTest to cover descriptor and attribute handling: add testGetAttributeOnUnreadableAttribute which registers a DynamicMBean with an unreadable attribute and asserts null is returned; add placeholder testGetAttributeOnReflectionException; add tests for descriptorForElement (verifies ImmutableDescriptor and field values), descriptorForElementOnNoDisciptorKeyAnnotated (expects EMPTY_DESCRIPTOR), and descriptorForAnnotations null/empty cases. Also add required imports and static imports (findMethod, ofArray, assertArrayEquals, assertInstanceOf, EMPTY_DESCRIPTOR) to support the new tests.
Add a setCacheSize(long) setter (annotated with @Units("bytes")) to the CacheControlMBean test interface so tests can modify the cache size. Also ensure file ends with a newline.
Introduce MBeanOperationInfoBuilder to construct MBeanOperationInfo (including impact and parameter helpers) and add methodSignature/descriptorForAnnotations helpers in JmxUtils to derive MBeanParameterInfo[] and descriptors from reflection. Add MBeanParameterInfoBuilder.parameter(Parameter) to build parameter metadata from java.lang.reflect.Parameter and extend Units test annotation to target parameters. Include unit tests for methodSignature and MBeanOperationInfoBuilder to validate generated signatures, descriptors and parameter metadata.
Introduce an abstract MBeanExecutableInfoBuilder that extends MBeanFeatureInfoBuilder to construct MBean constructor/operation info. It manages parameter signature state, provides signature(...) and param(...) fluent methods, a from(Executable) helper to populate name/descriptor/signature/description from a reflection Executable, and a toSignature() helper. Also defines NO_PARAMS constant and integrates with MBeanParameterInfoBuilder and JmxUtils utilities.
Introduce MBeanConstructorInfoBuilder to create javax.management.MBeanConstructorInfo instances. The builder extends MBeanExecutableInfoBuilder, provides a build() method that returns a MBeanConstructorInfo, and includes static factory methods constructor() and constructor(Constructor<?>). Added Javadoc and Apache license header under package io.microsphere.management.builder.
Change MBeanOperationInfoBuilder to extend MBeanExecutableInfoBuilder and delegate executable/signature handling to the superclass. Removed the local parameters list and related methods (signature, param), updated build() to call toSignature(), and simplified operation(Method) to use .from(method). Also cleaned up unused imports.
Add a new signature(Parameter[]) method that builds MBeanParameterInfo[] from an array of Parameters and refactor methodSignature(Method) to delegate to it. This consolidates parameter-processing logic into a reusable helper without changing behavior.
Introduce MBeanConstructorInfoBuilderTest to verify MBeanConstructorInfoBuilder behavior. Tests cover param chaining and building from a reflective Constructor (String(byte[])), asserting the resulting MBeanConstructorInfo name, description, signature length and parameter name. The test class extends AbstractMBeanFeatureInfoBuilderTest.
Introduce MBeanNotificationInfoBuilder to construct javax.management.MBeanNotificationInfo instances. The builder extends MBeanFeatureInfoBuilder, provides fluent setters, build() method, and static factory methods notification(Class<?>...) and notification(String...). It normalizes Class<?> inputs to type names via ClassUtils and safely handles null/empty type arrays.
Introduce unit tests for MBeanNotificationInfoBuilder in microsphere-java-core. Covers building with name, description and descriptor, and verifies notification type handling using the notification(...) helper (including non-empty and empty class arrays), asserting expected name/description/descriptor and notif types.
Introduce constants for GET/SET/IS method name prefixes and add utility methods to detect JavaBean-style methods: isIsMethod, isGetterMethod, isSetterMethod. Also add small helper methods getMethodName, matchesParameterCount, matchesReturnType and isNoArgMethod, and import startsWith from StringUtils. Adjusted the comment for the banned methods property name.
Expand MethodUtilsTest with new unit tests and helpers: assert constants, OBJECT_* collections/predicates, is/get/set method detectors, getMethodName, matchesParameterCount, and matchesReturnType. Add helper assertion methods and getMethod lookup, plus small cleanup replacing a println with an assertion. New tiny methods (isMethod/get/set/setValue) and imports were added to support edge-case tests and improve coverage of MethodUtils behavior.
Change MBeanAttributeInfoBuilder's attribute fields from private to package-private and rename attributeType to type. Update build() and attribute(...) to use the new field name. This relaxes visibility for package-level access and aligns the builder field naming.
Introduce an abstract JUnit 5 test class for MBeanDescribableBuilder implementations. The test provides common tests for description and descriptor setters, a reflection-based builder instantiation helper, and declares an abstract testBuild() to be implemented by concrete subclasses. The test is disabled (abstract) and includes constants for test data.
Refactor MBeanFeatureInfoBuilder to extend MBeanDescribableBuilder<B> and remove duplicated description and descriptor fields and their setters. The name field is now annotated @nullable and Javadoc was updated with a @param for the builder generic. This centralizes descriptor/description handling in the superclass and reduces duplicated code.
Make AbstractMBeanFeatureInfoBuilderTest extend AbstractMBeanDescribableBuilderTest to reuse common test behavior and remove duplicated setup/code. Removed builder field, setup helper, TEST_DESCRIPTION and TEST_DESCRIPTOR constants, and dedicated tests for description and descriptor; adjusted imports and updated testBuild to reference TEST_NAME with the class qualifier. This reduces duplication and centralizes describable-related tests in the base test class.
Change visibility of the `parameters` field in MBeanExecutableInfoBuilder from private to protected so subclasses can access or modify the MBeanParameterInfo list. No other logic changes were made.
Expose types(String...) and add an overload types(Class<?>...) to accept Class inputs (converted to class names). Add a static notification() factory and update notification(...) overloads to delegate to it. Also relax visibility of the types field to allow builder usage. These changes improve the builder's fluent API and make constructing MBeanNotificationInfo instances from Class types more convenient.
Rename the field 'type' to 'returnType' in MBeanOperationInfoBuilder and update usages accordingly (build() and operation(String)). Also relax visibility of returnType and impact from private to package-private. This clarifies the field's purpose without changing behavior.
Relaxed the visibility of MBeanParameterInfoBuilder.type from private to package-private so other classes in the same package (such as related builders or tests) can access it. This is a non-functional change limited to field accessibility.
Consolidate classpath resolution logic by introducing resolveClassPaths(boolean, Supplier<String>) and delegating initBootstrapClassPaths/initClassPaths to it. This removes duplication around checking whether a classpath is supported and fetching it via RuntimeMXBean. Also adds unit test coverage (testResolveClassPaths) to assert emptySet behavior for unsupported or empty classpath suppliers and updates imports accordingly.
Refactor ArchiveFileArtifactResourceResolver by extracting the filename-to-artifact parsing into a new static createArtifact(String, URL) method. resolve(...) now delegates to createArtifact(...). Added unit test testCreateArtifact to validate parsing of names like 'a-1.0.jar', 'a.jar', and empty input (null). This improves reuse and testability of artifact creation logic.
Refactor FastByteArrayOutputStream to extract the array-size check into a package-private assertCapacity(int) method and call it from ensureCapacity. Also relax MAX_ARRAY_SIZE visibility to package-private. Update unit tests to use explicit this. and add a test asserting assertCapacity(Integer.MAX_VALUE) throws OutOfMemoryError to increase coverage of the overflow check.
Changed CompositeSubProtocolURLConnectionFactory.selectFactory and selectFactoryIndex from private to package-private to allow test access. Updated CompositeSubProtocolURLConnectionFactoryTest to use a @beforeeach setup, use NO_PROXY and ofList helpers, and added new tests (testRemove, testSupports). Removed inline test factory classes from ExtendableProtocolURLStreamHandlerTest and added them as separate test files (FalseSubProtocolURLConnectionFactory, NullSubProtocolURLConnectionFactory). Adjusted imports accordingly to improve testability and reuse of test helpers.
Replace strict getClass() check with instanceof in ValueHolder.equals so ValueHolder subclasses can be considered equal; add braces/formatting for clarity. Update ValueHolderTest to reflect the behavior (add static import for Integer.valueOf, reorder assertions, and add an assertion ensuring a ValueHolder is not equal to a raw Integer).
Refactor MethodUtils and its tests: adjust the trace log formatting, change MethodKey constructor to varargs (Class<?>...), and fix equals to use instanceof with clearer field comparisons. Simplify hashCode to use existing hash(...) helpers and normalize toString usage. Update MethodUtilsTest to extend LoggingTest, import MethodKey, add null/inequality checks and a new test for nearest overridden method on Object, and add assertions validating MethodKey equality/inequality and behavior.
Rework resource discovery and error handling when scanning a package: remove the surrounding try/catch and use ThrowableSupplier.execute to wrap checked IO operations (getResources and new File(...).toURI().toURL()). Use ListUtils.newArrayList for repository results and simplify control flow by separating resourceURL fallback (ClassDataRepository) from class name resolution and class loading loops. Clean up unused imports (IOException, ArrayList) and keep behavior of collecting and loading classes intact.
Remove the unused 'accessible' flag and simplify exception handling in MethodUtils.invoke (call trySetAccessible without tracking and merge IllegalAccessException and IllegalArgumentException into a single IllegalArgumentException with an argument-mismatch message). Update tests: import isCallerSensitiveMethod, ensure Object.class methods are excluded in the predicate test, and add a test that verifies no methods on MethodUtilsTest are treated as caller-sensitive.
Import io.microsphere.LoggingTest and have MethodHandlesLookupUtilsTest extend LoggingTest to enable logging utilities/support during test execution.
Simplify CustomizedThreadFactory by replacing the static import of System.getSecurityManager with Thread.currentThread, and remove the SecurityManager conditional. The thread group is now always obtained from the current thread (currentThread().getThreadGroup()), simplifying the logic for constructing the thread factory.
Change resolveArguments visibility from private to package-private so it can be unit tested, and add ExceptionUtilsTest#testResolveArguments to verify behavior for exceptions with null message, with a message, and with an explicit cause. Also add required imports (ArrayUtils.ofArray and Assertions.assertArrayEquals) used by the new test.
Reduce log severity when a MethodHandle can't be found in MethodHandlesLookupUtils by switching from WARN to TRACE and updating the guard from isWarnEnabled() to isTraceEnabled(). This lowers noise for expected/missing lookups while preserving the detailed message for trace-level debugging.
Modify tests in MethodUtilsTest to use MethodKey instances for String.valueOf(boolean) and String.valueOf(char) instead of toString. Add an assertion to ensure the two valueOf overload keys are not equal, and change the final inequality check to compare against 'this' (a non-MethodKey) rather than the literal "String". These changes improve coverage of MethodKey comparisons by name and parameter types.
Add an assertion in JSONObjectTest to verify numberToString(Double.valueOf(1.23)) returns '1.23'. This ensures correct formatting of positive non-integer doubles and guards against regressions in numeric string conversion.
Introduce a static getDefaultClassLoader(ClassLoader) helper to centralize null->system ClassLoader resolution and update callers to use it. Add unit test testGetDefaultClassLoaderWithNull to verify behavior, add an extra null assertion in findLoadedClass-related tests, and fix a minor test formatting/brace placement.
Introduce a package-private overload shutdownHookThreadsMap(Class<?>) and make the existing private shutdownHookThreadsMap() delegate to it. This enables tests to invoke the helper directly (including passing null) to verify behavior. Updated tests to import shutdownHookThreadsMap and emptyMap, assert that addShutdownHookCallback(null) returns false, and add testShutdownHookThreadsMapWithNullClass to confirm it returns the same empty map when given null.
Introduce Logger and safer service loading in AbstractEventDispatcher: use getDefaultClassLoader and execute(...) to swallow errors with trace logging, add logger field, replace direct null-check with assertNotNull (documented as IllegalArgumentException), refactor doInListener by adding an overload that accepts an event type and delegating to it, and update imports accordingly. Update unit tests to match behavior changes: add setup, assert IllegalArgumentException for null executor, add tests for loading listeners, classloader-failure resilience, getExecutor, and doInListener(null) handling.
Wrap definition.isPresent() with Boolean.valueOf in AbstractReflectiveDefinitionTest and add a static import for java.lang.Boolean.valueOf. This makes the boxing explicit when passing the boolean result to assertNotNull, clarifying intent in the test.
Refactor testOpenConnectionOnResourceNotFound: add MalformedURLException to the test signature, move URL construction out of the lambda, and replace the lambda with a method reference (assertThrows(IOException.class, url::openStream)). Also add the MalformedURLException import to compile and improve readability.
Replace assertEquals/assertNotEquals usages with explicit assertTrue(...equals(...)) and assertFalse(...equals(...)) in MethodUtilsTest. This makes the intent explicit that the equals(Object) method is being tested (avoiding any ambiguity from generic assertion overloads) — two assertions updated.
Wrap direct execute calls in assertDoesNotThrow and add the import to explicitly assert that no exceptions are thrown during the tests. Updated several test methods (testExecute1, testExecute2, testExecute3, testExecute3OnHandleException) to use the assertion wrapper.
Add @OverRide to the testRemove() method in ReversedDequeTest to explicitly mark it as overriding the superclass implementation, enabling compiler checks and improving code clarity. No functional change to test behavior.
Add the @OverRide annotation to the testEquals method in ReflectiveDefinitionTest to explicitly mark that it overrides the superclass implementation. This clarifies intent and enables compile-time override checking; no functional behavior change.
Synchronize README module list and docs with project structure: add microsphere-java-annotations, microsphere-java-model, microsphere-jdk-tools, and microsphere-java-test; reorder and clarify the modules table; add 'Tools' and 'Testing' to features; update Javadoc links for the new modules. Also include minor formatting/whitespace fixes in XML examples for readability.
@codecov
Copy link

codecov bot commented Mar 4, 2026

Codecov Report

❌ Patch coverage is 98.47561% with 15 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...n/java/io/microsphere/reflect/ReflectionUtils.java 86.95% 0 Missing and 9 partials ⚠️
...java/io/microsphere/convert/AbstractConverter.java 33.33% 2 Missing and 2 partials ⚠️
.../io/microsphere/io/filter/FileExtensionFilter.java 66.66% 0 Missing and 1 partial ⚠️
...src/main/java/io/microsphere/json/JSONTokener.java 95.00% 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> (ø)
...ssloading/ArchiveFileArtifactResourceResolver.java 100.00% <100.00%> (+10.00%) 10.00 <0.00> (+3.00)
.../io/microsphere/classloading/ArtifactDetector.java 97.67% <ø> (+11.62%) 18.00 <0.00> (+3.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%) 14.00 <2.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%) 20.00 <2.00> (+2.00)
... and 103 more

... and 62 files with indirect coverage changes

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

@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 4, 2026

@mercyblitz mercyblitz merged commit 32b402d into release Mar 4, 2026
12 checks passed
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