Skip to content

Fix String initialiser type when java.lang.String is a stub #3657

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions jbmc/regression/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ add_subdirectory(jbmc)
add_subdirectory(strings-smoke-tests)
add_subdirectory(jbmc-strings)
add_subdirectory(jdiff)
add_subdirectory(janalyzer)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please also add it to the Makefile.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops. Well spotted.

add_subdirectory(janalyzer-taint)
add_subdirectory(jbmc-concurrency)
add_subdirectory(jbmc-inheritance)
Expand Down
3 changes: 2 additions & 1 deletion jbmc/regression/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# For the best possible utilisation of multiple cores when
# running tests in parallel, it is important that these directories are
# listed with decreasing runtimes (i.e. longest running at the top)
DIRS = janalyzer-taint \
DIRS = janalyzer \
janalyzer-taint \
jbmc \
jbmc-concurrency \
jbmc-inheritance \
Expand Down
3 changes: 3 additions & 0 deletions jbmc/regression/janalyzer/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
add_test_pl_tests(
"$<TARGET_FILE:janalyzer>"
)
21 changes: 21 additions & 0 deletions jbmc/regression/janalyzer/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
default: tests.log

include ../../src/config.inc

test:
@../$(CPROVER_DIR)/regression/test.pl -p -c ../../../src/janalyzer/janalyzer

tests.log: ../$(CPROVER_DIR)/regression/test.pl
@../$(CPROVER_DIR)/regression/test.pl -p -c ../../../src/janalyzer/janalyzer

show:
@for dir in *; do \
if [ -d "$$dir" ]; then \
vim -o "$$dir/*.java" "$$dir/*.out"; \
fi; \
done;

clean:
find -name '*.out' -execdir $(RM) '{}' \;
find -name '*.gb' -execdir $(RM) '{}' \;
$(RM) tests.log
Binary file not shown.
10 changes: 10 additions & 0 deletions jbmc/regression/janalyzer/string-initializer/Basic1.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class Basic1
{
public static void main(String[] args) {
String s = "Hello ";
s += "World!";
if(s.equals("Hello World!"))
System.out.printf("Hello World!");
}
};

9 changes: 9 additions & 0 deletions jbmc/regression/janalyzer/string-initializer/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CORE
Basic1.class
--location-sensitive --constants --show
^EXIT=0$
^SIGNAL=0$
Hello_20 = \{ \.@class_identifier="java::java\.lang\.String" \};
java::java\.lang\.String\.Literal\.Hello_20=\{ \.@class_identifier="java::java\.lang\.String" \}
--
^warning: ignoring
2 changes: 2 additions & 0 deletions jbmc/src/janalyzer/janalyzer_parse_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ janalyzer_parse_optionst::janalyzer_parse_optionst(int argc, const char **argv)

void janalyzer_parse_optionst::register_languages()
{
// Need ansi C language for __CPROVER_rounding_mode
register_language(new_ansi_c_language);
register_language(new_java_bytecode_language);
}

Expand Down
1 change: 1 addition & 0 deletions jbmc/src/java_bytecode/java_string_literals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ symbol_exprt get_or_create_string_literal_symbol(
// Case where java.lang.String was stubbed, and so directly defines
// @class_identifier
new_symbol.value = jlo_init;
new_symbol.value.type() = string_type;
}

bool add_failed = symbol_table.add(new_symbol);
Expand Down