Echtzeitsysteme / java-refactoring-ttc

Object-oriented Refactoring of Java Programs using Graph Transformation (TTC'2015)
0 stars 0 forks source link

Where we must rewrite source code? #11

Closed GerardPaligot closed 9 years ago

GerardPaligot commented 9 years ago

We would like to know where we must rewrite source code refactored. For now, we save the path given by createProgramGraph and we rewrite our source code at this location but ARTE doesn't seems to use it.

Any idea? Thanks in advance.

SvenPeldszus commented 9 years ago

The program located at the given path is just a temporal copy and has to be changed directly.

It sounds as you are rewriting your source code as intended by us.

Are you really changing the existing files or are you creating a new program besides the given one? Are all created files located in the src\ folder?

On my system ARTE works proper regarding the usage of the refactored program. However, a bug is still possible.

How have you determined whether ARTE uses the refactored program?

Which messages are printed by ARTE?

GerardPaligot commented 9 years ago

Are you really changing the existing files or are you creating a new program besides the given one?

For now, we are rewriting source code at the program location.

How have you determined whether ARTE uses the refactored program?

Which messages are printed by ARTE?

For example, the output of the test pub_pum2_1 is:

Executing test case: "pub_pum2_1"
    Description:
        PUM-NEG: (paper2) Pull-up of two classes into a parent class, which already has a method with the signature.

SUCCESS: The java program has been compiled.

    Output of execution before refactoring:
        Child says Hello World!
        Parent says Hello World!

sssssssssssssss Triggering Program Graph Generation ssssssssssssssss
avr. 16, 2015 11:02:02 AM fr.inria.SpoonTtc createProgramGraph
INFOS: parse /var/folders/yd/kdk6_3wn4fvc71sblyjpgnn80000gn/T/tmp_ttc/paper-example02
ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss

ssssssssssssss  Triggering Pull-Up Method Refactoring ssssssssssssss
avr. 16, 2015 11:02:03 AM fr.inria.SpoonTtc applyPullUpMethod
INFOS: apply pull up method
ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss

ssssssssssss  Triggering Synchronization with Java Code ssssssssssss
avr. 16, 2015 11:02:03 AM fr.inria.SpoonTtc synchronizeChanges
INFOS: will print to /var/folders/yd/kdk6_3wn4fvc71sblyjpgnn80000gn/T/tmp_ttc/paper-example02
ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss

SUCCESS: This static check whether a class contains a specific method or field was successful.
SUCCESS: This static check whether a class contains a specific method or field was successful.
SUCCESS: This static check whether a class contains a specific method or field was successful.

    Output of execution after refactoring:
        Child says Hello World!
        Parent says Hello World!

SUCCESS: Output before and after refactoring are equal.

We see at the end that he tries to do something after the refactoring. So we supposed that ARTE use a new version of the source code somewhere.

SvenPeldszus commented 9 years ago

After an refactoring at first checks for the containment and absence of methods and inheritance relations are executed.

SUCCESS: This static check whether a class contains a specific method or field was successful.
SUCCESS: This static check whether a class contains a specific method or field was successful.
SUCCESS: This static check whether a class contains a specific method or field was successful.

If these were successful the program is executed and the console output is compared with the recorded one before the refactoring.

Output of execution after refactoring:
        Child says Hello World!
        .Parent says Hello World!

SUCCESS: Output before and after refactoring are equal.

In the example you posted the refactoring is not applicable and therefore the program should not be changed.

Have you changed it on purpose to force a failure of the test?

Are you really changing the existing files or are you creating a new program besides the given one?

For now, we are rewriting source code at the program location. This sounds correct.

Can you write a dummy, which just deletes one of the classes, or removes one method from one of the child classes an post the output?

GerardPaligot commented 9 years ago

Can you write a dummy, which just deletes one of the classes, or removes one method from one of the child classes an post the output?

I renamed all classes for X1, X2, ..., Xn and the test given passed. So I don't rewrite source code at the right place.

Do we have to rewrite the source code or ARTE is based only on the boolean returned by applyPullUpMethod and applyCreateSuperclass?

SvenPeldszus commented 9 years ago

I renamed all classes for X1, X2, ..., Xn and the test given passed. So I don't rewrite source code at the right place.

In this case maybe the .class files of the "before-execution" are still available and are used again. It could be that we did not implemented a entire clean as the refactorings are not deleting or renaming classes and we expected the .class files to be always overwritten. I will check this.

Do we have to rewrite the source code or ARTE is based only on the boolean returned by applyPullUpMethod and applyCreateSuperclass?

ARTE checks the rewritten source code. However, if the value returned by applyPullUpMethod and applyCreateSuperclass does not fit to the expectations the test will always fail.

SvenPeldszus commented 9 years ago

In the latest version ARTE ensures now to delete all previous generated .class files. Hopefully this solves your problem.

GerardPaligot commented 9 years ago

I can't execute the jar since your last update:

$ java -jar ARTE.jar 
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/xtext/ISetup
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:455)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:367)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:455)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:367)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at arte.Arte.<init>(Arte.java:62)
    at arte.Arte.main(Arte.java:88)
Caused by: java.lang.ClassNotFoundException: org.eclipse.xtext.ISetup
    at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 26 more
SvenPeldszus commented 9 years ago

Please excuse me, I forgot to commit the updated libaries.

GerardPaligot commented 9 years ago

ok, I can execute it. So, to sum up:

We are ok with that?

SvenPeldszus commented 9 years ago

Yes, you are ok with that.

GerardPaligot commented 9 years ago

Ok, thanks @SvenPeldszus. I close this issue and open a new one if I have new questions or find new bugs.