• Home
    • View
    • Login
    This page
    • Normal
    • Export PDF
    • Page Information

    Loading...
  1. Dashboard
  2. Undefined Space
  3. Compiler
  4. Java Corpus Tools

Page History

Versions Compared

Old Version 103

changes.mady.by.user J. Duke

Saved on Aug 06, 2012

compared with

New Version 104

changes.mady.by.user J. Duke

Saved on Aug 06, 2012

  • Previous Change: Difference between versions 102 and 103
  • Next Change: Difference between versions 104 and 105
  • View Page History

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

...

Use Case 4: Find overloaded methods with multiple parameters that share a single type.

Covariant Arrays

Wiki MarkupIn 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:

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.

...

Use Case 6: Find occurences of nested try/catch blocks that rethrow an exception.

Evaluation

Wiki Markup*\[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 

JTL

  •  no working Eclipse plugin found. (authors emailed)
  • argument list pattern (sec 2.2) public _ (_, String, *) : any public method that accept a String as its second argument and returns any type
  • quantifiers: no, all, exists...
  • anonymous class
  • pattern naming (integral := byte | short | int | long)
  • variable binding
  • no structural matching of AST (deemed difficult because uses class files) (so can't look match on a loop for example or find all local variables in method)
  • no submethod information (local vars etc)
  • Wiki Markupread\[F\]/write\[F\] predicates to indicate whether a method reads/write to a field. Nice feature: write\[_\] tells whether method writes to a field at all. Q: How do we do this recursively? All methods within the method are not writing to fields...
  • no support for generics (according to documentation)

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

  • doesn't detect local inner classes (local & anonymous). Only inner classes (doesn't differentiate): class in all classes
  • no access to local variable declared in methods
  • no support for generics.
  • no support for constructors (considered as method init) 
  • no AST structural matching. (e.g loops ...)
  • no variable binding/unification
  • set operators (union, intersection)
  • support for read/write of fields references

Similar reasons to JTL.

SOUL

...

  • http://jquery.cs.ubc.ca/documentation/toc.html
  • http://jquery.cs.ubc.ca/documentation/appendix2.html
  • variable binding through predicatesunmigrated-wiki-markup
  • support for read & efftects of fields (write) \ [writes(?B,?F,?L) means: "Block ?B writes to field ?F at location ?L"\]
  • no structural (statement) matching (e.g pattern match on a loop or body of a method)
  • no generics support
  • no quantifiers

Similar reasons to JTL.

.QL

  • New version stores every AST node unit in DB
  • has notion of aggregates (count, sum, max, min, avg)
  • ".QL: Object-Oriented Queries made Easy"

Very expressive. Though sql statements may not scale for control flow matching. (direct ast pattern matching is clearer for some use cases)

...

  • http://www.ing.iac.es/~docs/external/java/pmd/rules/design.html
  • http://code.google.com/p/code-cop-code/wiki/PmdRulesCodecop
  • structural matching: all AST hiearchy can be queried through Xpath expression
  • can't express subtype relations. E.g. assignments where RHS is supertype of left handside and different
  • no variable binding
  • support generic constructors but not bind it to enclosing class: //ConstructorDeclaration//TypeParameters
  • no support for read/write effects

No variable binding support which restricts a lot of the analysis. 

Taxonomy

...

*\[This section is work in progress\]*

Query Language Features

  • variable binding
  • quantifiers (forall, exists, no)
  • predicates
  • set operators
  • aggregate operators
  • behavioural template matching
  • list pattern matching (parameters, generics)
  • querying style

...

  • Attributed AST Nodes
  • control flow statements
  • local variables
  • generics / wildcards
  • anonymous class

Conclusion/Ideas

Wiki Markup*\[This section is work in progress\]*[This section is work in progress]

Relational based query languages not low level enough. 

...

Week

Date

Log

Milestones

1

9 July - 13 July

  • Source Code Query Languages Research
  • Write up of Review on wiki

 

2

16 July - 20 July

  • Source Code Query Languages Evaluation & Taxonomy 
  • Write up of Results on wiki

 

3

23 July - 27 July

  • Tools research (parser, ide support, static analysis, database)
  • Comparison of static analysis API (pmd, tree, eclipse)
  • Working on Eclipse Plugin to query JCT use cases

Milestone 1 

  • Comparative Study of Source Code Query Languages

4

30 July - 3 August

  • Developed Eclipse plugin
  • Investigating Diagnostic Listener

 

5

6 August - 10 August

  • Come up with syntax queries expressing our use cases
  • Enhancing diagnostic created by java Compiler

 

6

13 August - 17 August

  • Research relations between Java elements that we are interested to store in database
  • Enhancing diagnostic created by java Compiler

Milestone 2 

  • Database representation of Java Source Code for Assignments and Method Declarations

7

20 August - 24 August

  • Develop backend API to query database

Milestone 3 

  • Develop backend API to query database

8

27 August - 31 August

  • Design Grammar of the Language

Milestone 4 

  • Design how general queries will look like in the query language

9

3 September - 7 September

  • Develop prototype to query database
  • Output in web interface

Milestone 5 

  • Develop Parser and Compiler to query covariant assignment and overloaded method with single type use cases
  • Front end displaying results of query

10

10 September - 14 September

  • Implement Test Coverage

 

11

17 September - 21 September

  • Extend database & backend support

 

12

24 September - 28 September

  • Preparing presentation for JavaONE

 

13

1 October - 5 October

  • BOF presentation at JavaOne

DEMO

14

8 October - 12 October

  • Stockholm presentation

DEMO

Demo Plan

Aim

Give a live demonstration of the query language for two use cases: Covariant Arrays assignments & Overloaded Methods sharing single type

...

- Web interface for Demo

Relevant Literature

Wiki Markup\[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/].unmigrated-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)unmigrated-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)unmigrated-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.

Related Projects

...

\[a\] Refactoring NG. [http://kenai.com/projects/refactoringng| http://kenai.com/projects/refactoringng]unmigrated-wiki-markup

\[b\] Tal  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)unmigrated-wiki-markup

\[c\] Browse By Query. [http://browsebyquery.sourceforge.net/| http://browsebyquery.sourceforge.net/]

Overview
Content Tools
ThemeBuilder

Terms of Use
• License: GPLv2
• Privacy • Trademarks • Contact Us

Powered by a free Atlassian Confluence Open Source Project License granted to https://www.atlassian.com/software/views/opensource-community-additional-license-offer. Evaluate Confluence today.

  • Kolekti ThemeBuilder Powered by Atlassian Confluence 8.5.23
  • Kolekti ThemeBuilder printed.by.atlassian.confluence
  • Report a bug
  • Atlassian News
Atlassian
Kolekti ThemeBuilder EngineAtlassian Confluence
{"serverDuration": 740, "requestCorrelationId": "779fde6958f07722"}