Skip to content

Commit ddf6882

Browse files
committed
2 parents cb242bd + 65e1e8b commit ddf6882

File tree

38 files changed

+331
-27
lines changed

38 files changed

+331
-27
lines changed

.travis.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
sudo: false
22
language: java
3-
jdk: oraclejdk8
3+
jdk: openjdk8
44
cache:
55
apt: true
66
directories:
77
- $HOME/.m2
8+
services:
9+
- xvfb
810
script: mvn clean verify -Pjacoco coveralls:report
9-
before_install:
10-
- "export DISPLAY=:99.0"
11-
- "sh -e /etc/init.d/xvfb start"
1211
notifications:
1312
slack: cunyponder:A8GuEoj0voEn2H7MJDL1eNji

CONTRIBUTING.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Please see [the wiki][wiki] for more information regarding development.
44

55
## Building
66

7-
The project includes a maven configuration file using the tycho plug-in, which is part of the [maven eclipse plugin](http://www.eclipse.org/m2e/). Running `mvn install` will install *most* dependencies. Note that if you are not using maven, this plugin depends on https://github.com/khatchad/edu.cuny.citytech.refactoring.common, the **Eclipse SDK**, **Eclipse SDK tests**, and the **Eclipse testing framework** (may also be called the **Eclipse Test Framework**). The latter three can be installed from the "Install New Software..." menu option under "Help" in Eclipse.
7+
The project includes a maven configuration file using the tycho plug-in, which is part of the [maven eclipse plugin](http://www.eclipse.org/m2e/). Running `mvn install` will install *most* dependencies. Note that if you are not using maven, this plugin depends on https://github.com/khatchad/edu.cuny.citytech.refactoring.common, the **Eclipse SDK**, **Eclipse SDK tests**, the **Eclipse testing framework** (may also be called the **Eclipse Test Framework**), and [Metrics](http://metrics2.sourceforge.net). Some of these can be installed from the "Install New Software..." menu option under "Help" in Eclipse.
88

99
## Generating Entry Points Files
1010

@@ -30,6 +30,8 @@ Key | Value Type | Description
3030
---------------- | ---------- | ----------
3131
nToUseForStreams | Integer | The value of N to use while building the nCFA for stream types.
3232

33+
More info can be found on [this wiki page](https://github.com/ponder-lab/Optimize-Java-8-Streams-Refactoring/wiki/Running-the-Evaluator).
34+
3335
[wiki]: https://github.com/ponder-lab/Optimize-Java-8-Streams-Refactoring/wiki
3436
[annotations]: https://github.com/ponder-lab/edu.cuny.hunter.streamrefactoring.annotations
3537
[wala]: https://github.com/wala/WALA

README.md

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
# Optimize Java 8 Streams Refactoring
22

3-
[![Build Status](https://travis-ci.com/ponder-lab/Optimize-Java-8-Streams-Refactoring.svg?branch=master)](https://travis-ci.com/ponder-lab/Optimize-Java-8-Streams-Refactoring) [![Coverage Status](https://coveralls.io/repos/github/ponder-lab/Optimize-Java-8-Streams-Refactoring/badge.svg?branch=master)](https://coveralls.io/github/ponder-lab/Optimize-Java-8-Streams-Refactoring?branch=master) [![GitHub license](https://img.shields.io/badge/license-Eclipse-blue.svg)](https://github.com/khatchadourian-lab/Java-8-Stream-Refactoring/raw/master/LICENSE.txt) [![DOI](https://zenodo.org/badge/78147265.svg)](https://zenodo.org/badge/latestdoi/78147265)
3+
[![Build Status](https://travis-ci.com/ponder-lab/Optimize-Java-8-Streams-Refactoring.svg?branch=master)](https://travis-ci.com/ponder-lab/Optimize-Java-8-Streams-Refactoring) [![Coverage Status](https://coveralls.io/repos/github/ponder-lab/Optimize-Java-8-Streams-Refactoring/badge.svg?branch=master)](https://coveralls.io/github/ponder-lab/Optimize-Java-8-Streams-Refactoring?branch=master) [![GitHub license](https://img.shields.io/badge/license-Eclipse-blue.svg)](https://github.com/khatchadourian-lab/Java-8-Stream-Refactoring/raw/master/LICENSE.txt) [![DOI](https://zenodo.org/badge/78147265.svg)](https://zenodo.org/badge/latestdoi/78147265) [![Java profiler](https://www.ej-technologies.com/images/product_banners/jprofiler_small.png)](https://www.ej-technologies.com/products/jprofiler/overview.html)
44

55
## Introduction
66

7-
<img src="https://raw.githubusercontent.com/ponder-lab/Optimize-Java-8-Streams-Refactoring/master/edu.cuny.hunter.streamrefactoring.ui/icons/icon.png" alt="Icon" align="left" height=150px width=150px/> The Java 8 Stream API sets forth a promising new programming model that incorporates functional-like, MapReduce-style features into a mainstream programming language. However, using streams efficiently may involve subtle considerations.
7+
<img src="https://raw.githubusercontent.com/ponder-lab/Optimize-Java-8-Streams-Refactoring/master/edu.cuny.hunter.streamrefactoring.ui/icons/icon.png" alt="Icon" align="left" height=150px width=150px/> The Java 8 Stream API sets forth a promising new programming model that incorporates functional-like, MapReduce-style features into a mainstream programming language. However, using streams efficiently may involve subtle considerations.
88

99
This tool consists of automated refactoring research prototype plug-ins for [Eclipse][eclipse] that assists developers in writing optimal stream client code in a semantics-preserving fashion. Refactoring preconditions and transformations for automatically determining when it is safe and possibly advantageous to convert a sequential stream to parallel and improve upon already parallel streams are included. The approach utilizes both [WALA][wala] and [SAFE][safe].
1010

1111
## Screenshot
12+
1213
![Screenshot](http://i2.wp.com/khatchad.commons.gc.cuny.edu/files/2018/03/Screenshot-from-2018-04-28-17-34-53.png)
1314

1415
## Demonstration
@@ -32,14 +33,16 @@ Currently, the refactoring works only via the package explorer and the outline v
3233

3334
## Installation
3435

36+
The latest release is [v0.18.0][v0.18.0]. It has been tested on Eclipse IDE for RCP and RAP Developers Version: 2019-03 (4.11.0), Build id: 20190314-1200 under OpenJDK Runtime Environment (build 1.8.0_212-8u212-b03-0ubuntu1.19.04.2-b03) and OpenJDK 64-Bit Server VM (build 25.212-b03, mixed mode) on Ubuntu 19.04.
37+
3538
[This video][install] demonstrates the different ways that this tool can be installed.
3639

3740
### Update Site
3841

3942
An alpha version of our tool is available via an Eclipse update site at: https://raw.githubusercontent.com/ponder-lab/Optimize-Java-8-Streams-Refactoring/master/edu.cuny.hunter.streamrefactoring.updatesite. Please choose the latest version of the "Optimize Stream Refactoring."
4043

4144
### Eclipse Marketplace
42-
45+
4346
You may also install the tool via the [Eclipse Marketplace](https://marketplace.eclipse.org/content/optimize-java-8-streams-refactoring) by dragging this icon to your running Eclipse workspace: [![Drag to your running Eclipse* workspace. *Requires Eclipse Marketplace Client](https://marketplace.eclipse.org/sites/all/themes/solstice/public/images/marketplace/btn-install.png)](http://marketplace.eclipse.org/marketplace-client-intro?mpc_install=4056021 "Drag to your running Eclipse* workspace. *Requires Eclipse Marketplace Client")
4447

4548
### Dependencies
@@ -68,7 +71,7 @@ Explicit entry points may be marked using the appropriate annotation found in th
6871

6972
There are currently some limitations with embedded streams (i.e., streams declared as part of lambda expressions sent as arguments to intermediate stream operations). This is due to model differences between the Eclipse JDT and WALA. See [#155](https://github.com/ponder-lab/Java-8-Stream-Refactoring/issues/155) for details.
7073

71-
In general, there is [an issue](https://github.com/wala/WALA/issues/281) with the mapping between the Eclipse DOM and WALA DOM, particuarly when using Anonymous Inner Classes (AICs). We are currently working with the WALA developers to resolve [this issue](https://github.com/ponder-lab/Java-8-Stream-Refactoring/issues/155).
74+
In general, there is [an issue](https://github.com/wala/WALA/issues/2/edit81) with the mapping between the Eclipse DOM and WALA DOM, particuarly when using Anonymous Inner Classes (AICs). We are currently working with the WALA developers to resolve [this issue](https://github.com/ponder-lab/Java-8-Stream-Refactoring/issues/155).
7275

7376
## Contributing
7477

@@ -82,6 +85,35 @@ For information on contributing, see [CONTRIBUTING.md][contrib].
8285

8386
See the [wiki][wiki] for further information.
8487

88+
## Publications
89+
90+
<a name="Khatchadourian2019"></a>Raffi Khatchadourian, Yiming Tang, Mehdi Bagherzadeh, and Syed Ahmed. Safe automated refactoring for intelligent parallelization of Java 8 streams. In <em>International Conference on Software Engineering</em>, ICSE '19, pages 619--630, Piscataway, NJ, USA, May 2019. ACM/IEEE, IEEE Press. [ <a href="http://www.cs.hunter.cuny.edu/~Raffi.Khatchadourian99/all_bib.html#Khatchadourian2019">bib</a> | <a href="http://dx.doi.org/10.1109/ICSE.2019.00072">DOI</a> | <a href="http://www.slideshare.net/khatchad/safe-automated-refactoring-for-intelligent-parallelization-of-java-8-streams">slides</a> | <a href="http://academicworks.cuny.edu/hc_pubs/489">http</a]
91+
92+
<a name="Khatchadourian2018b"></a>Raffi Khatchadourian, Yiming Tang, Mehdi Bagherzadeh, and Syed Ahmed. A tool for optimizing Java 8 stream software via automated refactoring. In <em>International Working Conference on Source Code Analysis and Manipulation</em>, SCAM '18, pages 34--39. IEEE, IEEE Press, September 2018. Engineering Track. [ <a href="http://www.cs.hunter.cuny.edu/~Raffi.Khatchadourian99/all_bib.html#Khatchadourian2018b">bib</a> | <a href="http://dx.doi.org/10.1109/SCAM.2018.00011">DOI</a> | <a href="http://www.slideshare.net/khatchad/a-tool-for-optimizing-java-8-stream-softwarevia-automated-refactoring">slides</a> | <a href="http://academicworks.cuny.edu/hc_pubs/429">http</a]
93+
94+
## Citation
95+
96+
Please cite this work as follows:
97+
98+
```bibtex
99+
@inproceedings{Khatchadourian2018b,
100+
author = {Raffi Khatchadourian and Yiming Tang and Mehdi Bagherzadeh and Syed Ahmed},
101+
title = {A Tool for Optimizing {Java} 8 Stream Software via Automated Refactoring},
102+
booktitle = {International Working Conference on Source Code Analysis and Manipulation},
103+
year = {2018},
104+
series = {SCAM '18},
105+
pages = {34--39},
106+
month = sep,
107+
organization = {IEEE},
108+
publisher = {IEEE Press},
109+
note = {Engineering Track.},
110+
doi = {10.1109/SCAM.2018.00011},
111+
issn = {2470-6892},
112+
location = {Madrid, Spain},
113+
numpages = {6},
114+
}
115+
```
116+
85117
[wiki]: https://github.com/ponder-lab/Java-8-Stream-Refactoring/wiki
86118
[challenges]: https://github.com/ponder-lab/Optimize-Java-8-Streams-Refactoring/wiki/Solutions-to-Engineering-Challenges
87119
[annotations]: https://github.com/ponder-lab/edu.cuny.hunter.streamrefactoring.annotations
@@ -92,4 +124,5 @@ See the [wiki][wiki] for further information.
92124
[install]: https://youtu.be/On4xBzvFk1c
93125
[entrypoints]: https://youtu.be/On4xBzvFk1c?t=2m6s
94126
[SCAM 2018]: http://www.ieee-scam.org/2018
95-
[paper]: https://khatchad.commons.gc.cuny.edu/research/publications/#Khatchadourian2018a
127+
[paper]: https://khatchad.commons.gc.cuny.edu/research/publications/#Khatchadourian2018b
128+
[v0.18.0]: https://github.com/ponder-lab/Optimize-Java-8-Streams-Refactoring/releases/tag/v0.18.0

edu.cuny.hunter.streamrefactoring.core/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
33
Bundle-Name: %Bundle-Name
44
Bundle-SymbolicName: edu.cuny.hunter.streamrefactoring.core;singleton:=true
5-
Bundle-Version: 1.6.0
5+
Bundle-Version: 1.9.0
66
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
77
Bundle-Vendor: %Bundle-Vendor
88
Bundle-ClassPath: .,

edu.cuny.hunter.streamrefactoring.core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xs
1111
</parent>
1212
<artifactId>edu.cuny.hunter.streamrefactoring.core</artifactId>
1313
<packaging>eclipse-plugin</packaging>
14-
<version>1.6.0</version>
14+
<version>1.9.0</version>
1515
</project>

edu.cuny.hunter.streamrefactoring.core/src/edu/cuny/hunter/streamrefactoring/core/analysis/Stream.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@
4141
import org.eclipse.jdt.core.dom.rewrite.ASTRewrite;
4242
import org.eclipse.jdt.internal.corext.dom.ASTNodes;
4343
import org.eclipse.jdt.internal.corext.dom.Bindings;
44-
import org.eclipse.jdt.internal.corext.refactoring.base.JavaStatusContext;
4544
import org.eclipse.jdt.internal.corext.refactoring.structure.CompilationUnitRewrite;
45+
import org.eclipse.jdt.internal.corext.refactoring.util.JavaStatusContext;
4646
import org.eclipse.jdt.internal.corext.util.JdtFlags;
4747
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
4848
import org.eclipse.ltk.core.refactoring.RefactoringStatusContext;

edu.cuny.hunter.streamrefactoring.core/src/edu/cuny/hunter/streamrefactoring/core/analysis/StreamStateMachine.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,15 +160,17 @@ public int getNumberOfStreamInstancesSkipped() {
160160
"java.util.stream.Stream.toArray", "java.util.stream.Stream.reduce", "java.util.stream.Stream.collect",
161161
"java.util.stream.Stream.min", "java.util.stream.Stream.max", "java.util.stream.Stream.count",
162162
"java.util.stream.Stream.anyMatch", "java.util.stream.Stream.allMatch", "java.util.stream.Stream.noneMatch",
163-
"java.util.stream.Stream.findFirst", "java.util.stream.Stream.findAny" };
163+
"java.util.stream.Stream.findFirst", "java.util.stream.Stream.findAny",
164+
"java.util.stream.BaseStream.iterator", "java.util.stream.BaseStream.spliterator" };
164165
// @formatter:on
165166

166167
// @formatter:off
167168
private static final String[] TERMINAL_OPERATIONS_WERE_REDUCE_ORDERING_MATTERS = {
168169
"java.util.stream.DoubleStream.forEachOrdered", "java.util.stream.IntStream.forEachOrdered",
169170
"java.util.stream.LongStream.forEachOrdered", "java.util.stream.Stream.forEachOrdered",
170171
"java.util.stream.DoubleStream.findFirst", "java.util.stream.IntStream.findFirst",
171-
"java.util.stream.LongStream.findFirst", "java.util.stream.Stream.findFirst" };
172+
"java.util.stream.LongStream.findFirst", "java.util.stream.Stream.findFirst",
173+
"java.util.stream.BaseStream.iterator", "java.util.stream.BaseStream.spliterator" };
172174
// @formatter:on
173175

174176
// @formatter:off

edu.cuny.hunter.streamrefactoring.core/src/edu/cuny/hunter/streamrefactoring/core/analysis/Util.java

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.eclipse.jdt.core.dom.ASTNode;
2727
import org.eclipse.jdt.core.dom.ASTVisitor;
2828
import org.eclipse.jdt.core.dom.CompilationUnit;
29+
import org.eclipse.jdt.core.dom.Expression;
2930
import org.eclipse.jdt.core.dom.ITypeBinding;
3031
import org.eclipse.jdt.core.dom.MethodInvocation;
3132
import org.eclipse.jdt.core.dom.SimpleName;
@@ -763,10 +764,27 @@ public static boolean matches(SSAInstruction instruction, MethodInvocation invoc
763764

764765
private static boolean matches(TypeReference methodDeclaringType, MethodReference method,
765766
MethodInvocation invocation) {
766-
if (getBinaryName(methodDeclaringType).equals(invocation.getExpression().resolveTypeBinding().getBinaryName()))
767-
// FIXME: This matching needs much work #153.
768-
if (method.getName().toString().equals(invocation.resolveMethodBinding().getName()))
769-
return true;
767+
String declaringTypeBinaryName = getBinaryName(methodDeclaringType);
768+
769+
if (declaringTypeBinaryName != null) {
770+
Expression expression = invocation.getExpression();
771+
772+
if (expression != null) {
773+
ITypeBinding typeBinding = expression.resolveTypeBinding();
774+
775+
if (typeBinding != null) {
776+
String expressionBinaryName = typeBinding.getBinaryName();
777+
778+
if (declaringTypeBinaryName.equals(expressionBinaryName))
779+
// FIXME: This matching needs much work #153.
780+
if (method.getName().toString().equals(invocation.resolveMethodBinding().getName()))
781+
return true;
782+
} else
783+
LOGGER.warning("typeBinding is null for expression: " + expression);
784+
} else
785+
LOGGER.warning("expression is null for invocation: " + invocation);
786+
} else
787+
LOGGER.warning("Binary name is null for method declarying type: " + methodDeclaringType);
770788
return false;
771789
}
772790

edu.cuny.hunter.streamrefactoring.core/src/edu/cuny/hunter/streamrefactoring/core/refactorings/OptimizeStreamsRefactoringProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434
import org.eclipse.jdt.core.refactoring.CompilationUnitChange;
3535
import org.eclipse.jdt.core.search.SearchEngine;
3636
import org.eclipse.jdt.internal.corext.codemanipulation.CodeGenerationSettings;
37-
import org.eclipse.jdt.internal.corext.refactoring.base.JavaStatusContext;
3837
import org.eclipse.jdt.internal.corext.refactoring.changes.DynamicValidationRefactoringChange;
3938
import org.eclipse.jdt.internal.corext.refactoring.structure.CompilationUnitRewrite;
39+
import org.eclipse.jdt.internal.corext.refactoring.util.JavaStatusContext;
4040
import org.eclipse.jdt.internal.corext.refactoring.util.RefactoringASTParser;
4141
import org.eclipse.jdt.internal.corext.refactoring.util.TextEditBasedChangeManager;
4242
import org.eclipse.jdt.internal.ui.JavaPlugin;

edu.cuny.hunter.streamrefactoring.eval/plugin.xml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77
description="Evaluates the Convert Stream to Parallel refactoring"
88
id="edu.cuny.hunter.evaluate.convert.stream.to.parallel.refactoring.command"
99
name="Evaluate Convert Stream To Parallel Refactoring"/>
10+
<command
11+
categoryId="org.eclipse.jdt.ui.category.source"
12+
defaultHandler="edu.cuny.hunter.streamrefactoring.eval.handlers.StreamMethodCallFinder"
13+
description="Counts the number of methods called that are stream methods"
14+
id="edu.cuny.hunter.count.stream.methods.command"
15+
name="Count the number of stream methods called">
16+
</command>
1017
</extension>
1118
<extension point="org.eclipse.ui.handlers">
1219
<handler
@@ -20,5 +27,21 @@
2027
</with>
2128
</activeWhen>
2229
</handler>
30+
<handler
31+
class="edu.cuny.hunter.streamrefactoring.eval.handlers.StreamMethodCallFinder"
32+
commandId="edu.cuny.hunter.count.stream.methods.command">
33+
<activeWhen>
34+
<with
35+
variable="selection">
36+
<iterate
37+
ifEmpty="false"
38+
operator="or">
39+
<instanceof
40+
value="org.eclipse.jdt.core.IJavaProject">
41+
</instanceof>
42+
</iterate>
43+
</with>
44+
</activeWhen>
45+
</handler>
2346
</extension>
2447
</plugin>

0 commit comments

Comments
 (0)