Skip to content

add visibility information for fields and methods #847

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
merged 1 commit into from
Apr 27, 2017

Conversation

mgudemann
Copy link
Contributor

membert has Booleans is_public, is_private and is_protected. This was used, but not set in fieldt and set but not used in methodt.
This also adds ID_default when no other flag is set, in Java this allows visibility in the package, but not subclasses outside the package (cf. https://docs.oracle.com/javase/tutorial/java/javaOO/accesscontrol.html)

Copy link
Collaborator

@tautschnig tautschnig left a comment

Choose a reason for hiding this comment

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

Minor suggestions for improvements.

@@ -287,13 +287,14 @@ void java_bytecode_convert_classt::convert(
component.set_base_name(f.name);
component.set_pretty_name(f.name);
component.type()=field_type;

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this blank line is safe to stay ;-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the line is back :-) this was an artifact from squashing some commits

@@ -232,6 +232,14 @@ void java_bytecode_convert_method_lazy(
method_symbol.mode=ID_java;
method_symbol.location=m.source_location;
method_symbol.location.set_function(method_identifier);
if(m.is_public)
member_type.set(ID_access, ID_public);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't this be using the same set_access API? (member_type will thus need to be converted to a more specific type than typet.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the problem is that set_access is defined for struct_union_typet and therefore is only really usable for fields here. I had thought about using a special java_typet derived from typet which could have the set_access, too. Would you prefer that?

Copy link
Collaborator

Choose a reason for hiding this comment

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

What I would like to avoid is having typet objects floating around that have ID_access set without anything ever making use of that. Notably, would equality comparison succeed on two typet with ID_access set to different values -- likely not. Thus such information should either be communicated via "#access" ("ID_C_access") or with objects of proper type and API. Maybe it takes introducing java_typet, but then this needs to propagate to, e.g., base_type_eq.

@mgudemann mgudemann force-pushed the feature/java_visibility branch from efa5962 to dbb9cfd Compare April 20, 2017 08:31
@kroening kroening merged commit 9e42f4f into diffblue:master Apr 27, 2017
@mgudemann mgudemann deleted the feature/java_visibility branch May 25, 2017 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants