JDK-6297094 : The result type of Class.getModifiers is labeled as a "boolean" to the optimizer instead of "int"
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 5.0u4,6u1
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2005-07-15
  • Updated: 2010-10-20
  • Resolved: 2007-03-29
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other JDK 6
5.0u12Fixed 6u2 b01Fixed
Related Reports
Duplicate :  
Relates :  
Description
There is a bug in the inlining of Class.getModifiers.  The result type of Class.getModifiers is labeled as a "boolean" to the optimizer instead of "int".  An inlined isFinal call masks with 16 - which against a boolean always returns a 0 (masking against an int produces the obvious extract instructions).  Bug can be reproduced by running JCK test "javasoft.sqe.tests.api.java.lang.Class.GetModifiersTests -TestCaseID ALL"
using C2 -Xcomp.   A suggested fix is provided.



###@###.### 2005-07-15 00:08:19 GMT

Comments
SUGGESTED FIX I have a C2-intrinsics workspace that fixes this problem.
01-02-2006

EVALUATION Yes, that's a bug, and the suggested fix is correct. ###@###.### 2005-07-15 05:01:45 GMT
15-07-2005

SUGGESTED FIX ==== //java/main-dev/java/hotspot/src/share/vm/opto/library_call.cpp#33 - /home/cliffc/HotSpot/cliffc-main/hotspot/src/share/vm/opto/library_call.cpp ==== @@ -1329,22 +1329,26 @@ int nargs; Node* prim_return_value = top(); // what happens if it's a primitive class? + const Type *result_phi_type = 0; switch (id) { case ciMethod::_isInstance: nargs = 1+1; // the Class mirror, plus the object getting queried about // nothing is an instance of a primitive type prim_return_value = intcon(0); + result_phi_type = TypeInt::BOOL; NOT_PRODUCT(iname = "Class.isInstance"); break; case ciMethod::_getModifiers: nargs = 1+0; // just the Class mirror prim_return_value = intcon(JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC); + result_phi_type = TypeInt::INT; NOT_PRODUCT(iname = "Class.getModifiers"); break; case ciMethod::_getClassAccessFlags: nargs = 1+0; // just the Class mirror prim_return_value = intcon(JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC); + result_phi_type = TypeInt::INT; NOT_PRODUCT(iname = "Reflection.getClassAccessFlags"); break; default: @@ -1380,7 +1384,7 @@ // Null-check the mirror, and the mirror's klass ptr (in case it is a primitive). RegionNode* region = new RegionNode(4); record_for_igvn(region); - Node* phi = new PhiNode(region, TypeInt::BOOL); + Node* phi = new PhiNode(region, result_phi_type); // The mirror will never be null of Reflection.getClassAccessFlags, however // it may be null for Class.isInstance or Class.getModifiers. Throw a NPE ###@###.### 2005-07-15 00:08:19 GMT
15-07-2005