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

Add java.lang.Class#getModule to MJI model class #125

Merged
merged 1 commit into from
Jul 27, 2018
Merged
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
7 changes: 7 additions & 0 deletions src/classes/modules/java.base/java/lang/Class.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ public final class Class<T> implements Serializable, GenericDeclaration, Type, A

private String name;

// set by VM
Copy link
Member

Choose a reason for hiding this comment

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

Could you please clarify this comment?
Does JPF's VM or the host VM try to set this field?
There is currently no accessor method, and as the field is now, it seems jpf-core would not use it at this point. However, without an accessor, the host VM could not set this field (except by reflection, which can access private data).

Copy link
Collaborator Author

@gayanW gayanW Jul 27, 2018

Choose a reason for hiding this comment

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

Based on the JDK source there is no accessor setModule. But through remote debugging, I was able to confirm that the java.lang.Class#getModule method in our Class model returns the correct (non-null) module for that class. So it should be set by the host VM, possibly through reflection.

private transient Module module;

private ClassLoader classLoader;

/**
Expand Down Expand Up @@ -359,4 +362,8 @@ public boolean isSynthetic (){
final int SYNTHETIC = 0x00001000;
return (getModifiers() & SYNTHETIC) != 0;
}

public Module getModule() {
return module;
}
}