missing field munging when recreating deftypes serialized into byte code

Description

deftypes with fields whose names get munged fail when constructed in data reader functions.

Cause: To embed deftypes in the bytecode the compiler emits the value of each field, then emits a call to the deftypes underlying class's constructor. To get a list of fields the compiler calls .getBasis. The getBasis fields are the "clojure" level field names of the deftype, which the actual "jvm" level field names have been munged (replacing - with _, etc), so the compiler tries to generate code to set values on non-existent fields.

Approach: Munge the field name before emitting it in bytecode.
Patch: clj-1399-with-test.diff
Screened by: Alex Miller

Environment

None

Attachments

2

Activity

Show:

Kevin DowneyApril 29, 2015 at 7:20 PM

clj-1399-with-test.diff adds a test

Alex MillerApril 29, 2015 at 5:36 PM

Could the patch have a test?

Chas EmerickApril 2, 2014 at 10:57 PM

FWIW, this was precipitated by real experience (I think I created the refheap paste). The workaround is easy (don't use dashes in field names of deftypes you want to return from data reader functions), but I wouldn't expect anyone to guess that that wasn't already oversensitized to munging edge cases.

Kevin DowneyApril 2, 2014 at 10:39 PM

this patch fixes the issue on the latest master for me

Kevin DowneyApril 2, 2014 at 10:26 PM

reproducing case

Completed

Details

Assignee

Reporter

Approval

Ok

Patch

Code and Test

Priority

Affects versions

Fix versions

Created April 2, 2014 at 10:13 PM
Updated July 18, 2015 at 12:55 AM
Resolved July 18, 2015 at 12:55 AM