bugKawa - Bugs: bug #15151, (slot-ref obj 'class) gives...

 
 

bug #15151: (slot-ref obj 'class) gives different result than (invoke obj 'getClass)

Submitter:  Dean Ferreyra <dferreyra>
Submitted:  Tue 06 Dec 2005 12:20:30 AM UTC
   
 
Category:  Code generation Severity:  3 - Normal
Item Group:  Unexpected result Status:  Fixed
Privacy:  Public Assigned to:  bothner
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 06 Dec 2005 07:58:56 AM UTC, comment #1: 

Oops.  The intent of the code is to handle (CLASS:.class),
and (static-field CLASS 'class).  But it doesn't work for
for non-static field accesses.  It does happen to work
in apply, when we know the actual type, but not compile.

It might be reasonable to suppress the translation of
(field OBJECT 'class) -> (invoke OBJECT 'getClass)
since I'm not sure "class" should be considered a
"property" of the OBJECT, in teh JavaBean sense.

I checked in the patch and a test-case.  The tricky
part was actually the test-case, because it triggered
a completely unrelated bug that I felt compelled to fix.

Per Bothner <bothner>
Group administrator
Tue 06 Dec 2005 12:20:30 AM UTC, original submission:  

Here's a snippet of code that demonstrates this:

  (module-static #t)
 
  (define o (make <java.util.Date>))
 
  (display (format "slot-ref class: ~A~%" (slot-ref o 'class)))
  (display (format "getClass(): ~A~%" (invoke o 'getClass)))

When I execute the resulting class, I get:

  slot-ref class: class java.lang.Object
  getClass(): class java.util.Date

Looking at the byte-code, it looks like the slot-ref is being optimized directly to class java.lang.Object.

We were afraid that this might have larger implications, though I see now that SlotGet.java treats 'class as a special case.

Dean Ferreyra <dferreyra>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #2495:  class-slot.patch added by bothner (633B - application/octet-stream - Patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

Only logged-in users can vote.

 

Follow 4 latest changes.

Date Changed by Updated Field Previous Value => Replaced by
2005-12-06 bothner StatusNone Fixed
    Assigned toNone bothner
    Open/ClosedOpen Closed
    Attached File- Added class-slot.patch, #3164

Back to the top

Powered by Savane 3.13-4b48.
Corresponding source code