71
71
@ AutomaticallyRegisteredFeature
72
72
public final class DynamicAccessDetectionFeature implements InternalFeature {
73
73
74
- private record MethodsByAccessKind (Map <DynamicAccessDetectionPhase .DynamicAccessKind , CallLocationsByMethod > methodsByAccessKind ) {
74
+ public record MethodsByAccessKind (Map <DynamicAccessDetectionPhase .DynamicAccessKind , CallLocationsByMethod > methodsByAccessKind ) {
75
75
MethodsByAccessKind () {
76
76
this (new ConcurrentSkipListMap <>());
77
77
}
@@ -85,7 +85,7 @@ public CallLocationsByMethod getCallLocationsByMethod(DynamicAccessDetectionPhas
85
85
}
86
86
}
87
87
88
- private record CallLocationsByMethod (Map <String , ConcurrentLinkedQueue <String >> callLocationsByMethod ) {
88
+ public record CallLocationsByMethod (Map <String , ConcurrentLinkedQueue <String >> callLocationsByMethod ) {
89
89
CallLocationsByMethod () {
90
90
this (new ConcurrentSkipListMap <>());
91
91
}
@@ -113,6 +113,7 @@ public ConcurrentLinkedQueue<String> getMethodCallLocations(String methodName) {
113
113
private static final String OUTPUT_DIR_NAME = "dynamic-access" ;
114
114
private static final String TRACK_NONE = "none" ;
115
115
private static final String TO_CONSOLE = "to-console" ;
116
+ private static final String NO_DUMP = "no-dump" ;
116
117
117
118
private UnmodifiableEconomicSet <String > sourceEntries ; // Class path entries and module or
118
119
// package names
@@ -122,6 +123,7 @@ public ConcurrentLinkedQueue<String> getMethodCallLocations(String methodName) {
122
123
private final OptionValues hostedOptionValues = HostedOptionValues .singleton ();
123
124
124
125
private boolean printToConsole ;
126
+ private boolean dumpJsonFiles = true ;
125
127
126
128
public DynamicAccessDetectionFeature () {
127
129
callsBySourceEntry = new ConcurrentSkipListMap <>();
@@ -169,7 +171,7 @@ private void printReportForEntry(String entry) {
169
171
}
170
172
}
171
173
172
- public static Path getOrCreateDirectory (Path directory ) throws IOException {
174
+ private static Path getOrCreateDirectory (Path directory ) throws IOException {
173
175
if (Files .exists (directory )) {
174
176
if (!Files .isDirectory (directory )) {
175
177
throw new NoSuchFileException (directory .toString (), null ,
@@ -225,7 +227,9 @@ private static String toMethodJson(DynamicAccessDetectionPhase.DynamicAccessKind
225
227
public void reportDynamicAccess () {
226
228
for (String entry : sourceEntries ) {
227
229
if (callsBySourceEntry .containsKey (entry )) {
228
- dumpReportForEntry (entry );
230
+ if (dumpJsonFiles ) {
231
+ dumpReportForEntry (entry );
232
+ }
229
233
if (printToConsole ) {
230
234
printReportForEntry (entry );
231
235
}
@@ -299,10 +303,13 @@ public void afterRegistration(AfterRegistrationAccess access) {
299
303
300
304
AccumulatingLocatableMultiOptionValue .Strings options = SubstrateOptions .TrackDynamicAccess .getValue ();
301
305
for (String optionValue : options .values ()) {
302
- if (optionValue .equals (TO_CONSOLE )) {
303
- printToConsole = true ;
304
- } else if (optionValue .equals (TRACK_NONE )) {
305
- printToConsole = false ;
306
+ switch (optionValue ) {
307
+ case TO_CONSOLE -> printToConsole = true ;
308
+ case NO_DUMP -> dumpJsonFiles = false ;
309
+ case TRACK_NONE -> {
310
+ printToConsole = false ;
311
+ dumpJsonFiles = true ;
312
+ }
306
313
}
307
314
}
308
315
@@ -324,8 +331,8 @@ public boolean isInConfiguration(IsInConfigurationAccess access) {
324
331
}
325
332
326
333
private static String dynamicAccessPossibleOptions () {
327
- return String .format ("[%s, %s, %s, %s]" ,
328
- TRACK_ALL , TRACK_NONE , TO_CONSOLE , IncludeOptionsSupport .possibleExtendedOptions ());
334
+ return String .format ("[%s, %s, %s, %s, %s ]" ,
335
+ TRACK_ALL , TRACK_NONE , TO_CONSOLE , NO_DUMP , IncludeOptionsSupport .possibleExtendedOptions ());
329
336
}
330
337
331
338
public static void parseDynamicAccessOptions (EconomicMap <OptionKey <?>, Object > hostedValues , NativeImageClassLoaderSupport classLoaderSupport ) {
@@ -340,8 +347,8 @@ public static void parseDynamicAccessOptions(EconomicMap<OptionKey<?>, Object> h
340
347
switch (option ) {
341
348
case TRACK_ALL -> classLoaderSupport .setTrackAllDynamicAccess (valueWithOrigin );
342
349
case TRACK_NONE -> classLoaderSupport .clearDynamicAccessSelectors ();
343
- case TO_CONSOLE -> {
344
- // This option is parsed later in the afterRegistration hook
350
+ case TO_CONSOLE , NO_DUMP -> {
351
+ // These options are parsed later in the afterRegistration hook
345
352
}
346
353
default -> parseIncludeSelector (optionArgument , valueWithOrigin , classLoaderSupport .getDynamicAccessSelectors (), IncludeOptionsSupport .ExtendedOption .parse (option ),
347
354
dynamicAccessPossibleOptions ());
0 commit comments