ponder-lab / Optimize-Java-8-Streams-Refactoring

Refactorings for optimizing Java 8 stream client code for greater parallelism and efficiency.
http://cuny.is/streams
Eclipse Public License 1.0
8 stars 7 forks source link

Fix testing infrastructure so that bytecode is available to WALA #24

Closed khatchad closed 7 years ago

khatchad commented 7 years ago

Was originally related to https://github.com/wala/WALA/issues/131 but that doesn't seem to be the case anymore. The root issue for the infrastructure problem is that the Eclipse Refactoring tests work on source code but our plug-in works on both source code and bytecode. So, we need both the source code and the bytecode in the test workspace for the tests to operate properly. Currently, only the source code is there.

khatchad commented 7 years ago

@saledouble I think that this one is important because it seems like we are having too many regressions. It's especially important to have this working before we start trying to improve performance. It may also be good for learning because it deals quite a bit with the integration of the Eclipse analysis framework and the WALA analysis framework, which is related to the last bug we just worked on. Thanks, and please let me know if you have any questions.

khatchad commented 7 years ago

More information on how WALA deals with classpaths can be found here.

khatchad commented 7 years ago

May want to have a look at (or change) WALA/com.ibm.wala.ide/src/com/ibm/wala/ide/util/EclipseProjectPath.java. May also want to subclass this class.

yiming-tang-cs commented 7 years ago

Hi, I may find the location which causes the error that we discussed in the meeting.

I have mentioned that I got a new exception when I run ConvertStreamToParallelRefactroingTest.testHashSetParallelStream as an Eclipse JUnit Plugin Test:

java.lang.IllegalArgumentException: method is null
    at com.ibm.wala.ipa.callgraph.AnalysisCache.getIR(AnalysisCache.java:72)
    at com.ibm.wala.ipa.callgraph.AnalysisCache.getIR(AnalysisCache.java:79)
    at edu.cuny.hunter.streamrefactoring.core.analysis.Stream.getEnclosingMethodIR(Stream.java:420)
    at edu.cuny.hunter.streamrefactoring.core.analysis.Stream.getInstructionForCreation(Stream.java:493)
    at edu.cuny.hunter.streamrefactoring.core.analysis.Stream.getUseValueNumberForCreation(Stream.java:540)
    at edu.cuny.hunter.streamrefactoring.core.analysis.Stream.inferInitialOrdering(Stream.java:569)
    at edu.cuny.hunter.streamrefactoring.core.analysis.Stream.<init>(Stream.java:183)
    at edu.cuny.hunter.streamrefactoring.core.analysis.StreamAnalysisVisitor.visit(StreamAnalysisVisitor.java:49)
    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.VariableDeclarationFragment.accept0(VariableDeclarationFragment.java:263)
    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.VariableDeclarationStatement.accept0(VariableDeclarationStatement.java:267)
    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.ui.tests.ConvertStreamToParallelRefactoringTest.helper(ConvertStreamToParallelRefactoringTest.java:177)
    at edu.cuny.hunter.streamrefactoring.ui.tests.ConvertStreamToParallelRefactoringTest.testHashSetParallelStream(ConvertStreamToParallelRefactoringTest.java:142)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at junit.framework.TestCase.runTest(TestCase.java:176)
    at junit.framework.TestCase.runBare(TestCase.java:141)
    at junit.framework.TestResult$1.protect(TestResult.java:122)
    at junit.framework.TestResult.runProtected(TestResult.java:142)
    at junit.framework.TestResult.run(TestResult.java:125)
    at junit.framework.TestCase.run(TestCase.java:129)
    at junit.extensions.TestDecorator.basicRun(TestDecorator.java:23)
    at junit.extensions.TestSetup$1.protect(TestSetup.java:23)
    at junit.framework.TestResult.runProtected(TestResult.java:142)
    at junit.extensions.TestSetup.run(TestSetup.java:27)
    at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:121)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
    at org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunner.main(RemotePluginTestRunner.java:66)
    at org.eclipse.pde.internal.junit.runtime.PlatformUITestHarness.lambda$0(PlatformUITestHarness.java:43)
    at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:37)
    at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:182)
    at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4033)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3700)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1155)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1044)
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:153)
    at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:680)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:594)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:148)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:151)
    at org.eclipse.pde.internal.junit.runtime.NonUIThreadTestApplication.runApp(NonUIThreadTestApplication.java:52)
    at org.eclipse.pde.internal.junit.runtime.UITestApplication.runApp(UITestApplication.java:43)
    at org.eclipse.pde.internal.junit.runtime.NonUIThreadTestApplication.start(NonUIThreadTestApplication.java:46)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:653)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:590)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1499)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1472)

However, if I test the code in a normal way (a user environment), there is no this exception.

When the code is run in different ways, I compared variables and I found the values of "map", which is in ClassHierarchy.java, are different. Hence, the project has different values for "Node n" in line 878.

  1. When I run code as an Eclipse Plug-in Test

map.get(a) (in the line 878) always returns null, that is why cls (in the line 838) is null. Then, lookupClass(TypeReference a) returns cls which is null.

image

  1. When I run code in a normal way

map.get(a) (in the line 878) returns a node (content is <Application,Lq/Test>), when the content of variable "a" is <Application,Lq/Test>, that is why lookupClass(TypeReference a) doesn't return a null.

image

I will add more details today and try to find a way to fix this one.

khatchad commented 7 years ago

Is the test jar being loaded?

khatchad commented 7 years ago

If it is loading the test jar, expand it to verify that the test class is there. If it's not loading the jar, then that may be the problem. Thanks!

yiming-tang-cs commented 7 years ago

Is the test jar being loaded?

Yes. I am trying to explain in a clear way, so I need one or two hours to write.

yiming-tang-cs commented 7 years ago

Hi, I have mentioned the error may come from the different values for "map" when the project is run in different ways. Actually, this is not the final reason. The final reason is that the project has different Extension when it is tested in different ways. The following table may be helpful.

variables Java File line JUnit Plug-in Test Normal Test comment
M ClassLoaderImpl.java 121 JarFileModule:/Applications/Eclipse.app/Contents/Eclipse/plugins/org.eclipse.jdt.ui.tests_3.13.0.v20170506-1842/testresources/rtstubs18.jar JarFileModule:/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/jre/lib/resources.jar ... M is Extention.
model ClassLoaderImpl.java 478 image image models are different
it ClassLoaderImpl.java 487 image image Iterator it = modules.iterator();
map ClassHierarchy. java 184 {} {} map is initialized uniformly, but addAllClasses(icl, progressMonitor) (line 244) operates map which results in different values of map. More details are from line 283 and line 324.
map (after running constructor) ClassHierarchy.java line 266 image image
n ClassHierarchy.java 878 always null become <Application,Lq/Test> eventually

According to the table above, there are two locations that can result in the different testing results (first two rows). Because the project loads different test jars (Extension), the init method (ClassLoaderImpl.java line 478) is run in different ways.

=> method makeNewClassLoader() (ClassLoaderFactoryImpl.java line 69) returns different cl => icl (ClassHierarchy.java line 231) has different values => addAllClasses(icl, progressMonitor); (ClassHierarchy.java line 244) different icl => map is different (ClassHierarchy.java line 324) => according to what I mentioned in this morning, the project has different results while testing in different ways.

Therefore, different test jars can cause different testing results.

yiming-tang-cs commented 7 years ago

If it is loading the test jar, expand it to verify that the test class is there. If it's not loading the jar, then that may be the problem. Thanks!

Test class is there: image

yiming-tang-cs commented 7 years ago
public void testHashSetParallelStream() throws Exception {
        helper("new HashSet<>().parallelStream()", ExecutionMode.PARALLEL, Ordering.UNORDERED);
    }

The code above can generate a test class in the background:

Class A{
    void m(){
        new HashSet<>().parallelStream();
     }
}
khatchad commented 7 years ago

The final reason is that the project has different Extension when it is tested in different ways.

Interesting. What are the differences exactly?

khatchad commented 7 years ago

Because the project loads different test jars (Extension), the init method (ClassLoaderImpl.java line 478) is run in different ways.

Also, what do you mean by different test jars?

khatchad commented 7 years ago

I believe that the problem is not with rtstubs18.jar. This is meant to be a Java "library" for Eclipse plug-in testing.

khatchad commented 7 years ago

If it is loading the test jar, expand it to verify that the test class is there. If it's not loading the jar, then that may be the problem. Thanks!

Test class is there:

Sorry, I meant inside the test jar file. jar xvf Test43348392.jar (something like that)

khatchad commented 7 years ago

Specially, you should find p/A.class in that jar.

khatchad commented 7 years ago

M is Extention.

What do you mean by this comment?

khatchad commented 7 years ago

If M is supposed to be the method being analyzed, it should not be an extension I believe. It should be under application.

khatchad commented 7 years ago

Actually, I'd be curious about the classModuleEntries variable.

yiming-tang-cs commented 7 years ago

Interesting. What are the differences exactly?

Sorry, I mean Primordial instead of Extension.

image

When project is tested in different ways, the Extension is always empty, but Primordial is different.

yiming-tang-cs commented 7 years ago

Also, what do you mean by different test jars?

Sorry, it is my mistake. I mean different Primordial. When I run project as a plug-in Test, there is only one jar file in Primordial. However, when I run project in a user environment, there are 26 jar files.

khatchad commented 7 years ago

Also, what do you mean by different test jars?

Sorry, it is my mistake. I mean different Primordial. When I run project as a plug-in Test, there is only one jar file in Primordial. However, when I run project in a user environment, there are 26 jar files.

But, why do you feel that that is the cause of the error? When 'm' can't be found, 'm' is an application method, no?

yiming-tang-cs commented 7 years ago

If M is supposed to be the method being analyzed, it should not be an extension I believe. It should be under application.

You are right, M is not an extension, but it is one element of Primordial. image

Sorry, I meant inside the test jar file. jar xvf Test43348392.jar (something like that) Specially, you should find p/A.class in that jar.

Sorry, when you mentioned a test jar, I thought it is a Java Library for testing, so I said yes. Actually, I did not find a jar like Test43348392.jar, but I found a java project file -- TestProject1506727335365 in the workspace of junit.

image

image

Sorry, it is my mistake. I mean different Primordial. When I run project as a plug-in Test, there is only one jar file in Primordial. However, when I run project in a user environment, there are 26 jar files.

But, why do you feel that that is the cause of the error?

In the first two rows of the table above, we can see M and models have different values when the project is tested in different ways. M is a variable storing an element of Primordial and models is an ArrayList storing a full Primordial. Those two differences are the original places causing the error.

What I wrote after the table above is equal to this: different primordial => different models => different classloader => different loadedclasses => different map (this map maps the Reference of loadedclasses to the {@link Node}) => Although I test a same testing project, the reference of the test class can be found in map when the project is tested in a user environment and the reference of the test class cannot be found in map when the project is run as a Eclipse Plug-in Test (that is the reason that method cannot be found).

When 'm' can't be found, 'm' is an application method, no?

Yes, I think.

khatchad commented 7 years ago

Those two differences are the original places causing the error.

But why do you feel that way?

Although I test a same testing project, the reference of the test class can be found in map when the project is tested in a user environment and the reference of the test class cannot be found in map when the project is run as a Eclipse Plug-in Test (that is the reason that method cannot be found).

Yes, exactly. This is the problem. But what is the cause?

yiming-tang-cs commented 7 years ago

Those two differences are the original places causing the error. But why do you feel that way?

Because I debugged again and again and I found this is the first place in the project that variables have different values when the project is run in different ways.

Yes, exactly. This is the problem. But what is the cause?

The cause in your project is that the project has different primordial for testing in different ways.

image

image

Then, according to derivations above, the project returns different results when it is run in different ways.

In addition, I think the cause which is outside your project is that there is inconsistency between Java libraries for running in a normal way and rtstubs18.jar for Plug-in Test. Although project has different Java libraries when it is run in different ways, it should have gotten the same loadedclasses. However, I have no idea to test it now.

khatchad commented 7 years ago

Because I debugged again and again and I found this is the first place in the project that variables have different values when the project is run in different ways.

I feel that this difference is not relevant to the underlying problem. If you're not convinced, try looking up a library class. You should see that it succeeds.

I see that there are some exclusions in the latter screenshot. Are there any exclusions in the former?

khatchad commented 7 years ago

Let's back up a bit here. From your early comment:

map.get(a) (in the line 878) returns a node (content is <Application,Lq/Test>), when the content of variable "a" is <Application,Lq/Test>, that is why lookupClass(TypeReference a) doesn't return a null.

When running the JUnit test, what is the value of TypeReference a when the error occurs? Is it <Application,Lq/Test>? If so, is that class located in bin directory of the test project workspace?

yiming-tang-cs commented 7 years ago

When running the JUnit test, what is the value of TypeReference a when the error occurs? Is it <Application,Lq/Test>? If so, is that class located in bin directory of the test project workspace?

Yes, the value of a is <Application,Lq/Test>. Yes, it is located. The problem is that that typeReference cannot be found in map.

khatchad commented 7 years ago

@saledouble and I found out that the problem is that the Eclipse refactoring tests don't work on class files. They work instead of source files, which makes perfect sense. Eclipse only needs source code for refactoring. We, on the other hand, are using the bytecode (.class file) for analysis purposes. WALA does also only work on source code but that part of WALA is outdated. So, we use WALA's bytecode analysis.

khatchad commented 7 years ago

Here's the WALA patch we used:

 .../src/com/ibm/wala/client/AbstractAnalysisEngine.java            | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/com.ibm.wala.core/src/com/ibm/wala/client/AbstractAnalysisEngine.java b/com.ibm.wala.core/src/com/ibm/wala/client/AbstractAnalysisEngine.java
index a7d6f83eb..6f67d890c 100644
--- a/com.ibm.wala.core/src/com/ibm/wala/client/AbstractAnalysisEngine.java
+++ b/com.ibm.wala.core/src/com/ibm/wala/client/AbstractAnalysisEngine.java
@@ -181,9 +181,12 @@ public abstract class AbstractAnalysisEngine<I extends InstanceKey> implements A
    */
   public IClassHierarchy buildClassHierarchy() {
     IClassHierarchy cha = null;
-    ClassLoaderFactory factory = makeClassLoaderFactory(getScope().getExclusions());
+    AnalysisScope scope2 = getScope();
+    SetOfClasses exclusions = scope2.getExclusions();
+    System.out.println("Exclusions: " + exclusions);
+    ClassLoaderFactory factory = makeClassLoaderFactory(exclusions);
     try {
-      cha = ClassHierarchyFactory.make(getScope(), factory);
+      cha = ClassHierarchyFactory.make(scope2, factory);
     } catch (ClassHierarchyException e) {
       System.err.println("Class Hierarchy construction failed");
       System.err.println(e.toString());
khatchad commented 7 years ago

We compiled the source file by hand and it worked.

We need an automated solution. Here are some options:

  1. Have Eclipse do the compilation of the input source.
  2. Inside edu.cuny.hunter.streamrefactoring.ui.tests.ConvertStreamToParallelRefactoringTest.helper(String, ExecutionMode, Ordering), we actually compile the source using edu.cuny.hunter.streamrefactoring.ui.tests.ConvertStreamToParallelRefactoringTest.compiles(String). However, that method compiles in an unrelated temporary directory via Files.createTempDirectory(null);. Instead, we can reuse the test project directory.
khatchad commented 7 years ago

BTW, the RefactoringTest code is here.

yiming-tang-cs commented 7 years ago

It seems that Plug-in Test can work for the second testing example.

"new HashSet<>().parallelStream()"

image

image

yiming-tang-cs commented 7 years ago

If I test 7 examples, the result is not OK.

image

If I test example one by one, some of examples are OK.

  1. testArraysAsList
package p;

import java.util.Arrays;

class A {
    void m() {
        Arrays.asList().stream();
    }
}

image

  1. testHashSetParallelStream
package p;

import java.util.HashSet;
import java.util.stream.*;

class A {
    void m() {
        Stream<Object> stream = new HashSet<>().parallelStream();
    }
}

image

image

  1. testArraysStream
package p;

import java.util.Arrays;

class A {
    void m() {
        Arrays.stream(new Object[1]);
    }
}

image

  1. testBitSet
    
    package p;

import java.util.BitSet; import java.util.OptionalDouble;

class A { void m() { BitSet set = new BitSet(); OptionalDouble average = set.stream().average(); } }


![image](https://user-images.githubusercontent.com/10117031/31105348-7a344e0c-a7b1-11e7-835f-de0730467e8d.png)

![image](https://user-images.githubusercontent.com/10117031/31105344-70eff990-a7b1-11e7-8da3-80c982f481c6.png)

5. testIntermediateOperations

package p;

import java.util.BitSet; import java.util.stream.IntStream;

class A { void m() { BitSet set = new BitSet(); IntStream stream2 = set.stream(); IntStream stream3 = stream2.distinct(); stream2.average(); stream3.average(); } }

![image](https://user-images.githubusercontent.com/10117031/31105622-9ef7ccd0-a7b3-11e7-8d68-320af722b565.png)

![image](https://user-images.githubusercontent.com/10117031/31105631-a5eb89c8-a7b3-11e7-8b21-10a38c3a0f51.png)

6. testGenerate

package p;

import java.util.stream.Stream;

class A { void m() { Stream.generate(() -> 1);
} }

![image](https://user-images.githubusercontent.com/10117031/31105446-419c080e-a7b2-11e7-8f90-371f43493322.png)

7. testTypeResolution

package p;

import java.util.HashSet; import java.util.Set;

class A { void m() { Set anotherSet = new HashSet<>(); anotherSet.parallelStream(); } }


![image](https://user-images.githubusercontent.com/10117031/31105586-65d6c762-a7b3-11e7-9e65-4a0fcb6c10cd.png)

![image](https://user-images.githubusercontent.com/10117031/31105582-5c45679e-a7b3-11e7-90f2-3d3a28fe70fa.png)
khatchad commented 7 years ago

Yiming, could you please focus on the problem we discussed yesterday? Specifically, please focus on the testArraysAsList() test. Please make sure that the test class is available in the class hierarchy. Let me know if you have any questions.

khatchad commented 7 years ago

Hm, interesting how testArraysStream works with the fix but not some of the other ones. In other words, without the fix, testArraysStream and testTypeResolution both fail. With the fix, however, testArraysStream passes but testTypeResolution still fails. Why?

khatchad commented 7 years ago

OK, I'm rereading some of the comments from @saledouble above. Looks like there's a test ordering issue. Sorry I missed that previously.

khatchad commented 7 years ago

Indeed, running testTypeResolution in isolation passes the test.

khatchad commented 7 years ago

When running all the tests, testTypeResolution fails due to this assertion:

junit.framework.AssertionFailedError
    at junit.framework.Assert.fail(Assert.java:55)
    at junit.framework.Assert.assertTrue(Assert.java:22)
    at junit.framework.Assert.assertTrue(Assert.java:31)
    at junit.framework.TestCase.assertTrue(TestCase.java:201)
    at org.eclipse.jdt.ui.tests.refactoring.RefactoringTest.createCU(RefactoringTest.java:468)
    at org.eclipse.jdt.ui.tests.refactoring.RefactoringTest.createCUfromTestFile(RefactoringTest.java:430)
    at org.eclipse.jdt.ui.tests.refactoring.RefactoringTest.createCUfromTestFile(RefactoringTest.java:419)
    at edu.cuny.hunter.streamrefactoring.ui.tests.ConvertStreamToParallelRefactoringTest.createCUfromTestFile(ConvertStreamToParallelRefactoringTest.java:113)
    at edu.cuny.hunter.streamrefactoring.ui.tests.ConvertStreamToParallelRefactoringTest.helper(ConvertStreamToParallelRefactoringTest.java:174)
    at edu.cuny.hunter.streamrefactoring.ui.tests.ConvertStreamToParallelRefactoringTest.testTypeResolution(ConvertStreamToParallelRefactoringTest.java:169)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at junit.framework.TestCase.runTest(TestCase.java:176)
    at junit.framework.TestCase.runBare(TestCase.java:141)
    at junit.framework.TestResult$1.protect(TestResult.java:122)
    at junit.framework.TestResult.runProtected(TestResult.java:142)
    at junit.framework.TestResult.run(TestResult.java:125)
    at junit.framework.TestCase.run(TestCase.java:129)
    at junit.framework.TestSuite.runTest(TestSuite.java:252)
    at junit.framework.TestSuite.run(TestSuite.java:247)
    at junit.extensions.TestDecorator.basicRun(TestDecorator.java:23)
    at junit.extensions.TestSetup$1.protect(TestSetup.java:23)
    at junit.framework.TestResult.runProtected(TestResult.java:142)
    at junit.extensions.TestSetup.run(TestSetup.java:27)
    at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:86)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
    at org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunner.main(RemotePluginTestRunner.java:66)
    at org.eclipse.pde.internal.junit.runtime.PlatformUITestHarness.lambda$0(PlatformUITestHarness.java:43)
    at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:37)
    at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:182)
    at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4497)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:4110)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1150)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1039)
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:153)
    at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:680)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:594)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:148)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:151)
    at org.eclipse.pde.internal.junit.runtime.NonUIThreadTestApplication.runApp(NonUIThreadTestApplication.java:52)
    at org.eclipse.pde.internal.junit.runtime.UITestApplication.runApp(UITestApplication.java:43)
    at org.eclipse.pde.internal.junit.runtime.NonUIThreadTestApplication.start(NonUIThreadTestApplication.java:46)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:653)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:590)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1499)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1472)

Let's have a closer took at at org.eclipse.jdt.ui.tests.refactoring.RefactoringTest.createCU(RefactoringTest.java:468):

https://github.com/eclipse/eclipse.jdt.ui/blob/d44e72a1953b1f212b3958040ea16a717239a07e/org.eclipse.jdt.ui.tests.refactoring/test%20cases/org/eclipse/jdt/ui/tests/refactoring/RefactoringTest.java#L467-L472

khatchad commented 7 years ago
assertTrue(!pack.getCompilationUnit(name).exists());

name is the name of the compilation unit. pack is the package fragment. This assertion statement is asserting that the compilation unit should not exist. My guess is that something is not being deleted that should be.

@saledouble Could you debug this and see what is going on?

yiming-tang-cs commented 7 years ago

When all tests are run, I got a different exception: image

yiming-tang-cs commented 7 years ago

Did you get the same exception as mine?

khatchad commented 7 years ago

Nope. I'm on 64b9105dc7e737b94ddd500050dd7064201de764.

khatchad commented 7 years ago
commit 64b9105dc7e737b94ddd500050dd7064201de764
Merge: 7912e80 f86a22c
Author: Raffi Khatchadourian <raffi.khatchadourian@hunter.cuny.edu>
Date:   Fri Oct 6 11:36:11 2017 -0400

    Merge branch 'master' of https://github.com/saledouble/Java-8-Stream-Refactoring into saledouble-master

commit f86a22c982791d5209d58ee6999c0847b268de07
Author: Raffi Khatchadourian <raffi.khatchadourian@hunter.cuny.edu>
Date:   Fri Oct 6 11:24:52 2017 -0400

    Suppress unused warning for old compiles method.

commit 7912e80a6036581ba888f08cb26f3fc0bee3d258
Merge: 9d49d11 4e8308a
Author: Raffi Khatchadourian <raffi.khatchadourian@hunter.cuny.edu>
Date:   Fri Oct 6 11:20:31 2017 -0400

    Merge branch 'master' of https://github.com/saledouble/Java-8-Stream-Refactoring into saledouble-master

commit 4e8308ac61fcd8cf3379b021599c184fc364cb76
Author: Raffi Khatchadourian <raffi.khatchadourian@hunter.cuny.edu>
Date:   Fri Oct 6 11:18:06 2017 -0400

    Fix whitespace.

commit c29f77148a4be603e7d1018e783f2b4113e03b57
Author: Raffi Khatchadourian <raffi.khatchadourian@hunter.cuny.edu>
Date:   Fri Oct 6 11:17:23 2017 -0400

    Replace comment.

commit 2f0567bfd438e5dc8dbb2ec6143c7b8a7d0cd479
Author: Raffi Khatchadourian <raffi.khatchadourian@hunter.cuny.edu>
Date:   Fri Oct 6 11:15:52 2017 -0400

    Move `compiles()` method closer to original.

    So that we can see the changes more clearly.

commit 31b8a154852f7267360a8dca7646ff24cf770d2e
Author: Yiming Tang <tangyiming0717@outlook.com>
Date:   Fri Oct 6 09:20:06 2017 -0400

    #24 delete duplicate code

commit fe48feaa6007552d41ec2b5a93c2cdd15cbf140e
Author: Yiming Tang <tangyiming0717@outlook.com>
Date:   Thu Oct 5 13:23:39 2017 -0400

    format

commit 366897d83bad49c7f400f650bb58a83610b44e4e
Author: Yiming Tang <tangyiming0717@outlook.com>
Date:   Thu Oct 5 13:19:49 2017 -0400

    #24 Fix testing infrastructure so that bytecode is available to WALA

commit 9d49d11c6fc0b1aa754ededd45d33935e8a6907e
Author: Raffi Khatchadourian <raffi.khatchadourian@hunter.cuny.edu>
Date:   Wed Oct 4 11:37:18 2017 -0400

    Better exception message.

...
khatchad commented 7 years ago
On branch saledouble-master
nothing to commit, working tree clean
khatchad commented 7 years ago

According to https://github.com/ponder-lab/Java-8-Stream-Refactoring/issues/24#issuecomment-333707924, it looked like this test was passing for you.

yiming-tang-cs commented 7 years ago

Sorry, I have fetched and merged, but I did not get your error.

image

khatchad commented 7 years ago

But the top is still not the same as mine. Try checking out f86a22c982791d5209d58ee6999c0847b268de07 and ensure that there are no local changes in your working copy.

yiming-tang-cs commented 7 years ago

The change for f86a22c exists in my local workspace.

image

I think I have no local changes: image

Still get :

java.lang.IllegalArgumentException: illegal value number: -1 in Node: < Application, Lp/A, m()V > Context: CallStringContext: [ com.ibm.wala.FakeRootClass.fakeRootMethod()V@3 ]
    at com.ibm.wala.ipa.callgraph.propagation.cfa.DefaultPointerKeyFactory.getPointerKeyForLocal(DefaultPointerKeyFactory.java:37)
    at com.ibm.wala.ipa.callgraph.propagation.PointerAnalysisImpl$HModel.getPointerKeyForLocal(PointerAnalysisImpl.java:494)
    at edu.cuny.hunter.streamrefactoring.core.analysis.Util.getPossibleTypesInterprocedurally(Util.java:196)
    at edu.cuny.hunter.streamrefactoring.core.analysis.Stream.inferInitialOrdering(Stream.java:575)
    at edu.cuny.hunter.streamrefactoring.core.analysis.Stream.<init>(Stream.java:183)
    at edu.cuny.hunter.streamrefactoring.core.analysis.StreamAnalysisVisitor.visit(StreamAnalysisVisitor.java:49)
    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.ui.tests.ConvertStreamToParallelRefactoringTest.helper(ConvertStreamToParallelRefactoringTest.java:185)
    at edu.cuny.hunter.streamrefactoring.ui.tests.ConvertStreamToParallelRefactoringTest.testTypeResolution(ConvertStreamToParallelRefactoringTest.java:169)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at junit.framework.TestCase.runTest(TestCase.java:176)
    at junit.framework.TestCase.runBare(TestCase.java:141)
    at junit.framework.TestResult$1.protect(TestResult.java:122)
    at junit.framework.TestResult.runProtected(TestResult.java:142)
    at junit.framework.TestResult.run(TestResult.java:125)
    at junit.framework.TestCase.run(TestCase.java:129)
    at junit.framework.TestSuite.runTest(TestSuite.java:252)
    at junit.framework.TestSuite.run(TestSuite.java:247)
    at junit.extensions.TestDecorator.basicRun(TestDecorator.java:23)
    at junit.extensions.TestSetup$1.protect(TestSetup.java:23)
    at junit.framework.TestResult.runProtected(TestResult.java:142)
    at junit.extensions.TestSetup.run(TestSetup.java:27)
    at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:86)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
    at org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunner.main(RemotePluginTestRunner.java:66)
    at org.eclipse.pde.internal.junit.runtime.PlatformUITestHarness.lambda$0(PlatformUITestHarness.java:43)
    at org.eclipse.pde.internal.junit.runtime.PlatformUITestHarness$$Lambda$312/1322397634.run(Unknown Source)
    at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:37)
    at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:182)
    at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4033)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3700)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1155)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1044)
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:153)
    at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:680)
    at org.eclipse.ui.internal.Workbench$$Lambda$15/1457352442.run(Unknown Source)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:594)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:148)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:151)
    at org.eclipse.pde.internal.junit.runtime.NonUIThreadTestApplication.runApp(NonUIThreadTestApplication.java:52)
    at org.eclipse.pde.internal.junit.runtime.UITestApplication.runApp(UITestApplication.java:43)
    at org.eclipse.pde.internal.junit.runtime.NonUIThreadTestApplication.start(NonUIThreadTestApplication.java:46)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:653)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:590)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1499)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1472)
khatchad commented 7 years ago

The change for f86a22c exists in my local workspace.

Try checking out f86a22c.

khatchad commented 7 years ago

git checkout f86a22c982791d5209d58ee6999c0847b268de07