3838import java .util .function .BiConsumer ;
3939import java .util .function .Consumer ;
4040
41- import com .oracle .graal .pointsto .util .AtomicUtils ;
4241import org .graalvm .nativeimage .hosted .Feature .DuringAnalysisAccess ;
4342
4443import com .oracle .graal .pointsto .BigBang ;
4746import com .oracle .graal .pointsto .reports .ReportUtils ;
4847import com .oracle .graal .pointsto .util .AnalysisError ;
4948import com .oracle .graal .pointsto .util .AnalysisFuture ;
49+ import com .oracle .graal .pointsto .util .AtomicUtils ;
5050import com .oracle .graal .pointsto .util .ConcurrentLightHashSet ;
5151
5252import jdk .graal .compiler .debug .GraalError ;
@@ -309,8 +309,7 @@ private void build() {
309309 while (!reasonStack .isEmpty ()) {
310310 boolean expanded ;
311311 Object top = reasonStack .peekLast ();
312- if (top instanceof CompoundReason ) {
313- CompoundReason compoundReason = (CompoundReason ) top ;
312+ if (top instanceof CompoundReason compoundReason ) {
314313 if (compoundReason .isFirst ()) {
315314 compoundReason .storeCurrentIndent (indent );
316315 }
@@ -378,23 +377,20 @@ private boolean processReason(Object current, String prefix) {
378377 if (current instanceof String ) {
379378 reasonStr = "str: " + current ;
380379
381- } else if (current instanceof AnalysisMethod ) {
382- AnalysisMethod method = (AnalysisMethod ) current ;
383- reasonStr = "at " + method .format ("%f method %H.%n(%p)" ) + ", " + methodReasonStr (method );
384- expanded = methodReason ((AnalysisMethod ) current );
380+ } else if (current instanceof AnalysisMethod method ) {
381+ reasonStr = "at " + method .format ("%f method %H.%n(%p)" ) + " " + methodReasonStr (method );
382+ expanded = methodReason (method );
385383
386- } else if (current instanceof AnalysisField ) {
387- AnalysisField field = (AnalysisField ) current ;
384+ } else if (current instanceof AnalysisField field ) {
388385 reasonStr = "field " + field .format ("%H.%n" ) + " " + fieldReasonStr (field );
389386 expanded = fieldReason (field );
390387
391- } else if (current instanceof AnalysisType ) {
392- AnalysisType type = (AnalysisType ) current ;
393- reasonStr = "type " + (type ).toJavaName () + " " + typeReasonStr (type );
388+ } else if (current instanceof AnalysisType type ) {
389+ reasonStr = "type " + type .toJavaName () + " " + typeReasonStr (type );
394390 expanded = typeReason (type );
395391
396- } else if (current instanceof ResolvedJavaMethod ) {
397- reasonStr = (( ResolvedJavaMethod ) current ) .format ("%f method %H.%n" );
392+ } else if (current instanceof ResolvedJavaMethod method ) {
393+ reasonStr = method .format ("%f method %H.%n" );
398394
399395 } else if (current instanceof ResolvedJavaField field ) {
400396 /*
@@ -408,26 +404,23 @@ private boolean processReason(Object current, String prefix) {
408404 if (analysisField != null ) {
409405 return processReason (analysisField , prefix );
410406 } else {
411- reasonStr = "field " + (( ResolvedJavaField ) current ) .format ("%H.%n" );
407+ reasonStr = "field " + field .format ("%H.%n" );
412408 }
413409
414410 } else if (current instanceof ResolvedJavaType ) {
415411 reasonStr = "type " + ((ResolvedJavaType ) current ).getName ();
416412
417- } else if (current instanceof BytecodePosition ) {
418- BytecodePosition position = (BytecodePosition ) current ;
413+ } else if (current instanceof BytecodePosition position ) {
419414 ResolvedJavaMethod method = position .getMethod ();
420415 reasonStr = "at " + method .format ("%f" ) + " method " + method .asStackTraceElement (position .getBCI ()) + ", " + methodReasonStr (method );
421416 expanded = methodReason (position .getMethod ());
422417
423- } else if (current instanceof MethodParsing ) {
424- MethodParsing methodParsing = (MethodParsing ) current ;
418+ } else if (current instanceof MethodParsing methodParsing ) {
425419 AnalysisMethod method = methodParsing .getMethod ();
426420 reasonStr = "at " + method .format ("%f method %H.%n(%p)" ) + ", " + methodReasonStr (method );
427421 expanded = methodReason (methodParsing .getMethod ());
428422
429- } else if (current instanceof ObjectScanner .ScanReason ) {
430- ObjectScanner .ScanReason scanReason = (ObjectScanner .ScanReason ) current ;
423+ } else if (current instanceof ObjectScanner .ScanReason scanReason ) {
431424 reasonStr = scanReason .toString (bb );
432425 expanded = maybeExpandReasonStack (scanReason .getPrevious ());
433426
@@ -447,6 +440,8 @@ private void print(String prefix, String reasonStr) {
447440 private boolean typeReason (AnalysisType type ) {
448441 if (type .isInstantiated ()) {
449442 return maybeExpandReasonStack (type .getInstantiatedReason ());
443+ } else if (type .isAnySubtypeInstantiated ()) {
444+ return maybeExpandReasonStack (type .getAnyInstantiatedSubtype ());
450445 } else {
451446 return maybeExpandReasonStack (type .getReachableReason ());
452447 }
@@ -455,6 +450,8 @@ private boolean typeReason(AnalysisType type) {
455450 private static String typeReasonStr (AnalysisType type ) {
456451 if (type .isInstantiated ()) {
457452 return "is marked as instantiated" ;
453+ } else if (type .isAnySubtypeInstantiated ()) {
454+ return "has a subtype marked as instantiated" ;
458455 }
459456 return "is reachable" ;
460457 }
@@ -489,8 +486,7 @@ private static String fieldReasonStr(AnalysisField field) {
489486 }
490487
491488 private boolean methodReason (ResolvedJavaMethod method ) {
492- if (method instanceof AnalysisMethod ) {
493- AnalysisMethod aMethod = (AnalysisMethod ) method ;
489+ if (method instanceof AnalysisMethod aMethod ) {
494490 if (aMethod .isSimplyImplementationInvoked ()) {
495491 if (aMethod .isStatic ()) {
496492 return maybeExpandReasonStack (aMethod .getImplementationInvokedReason ());
@@ -522,29 +518,28 @@ private boolean maybeExpandReasonStack(Object reason) {
522518 }
523519
524520 private static String methodReasonStr (ResolvedJavaMethod method ) {
525- if (method instanceof AnalysisMethod ) {
526- AnalysisMethod aMethod = (AnalysisMethod ) method ;
521+ if (method instanceof AnalysisMethod aMethod ) {
527522 if (aMethod .isSimplyImplementationInvoked ()) {
528523 if (aMethod .isStatic ()) {
529- return "implementation invoked" ;
524+ return "is implementation invoked" ;
530525 } else {
531526 /* For virtual methods we follow back type reachability. */
532527 AnalysisType declaringClass = aMethod .getDeclaringClass ();
533528 assert declaringClass .isInstantiated () || declaringClass .isAbstract () ||
534529 (declaringClass .isInterface () && aMethod .isDefault ()) || declaringClass .isReachable () : declaringClass + " is not reachable" ;
535- return "implementation invoked" ;
530+ return "is implementation invoked" ;
536531 }
537532 } else if (aMethod .isInlined ()) {
538533 if (aMethod .isStatic ()) {
539- return "inlined" ;
534+ return "is inlined" ;
540535 } else {
541536 AnalysisType declaringClass = aMethod .getDeclaringClass ();
542537 assert declaringClass .isInstantiated () || declaringClass .isAbstract () ||
543538 (declaringClass .isInterface () && aMethod .isDefault ()) || declaringClass .isReachable () : declaringClass + " is not reachable" ;
544- return "inlined" ;
539+ return "is inlined" ;
545540 }
546541 } else if (aMethod .isIntrinsicMethod ()) {
547- return "intrinsified" ;
542+ return "is intrinsified" ;
548543 }
549544 }
550545 return "<no available reason>" ;
0 commit comments