playframework / playframework/play1

Play Java 11 JDWP support

Open
#1,356 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
1.6k
Forks
671
Avg merge
12d 15h
Merged PRs (30d)
1

Description

Are you looking for help?

This is an issue when with the new updated versions of play 1.5.x that allows support for Java 11.
The code itself can run on Java 11 but there's no support from the runner for JDWP

Play Version (1.5.x / etc)

v 1.5.3

Operating System (Ubuntu 15.10 / MacOS 10.10 / Windows 10)

Docker image openjdk:11-jre-slim

Linux 8a5a886fc0d3 5.10.25-linuxkit #1 SMP Tue Mar 23 09:27:39 UTC 2021 x86_64 GNU/Linux

JDK (Oracle 1.8.0_72, OpenJDK 1.8.x, Azul Zing)
openjdk version "11.0.11" 2021-04-20
OpenJDK Runtime Environment 18.9 (build 11.0.11+9)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.11+9, mixed mode, sharing)
Expected Behavior

Please describe the expected behavior of the issue, starting from the first action.

  1. WHEN invoking play run in a dev environment
  2. AND the java_version is one of the supported versions in Play 1.5.3 ( i.e java version 9, 10, 11)
  3. THEN the new command line option for JDWP since Java 9 should be used
    (i.e -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=127.0.0.1:8000 )
Actual Behavior
  1. When attaching a debugger on port 8000 in dev mode the connection closes immediately
  2. When attempting to add the new argument for JDWP since java 9:
    i.e play run --%dev -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=127.0.0.1:8000

Play fails to start with the error

ERROR:   Cannot load this JVM TI agent twice, check your java command line for duplicate jdwp options.
                Error occurred during initialization of VM
                agent library failed to init: jdwp
  1. There is no way to remove the redundant JDWP options while running in dev mode, because of the following logic in the python runner https://github.com/playframework/play1/blob/1.5.3/framework/pym/play/application.py#L308
Potential Fix

On line https://github.com/playframework/play1/blob/1.5.3/framework/pym/play/application.py#L305

  if application_mode == 'dev':
      self.check_jpda()
      java_args.append('-Xdebug')
      if javaVersion.startswith("9") or javaVersion.startswith("10") or javaVersion.startswith("11"):
         java_args.append('-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:%s' % self.jpda_port)
     else
         java_args.append('-Xrunjdwp:transport=dt_socket,address=%s,server=y,suspend=n' % self.jpda_port)
     java_args.append('-Dplay.debug=yes')

Thanks for the help in advance for any workarounds or fixes that come from this. I'm ok to Fork and open a PR if warranted

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Inspect framework/pym/play/application.py around lines 305-308, then reproduce play run --%dev with Java 11 using the reported JDWP arguments. Done means the Java 9+ JDWP option is selected once in dev mode, without the duplicate-agent startup error, and a debugger can attach on the configured port.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, python
Domain
devtools
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.