Echtzeitsysteme / java-refactoring-ttc

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

ARTE dies with java.lang.NoSuchMethodError: java.lang.reflect.Method.getParameterCount()I #21

Closed tsdh closed 9 years ago

tsdh commented 9 years ago

When I run execute --test pub_pum1_2 in ARTE, I get the following output which ends with an exception which makes ARTE die.

execute --test pub_pum1_2       

####################################################################
####################   Executing public tests.  ####################
####################################################################

Executing test case: "pub_pum1_2"
    Description:
        PUM-NEG: Pull-up from child of a not existing parent class.

SUCCESS: The java program has been compiled.

    Output of execution before refactoring:
        c1:Hello World
        c1:Hello World
        c1:Hello World
        c2:Hello World
        c2:Hello World
        c2:Hello World

sssssssssssssss Triggering Program Graph Generation ssssssssssssssss
createProgramGraph(/tmp/tmp_ttc/paper-example01)
Parsing file /tmp/tmp_ttc/paper-example01/src/example01/ParentClass.java... Done
Parsing file /tmp/tmp_ttc/paper-example01/src/example01/ChildClass2.java... Done
Parsing file /tmp/tmp_ttc/paper-example01/src/example01/ChildClass1.java... Done
Base-package is example01
ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss

ssssssssssssss  Triggering Pull-Up Method Refactoring ssssssssssssss
applyPullUpMethod(example01.Foo, method)
No such TClass example01.Foo
ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss

ssssssssssss  Triggering Synchronization with Java Code ssssssssssss
Saving resource to /tmp/tmp_ttc/paper-example01/src/example01/ParentClass.java
Saving resource to /tmp/tmp_ttc/paper-example01/src/example01/ChildClass2.java
Saving resource to /tmp/tmp_ttc/paper-example01/src/example01/ChildClass1.java
ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss

Exception in thread "main" java.lang.NoSuchMethodError: java.lang.reflect.Method.getParameterCount()I
    at arte.execution.TestExecution.isMethodContainedInClass(TestExecution.java:709)
    at arte.execution.TestExecution.handleContainment(TestExecution.java:645)
    at arte.execution.TestExecution.handleTestStepElement(TestExecution.java:300)
    at arte.execution.TestExecution.executeTestCase(TestExecution.java:203)
    at arte.execution.TestExecution.executeTestCase(TestExecution.java:145)
    at arte.execution.TestExecution.executeTestByName(TestExecution.java:113)
    at arte.shell.commands.impl.ExecuteTestCommand.execute(ExecuteTestCommand.java:93)
    at arte.shell.Shell.executeCommand(Shell.java:100)
    at arte.shell.Shell.shell(Shell.java:57)
    at arte.Arte.main(Arte.java:96)
SvenPeldszus commented 9 years ago

There was a bug in the test case. However, we fixed it already last week. Maybe the file has not been replaced with the latest version.

Try to delete the following files in ARTE and replace them with the latest from the repository. ARTE/data/testcases/public_pum_1.ttc ARTE/data/testcases/given_test_cases/pum/pum.zip

tsdh commented 9 years ago

Well, I'm on your current HEAD 88aad3b without any local modifications, so these files (I guess the former is actually ARTE/data/testcases/public_pum_1.ttc because there is neither a ARTE/data_testcases/pub_pum1.tcc nor a ARTE/data/testcases/pub_pum1.tcc) are already up to date.

To be really sure, I did:

% git reset --hard origin/master 
HEAD is now at 88aad3b fixed failing inheritance check for fully qualified references instead of imports
% git stat
On branch master
Your branch is up-to-date with 'origin/master'.
Untracked files:
  (use "git add <file>..." to include in what will be committed)

    ARTE/log/
    ARTE/user_data/

nothing added to commit but untracked files present (use "git add" to track)
SvenPeldszus commented 9 years ago

Ok, I can not reproduce this error.

Can you please give me your solution.

tsdh commented 9 years ago

https://github.com/tsdh/ttc15-java-refactoring-funnyqt

SvenPeldszus commented 9 years ago

On my system the test is successful

####################################################################
####################   Executing public tests.  ####################
####################################################################

Executing test case: "pub_pum1_2"
    Description:
        PUM-NEG: Pull-up from child of a not existing parent class.

SUCCESS: The java program has been compiled.

    Output of execution before refactoring:
        c1:Hello World
        c1:Hello World
        c1:Hello World
        c2:Hello World
        c2:Hello World
        c2:Hello World

sssssssssssssss Triggering Program Graph Generation ssssssssssssssss
createProgramGraph(/tmp/tmp_ttc/paper-example01)
Copying program to /home/horn/tmp/JR/paper-example01
Parsing file /tmp/tmp_ttc/paper-example01/src/example01/ParentClass.java... Done
Parsing file /tmp/tmp_ttc/paper-example01/src/example01/ChildClass2.java... Done
Parsing file /tmp/tmp_ttc/paper-example01/src/example01/ChildClass1.java... Done
Base-package is example01
ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss

ssssssssssssss  Triggering Pull-Up Method Refactoring ssssssssssssss
applyPullUpMethod(example01.Foo, method)
No such TClass example01.Foo
ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss

ssssssssssss  Triggering Synchronization with Java Code ssssssssssss
synchronizeChanges()
Saving resource to /tmp/tmp_ttc/paper-example01/src/example01/ParentClass.java
Saving resource to /tmp/tmp_ttc/paper-example01/src/example01/ChildClass2.java
Saving resource to /tmp/tmp_ttc/paper-example01/src/example01/ChildClass1.java
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.

    Output of execution after refactoring:
        c1:Hello World
        c1:Hello World
        c1:Hello World
        c2:Hello World
        c2:Hello World
        c2:Hello World

SUCCESS: Output before and after refactoring are equal.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
SUCCESS: Test case "pub_pum1_2" has been executed SUCCESSFULLY.
The solution needed 0,104 seconds for execution. 
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

####################################################################
####################  Summary of test results.  ####################
####################################################################

The test case "pub_pum1_2" was executed with status "SUCCESS".

Summary of the test results:
+ 100% of the test cases were executed successfull
? 0% of the test cases ended in a warning but were still successful.
- 0% of the test cases resulted in a failure.

Can you please post the contents of the file ARTE/data/testcases/public_pum_1.ttc. By the way, I really had two typos in the file in my post above.

tsdh commented 9 years ago

The contents are:

TestFile public_pum_1 {

        class child1 {
                package "example01"
                name    "ChildClass1"
        }

        class child2 {
                package "example01"
                name    "ChildClass2"
        }

        class existing_parent {
                package "example01"
                name    "ParentClass"
        }

        class String {
                package "java.lang"
                name    "String"
        }

        class int {
                name "int"
        }

        method child_method {
                name "method"
                params String, int
        }

        pullup_method executable_pum {
                parent existing_parent
                method child_method
        }

        case pub_pum1_1_paper1 {
                description "PUM-POS: (paper1) Pull-up of two classes into a parent class."
                program "paper-example01"

                testflow {
                        assertTrue(executable_pum)

                        existing_parent contains child_method
                        child1 ~contains child_method
                        child2 ~contains child_method
                }
        }

        class not_existing_parent {
                package "example01"
                name    "Foo"
        }

        pullup_method not_executable_pum {
                parent not_existing_parent
                method child_method
        }

        case pub_pum1_2 {
                description "PUM-NEG: Pull-up from child of a not existing parent class."
                program "paper-example01"

                testflow {
                        assertFalse(not_executable_pum)

                        child1 contains child_method
                        child2 contains child_method
                }
        }

}
SvenPeldszus commented 9 years ago

Ok, the file is up to date.

Maybe the .class files are deleted too early. I will create a version of ARTE with some debug messages for this problem.

tsdh commented 9 years ago

Of course it is up to date. I did a git reset --hard origin/master and origin is this very repository. ;-)

Ah, I know what's the problem. The method java.lang.reflect.Method.getParameterCount() is new in JDK 8 and I'm running JDK 7. In JDK 7, you can get the parameter count using someMethod.getParameterTypes().length.

SvenPeldszus commented 9 years ago

ok, thanks for the help I will change it

SvenPeldszus commented 9 years ago

I have pushed the new version. Hopefully this fixes your problems

tsdh commented 9 years ago

Now I get: java.lang.NoSuchMethodError: java.lang.Class.getTypeName()Ljava/lang/String;. That's another method which is new in Java 8.

Could you please test with a JDK 7 (or JDK 8 with the corresponding compatibility settings) yourself? I'd really appreciate if I could start working on my solution anytime soon...

SvenPeldszus commented 9 years ago

Sorry, I accidentally forgot to switch my JDK

tsdh commented 9 years ago

No problem, https://github.com/Echtzeitsysteme/java-refactoring-ttc/commit/32197e5b12dcb0aa6298996729ac308951cef818 works now. I'm closing this issue.

Thanks!