United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: 6297094 The result type of Class.getModifiers is labeled as a "boolean" to the optimizer instead of "int"
6297094 : The result type of Class.getModifiers is labeled as a "boolean" to the optimizer instead of "int"

Details
Type:
Bug
Submit Date:
2005-07-15
Status:
Resolved
Updated Date:
2010-10-20
Project Name:
JDK
Resolved Date:
2007-03-29
Component:
hotspot
OS:
generic
Sub-Component:
compiler
CPU:
generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
5.0u4,6u1
Fixed Versions:
6u2

Related Reports
Backport:
Duplicate:
Relates:

Sub Tasks

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.
                                     
2006-02-01
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
                                     
2005-07-15
EVALUATION

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



Hardware and Software, Engineered to Work Together