[ 
https://issues.apache.org/jira/browse/OPENJPA-3078?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Richard Zowalla updated OPENJPA-3078:
-------------------------------------
    Fix Version/s:     (was: 4.2.0)

> Dynamic enhancement agent cannot attach itself on JDK 9+ (no tools.jar)
> -----------------------------------------------------------------------
>
>                 Key: OPENJPA-3078
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-3078
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: Enhance
>            Reporter: Richard Zowalla
>            Assignee: Richard Zowalla
>            Priority: Major
>
> With openjpa.DynamicEnhancementAgent=true (the default) OpenJPA tries to 
> attach its enhancement agent to the running JVM. 
> InstrumentationFactory.getInstrumentation() looks for lib/tools.jar 
> (findToolsJar) to load com.sun.tools.attach.VirtualMachine. tools.jar does 
> not exist since JDK 9, so on the supported JDKs (17+) the agent is never 
> attached and entities are not enhanced at runtime unless -javaagent is given 
> explicitly.
> On JDK 9+ the attach API is in the jdk.attach module, so the class can be 
> loaded without tools.jar. Attaching to the own process additionally needs 
> -Djdk.attach.allowAttachSelf=true, and since JDK 21 dynamically loaded agents 
> print a warning (JEP 451) and will need -XX:+EnableDynamicAgentLoading in a 
> future JDK.
> Options: use the jdk.attach module when it is available (and report clearly 
> when self-attach is not allowed), or drop self-attach and document -javaagent 
> / build-time enhancement as the supported ways. Found while fixing the 
> test-dynamic-enhancer profile (OPENJPA-3077), which now uses -javaagent.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to