New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command Line debugging fails to trace back to single line if statement #1173

Open
JoshuaMcManus opened this Issue Dec 5, 2017 · 2 comments

Comments

Projects
2 participants
@JoshuaMcManus

JoshuaMcManus commented Dec 5, 2017

Brief Description

Refer to Issue #882 to see changes made for command line debugging. (See ignored test testbed/test/cruise.runtime.RuntimeErrorOutputTests.BeforeAfterCustomInOriginal())

When generating Java from Umple code, if there is code to be injected before a return statement that is surrounded by braces on a single line (in an if statement, for example), then the outputted Java creates new lines for each bracket and the return statement. While this creates more readable code, it breaks the run-time command line debugging if the return statement happens to have a run-time error in it. The reason for this is that the translation from Java line numbers back to Umple line numbers no longer line up due to the extra new lines added.

Minimum Steps to Reproduce

class BeforeAfterCustomInOriginal
{
    after custom foo() {
        int b = 0;
    }
    
    public static void main(String [] argv){
       BeforeAfterCustomInOriginal x = new BeforeAfterCustomInOriginal();
       x.foo();
    }

    public int foo() {
        int a = 0;
        a++;
        // This is a comment
        if (a > 0) { return 0 / 0; }
        a++;
        return a;
    }
}

Expected Result

Running the above code should give the following console error:

java.lang.ArithmeticException: / by zero
	at test.BeforeAfterCustomInOriginal.foo(test.ump:18)
	at test.BeforeAfterCustomInOriginal.main(test.ump:11)

Actual Result

java.lang.ArithmeticException: / by zero
	at test.BeforeAfterCustomInOriginal.foo(test.ump:19)
	at test.BeforeAfterCustomInOriginal.main(test.ump:11)

Getting Started

I suggest you start by looking into the file UmpleToJava/UmpleTLTemplates/class_MethodDeclaration.ump inside the statement:
if(properMethodBody.contains("return"))
This is where the return statements is divided up into multiple lines

@TimLethbridge TimLethbridge changed the title from Command Line debugging fails to trace back to single line if statemtent to Command Line debugging fails to trace back to single line if statement Dec 5, 2017

@TimLethbridge

This comment has been minimized.

Show comment
Hide comment
@TimLethbridge

TimLethbridge Dec 8, 2017

Member

It might be simplest to generate a long line to work around this problem, instead of splitting onto several lines.

Member

TimLethbridge commented Dec 8, 2017

It might be simplest to generate a long line to work around this problem, instead of splitting onto several lines.

@TimLethbridge TimLethbridge added this to the April 2018 for release 1.28 milestone Dec 8, 2017

@TimLethbridge

This comment has been minimized.

Show comment
Hide comment
@TimLethbridge

TimLethbridge Jun 23, 2018

Member

See also #1175

Member

TimLethbridge commented Jun 23, 2018

See also #1175

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment