• 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 27

changes.mady.by.user J. Duke

Saved on Jul 20, 2012

compared with

New Version 28

changes.mady.by.user J. Duke

Saved on Jul 20, 2012

  • Previous Change: Difference between versions 26 and 27
  • Next Change: Difference between versions 28 and 29
  • View Page History

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Table

...

of

...

Contents

...

Table of Contents

...

maxLevel

...

4

Vision

  1. Create a platform to enable language designers and the community to validate extensions to Java.
  2. Encourage and facilitate empirical research of features in Java.

A Query Language for Language Designers

Java Source Code Query Languages

In this section, we give an overview of the seven query languages that we evaluate in this paper: Java Tools Language, Browse-By-Query,

...

SOUL,

...

JQuery,

...

.QL,

...

Jackpot

...

and

...

PMD.

...

We

...

selected

...

these

...

languages

...

because

...

they

...

provide

...

a

...

variety

...

of

...

design

...

choices

...

and

...

strictly

...

provide

...

a

...

query

...

language.

...

For

...

example,

...

we

...

didn't

...

select

...

Findbugs

...

as

...

it

...

only

...

lets

...

programmers

...

query

...

source

...

by

...

creating

...

new

...

classes

...

based

...

on

...

a

...

Java

...

framework.

...

We

...

also

...

only

...

selected

...

source

...

code

...

query

...

languages

...

that

...

included

...

a

...

guide

...

or

...

a

...

working

...

implementation.

...

Java

...

Language

...

Tools

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.

...

For

...

example,

...

one

...

could

...

find

...

all

...

methods

...

taking

...

three

...

int

...

parameters

...

and

...

returning

...

a

...

subclass

...

of

...

Java's

...

Date

...

class

...

using

...

the

...

follow

...

query:

{
Code Block
}
public static D method(int, int, int), D extends* /java.util.Date;
{code}

In

...

addition,

...

JTL

...

features

...

variable

...

binding

...

and

...

data

...

flow

...

queries.

...

Browse-By-Query

...

Browse-By-Query

...

(BBQ)

...

reads

...

Java

...

bytecode

...

files

...

and

...

creates

...

a

...

database

...

representing

...

classes,

...

method

...

calls,

...

fields,

...

field

...

references,

...

string

...

constants

...

and

...

string

...

constant

...

references.

...

This

...

database

...

can

...

then

...

be

...

interrogated

...

through

...

English-like

...

queries.

...

The

...

syntax

...

is

...

motivated

...

by

...

the

...

desire

...

to

...

be

...

intuitive.

...

For

...

example,

...

one

...

could

...

find

...

all

...

the

...

methods

...

that

...

call

...

a

...

method

...

whose

...

name

...

matches

...

start

...

by

...

composing

...

the

...

following

...

query:

{
Code Block
}
methods containing calls to matching "start" methods in all classes
{code}

In

...

addition,

...

BBQ

...

provides

...

filtering

...

mechanisms,

...

set

...

and

...

and

...

relational

...

operators

...

that

...

can

...

be

...

combined

...

to

...

compose

...

more

...

complex

...

queries.

...

SOUL

SOUL is a logic-paradigm

...

query

...

language.

...

It

...

contains

...

an

...

extensive

...

predicate

...

library

...

called

...

CAVA

...

that

...

matches

...

queries

...

against

...

AST

...

nodes

...

of

...

a

...

Java

...

program

...

generated

...

by

...

the

...

Eclipse

...

JDT.

...

SOUL

...

facilitates

...

the

...

specification

...

of

...

queries

...

by

...

using

...

example-driven

...

matching

...

of

...

templates

...

and

...

structural

...

unification

...

to

...

match

...

a

...

code

...

excerpt

...

with

...

an

...

AST

...

node.

...

In

...

practice,

...

this

...

means

...

a

...

user

...

can

...

create

...

a

...

logic

...

variable

...

to

...

match

...

an

...

AST

...

node

...

and

...

reuse

...

this

...

variable

...

within

...

the

...

query

...

regardless

...

of

...

the

...

execution

...

path

...

where

...

the

...

variable

...

appears.

...

For

...

example,

...

one

...

could

...

specify

...

a

...

query

...

that

...

finds

...

instances

...

of

...

Scanner

...

that

...

is

...

read

...

after

...

it

...

was

...

closed

...

as

...

follows: 

Code Block

 

{code}
if jtMethodDeclaration(?m){
  public static void main(String[] args) {
    ?scanner := [new java.util.Scanner(?argList);]
    ?scanner.close();
    ?scanner.next();
  }
}
{code}

h4. JQuery


h5.

JQuery is a 

JQuery

JQuery is a logic-paradigm

...

query

...

language

...

built

...

on

...

top

...

of

...

the

...

logic

...

programming

...

language

...

TyRuBa.

...

The

...

implementation

...

of

...

JQuery

...

analyse

...

the

...

AST

...

of

...

a

...

Java

...

program

...

by

...

making

...

calls

...

to

...

the

...

Eclipse

...

JDT.

...

JQuery

...

includes

...

a

...

library

...

of

...

predicates

...

that

...

allows

...

querying

...

Java

...

elements

...

and

...

the

...

relationships

...

between

...

them.

...

For

...

example,

...

the

...

following

...

query

...

finds

...

all

...

method

...

declarations

...

?M

...

that

...

have

...

at

...

least

...

one

...

parameter

...

of

...

type

...

Integer:

{
Code Block
}
method(?M, paramType, ?PT), match(?PT, /Integer/).
{code}

h4. 

.QL

...

.QL is an object-oriented

...

query

...

language.

...

It

...

enables

...

programmers

...

to

...

query

...

Java

...

source

...

code

...

by

...

composing

...

queries

...

that

...

look

...

like

...

SQL.

...

The

...

motivation

...

for

...

this

...

design

...

choice

...

is

...

to

...

reduce

...

barrier

...

to

...

entry

...

for

...

developers

...

that

...

learn

...

it.

...

In

...

addition,

...

the

...

authors

...

argue

...

that

...

object-orientation

...

provides

...

the

...

structure

...

necessary

...

for

...

building

...

reusable

...

queries.

...

An

...

implementation

...

is

...

available,

...

called

...

SemmleCode,

...

which

...

includes

...

an

...

editor

...

and

...

various

...

optimisations.

...

As

...

an

...

example,

...

the

...

following

...

query

...

describes

...

how

...

to

...

find

...

all

...

classes

...

that

...

declare

...

a

...

method

...

equals,

...

but

...

which

...

do

...

not

...

specify

...

a

...

method

...

hashCode.

{
Code Block
}
from Class c
    where c.declaresMethod("equals") and
        not (c.declaresMethod("hashCode")) and
        c.fromSource()
select c.getPackage(), c
{code}

h4. Jackpot


h5.

Jackpot is a module for the NetBeans IDE for querying and transforming Java source files. Jackpot lets user query the AST of a Java program by composing rules under the form of a Java expression. In addition, one can specify variables to bind to a matching AST node. For example, the following query will match any code surrounded by a call to readLock() and readUnlock():

Jackpot

Jackpot is a module for the NetBeans IDE for querying and transforming Java source files. Jackpot lets user query the AST of a Java program by composing rules under the form of a Java expression. In addition, one can specify variables to bind to a matching AST node. For example, the following query will match any code surrounded by a call to readLock() and readUnlock():

Code Block
{code}
$document.readLock();
$statementsUnderLock$;
$document.readUnlock();
{code}

PMD

PMD is a ruleset based Java source code analyzer that identifies bugs or potential problems including dead code, duplicate code or overcomplicated expressions. PMD has an extensive archive of built-in rules that can be used to identify such problems. One can specify new rules by writing it in Java and making use of the PMD helper classes. Alternatively, one can also compose custom rules via an XPath expression that queries the AST of the program to analyze. For example, the following query finds all method declarations that have at least one parameter of type Integer:

Code Block

h4. PMD


h5.

PMD is a ruleset based Java source code analyzer that identifies bugs or potential problems including dead code, duplicate code or overcomplicated expressions. PMD has an extensive archive of built-in rules that can be used to identify such problems. One can specify new rules by writing it in Java and making use of the PMD helper classes. Alternatively, one can also compose custom rules via an XPath expression that queries the AST of the program to analyze. For example, the following query finds all method declarations that have at least one parameter of type Integer:

{code}
//MethodDeclarator/FormalParameters
 [FormalParameter/Type/ReferenceType/ClassOrInterfaceType
  [@Image = 'Integer']]
{code}

Uses Cases

In this section, we describe the use cases examined for the evaluation. We selected use cases that are source of language design discussions and make use of a variety of Java features.

Final Array and Anonymous Inner Classes

Java lets programmers create inner classes, which is a nested class not declared static. There exists three different types of inner classes: non-static member, local and anonymous classes.

Inner classes have a restriction that any local variable, formal parameter, or exception parameter used but not declared in the inner class must be declared final.

However, programmers can circumvent this restriction by declaring a final array with only one element and mutate the element of the array. The following code illustrates this mechanism:

Code Block

public class OutsideClass
{
   

h3. Uses Cases

In this section, we describe the use cases examined for the evaluation. We selected use cases that are source of language design discussions and make use of a variety of Java features.


h4. Final Array and Anonymous Inner Classes

Java lets programmers create inner classes, which is a nested class not declared static. There exists three different types of inner classes: non-static member, local and anonymous classes.

Inner classes have a restriction that any local variable, formal parameter, or exception parameter used but not declared in the inner class must be declared final.

However, programmers can circumvent this restriction by declaring a final array with only one element and mutate the element of the array. The following code illustrates this mechanism:\\

{code}


public class OutsideClass

{

    public void methodA()

       {

               final String\[\] s = new String\[1\];

               class InnerClass

        {

                   {
            public void methodB()

            {

                s\[0\            {
                s[0] = "bypass"; // accepted by compiler

            }

        }

    }

}

{code}\\

*Use Case 1*: Find occurrence of an anonymous inner class whose code references a final array variable in the enclosing scope and which mutates array elements via that variable.

h5.


h4. Generic Constructors


h5.


h5. A constructor can have two sets of type arguments. A constructor can use the type parameters declared in a generic class. One can then specify the types after the class name: \texttt{new Foo<Integer>()}. In addition, a constructor can declare its own type parameters. The types are then specified between the \texttt{new} token and the class name: \texttt{new <Integer> Foo<Number>()}. The code below illustrates a constructor of class \texttt{Foo} which declares its own type parameter \texttt{S} that             }
        }
    }
}

Use Case 1: Find occurrence of an anonymous inner class whose code references a final array variable in the enclosing scope and which mutates array elements via that variable.

Generic Constructors

A constructor can have two sets of type arguments. A constructor can use the type parameters declared in a generic class. One can then specify the types after the class name: new Foo<Integer>(). In addition, a constructor can declare its own type parameters. The types are then specified between the new token and the class name: new <Integer> Foo<Number>(). The code below illustrates a constructor of class Foo which declares its own type parameter S that extends the class's own parameters.

Code Block
extends the class's own parameters.{code}class Foo<T extends Number> {&nbsp; &nbsp;
    <S extends T> Foo() {}}{code}


h5. A constructor can have two sets of type arguments. A constructor can use the type parameters declared in a generic class. One can then specify the types after the class name: new Foo<Integer>(). In addition, a constructor can declare its own type parameters. The types are then specified between the new token and the class name: new <Integer> Foo<Number>(). The code below illustrates a constructor of class Foo which declares its own type parameter S that extends the class's own parameters.


h5. {code}class Foo<T extends Number> {


h5. &nbsp; &nbsp; <S extends T> Foo() {}


h5. }{code}


h5. Capture Conversion Idiom


h5. Overloaded Methods


h5. Covariant Arrays


h3. Evaluation


|| || Final Array & Anonymous Class || Generic Constructors || Capture Conversion Idiom || Overloaded Methods || Covariant Arrays ||
| +JTL+ | | | X | | |
| +BBQ+ | X | X | X | *&nbsp;?* | |
| +SOUL+ | | | | | |
| +JQuery+ | X | X | X | *?* | X |
| +.QL+ | | | | | |
| +Jackpot+ | | | | | |
| +PMD+ | | | | | |

*{+}JTL{+}*

* &nbsp;

*{+}BBQ{+}*

* {color:#ff0000}doesn't detect local inner classes (local & anonymous). Only inner classes (doesn't differentiate): class in all classes{color}
* {color:#ff0000}no access to local variable declared in methods{color}
* {color:#ff0000}no support for generics on declaration.{color}
* {color:#ff0000}no support for constructors (considered as method init)&nbsp;{color}
* {color:#ff0000}no AST structural matching. (e.g loops ...){color}
* {color:#ff0000}no variable binding/unification{color}
* {color:#008000}set operators (union, intersection){color}
* {color:#008000}support for read/write of{color} {color:#008000}{+}fields{+}{color} {color:#008000}references{color}

*{+}SOUL{+}*

* &nbsp;

*{+}Jquery{+}*

* [
}

Capture Conversion Idiom

Overloaded Methods

Covariant Arrays

Evaluation

 

Final Array & Anonymous Class

Generic Constructors

Capture Conversion Idiom

Overloaded Methods

Covariant Arrays

JTL

 

 

X

 

 

BBQ

X

X

X

 ?

 

SOUL

 

 

 

 

 

JQuery

X

X

X

?

X

.QL

 

 

 

 

 

Jackpot

 

 

 

 

 

PMD

 

 

 

 

 

JTL

  •  

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 on declaration.
  • 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

SOUL

  •  

Jquery

  • http://jquery.cs.ubc.ca/documentation/toc.html

...

  • http://jquery.cs.ubc.ca/documentation/appendix2.html

...

  • variable binding through predicates
  • Wiki Markup
    support for read & mutation of fields (write)&nbsp;\[writes(?B,?F,?L) means: "Block ?B writes to field ?F at location ?L"\]

...

  • no structural matching (e.g

...

  • pattern

...

  • match

...

  • on

...

  • a

...

  • loop

...

  • or

...

  • body

...

  • of

...

  • a

...

  • method)

...

  • no generics support

.QL

  •  

Jackpot

  • https://bitbucket.org/jlahoda/jackpot30/wiki/RulesLanguageAdditionalDocs

...

PMD

  •  

Time Plan

 

Week 1

Week 2

Week 3

Week 4

Week 5

July

Raoul in Cambridge

  • Source Code Query Languages Literature Review
  • paper: Background
  • paper: Abstract, Intro, Use Cases
  • Start evaluation of Source Code QL
  • Joel: away Stockholm
  • Evaluation of Source Code QL
  • Create Taxonomy
  • paper: Evaluation/Taxonomy
  • Joel: away Stockholm
  • paper: Related Work/Conclusion & make it top notch
  • paper: Get reviews & integrate feedback

August

  • corpus: Review of existing Java Corpora
  • corpus: Build Corpus infrastructure (pluggable javac)
  • PLATEAU paper deadline 10/8
  • corpus: Prototype of Community Corpus
  • corpus: Prototype of Community Corpus
  • JavaOne slides deadline 22/8
  • Research ranking of source code query results

September

 

 

 

 

 

October

Joel JavaOne

 

Raoul in Cambridge

Raoul in Cambridge

Raoul in Cambridge

Color scheme:

  • Alex
  • Joel
  • Raoul

Relevant Literature

Wiki Markup
\[1\] Brian Goetz. Language designer's notebook: Quantitative language design.&nbsp;[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)

...

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.

...

Related

...

Projects

Wiki Markup
\[a\] Refactoring NG.&nbsp;[http://kenai.com/projects/refactoringng|http://kenai.com/projects/refactoringng]

...

Wiki Markup
\[b\]&nbsp;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)

...

Wiki Markup
\[c\] Browse By Query.&nbsp;[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": 2172, "requestCorrelationId": "94bb4aa65d2bfdce"}