United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: 7143353 -Xrunhprof fails in Java 7 due to bad switch
7143353 : -Xrunhprof fails in Java 7 due to bad switch

Details
Type:
Bug
Submit Date:
2012-02-07
Status:
Closed
Updated Date:
2012-07-16
Project Name:
JDK
Resolved Date:
2012-07-16
Component:
tools
OS:
linux,solaris_10
Sub-Component:
hprof
CPU:
x86
Priority:
P4
Resolution:
Fixed
Affected Versions:
7
Fixed Versions:
7u6

Related Reports
Duplicate:

Sub Tasks

Description
FULL PRODUCT VERSION :
java version "1.7.0_02"
Java(TM) SE Runtime Environment (build 1.7.0_02-b13)
Java HotSpot(TM) 64-Bit Server VM (build 22.0-b10, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Linux headius-Server 3.0.0-12-generic #20-Ubuntu SMP Fri Oct 7 14:56:25 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux

Darwin Charles-Oliver-Nutters-MacBook-Pro.local 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun  7 16:32:41 PDT 2011; root:xnu-1504.15.3~1/RELEASE_X86_64 x86_64

A DESCRIPTION OF THE PROBLEM :
In all builds of OpenJDK 7 I have tried, the -Xrunhprof switch (for the "demo" JVMTI profiler) fails to work with the following error when run against code that uses invokedynamic or methodhandle/methodtype references:

HPROF ERROR: Unknown constant
[../../../src/share/demo/jvmti/java_crw_demo/java_crw_demo.c:693]
[hprof_init.c:210]
HPROF TERMINATED PROCESS

The problem lies in the file listed here. A switch statement (at
java_crw_demo.c:662 in my copy) is not handling the two new constant types JVM_CONSTANT_MethodHandle and JVM_CONSTANT_MethodType.

I'm not sure the right way to handle them, but because they are missing the switch falls off the end and produces this error.

I understand that "hprof" is demonstration code, but there are folks like
myself that actually use its output.

Note that the switch in question is missing *at least* the constants I
reported. There may be others.

I also did a quick audit of other places where these constants are used and found the following files that might be worth examining...

hotspot/src/share/vm/oops/constantPoolOop.cpp in
constantPoolOopDesc::shared_symbols_iterate,
constantPoolOopDesc::shared_strings_iterate, print_cpool_bytes (some of these may be filtered out elsewhere)

hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp in
VM_RedefineClasses::append_entry

This is not a complete list, but they were at least suspicious.

REGRESSION.  Last worked in version 6u29

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run any program that uses invokedynamic, methodhandle, or methodtype constant pool entries with the -Xrunhprof flag passed to the JVM.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The "hprof" JVMTI profiler should profile the program.
ACTUAL -
The error mentioned in the description is produced.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
HPROF ERROR: Unknown constant
[../../../src/share/demo/jvmti/java_crw_demo/java_crw_demo.c:693]
[hprof_init.c:210]
HPROF TERMINATED PROCESS

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
It is not possible to produce Java source code that compiles to a .class file with invokedynamic, methodhandle, or methodtype constant pool entries. The invokedynamic-related test code in OpenJDK should work as an example case.
---------- END SOURCE ----------

                                    

Comments
EVALUATION

http://hg.openjdk.java.net/jdk7u/jdk7u-dev/jdk/rev/61517f1fe79e
                                     
2012-05-25
EVALUATION

http://hg.openjdk.java.net/jdk8/tl/jdk/rev/5ec5588c733d
                                     
2012-05-24
EVALUATION

see comments
                                     
2012-05-22



Hardware and Software, Engineered to Work Together