6262 */
6363public final class PreprocessorUtils {
6464
65+ /**
66+ * Property if defined and true then search of services in class path is disabled.
67+ *
68+ * @since 7.2.0
69+ */
70+ public static final String SYSTEM_PROPERTY_DISABLE_SEARCH_SERVICES =
71+ "jcp.preprocessor.disable.search.services" ;
6572 private static final Pattern PATTERN_MACROS_WITH_SPACES =
6673 Pattern .compile ("\\ /\\ *\\ s*\\ $(.*?)\\ $\\ s*\\ *\\ /" );
6774
@@ -113,7 +120,6 @@ public static PreprocessorExtension findAndInstantiatePreprocessorExtensionForCl
113120 }
114121 }
115122
116-
117123 /**
118124 * Find comment remover type for provided identifier. Decoding also true and false values.
119125 *
@@ -154,7 +160,6 @@ public static String getFileExtension(final File file) {
154160 return result ;
155161 }
156162
157-
158163 public static BufferedReader makeFileReader (final File file , final Charset charset ,
159164 final int bufferSize ) throws IOException {
160165 Objects .requireNonNull (file , "File is null" );
@@ -182,12 +187,10 @@ public static String[] replaceChar(final String[] source,
182187 return result ;
183188 }
184189
185-
186190 public static String extractTrimmedTail (final String prefix , final String value ) {
187191 return extractTail (prefix , value ).trim ();
188192 }
189193
190-
191194 public static String extractTail (final String prefix , final String value ) {
192195 Objects .requireNonNull (prefix , "Prefix is null" );
193196 Objects .requireNonNull (value , "Value is null" );
@@ -226,7 +229,6 @@ public static boolean copyFileAttributes(final File from, final File to) {
226229 return result ;
227230 }
228231
229-
230232 public static String replacePartByChar (final String text , final char chr , final int startPosition ,
231233 final int length ) {
232234 if (startPosition < 0 ) {
@@ -247,6 +249,9 @@ public static String replacePartByChar(final String text, final char chr, final
247249 }
248250
249251 public static <T > List <T > findAndInstantiateAllServices (final Class <T > serviceClass ) {
252+ if (Boolean .getBoolean (SYSTEM_PROPERTY_DISABLE_SEARCH_SERVICES )) {
253+ return List .of ();
254+ }
250255 final ServiceLoader <T > serviceLoader = ServiceLoader .load (serviceClass );
251256 return serviceLoader .stream ().map (ServiceLoader .Provider ::get ).collect (Collectors .toList ());
252257 }
0 commit comments