- Loading...
...
The Java Tools Language (JTL) is a logic-paradigm query language to select Java elements in a code base. The current implementation is based on an analysis of Java bytecode classes. The JTL syntax is inspired by Query-by-Example ideas in order to increase productivity of users. JTL also relies on Datalog-like semantics. For example, one could find all methods taking three int parameters and returning a subclass of Java's Date class using the follow query:
...
Use Case 4: Find overloaded methods with multiple parameters that share a single type.
In Java and C#, array subtyping is covariant, meaning that type B\[\] is considered a subtype of A\[\] whenever B is a subtype of A. However, this relation can cause runtime exceptions. Consider the following Java code where Banana and Apple are subtypes of Fruit: Wiki Markup
Code Block |
---|
Banana[] bananas = new Banana[5]; Fruit[] fruit = bananas; fruits[0] = new Apple(); // ArrayStore Exception peelBanana(bananas[0]); // Apple??? |
...
The assignment to the first element of the variable fruit on line 3 will cause an ArrayStore exception. Although statically, the variable fruit has type Fruit\[\], its runtime type is Banana\[\] and thus we cannot use it to store an Apple.
Use Case 5: Find occurences of covariant array uses in assignment, method calls, constructor instantiations and return statements.
...
This new feature introduced two source incompatibility incompatibilities with respect to Java 6. The code below illustrates the changes. Previously, the statement throw exception would throw a Foo exception. Now, it throws a DaughterOfFoo exception. As a consequence, the catch block catch(SonOfFoo anotherException) is not reachable anymore as the try only throws a DaughterOfFoo exception.
...
Use Case 6: Find occurences of nested try/catch blocks that rethrow an exception.
[This section is work in progress]
X = not supported
✓ = supported
? = not sure
| Final Array & Anonymous Class | Generic Constructors | Capture Conversion Idiom | Overloaded Methods Sharing Single Type | Covariant Arrays | Rethrown Exception |
---|---|---|---|---|---|---|
JTL | X | X | X | ? | X | X |
BBQ | X | X | X | ? | X | X |
SOUL | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
JQuery | X | X | X | X (*1) | X | X |
.QL (*2) | ✓ | ? | ? | ? | ✓ | ? |
Jackpot | X | ✓ | X | X | X | ✓ |
PMD (Xpath) | X | X | X | X | X | X |
*1: can find overloaded methods but not sharing single type: method(?C, ?M1), method(?C, ?M2), likeThis(?M1, ?M2). Tested with operations available in eclipse plugin. Paper describe different operations that don't seem to be supported.
*2: .QL documentation & tool is kept secretive for competitive advantage protection
Covariant Arrays
- no support for statement level information
JTL
Use case 1 not possible because no support for local variable decl. Use case 2 & 3 not possible because no support for generics/wildcards (due to bytecode source). Use 4 not possible because no support for statements & types of expressions. Use case 6 not possible because no control flow support.
BBQ
Similar reasons to JTL.
Wiki Markup |
---|
*{+}SOUL \[authors replying on Tuesday\]+* |
SOUL
Jquery
Similar reasons to JTL.unmigrated-wiki-markup
*+.QL \[authors emailed\]+*
Very expressive. Though sql statements may not scale for control flow matching. (direct ast pattern matching is clearer for some use cases)
Wiki Markup |
---|
*{+}Jackpot \[emailed Jan from Netbeans\]+* |
Jackpot
PMD
No variable binding support which restricts a lot of the analysis.
...
[This section is work in progress]
...
...
[This section is work in progress]
Relational based query languages not low level enough.
...
Idea: decouple query-by-example from constraints on variables. - two different views-
...
...
Week 1
...
Week 2
...
Week 3
...
Week 4
...
Week 5
...
July
...
Raoul in Cambridge
...
...
...
...
...
August
...
...
September
...
...
...
...
...
...
October
...
Joel JavaOne
...
...
Raoul in Cambridge
...
Raoul in Cambridge
...
Raoul in Cambridge
It seems pure template based languages are not expressive enough and so are pure logic-based queries.
Sweet spot a combination of both mechanisms (which SOUL provides).
Week | Date | Log | Milestones |
---|---|---|---|
1 | 9 July - 13 July |
|
|
2 | 16 July - 20 July |
|
|
3 | 23 July - 27 July |
| Milestone 1
|
4 | 30 July - 3 August |
|
|
5 | 6 August - 10 August |
|
|
6 | 13 August - 17 August |
| Milestone 2
|
7 | 20 August - 24 August |
| Milestone 3
|
8 | 27 August - 31 August |
| Milestone 4
|
9 | 3 September - 7 September |
| Milestone 5
|
10 | 10 September - 14 September |
|
|
11 | 17 September - 21 September |
|
|
12 | 24 September - 28 September |
|
|
13 | 1 October - 5 October |
| DEMO |
14 | 8 October - 12 October |
| DEMO |
Give a live demonstration of the query language for two use cases: Covariant Arrays assignments & Overloaded Methods sharing single type
7th September
Build the minimum vertical implementation to make this possible. This consists of the following milestones:
1) Create a database representation of a Java program, which stores information attributed AST nodes of assignments and method declarations. (deadline: 17/8)
2) Develop backend API that will query the database. (deadline: 23/8)
3) Design query language, different types of queries it will support (deadline: 29/8)
4) Build minimum grammar & parser & compiler to query the two use cases (deadline: 6/9)
5) Output results frontend (deadline: 7/9)
Extra time will be used to expand the infrastructure horizontally:
- Support more AST nodes and relations
- Support more types of queries
- Extend backend
- Test coverage
- Web interface for Demo
[1] Brian Goetz. Language designer's notebook: Quantitative language design.
Color scheme:
\[1\] Brian Goetz. Language designer's notebook: Quantitative language design. [http://www.ibm.com/developerworks/java/library/j-ldn1/|http://www.ibm.com/developerworks/java/library/j-ldn1/]. Wiki Markup
\[2\] Chris Parnin, Christian Bird, and Emerson Murphy-Hill. 2011. Java generics adoption: how new features are introduced, championed, or ignored. In Proceedings of the 8th Working Conference on Mining Software Repositories (MSR '11)'11) Wiki Markup
\[3\] Ewan Tempero, Craig Anslow, Jens Dietrich, Ted Han, Jing Li, Markus Lumpe, Hayden Melton, and James Noble. 2010. The Qualitas Corpus: A Curated Collection of Java Code for Empirical Studies. In Proceedings of the 2010 Asia Pacific Software Engineering Conference (APSEC '10) Wiki Markup
\[4\] Joseph Gil and Keren Lenz. 2010. The use of overloading in JAVA programs. In Proceedings of the 24th European conference on Object-oriented programming (ECOOP '10) Wiki Markup
\[5\] Raoul-Gabriel Urma and Janina Voigt. Using the OpenJDK to Investigate Covariance in Java. Java Magazine May/June 2012. Wiki Markup
\[a\] Refactoring NG. [ http://kenai.com/projects/refactoringng|http://kenai.com/projects/refactoringng] Wiki Markup
Wiki Markup |
---|
\[b\] Tal Cohen, Joseph (Yossi) Gil, and Itay Maman. 2006. JTL: the Java tools language. In Proceedings of the 21st annual ACM SIGPLAN conference on Object-oriented programming systems, languages, and applications (OOPSLA '06) |
[b] Tal Cohen, Joseph (Yossi) Gil, and Itay Maman. 2006. JTL: the Java tools language. In Proceedings of the 21st annual ACM SIGPLAN conference on Object-oriented programming systems, languages, and applications (OOPSLA '06)
[c] Browse By Query. \[c\] Browse By Query. [http://browsebyquery.sourceforge.net/|http://browsebyquery.sourceforge.net/] Wiki Markup