RFR: 6964: [Agent] Automatically open base module for accessing Unsafe on JDK 11+ [v2]

Gunnar Morling github.com+28612+gunnarmorling at openjdk.java.net
Sun Nov 15 09:53:54 UTC 2020


On Tue, 10 Nov 2020 23:14:37 GMT, Marcus Hirt <hirt at openjdk.org> wrote:

>> Gunnar Morling has refreshed the contents of this pull request, and previous commits have been removed. The incremental views will show differences compared to the previous content of the PR. The pull request contains one new commit since the last revision:
>> 
>>   6964: Automatically open base module for accessing Unsafe on JDK 11+
>
> Changes requested by hirt (Lead).

Thanks for reviewing, @thegreystone. Will update in a bit.

> agent/src/main/java/org/openjdk/jmc/agent/Agent.java line 97:
> 
>> 95: 				);
>> 96: 			} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
>> 97: 				System.out.println(
> 
> Perhaps moving the openUnsafePackage method out of the Agent class might be nice to keep the agent class clean. Also, since you use the same pattern in the VersionUtils, perhaps some static printAndExit(Exception e, int errorCode, String message) too. And perhaps use different exit codes for failing to open up the package vs not being able to determine the version.
> 
> Perhaps you could have an AgentStartupUtils under the agent.impl package and move the VersionUtils methods there too? These are only used when starting the agent.

Good ideas, will rework based on that. Re VersionUtils, there's similar demands for that elsewhere; seeing now I probably should merge this with `VersionResolver`.

-------------

PR: https://git.openjdk.java.net/jmc/pull/152


More information about the jmc-dev mailing list