google-code-export / umple

Automatically exported from code.google.com/p/umple
1 stars 0 forks source link

Abstract methods declaring an exception are not correctly handled in abstract classes. #643

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.Create an abstract class having an abstract method declaring an exception, as 
in the following code snippet:
------------
class AssociationRule
{
 abstract;
 public abstract double getPrimaryMetricValue() throws Exception ;
}
------------
What is the expected output? What do you see instead?

The abstract method should be considered as extracode.
Instead, the statement ' throws Exception ' is taken as an attribute so it 
generates (in Java for instance) private throws Exception;.

Original issue reported on code.google.com by asopa...@gmail.com on 7 Oct 2014 at 2:51

GoogleCodeExporter commented 9 years ago
If there was another abstract method with a different method name, also doing a 
throw, it wouldn't even be parsed.

One option is to make these extra code. This would be a good first step in an 
agile approach to this problem.

Another option is to make them parse properly as methods and generate properly 
(this would be the best end result since we are trying now to parse methods)

Original comment by TimothyCLethbridge on 15 Oct 2014 at 7:18

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I tried to replicate this issue using Umple Online, but I used this sample 
input: 

http://preview.tinyurl.com/lpgo3ev

This code appears correct. 

Original comment by kevin.br...@gmail.com on 17 Jan 2015 at 6:00

GoogleCodeExporter commented 9 years ago
Trying again to post code: 

{{{
class AssociationRule
{
  abstract;

  public abstract double getPrimaryMetricValue() throws Exception ;

  public abstract int getNoValue() throws RuntimeException;
}

class Rule {
  isA AssociationRule;

  public double getPrimaryMetricValue() throws Exception { 
    return 0.0;
  }

  public int getNoValue() throws RuntimeException {
    return 0;
  }
}
}}}

This code generated proper Java code. 

Original comment by kevin.br...@gmail.com on 17 Jan 2015 at 6:02

GoogleCodeExporter commented 9 years ago
I agree with Kevin. Both the original example and Kevin's example generate 
valid Java code, without having the "throws Exception" being generated as 
private member variables.

Original comment by CraigBry...@gmail.com on 7 Feb 2015 at 5:08