Skip to content

State checking for extending abstract classes #131

@CatarinaGamboa

Description

@CatarinaGamboa

Currently, reusing state refinements from an abstract superclass in a concrete class is not fully implemented, and gives an error like the one below.
Image

Example for abstract class java.net.URLConnection:

@ExternalRefinementsFor("java.net.URLConnection")
@StateSet({"setup", "connected"})
public interface URLConnectionRefinements {
 
    @StateRefinement(to="setup(this)")
    public void URLConnection(URL url);

    @StateRefinement(from="setup(this)")
    public void setDoInput(boolean doinput);

    @StateRefinement(from="setup(this)", to="connected(this)")
    public void connect();

    @StateRefinement(from="connected(this)")
    public Object getContent();
 
}

Extended in class URLExt:

class URLExt extends URLConnection{

    public URLExt(URL url){
        super(url);
    }

    @Override
    public void connect() throws IOException {
        // TODO Auto-generated method stub
        throw new UnsupportedOperationException("Unimplemented method 'connect'");
    }
    
}```

Tested in:
```java
class Testurl {
    void test() throws URISyntaxException, IOException {

        URLExt u = new URLExt(new URI("http://example.com").toURL());
        u.setDoInput(false); // should not be an error but it is 
        u.getContent(); // should be an error

    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions