@@ -90,6 +90,7 @@ public int order() {
9090 }
9191
9292 public List <Instrumenter > typeInstrumentations () {
93+ preloadClasses ();
9394 return singletonList (this );
9495 }
9596
@@ -214,6 +215,28 @@ protected final boolean isShortcutMatchingEnabled(boolean defaultToShortcut) {
214215 .isIntegrationShortcutMatchingEnabled (singletonList (name ()), defaultToShortcut );
215216 }
216217
218+ /**
219+ * Force loading of classes that need to be instrumented, but are using during instrumentation.
220+ */
221+ @ SuppressForbidden // allow this use of Class.forName()
222+ protected void preloadClasses () {
223+ String [] list = preloadClassNames ();
224+ if (list != null ) {
225+ for (String clazz : list ) {
226+ try {
227+ Class .forName (clazz );
228+ } catch (Throwable t ) {
229+ log .debug ("Error force loading {} class" , clazz );
230+ }
231+ }
232+ }
233+ }
234+
235+ /** Get classes to force load */
236+ public String [] preloadClassNames () {
237+ return null ;
238+ }
239+
217240 /** Parent class for all tracing related instrumentations */
218241 public abstract static class Tracing extends InstrumenterModule {
219242 public Tracing (String instrumentationName , String ... additionalNames ) {
@@ -258,18 +281,11 @@ public final boolean isApplicable(Set<TargetSystem> enabledSystems) {
258281 }
259282
260283 /** Parent class for all IAST related instrumentations */
261- @ SuppressForbidden
262284 public abstract static class Iast extends InstrumenterModule {
263285 public Iast (String instrumentationName , String ... additionalNames ) {
264286 super (instrumentationName , additionalNames );
265287 }
266288
267- @ Override
268- public List <Instrumenter > typeInstrumentations () {
269- preloadClassNames ();
270- return super .typeInstrumentations ();
271- }
272-
273289 @ Override
274290 public final boolean isApplicable (Set <TargetSystem > enabledSystems ) {
275291 if (enabledSystems .contains (TargetSystem .IAST )) {
@@ -282,27 +298,6 @@ public final boolean isApplicable(Set<TargetSystem> enabledSystems) {
282298 return cfg .getAppSecActivation () == ProductActivation .FULLY_ENABLED ;
283299 }
284300
285- /**
286- * Force loading of classes that need to be instrumented, but are using during instrumentation.
287- */
288- private void preloadClassNames () {
289- String [] list = getClassNamesToBePreloaded ();
290- if (list != null ) {
291- for (String clazz : list ) {
292- try {
293- Class .forName (clazz );
294- } catch (Throwable t ) {
295- log .debug ("Error force loading {} class" , clazz );
296- }
297- }
298- }
299- }
300-
301- /** Get classes to force load* */
302- public String [] getClassNamesToBePreloaded () {
303- return null ;
304- }
305-
306301 @ Override
307302 public Advice .PostProcessor .Factory postProcessor () {
308303 return IastPostProcessorFactory .INSTANCE ;
0 commit comments