Skip to content

Select concrete class for abstract types #1100

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

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
interface I
{
int getANumber();
}

class A implements I {
public int a;

public int getANumber() { return a; }
}

class B implements I {
public int b;
public int getANumber() { return b; }
}

class TestClass
{
public I someObject;

public boolean foo() {
if(someObject!=null)
{
int result = someObject.getANumber();
if(result == 42) {
return true;
} else {
return false;
}
}
else
{
return false;
}
}

public static void main(String[] args)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

main function is not needed (in other tests, too)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, understood, could you change the comment into something along the line

// ensure that A, B are referenced explicitly in order to get them converted into GOTO

{
// ensure that A, B are referenced explicitly
// in order to get them converted into GOTO
A a = new A();
B b = new B();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
CORE
TestClass.class
--cover location --function TestClass.foo --show-goto-functions
\.someObject = \(struct I \*\)\w+
@class_identifier = "java::A";
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
interface I
{
int getANumber();
}

class A implements I {
public int a;

public int getANumber() { return a; }
}

class B implements I {
public int b;
public int getANumber() { return b; }
}

interface J
{
int getANumber();
}

class C implements J {
public int c;
public int getANumber() { return c; }
}

class D implements J {
public int d;
public int getANumber() { return d; }
}

class TestClass
{
public I someObject1;
public J someObject2;

public boolean foo() {
if(someObject1 != null && someObject2 != null)
{
if(someObject1.getANumber() == someObject2.getANumber()) {
return true;
} else {
return false;
}
}
else
{
return false;
}
}

public static void main(String[] args)
{
// ensure that A, B, C, D are referenced explicitly
// in order to get them converted into GOTO
A a = new A();
B b = new B();
C c = new C();
D d = new D();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CORE
TestClass.class
--cover location --function TestClass.foo --show-goto-functions
@class_identifier = "java::A";
@class_identifier = "java::C";
.someObject1 = \(struct I \*\)
.someObject2 = \(struct J \*\)
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
interface I
{
int getANumber();
}

class A implements I {
public int a;

public int getANumber() { return a; }
}

class B implements I {
public int b;
public int getANumber() { return b; }
}

class TestClass
{
public static boolean foo(I someObject) {
if(someObject!=null)
{
int result = someObject.getANumber();
if(result == 42) {
return true;
} else {
return false;
}
}
else
{
return false;
}
}

public static void main(String[] args)
{
// ensure that A, B are referenced explicitly
// in order to get them converted into GOTO
A a = new A();
B b = new B();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CORE
TestClass.class
--cover location --function TestClass.foo --show-goto-functions
@class_identifier = "java::A";
= \(struct I \*\)
tmp_object_factory\$\d+ = null;
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
interface I
{
int getANumber();
}

class A implements I {
public int a;
public int getANumber() { return a; }
}

class B implements I {
public int b;
public int getANumber() { return b; }
}

interface J
{
int getANumber();
}

class C implements J {
public int c;
public int getANumber() { return c; }
}

class D implements J {
public int d;
public int getANumber() { return d; }
}

class TestClass
{
public static boolean foo(I someObject1, J someObject2) {
if(someObject1 != null && someObject2 != null)
{
if(someObject1.getANumber() == someObject2.getANumber()) {
return true;
} else {
return false;
}
}
else
{
return false;
}
}

public static void main(String[] args)
{
// ensure that A, B, C, D are referenced explicitly
// in order to get them converted into GOTO
A a = new A();
B b = new B();
C c = new C();
D d = new D();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CORE
TestClass.class
--cover location --function TestClass.foo --show-goto-functions
@class_identifier = "java::A";
= \(struct I \*\)
@class_identifier = "java::C";
= \(struct J \*\)
tmp_object_factory\$\d+ = null;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing new line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
interface I
{
int getANumber();
}

class A implements I {
public int a;

public int getANumber() { return a; }
}

class B implements I {
public int b;
public int getANumber() { return b; }
}

class TestClass
{
public static boolean foo(I someObject1, I someObject2) {
if(someObject1 != null && someObject2 != null)
{
if(someObject1.getANumber() == someObject2.getANumber()) {
return true;
} else {
return false;
}
}
else
{
return false;
}
}

public static void main(String[] args)
{
// ensure that A, B are referenced explicitly
// in order to get them converted into GOTO
A a = new A();
B b = new B();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CORE
TestClass.class
--cover location --function TestClass.foo --show-goto-functions
@class_identifier = "java::A";
= \(struct I \*\)
tmp_object_factory\$\d+ = null;
2 changes: 1 addition & 1 deletion regression/strings-smoke-tests/jsonArrays/test.desc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ test.class
--refine-strings --function test.check --json-ui --trace --string-max-length 100 --cover location
^EXIT=0$
^SIGNAL=0$
\"data\".*\"tmp_object_factory\$6.*\"
\"data\".*\"tmp_object_factory\$\d+.*\"
--
This checks that tmp_object_factory$6 gets affected to the data field
of some strings, which was not the case in previous versions of cbmc,
Expand Down
2 changes: 2 additions & 0 deletions src/java_bytecode/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ SRC = bytecode_info.cpp \
character_refine_preprocess.cpp \
ci_lazy_methods.cpp \
expr2java.cpp \
get_concrete_class_alphabetically.cpp \
jar_file.cpp \
java_bytecode_convert_class.cpp \
java_bytecode_convert_method.cpp \
Expand All @@ -24,6 +25,7 @@ SRC = bytecode_info.cpp \
java_string_library_preprocess.cpp \
java_types.cpp \
java_utils.cpp \
select_pointer_type.cpp \
# Empty last line

INCLUDES= -I ..
Expand Down
Loading