Skip to content

Commit

Permalink
make DomainPlugins package-private
Browse files Browse the repository at this point in the history
We should rather extend the plugin instantiation logic to allow non-public constructors
than making it public to be possibly invoked by users.

Signed-off-by: Peter Gafert <peter.gafert@archunit.org>
  • Loading branch information
codecholeric committed Jan 20, 2025
1 parent 7192144 commit 04cb26f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,14 @@
*/
package com.tngtech.archunit.core.domain;

import com.tngtech.archunit.Internal;
import com.tngtech.archunit.core.InitialConfiguration;
import com.tngtech.archunit.core.PluginLoader;

/**
* Resolved via {@link PluginLoader}
*/
@SuppressWarnings("unused")
@Internal
public class Java9DomainPlugin implements DomainPlugin {
class Java9DomainPlugin implements DomainPlugin {
@Override
public void plugInAnnotationPropertiesFormatter(InitialConfiguration<AnnotationPropertiesFormatter> propertiesFormatter) {
propertiesFormatter.set(AnnotationPropertiesFormatter.configure()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package com.tngtech.archunit.core;

import java.lang.reflect.Constructor;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -83,7 +84,9 @@ private T create(String className) {
try {
Class<?> clazz = Class.forName(className);
checkCompatibility(className, clazz);
return (T) clazz.getConstructor().newInstance();
Constructor<?> constructor = clazz.getDeclaredConstructor();
constructor.setAccessible(true);
return (T) constructor.newInstance();
} catch (Exception e) {
throw new PluginLoadingFailedException(e, "Couldn't load plugin of type %s", className);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,14 @@
*/
package com.tngtech.archunit.core.domain;

import com.tngtech.archunit.Internal;
import com.tngtech.archunit.core.InitialConfiguration;
import com.tngtech.archunit.core.PluginLoader;

/**
* Resolved via {@link PluginLoader}
*/
@SuppressWarnings("unused")
@Internal
public class Java14DomainPlugin implements DomainPlugin {
class Java14DomainPlugin implements DomainPlugin {
@Override
public void plugInAnnotationPropertiesFormatter(InitialConfiguration<AnnotationPropertiesFormatter> propertiesFormatter) {
propertiesFormatter.set(AnnotationPropertiesFormatter.configure()
Expand Down

0 comments on commit 04cb26f

Please sign in to comment.