Skip to content
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

The Java bridge can't always resolve imported VDM-SL types #676

Closed
peterwvj opened this issue Mar 14, 2018 · 1 comment
Closed

The Java bridge can't always resolve imported VDM-SL types #676

peterwvj opened this issue Mar 14, 2018 · 1 comment
Labels
bug Incorrect behaviour of the tool
Milestone

Comments

@peterwvj
Copy link
Member

Description

The Java bridge can't always resolve imported VDM-SL types.

Steps to Reproduce

  1. Create a file A.vdmsl with the following content:
module G
exports all
definitions
types
T = int;
end G

module A
imports from G all
exports all
definitions
operations
op : () ==> G`T
op () == is not yet specified;
end A

module B
imports from A all
exports all
definitions
operations
op2 : () ==> int
op2 () == A`op();
end B
  1. Create a Java implementation of the operation in A:
import org.overture.ast.analysis.AnalysisException;
import org.overture.interpreter.values.Value;
import org.overture.interpreter.values.ValueFactory;

public class A
{
	public static Value op() throws AnalysisException
	{
		return ValueFactory.mkInvariant("G", "T", ValueFactory.mkInt(5));
	}
}
  1. Export this Java class as a JAR file, named lib.jar.

  2. Execute B`op() in the following way:

java -cp Overture-2.6.0.jar:lib.jar org.overture.interpreter.VDMJ -vdmsl -default B -e 'B`op2()' A.vdmsl

Expected behavior:

Expected the model to terminate gracefully:

λ java -cp Overture-2.6.1-SNAPSHOT.jar:lib.jar org.overture.interpreter.VDMJ -vdmsl -default B -e 'B`op2()' A.vdmsl
Parsed 3 modules in 0.041 secs. No syntax errors
Type checked 3 modules in 0.055 secs. No type errors
Initialized 3 modules in 0.048 secs. 
5
Bye

Actual behavior:

The model crashes, complaining that the type G`T cannot be found:

λ java -cp Overture-2.6.1-SNAPSHOT.jar:lib.jar org.overture.interpreter.VDMJ -vdmsl -default B -e 'B`op2()' A.vdmsl
Parsed 3 modules in 0.047 secs. No syntax errors
Type checked 3 modules in 0.055 secs. No type errors
Initialized 3 modules in 0.047 secs. 
Failed in native method: Definition G`T not found
org.overture.interpreter.runtime.ValueException: Definition G`T not found

Execution: Internal 0059: Failed in native method: Definition G`T not found
org.overture.interpreter.runtime.ValueException: Definition G`T not found

Bye

Reproduces how often:

Every time.

Versions

Overture 2.6.0
OpenJDK Runtime Environment (build 1.8.0_151-8u151-b12-0ubuntu0.17.10.2-b12)
Linux, Ubuntu 17.10

Additional Information

I have a fix for this, I'll submit it as a pull request later for discussion.

@peterwvj peterwvj added the bug Incorrect behaviour of the tool label Mar 14, 2018
@peterwvj peterwvj added this to the v2.6.2 milestone Mar 14, 2018
peterwvj added a commit that referenced this issue Mar 14, 2018
@peterwvj
Copy link
Member Author

Was fixed in #677

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Incorrect behaviour of the tool
Projects
None yet
Development

No branches or pull requests

1 participant