Closed khatchad closed 6 years ago
@saledouble This one seems very much related to #67 but is still failing it seems. Can you have a look at this one next? Thanks so much.
The current exception:
!ENTRY org.eclipse.jdt.ui 4 10001 2017-11-05 22:08:39.730
!MESSAGE Internal Error
!STACK 0
java.lang.IllegalArgumentException: Can't find instance key for: Stream [streamCreation=Arrays.stream(new Object[1]), enclosingMethodDeclaration=m, possibleExecutionModes=[SEQUENTIAL], possibleOrderings=[null], status=0] using tracked instances: [SITE_IN_NODE{< Primordial, Ljava/util/stream/StreamSupport, stream(Ljava/util/Spliterator;Z)Ljava/util/stream/Stream; >:NEW <Primordial,Ljava/util/stream/ReferencePipeline$Head>@5 in CallStringContext: [ java.util.Arrays.stream([Ljava/lang/Object;II)Ljava/util/stream/Stream;@7 java.util.Arrays.stream([Ljava/lang/Object;)Ljava/util/stream/Stream;@4 ]}]
at edu.cuny.hunter.streamrefactoring.core.analysis.Stream.lambda$5(Stream.java:640)
at java.util.Optional.orElseThrow(Optional.java:290)
at edu.cuny.hunter.streamrefactoring.core.analysis.Stream.getInstanceKey(Stream.java:640)
at edu.cuny.hunter.streamrefactoring.core.analysis.StreamStateMachine.start(StreamStateMachine.java:474)
at edu.cuny.hunter.streamrefactoring.core.analysis.Stream.<init>(Stream.java:206)
at edu.cuny.hunter.streamrefactoring.core.analysis.StreamAnalysisVisitor.visit(StreamAnalysisVisitor.java:51)
at org.eclipse.jdt.core.dom.MethodInvocation.accept0(MethodInvocation.java:231)
at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2711)
at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:2759)
at org.eclipse.jdt.core.dom.ExpressionStatement.accept0(ExpressionStatement.java:145)
at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2711)
at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2782)
at org.eclipse.jdt.core.dom.Block.accept0(Block.java:137)
at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2711)
at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:2759)
at org.eclipse.jdt.core.dom.MethodDeclaration.accept0(MethodDeclaration.java:635)
at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2711)
at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2782)
at org.eclipse.jdt.core.dom.TypeDeclaration.accept0(TypeDeclaration.java:470)
at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2711)
at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2782)
at org.eclipse.jdt.core.dom.CompilationUnit.accept0(CompilationUnit.java:212)
at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2711)
at edu.cuny.hunter.streamrefactoring.core.refactorings.ConvertToParallelStreamRefactoringProcessor.checkFinalConditions(ConvertToParallelStreamRefactoringProcessor.java:191)
at org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring.checkFinalConditions(ProcessorBasedRefactoring.java:222)
at org.eclipse.ltk.core.refactoring.Refactoring.checkAllConditions(Refactoring.java:162)
at edu.cuny.hunter.streamrefactoring.eval.handlers.EvaluateConvertToParallelStreamRefactoringHandler.lambda$0(EvaluateConvertToParallelStreamRefactoringHandler.java:145)
at org.eclipse.core.runtime.jobs.Job$1.run(Job.java:161)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:56)
The exception is thrown by:
https://github.com/ponder-lab/Java-8-Stream-Refactoring/blob/0962c05e807a47c676d096e9ebe207df8c1f8f9e/edu.cuny.hunter.streamrefactoring.core/src/edu/cuny/hunter/streamrefactoring/core/analysis/Stream.java#L634-L642
The problem is from the method instanceKeyCorrespondsWithInstantiationInstruction
:
https://github.com/ponder-lab/Java-8-Stream-Refactoring/blob/0962c05e807a47c676d096e9ebe207df8c1f8f9e/edu.cuny.hunter.streamrefactoring.core/src/edu/cuny/hunter/streamrefactoring/core/safe/Util.java#L58
The value of callSiteReference:
invokestatic < Primordial, Ljava/util/stream/StreamSupport, stream(Ljava/util/Spliterator;Z)Ljava/util/stream/Stream; >@7
invokestatic < Primordial, Ljava/util/Arrays, stream([Ljava/lang/Object;II)Ljava/util/stream/Stream; >@4
The value of instruction.getCallSite():
invokestatic < Application, Ljava/util/Arrays, stream([Ljava/lang/Object;)Ljava/util/stream/Stream; >@4
Ah, I mentioned this issue in #67
I don't think that node corresponds to the call in question per say. clinit stands for "class init" I believe.
This seems related to #98. Perhaps the reason that there's a null PA is because the instance key isn't found.
Actually, for the Arrays.stream()
test case, I am seeing the following:
WARNING: Encountered probable unhandled case while processing: Arrays.stream(new Object[1])
edu.cuny.hunter.streamrefactoring.core.analysis.InstanceKeyNotFoundException: ...
It continues:
Can't find instance key for: Arrays.stream(new Object[1]) using tracked instances: [SITE_IN_NODE{< Primordial, Ljava/util/stream/StreamSupport, stream(Ljava/util/Spliterator;Z)Ljava/util/stream/Stream; >:NEW <Primordial,Ljava/util/stream/ReferencePipeline$Head>@5 in CallStringContext: [ java.util.Arrays.stream([Ljava/lang/Object;II)Ljava/util/stream/Stream;@7 java.util.Arrays.stream([Ljava/lang/Object;)Ljava/util/stream/Stream;@4 ]}]
And the stack trace:
at edu.cuny.hunter.streamrefactoring.core.analysis.Stream.lambda$5(Stream.java:675)
at java.util.Optional.orElseThrow(Optional.java:290)
at edu.cuny.hunter.streamrefactoring.core.analysis.Stream.getInstanceKey(Stream.java:675)
at edu.cuny.hunter.streamrefactoring.core.analysis.StreamStateMachine.start(StreamStateMachine.java:474)
at edu.cuny.hunter.streamrefactoring.core.analysis.Stream.<init>(Stream.java:214)
at edu.cuny.hunter.streamrefactoring.core.analysis.StreamAnalysisVisitor.visit(StreamAnalysisVisitor.java:51)
at org.eclipse.jdt.core.dom.MethodInvocation.accept0(MethodInvocation.java:231)
at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2796)
at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:2844)
at org.eclipse.jdt.core.dom.ExpressionStatement.accept0(ExpressionStatement.java:145)
at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2796)
at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2867)
at org.eclipse.jdt.core.dom.Block.accept0(Block.java:137)
at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2796)
at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:2844)
at org.eclipse.jdt.core.dom.MethodDeclaration.accept0(MethodDeclaration.java:635)
at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2796)
at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2867)
at org.eclipse.jdt.core.dom.TypeDeclaration.accept0(TypeDeclaration.java:470)
at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2796)
at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2867)
at org.eclipse.jdt.core.dom.CompilationUnit.accept0(CompilationUnit.java:260)
at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2796)
at edu.cuny.hunter.streamrefactoring.ui.tests.ConvertStreamToParallelRefactoringTest.helper(ConvertStreamToParallelRefactoringTest.java:258)
at edu.cuny.hunter.streamrefactoring.ui.tests.ConvertStreamToParallelRefactoringTest.testArraysStream(ConvertStreamToParallelRefactoringTest.java:359)
...
So it looks like the instance key for Arrays.stream(new Object[1])
(whatever that is?) doesn't match the instance key containing stream(Ljava/util/Spliterator;Z)Ljava/util/stream/Stream;
.
This seems related to #98. Perhaps the reason that there's a null PA is because the instance key isn't foun
Yes, it is related to #98.
The current type of classloader for Arrays is Application (the right one should be Primordial?), which is gotten from method buildCallGraph().
It is clear that the problem is from entry point.
If the wrong classloader is being used for Arrays
, that doesn't sound related to #98 at all. Arrays
is a library method, so it should not be in Application
.
I am actually not convinced that it's related to #98 by looking at the test case in question: https://github.com/ponder-lab/Java-8-Stream-Refactoring/blob/312334fe6047b09db40e5d551c7aff8861fe46eb/edu.cuny.hunter.streamrefactoring.tests/resources/ConvertStreamToParallel/testArraysStream/in/A.java#L5-L9
In fact, in this example, there is only one method and it happens to be the "declaring" method, i.e., the method that instantiates the stream. As such, given the current implementation, it will be set as the entry point.
the array is instantiated in the same method
It seems that the array is not instantiated. The test case just calls the static method of class Arrays. Did you mean new Object[1]
in the test case?
It seems that the array is not instantiated.
What makes you feel that way?
Did you mean
new Object[1]
in the test case?
Indeed, that is an array instantiation.
I would think that these two call site references should match:
invokestatic < Primordial, Ljava/util/Arrays, stream([Ljava/lang/Object;II)Ljava/util/stream/Stream; >@4
invokestatic < Application, Ljava/util/Arrays, stream([Ljava/lang/Object;)Ljava/util/stream/Stream; >@4
I wonder what the II means.
Having trouble reproducing this.
I think a problem here is that N=2 is not enough for this case.
Related to #176.
Ran into a snag here. There's some code in WALA that won't use the given length under certain conditions, so we can't increase the call string length arbitrarily. Looking into why those conditions are there.
OK, it looks like WALA is trying to build a call string with the lenght we give it but it is an incremental process. It looks like in one our test cases, it just never gets up to this length. Not sure why. The result is that we don't get up to the client code.
I wonder how this test was passing previously ...
Looks like ctors return void and we are asking where ctors that construct streams implement base stream by examining their return type (void), which, of course, is false. If it's a ctor, then we need to use the declaring class.