-
Notifications
You must be signed in to change notification settings - Fork 273
Parse bridge flag [TG-4115] #2582
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
mgudemann
merged 2 commits into
diffblue:develop
from
jeannielynnmoulton:jeannie/parse-bridge-flag-for-thk123
Jul 17, 2018
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+620 Bytes
jbmc/unit/java_bytecode/java_bytecode_convert_method/ClassWithBridgeMethod.class
Binary file not shown.
5 changes: 5 additions & 0 deletions
5
jbmc/unit/java_bytecode/java_bytecode_convert_method/ClassWithBridgeMethod.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
public class ClassWithBridgeMethod implements Comparable<ClassWithBridgeMethod> { | ||
public int compareTo(ClassWithBridgeMethod other) { | ||
return 0; | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
jbmc/unit/java_bytecode/java_bytecode_convert_method/convert_method.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/*******************************************************************\ | ||
|
||
Module: Unit tests for converting constructors and static initializers | ||
|
||
Author: Diffblue Limited. | ||
|
||
\*******************************************************************/ | ||
|
||
#include <testing-utils/catch.hpp> | ||
|
||
#include <util/symbol_table.h> | ||
|
||
#include <java-testing-utils/load_java_class.h> | ||
#include <java-testing-utils/require_type.h> | ||
|
||
SCENARIO( | ||
"java_bytecode_convert_bridge_method", | ||
"[core][java_bytecode][java_bytecode_convert_method]") | ||
{ | ||
GIVEN("A class with a bridge method") | ||
{ | ||
const symbol_tablet symbol_table = load_java_class( | ||
"ClassWithBridgeMethod", "./java_bytecode/java_bytecode_convert_method"); | ||
|
||
const std::string method_name = "java::ClassWithBridgeMethod.compareTo"; | ||
|
||
WHEN("When parsing the bridge method") | ||
{ | ||
const symbolt function_symbol = | ||
symbol_table.lookup_ref(method_name + ":(Ljava/lang/Object;)I"); | ||
|
||
const code_typet &function_type = | ||
require_type::require_code(function_symbol.type); | ||
THEN("The method should be marked as a bridge method") | ||
{ | ||
REQUIRE(function_type.get_bool(ID_is_bridge_method)); | ||
} | ||
} | ||
WHEN("When parsing a non-bridge method") | ||
{ | ||
THEN("THe method should not be marked as a bridge method") | ||
{ | ||
const symbolt function_symbol = | ||
symbol_table.lookup_ref(method_name + ":(LClassWithBridgeMethod;)I"); | ||
|
||
const code_typet &function_type = | ||
require_type::require_code(function_symbol.type); | ||
THEN("The method should be marked as a bridge method") | ||
{ | ||
REQUIRE_FALSE(function_type.get_bool(ID_is_bridge_method)); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is something I'll have to remind Thomas about, but setting class fields like that is prone to errors. It's much better to define their default values in the class definition, like so:
That way, when you decide to define extra constructors, there's no risk of ever forgetting to initialize values.