62
62
*/
63
63
public final class PreprocessorUtils {
64
64
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" ;
65
72
private static final Pattern PATTERN_MACROS_WITH_SPACES =
66
73
Pattern .compile ("\\ /\\ *\\ s*\\ $(.*?)\\ $\\ s*\\ *\\ /" );
67
74
@@ -113,7 +120,6 @@ public static PreprocessorExtension findAndInstantiatePreprocessorExtensionForCl
113
120
}
114
121
}
115
122
116
-
117
123
/**
118
124
* Find comment remover type for provided identifier. Decoding also true and false values.
119
125
*
@@ -154,7 +160,6 @@ public static String getFileExtension(final File file) {
154
160
return result ;
155
161
}
156
162
157
-
158
163
public static BufferedReader makeFileReader (final File file , final Charset charset ,
159
164
final int bufferSize ) throws IOException {
160
165
Objects .requireNonNull (file , "File is null" );
@@ -182,12 +187,10 @@ public static String[] replaceChar(final String[] source,
182
187
return result ;
183
188
}
184
189
185
-
186
190
public static String extractTrimmedTail (final String prefix , final String value ) {
187
191
return extractTail (prefix , value ).trim ();
188
192
}
189
193
190
-
191
194
public static String extractTail (final String prefix , final String value ) {
192
195
Objects .requireNonNull (prefix , "Prefix is null" );
193
196
Objects .requireNonNull (value , "Value is null" );
@@ -226,7 +229,6 @@ public static boolean copyFileAttributes(final File from, final File to) {
226
229
return result ;
227
230
}
228
231
229
-
230
232
public static String replacePartByChar (final String text , final char chr , final int startPosition ,
231
233
final int length ) {
232
234
if (startPosition < 0 ) {
@@ -247,6 +249,9 @@ public static String replacePartByChar(final String text, final char chr, final
247
249
}
248
250
249
251
public static <T > List <T > findAndInstantiateAllServices (final Class <T > serviceClass ) {
252
+ if (Boolean .getBoolean (SYSTEM_PROPERTY_DISABLE_SEARCH_SERVICES )) {
253
+ return List .of ();
254
+ }
250
255
final ServiceLoader <T > serviceLoader = ServiceLoader .load (serviceClass );
251
256
return serviceLoader .stream ().map (ServiceLoader .Provider ::get ).collect (Collectors .toList ());
252
257
}
0 commit comments