Bug 205523

Summary: java/openjdk8: support getThreadCpuTime()
Product: Ports & Packages Reporter: Duraid Madina <duraid>
Component: Individual Port(s)Assignee: Jung-uk Kim <jkim>
Status: Closed FIXED    
Severity: Affects Some People CC: jkim
Priority: --- Flags: bugzilla: maintainer-feedback? (java)
Version: Latest   
Hardware: Any   
OS: Any   

Description Duraid Madina 2015-12-22 22:03:16 UTC
For some years now, FreeBSD java users have encountered:

java.lang.UnsupportedOperationException: Thread CPU time measurement is not supported.
	at sun.management.ThreadImpl.verifyThreadCpuTime(ThreadImpl.java:232)
	at sun.management.ThreadImpl.getThreadCpuTime(ThreadImpl.java:251)
	at sun.management.ThreadImpl.getThreadCpuTime(ThreadImpl.java:222)

which is particularly problematic when dealing with (buggy) software that assumes getThreadCpuTime() calls will succeed.

Will Andrews has apparently fixed this issue, see:

http://mail.openjdk.java.net/pipermail/bsd-port-dev/2015-May/002557.html

for a description and patches. It would be great to have this issue fixed in the JDKs distributed with FreeBSD.
Comment 1 Jung-uk Kim freebsd_committer 2015-12-22 22:55:36 UTC
I'll take it.
Comment 2 commit-hook freebsd_committer 2015-12-23 00:23:06 UTC
A commit references this bug:

Author: jkim
Date: Wed Dec 23 00:22:15 UTC 2015
New revision: 404270
URL: https://svnweb.freebsd.org/changeset/ports/404270

Log:
  Implement ThreadMXBean.getThreadCpuTime(), etc.

  PR:		205523
  Submitted by:	will (via bsd-port-dev@openjdk.java.net)

Changes:
  head/java/openjdk8/Makefile
  head/java/openjdk8/files/patch-hotspot_src_os_bsd_vm_os__bsd.cpp
  head/java/openjdk8/files/patch-hotspot_src_os_bsd_vm_os__bsd.hpp
Comment 3 Jung-uk Kim freebsd_committer 2015-12-23 00:24:53 UTC
Committed with minor style changes (r404270), thanks!
Comment 4 commit-hook freebsd_committer 2015-12-23 00:48:14 UTC
A commit references this bug:

Author: jkim
Date: Wed Dec 23 00:47:12 UTC 2015
New revision: 404273
URL: https://svnweb.freebsd.org/changeset/ports/404273

Log:
  Fix the previous commit.  We do not support getThreadUserTime().

  PR:		205523

Changes:
  head/java/openjdk8/files/patch-hotspot_src_os_bsd_vm_os__bsd.cpp
Comment 5 Duraid Madina 2015-12-23 01:02:18 UTC
That was quick! Thanks, Jung-uk.

Wouldn't it be worth supporting getThreadUserTime()? AFAICS this is supported by FreeBSD 8.1+ through getrusage(RUSAGE_THREAD, ...).
Comment 6 commit-hook freebsd_committer 2016-01-05 22:40:22 UTC
A commit references this bug:

Author: jkim
Date: Tue Jan  5 22:39:47 UTC 2016
New revision: 405320
URL: https://svnweb.freebsd.org/changeset/ports/405320

Log:
  - Partially implement getThreadUserTime() using getrusage(2).  Note we can
  only get usage for the current thread.  Return -1 if the requested function
  is not supported, i.e., user time for other threads, rather than crash. [1]
  - Properly implement os::elapsedVTime() using getrusage().  Basically, it is
  taken from Linux version.
  - Temporarily revert r403748 to fix bootstrapping with earlier OpenJDK8. [2]

  PR:		205523, 205843 [1]
  PR:		205544 [2]

Changes:
  head/java/openjdk8/Makefile
  head/java/openjdk8/files/patch-hotspot_src_os_bsd_vm_os__bsd.cpp
Comment 7 commit-hook freebsd_committer 2016-01-13 18:14:33 UTC
A commit references this bug:

Author: jkim
Date: Wed Jan 13 18:13:57 UTC 2016
New revision: 406064
URL: https://svnweb.freebsd.org/changeset/ports/406064

Log:
  MFH:	r405058, r405320

  - Stub implementation of OperatingSystemImpl.
  - Partially implement getThreadUserTime() using getrusage(2).  Note we can
  only get usage for the current thread.  Return -1 if the requested function
  is not supported, i.e., user time for other threads, rather than crash.
  - Properly implement os::elapsedVTime() using getrusage().  Basically, it is
  taken from Linux version.
  - Temporarily revert r403748 to fix bootstrapping with earlier OpenJDK8.

  PR:		205229, 205523, 205544, 205843
  Approved by:	ports-secteam (feld)

Changes:
_U  branches/2016Q1/
  branches/2016Q1/java/openjdk8/Makefile
  branches/2016Q1/java/openjdk8/files/patch-hotspot_src_os_bsd_vm_os__bsd.cpp
  branches/2016Q1/java/openjdk8/files/patch-jdk-src-solaris-native-sun-management-BsdOperatingSystem.c