@@ -188,27 +188,7 @@ public Stream(MethodInvocation streamCreation) throws ClassHierarchyException, I
188
188
this .orderingInference = new OrderingInference (this .getClassHierarchy ());
189
189
190
190
this .inferInitialExecution ();
191
-
192
- try {
193
- this .inferInitialOrdering ();
194
- } catch (InconsistentPossibleOrderingException e ) {
195
- LOGGER .log (Level .WARNING , "Exception caught while processing: " + streamCreation , e );
196
- addStatusEntry (PreconditionFailure .INCONSISTENT_POSSIBLE_STREAM_SOURCE_ORDERING ,
197
- "Stream: " + streamCreation + " has inconsistent possible source orderings." );
198
- } catch (NoniterableException e ) {
199
- LOGGER .log (Level .WARNING , "Exception caught while processing: " + streamCreation , e );
200
- addStatusEntry (PreconditionFailure .NON_ITERABLE_POSSIBLE_STREAM_SOURCE ,
201
- "Stream: " + streamCreation + " has a non-iterable possible source." );
202
- } catch (NoninstantiableException e ) {
203
- LOGGER .log (Level .WARNING , "Exception caught while processing: " + streamCreation , e );
204
- addStatusEntry (PreconditionFailure .NON_INSTANTIABLE_POSSIBLE_STREAM_SOURCE , "Stream: " + streamCreation
205
- + " has a non-instantiable possible source with type: " + e .getSourceType () + "." );
206
- } catch (CannotExtractSpliteratorException e ) {
207
- LOGGER .log (Level .WARNING , "Exception caught while processing: " + streamCreation , e );
208
- addStatusEntry (PreconditionFailure .NON_DETERMINABLE_STREAM_SOURCE_ORDERING ,
209
- "Cannot extract spliterator from type: " + e .getFromType () + " for stream: " + streamCreation
210
- + "." );
211
- }
191
+ this .inferInitialOrdering ();
212
192
213
193
try {
214
194
// start the state machine.
@@ -468,7 +448,7 @@ public TypeDeclaration getEnclosingTypeDeclaration() {
468
448
return enclosingTypeDeclaration ;
469
449
}
470
450
471
- private TypeReference getEnclosingTypeReference () {
451
+ public TypeReference getEnclosingTypeReference () {
472
452
JDTIdentityMapper mapper = getJDTIdentifyMapper (getEnclosingTypeDeclaration ());
473
453
TypeReference ref = mapper .getTypeRef (getEnclosingTypeDeclaration ().resolveBinding ());
474
454
@@ -572,10 +552,8 @@ private void inferInitialExecution() {
572
552
this .setInitialExecutionMode (ExecutionMode .SEQUENTIAL );
573
553
}
574
554
575
- private void inferInitialOrdering ()
576
- throws IOException , CoreException , ClassHierarchyException , InvalidClassFileException ,
577
- InconsistentPossibleOrderingException , NoniterableException , NoninstantiableException ,
578
- CannotExtractSpliteratorException , CallGraphBuilderCancelException , CancelException {
555
+ private void inferInitialOrdering () throws IOException , CoreException , ClassHierarchyException ,
556
+ InvalidClassFileException , CallGraphBuilderCancelException , CancelException {
579
557
ITypeBinding expressionTypeBinding = this .getCreation ().getExpression ().resolveTypeBinding ();
580
558
String expressionTypeQualifiedName = expressionTypeBinding .getErasure ().getQualifiedName ();
581
559
IMethodBinding calledMethodBinding = this .getCreation ().resolveMethodBinding ();
@@ -604,19 +582,42 @@ private void inferInitialOrdering()
604
582
node = this .getEnclosingMethodNode ();
605
583
} catch (NoEnclosingMethodNodeFoundException e ) {
606
584
LOGGER .log (Level .WARNING , "Can't find enclosing method node for " + this .getCreation ()
607
- + ". Falling back to " + Ordering .ORDERED , e );
585
+ + ". Falling back to: " + Ordering .ORDERED + "." , e );
608
586
this .setInitialOrdering (Ordering .ORDERED );
609
587
return ;
610
588
}
611
589
612
- Collection <TypeAbstraction > possibleTypes = getPossibleTypesInterprocedurally (node , valueNumber ,
613
- this .getAnalysisEngine ().getHeapGraph ().getHeapModel (),
614
- this .getAnalysisEngine ().getPointerAnalysis (), this , LOGGER );
590
+ Collection <TypeAbstraction > possibleTypes = null ;
591
+ IMethod calledMethod = null ;
592
+ Ordering ordering = null ;
593
+ try {
594
+ possibleTypes = getPossibleTypesInterprocedurally (node , valueNumber ,
595
+ this .getAnalysisEngine ().getHeapGraph ().getHeapModel (),
596
+ this .getAnalysisEngine ().getPointerAnalysis (), this , LOGGER );
615
597
616
- // Possible types: check each one.
617
- IMethod calledMethod = (IMethod ) calledMethodBinding .getJavaElement ();
598
+ // Possible types: check each one.
599
+ calledMethod = (IMethod ) calledMethodBinding .getJavaElement ();
618
600
619
- Ordering ordering = this .getOrderingInference ().inferOrdering (possibleTypes , calledMethod );
601
+ ordering = this .getOrderingInference ().inferOrdering (possibleTypes , calledMethod );
602
+ } catch (NoniterableException e ) {
603
+ LOGGER .log (Level .WARNING , "Stream: " + this .getCreation ()
604
+ + " has a non-iterable possible source. Falling back to: " + Ordering .ORDERED + "." , e );
605
+ ordering = Ordering .ORDERED ;
606
+ } catch (NoninstantiableException e ) {
607
+ LOGGER .log (Level .WARNING ,
608
+ "Stream: " + this .getCreation () + " has a non-instantiable possible source with type: "
609
+ + e .getSourceType () + ". Falling back to: " + Ordering .ORDERED + "." ,
610
+ e );
611
+ ordering = Ordering .ORDERED ;
612
+ } catch (CannotExtractSpliteratorException e ) {
613
+ LOGGER .log (Level .WARNING , "Cannot extract spliterator from type: " + e .getFromType () + " for stream: "
614
+ + this .getCreation () + ". Falling back to: " + Ordering .ORDERED + "." , e );
615
+ ordering = Ordering .ORDERED ;
616
+ } catch (InconsistentPossibleOrderingException e ) {
617
+ LOGGER .log (Level .WARNING , "Stream: " + this .getCreation ()
618
+ + " has inconsistent possible source orderings. Falling back to: " + Ordering .ORDERED + "." , e );
619
+ ordering = Ordering .ORDERED ;
620
+ }
620
621
621
622
if (ordering == null ) {
622
623
ordering = Ordering .ORDERED ;
@@ -656,6 +657,7 @@ protected CGNode getEnclosingMethodNode() throws IOException, CoreException, NoE
656
657
* in the {@link CallGraph} are {@link FakeRootMethod}s.
657
658
* @apiNote The may be an issue here related to #106.
658
659
*/
660
+ @ SuppressWarnings ("unused" )
659
661
private static boolean allFake (Set <CGNode > nodes , CallGraph callGraph ) {
660
662
// for each node.
661
663
for (CGNode cgNode : nodes ) {
@@ -787,7 +789,13 @@ protected void buildCallGraph() throws IOException, CoreException, CallGraphBuil
787
789
// Doesn't make sense. Maybe we need to collect all enclosing
788
790
// methods
789
791
// and use those as entry points.
790
- getAnalysisEngine ().buildSafeCallGraph (options );
792
+ try {
793
+ getAnalysisEngine ().buildSafeCallGraph (options );
794
+ } catch (IllegalStateException e ) {
795
+ LOGGER .log (Level .SEVERE , e , () -> "Exception encountered while building call graph for Stream: " + this
796
+ + " in project: " + this .getCreationJavaProject ());
797
+ throw e ;
798
+ }
791
799
// TODO: Can I slice the graph so that only nodes relevant to the
792
800
// instance in question are present?
793
801
0 commit comments